Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Made sure Rhill gets saved in the output file so that it doesn't get …
Browse files Browse the repository at this point in the history
…re-computed on a restart. This would change the encounter distance, causing restarted runs to diverge from the original.
  • Loading branch information
daminton committed Jan 7, 2023
1 parent 5a3efb8 commit 036f2c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,7 @@ module subroutine swiftest_io_netcdf_initialize_output(self, param)
end if

call netcdf_io_check( nf90_def_var(nc%id, nc%Gmass_varname, nc%out_type, [nc%name_dimid, nc%time_dimid], nc%Gmass_varid), "netcdf_io_initialize_output nf90_def_var Gmass_varid" )

if (param%lrhill_present) then
call netcdf_io_check( nf90_def_var(nc%id, nc%rhill_varname, nc%out_type, [nc%name_dimid, nc%time_dimid], nc%rhill_varid), "netcdf_io_initialize_output nf90_def_var rhill_varid" )
end if
call netcdf_io_check( nf90_def_var(nc%id, nc%rhill_varname, nc%out_type, [nc%name_dimid, nc%time_dimid], nc%rhill_varid), "netcdf_io_initialize_output nf90_def_var rhill_varid" )

if (param%lclose) then
call netcdf_io_check( nf90_def_var(nc%id, nc%radius_varname, nc%out_type, [nc%name_dimid, nc%time_dimid], nc%radius_varid), "netcdf_io_initialize_output nf90_def_var radius_varid" )
Expand Down Expand Up @@ -820,8 +817,8 @@ module subroutine swiftest_io_netcdf_open(self, param, readonly)
implicit none
! Arguments
class(swiftest_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
logical, optional, intent(in) :: readonly !! Logical flag indicating that this should be open read only
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
logical, optional, intent(in) :: readonly !! Logical flag indicating that this should be open read only
! Internals
integer(I4B) :: mode, status
character(len=STRMAX) :: errmsg
Expand Down Expand Up @@ -891,13 +888,9 @@ module subroutine swiftest_io_netcdf_open(self, param, readonly)
! call netcdf_io_check( nf90_inq_varid(nc%id, nc%q_varname, nc%Q_varid), "swiftest_io_netcdf_open nf90_inq_varid Q_varid" )
! end if

! Optional Variables
if (param%lrhill_present) then
status = nf90_inq_varid(nc%id, nc%rhill_varname, nc%rhill_varid)
if (status /= NF90_NOERR) write(*,*) "Warning! RHILL variable not set in input file. Calculating."
end if

! Optional variables The User Doesn't Need to Know About
status = nf90_inq_varid(nc%id, nc%rhill_varname, nc%rhill_varid)
param%lrhill_present = (status == NF90_NOERR)
status = nf90_inq_varid(nc%id, nc%npl_varname, nc%npl_varid)
status = nf90_inq_varid(nc%id, nc%status_varname, nc%status_varid)
status = nf90_inq_varid(nc%id, nc%ntp_varname, nc%ntp_varid)
Expand Down Expand Up @@ -1100,9 +1093,10 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier
pl%Gmass(:) = pack(rtemp, plmask)
pl%mass(:) = pl%Gmass(:) / param%GU

if (param%lrhill_present) then
call netcdf_io_check( nf90_get_var(nc%id, nc%rhill_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_io_read_frame_system nf90_getvar rhill_varid" )
status = nf90_get_var(nc%id, nc%rhill_varid, rtemp, start=[1, tslot], count=[idmax,1])
if (status == NF90_NOERR) then
pl%rhill(:) = pack(rtemp, plmask)
param%lrhill_present = .true.
end if
end if

Expand Down
2 changes: 1 addition & 1 deletion src/swiftest/swiftest_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ end subroutine swiftest_io_netcdf_initialize_output
module subroutine swiftest_io_netcdf_open(self, param, readonly)
implicit none
class(swiftest_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
logical, optional, intent(in) :: readonly !! Logical flag indicating that this should be open read only
end subroutine swiftest_io_netcdf_open

Expand Down

0 comments on commit 036f2c9

Please sign in to comment.