From 8cc8b840eeebf9b869a55ecbdd1d1025a28e6f4b Mon Sep 17 00:00:00 2001 From: Carlisle April Wishard Date: Fri, 4 Mar 2022 12:40:09 -0500 Subject: [PATCH 1/2] Fixed a few things with j2rp2 in NetCDF. Runtime error NetCDF: Start+count exceeds dimension bound --- src/netcdf/netcdf.f90 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/netcdf/netcdf.f90 b/src/netcdf/netcdf.f90 index 4cfe7361d..215a3b7c2 100644 --- a/src/netcdf/netcdf.f90 +++ b/src/netcdf/netcdf.f90 @@ -341,10 +341,8 @@ module subroutine netcdf_initialize_output(self, param) !call check( nf90_def_var_chunking(self%ncid, self%GMescape_varid, NF90_CHUNKED, [self%time_chunk]) ) end if - if (param%loblatecb) then - call check( nf90_def_var(self%ncid, J2RP2_VARNAME, self%out_type, self%time_dimid, self%j2rp2_varid) ) - call check( nf90_def_var(self%ncid, J4RP4_VARNAME, self%out_type, self%time_dimid, self%j4rp4_varid) ) - end if + call check( nf90_def_var(self%ncid, J2RP2_VARNAME, self%out_type, self%time_dimid, self%j2rp2_varid) ) + call check( nf90_def_var(self%ncid, J4RP4_VARNAME, self%out_type, self%time_dimid, self%j4rp4_varid) ) ! Set fill mode to NaN for all variables call check( nf90_inquire(self%ncid, nVariables=nvar) ) @@ -479,10 +477,8 @@ module subroutine netcdf_open(self, param, readonly) call check( nf90_inq_varid(self%ncid, GMESCAPE_VARNAME, self%GMescape_varid) ) end if - if (param%loblatecb) then - call check( nf90_inq_varid(self%ncid, J2RP2_VARNAME, self%j2rp2_varid) ) - call check( nf90_inq_varid(self%ncid, J4RP4_VARNAME, self%j4rp4_varid) ) - end if + call check( nf90_inq_varid(self%ncid, J2RP2_VARNAME, self%j2rp2_varid) ) + call check( nf90_inq_varid(self%ncid, J4RP4_VARNAME, self%j4rp4_varid) ) return end subroutine netcdf_open @@ -665,6 +661,13 @@ module function netcdf_read_frame_system(self, iu, param) result(ierr) if (npl > 0) pl%Q(:) = pack(rtemp, plmask) end if + call check( nf90_get_var(iu%ncid, iu%j2rp2_varid, rtemp, start=[1, tslot]) ) + cb%j2rp2 = rtemp(1) + if (cb%j2rp2 /= 0.0_DP) param%loblatecb = .true. + + call check( nf90_get_var(iu%ncid, iu%j4rp4_varid, rtemp, start=[1, tslot]) ) + cb%j4rp4 = rtemp(1) + call self%read_particle_info(iu, param, plmask, tpmask) end associate @@ -975,10 +978,8 @@ module subroutine netcdf_write_frame_base(self, iu, param) call check( nf90_put_var(iu%ncid, iu%Gmass_varid, self%Gmass, start=[idslot, tslot]) ) if (param%lclose) call check( nf90_put_var(iu%ncid, iu%radius_varid, self%radius, start=[idslot, tslot]) ) - if (param%loblatecb) then - call check( nf90_put_var(iu%ncid, iu%j2rp2_varid, self%j2rp2, start=[idslot, tslot])) - call check( nf90_put_var(iu%ncid, iu%j4rp4_varid, self%j4rp4, start=[idslot, tslot])) - end if + call check( nf90_put_var(iu%ncid, iu%j2rp2_varid, self%j2rp2, start=[idslot, tslot])) + call check( nf90_put_var(iu%ncid, iu%j4rp4_varid, self%j4rp4, start=[idslot, tslot])) if (param%lrotation) then call check( nf90_put_var(iu%ncid, iu%Ip1_varid, self%Ip(1), start=[idslot, tslot]) ) call check( nf90_put_var(iu%ncid, iu%Ip2_varid, self%Ip(2), start=[idslot, tslot]) ) From 757118c8e03bfe0057f2f3041120f87ffe5079a2 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 4 Mar 2022 16:21:24 -0500 Subject: [PATCH 2/2] Fixed dimensionality of the j2rp2 and j4rp4 variables in NetCDF reads and writes. Now it only varies in the time dimension --- src/io/io.f90 | 2 +- src/netcdf/netcdf.f90 | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/io/io.f90 b/src/io/io.f90 index 18a22ccb9..503f61659 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -1364,7 +1364,7 @@ subroutine io_read_in_cb(self, param) if (ierr == 0) then - if (self%j2rp2 /= 0.0_DP) param%loblatecb = .true. + param%loblatecb = ((self%j2rp2 /= 0.0_DP) .or. (self%j4rp4 /= 0.0_DP)) if (param%rmin < 0.0) param%rmin = self%radius select type(cb => self) diff --git a/src/netcdf/netcdf.f90 b/src/netcdf/netcdf.f90 index 215a3b7c2..0b84fa40b 100644 --- a/src/netcdf/netcdf.f90 +++ b/src/netcdf/netcdf.f90 @@ -661,12 +661,9 @@ module function netcdf_read_frame_system(self, iu, param) result(ierr) if (npl > 0) pl%Q(:) = pack(rtemp, plmask) end if - call check( nf90_get_var(iu%ncid, iu%j2rp2_varid, rtemp, start=[1, tslot]) ) - cb%j2rp2 = rtemp(1) - if (cb%j2rp2 /= 0.0_DP) param%loblatecb = .true. - - call check( nf90_get_var(iu%ncid, iu%j4rp4_varid, rtemp, start=[1, tslot]) ) - cb%j4rp4 = rtemp(1) + call check( nf90_get_var(iu%ncid, iu%j2rp2_varid, cb%j2rp2, start=[tslot]) ) + call check( nf90_get_var(iu%ncid, iu%j4rp4_varid, cb%j4rp4, start=[tslot]) ) + param%loblatecb = ((cb%j2rp2 /= 0.0_DP) .or. (cb%j4rp4 /= 0.0_DP)) call self%read_particle_info(iu, param, plmask, tpmask) end associate @@ -978,8 +975,8 @@ module subroutine netcdf_write_frame_base(self, iu, param) call check( nf90_put_var(iu%ncid, iu%Gmass_varid, self%Gmass, start=[idslot, tslot]) ) if (param%lclose) call check( nf90_put_var(iu%ncid, iu%radius_varid, self%radius, start=[idslot, tslot]) ) - call check( nf90_put_var(iu%ncid, iu%j2rp2_varid, self%j2rp2, start=[idslot, tslot])) - call check( nf90_put_var(iu%ncid, iu%j4rp4_varid, self%j4rp4, start=[idslot, tslot])) + call check( nf90_put_var(iu%ncid, iu%j2rp2_varid, self%j2rp2, start=[tslot])) + call check( nf90_put_var(iu%ncid, iu%j4rp4_varid, self%j4rp4, start=[tslot])) if (param%lrotation) then call check( nf90_put_var(iu%ncid, iu%Ip1_varid, self%Ip(1), start=[idslot, tslot]) ) call check( nf90_put_var(iu%ncid, iu%Ip2_varid, self%Ip(2), start=[idslot, tslot]) )