From 88f45e683010db51b332d112efbbaea8ccbcf88b Mon Sep 17 00:00:00 2001 From: Yonggang Yu Date: Fri, 8 Nov 2024 11:29:06 -0700 Subject: [PATCH 1/5] ... From db3b06a6dec4f1d446e5162c70a3c817ef057f51 Mon Sep 17 00:00:00 2001 From: Yonggang Yu Date: Fri, 8 Nov 2024 14:39:14 -0700 Subject: [PATCH 2/5] Fix bugs in trajectory sampler when test against ARGOS_geolocation_sample - add missing if group_name /='' - add back the missing first time point in trajectory --- base/Plain_netCDF_Time.F90 | 10 +++++----- gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/base/Plain_netCDF_Time.F90 b/base/Plain_netCDF_Time.F90 index 8733f178b3ab..33c63a601a82 100644 --- a/base/Plain_netCDF_Time.F90 +++ b/base/Plain_netCDF_Time.F90 @@ -221,13 +221,13 @@ subroutine get_v1d_netcdf_R8(filename, name, array, Xdim, group_name, rc) integer :: ncid, varid, ncid2 call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) - if(present(group_name)) then + if(present(group_name) .AND. group_name/='') then ncid2= ncid call check_nc_status(nf90_inq_ncid(ncid2, group_name, ncid), _RC) end if call check_nc_status(nf90_inq_varid(ncid, name, varid), _RC) call check_nc_status(nf90_get_var(ncid, varid, array), _RC) - if(present(group_name)) then + if(present(group_name) .AND. group_name/='') then call check_nc_status(nf90_close(ncid2), _RC) else call check_nc_status(nf90_close(ncid), _RC) @@ -255,7 +255,7 @@ subroutine get_v1d_netcdf_R8_complete(filename, varname, array, att_name, att_va call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) ncid_sv = ncid - if(present(group_name)) then + if(present(group_name) .AND. group_name/='') then call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) ! mod ncid = ncid_grp @@ -295,7 +295,7 @@ subroutine get_att_real_netcdf(filename, varname, att_name, att_value, group_nam call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) ncid_sv = ncid - if(present(group_name)) then + if(present(group_name) .AND. group_name/='') then call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) ! overwrite ncid = ncid_grp @@ -323,7 +323,7 @@ subroutine get_att_char_netcdf(filename, varname, att_name, att_value, group_nam call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) ncid_sv = ncid - if(present(group_name)) then + if(present(group_name) .AND. group_name/='') then call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) ! overwrite ncid = ncid_grp diff --git a/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 b/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 index dc4e8f258851..15d3d11317f4 100644 --- a/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 +++ b/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 @@ -741,7 +741,9 @@ zero_obs = .false. if (jt1/=jt2) then zero_obs = .false. - if (jt1==0) jt1=1 + !-- YGYU: 8-Nov-2024 : + ! this fix bug, otherwise, the first time point is missing in ARGOS_geolocation + !!if (jt1==0) jt1=1 else ! at most one obs point exist, set it .true. zero_obs = .true. From f5776af95094b1cf0323e0aa3d56002a17307703 Mon Sep 17 00:00:00 2001 From: Yonggang Yu Date: Fri, 8 Nov 2024 15:02:05 -0700 Subject: [PATCH 3/5] more addition --- base/Plain_netCDF_Time.F90 | 49 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/base/Plain_netCDF_Time.F90 b/base/Plain_netCDF_Time.F90 index 33c63a601a82..b9c163816647 100644 --- a/base/Plain_netCDF_Time.F90 +++ b/base/Plain_netCDF_Time.F90 @@ -218,20 +218,21 @@ subroutine get_v1d_netcdf_R8(filename, name, array, Xdim, group_name, rc) real(REAL64), dimension(Xdim), intent(out) :: array integer, optional, intent(out) :: rc integer :: status - integer :: ncid, varid, ncid2 + integer :: ncid, varid, ncid2, ncid_sv call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) - if(present(group_name) .AND. group_name/='') then - ncid2= ncid - call check_nc_status(nf90_inq_ncid(ncid2, group_name, ncid), _RC) + ncid_sv = ncid + + if(present(group_name)) then + if(group_name/='') then + ncid2= ncid + call check_nc_status(nf90_inq_ncid(ncid2, group_name, ncid), _RC) + end if end if call check_nc_status(nf90_inq_varid(ncid, name, varid), _RC) call check_nc_status(nf90_get_var(ncid, varid, array), _RC) - if(present(group_name) .AND. group_name/='') then - call check_nc_status(nf90_close(ncid2), _RC) - else - call check_nc_status(nf90_close(ncid), _RC) - end if + + call check_nc_status(nf90_close(ncid_sv), _RC) _RETURN(_SUCCESS) end subroutine get_v1d_netcdf_R8 @@ -255,10 +256,12 @@ subroutine get_v1d_netcdf_R8_complete(filename, varname, array, att_name, att_va call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) ncid_sv = ncid - if(present(group_name) .AND. group_name/='') then - call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) - ! mod - ncid = ncid_grp + if(present(group_name)) then + if(group_name/='') then + call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) + ! mod + ncid = ncid_grp + end if end if call check_nc_status(nf90_inq_varid(ncid, varname, varid), _RC) call check_nc_status(nf90_get_var(ncid, varid, array), _RC) @@ -295,10 +298,12 @@ subroutine get_att_real_netcdf(filename, varname, att_name, att_value, group_nam call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) ncid_sv = ncid - if(present(group_name) .AND. group_name/='') then - call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) - ! overwrite - ncid = ncid_grp + if(present(group_name)) then + if(group_name/='') then + call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) + ! overwrite + ncid = ncid_grp + end if end if call check_nc_status(nf90_inq_varid(ncid, varname, varid), _RC) call check_nc_status(nf90_get_att(ncid, varid, att_name, att_value), _RC) @@ -323,10 +328,12 @@ subroutine get_att_char_netcdf(filename, varname, att_name, att_value, group_nam call check_nc_status(nf90_open(trim(fileName), NF90_NOWRITE, ncid), _RC) ncid_sv = ncid - if(present(group_name) .AND. group_name/='') then - call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) - ! overwrite - ncid = ncid_grp + if(present(group_name)) then + if(group_name/='') then + call check_nc_status(nf90_inq_ncid(ncid, group_name, ncid_grp), _RC) + ! overwrite + ncid = ncid_grp + end if end if call check_nc_status(nf90_inq_varid(ncid, varname, varid), _RC) call check_nc_status(nf90_get_att(ncid, varid, att_name, att_value), _RC) From 1e078a47c0d0440af473f2de3e37c070f7d4144b Mon Sep 17 00:00:00 2001 From: Yonggang Yu Date: Fri, 8 Nov 2024 15:07:14 -0700 Subject: [PATCH 4/5] add items in CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aee52b7bc2d4..0e9ee90c14f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allow update offsets of ±timestep in ExtData2G - Minor revision (and generalization) of grid-def for GSI purposes +- Trajectory sampler: fix a bug when group_name does not exist in netCDF file and a bug that omitted the first time point ### Changed From bc5f383e57ba5554f92ee69f9fd1c4d69149786e Mon Sep 17 00:00:00 2001 From: Yonggang Yu Date: Sat, 9 Nov 2024 01:05:21 -0700 Subject: [PATCH 5/5] clean up --- gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 b/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 index 15d3d11317f4..4ae3193970c9 100644 --- a/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 +++ b/gridcomps/History/Sampler/MAPL_TrajectoryMod_smod.F90 @@ -732,22 +732,11 @@ times_R8_full(1), times_R8_full(nend)) call lgr%debug ('%a %i20 %i20', 'jt1, jt2 [final intercepted position]', jt1, jt2) - -! if (jt1==jt2) then -! _FAIL('Epoch Time is too small, empty grid is generated, increase Epoch') -! endif - - !-- shift the zero item to index 1 - zero_obs = .false. if (jt1/=jt2) then zero_obs = .false. - !-- YGYU: 8-Nov-2024 : - ! this fix bug, otherwise, the first time point is missing in ARGOS_geolocation - !!if (jt1==0) jt1=1 else ! at most one obs point exist, set it .true. zero_obs = .true. - !! if (jt1==0) jt1=1 end if !