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

Commit

Permalink
Allowing for I/O of cb%rotphase in .nc files
Browse files Browse the repository at this point in the history
  • Loading branch information
anand43 committed Feb 9, 2024
1 parent 6592a7e commit bcbf96b
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,8 @@ module subroutine swiftest_io_netcdf_initialize_output(self, param)
call netcdf_io_check( nf90_def_var(nc%id, nc%rot_varname, nc%out_type, [nc%space_dimid, nc%name_dimid, nc%time_dimid], &
nc%rot_varid), &
"netcdf_io_initialize_output nf90_def_var rot_varid" )
call netcdf_io_check( nf90_def_var(nc%id, nc%rotphase_varname, nc%out_type, nc%time_dimid, nc%rotphase_varid), &
"netcdf_io_initialize_output nf90_def_var rotphase_varid" )
end if

! if (param%ltides) then
Expand Down Expand Up @@ -1179,6 +1181,14 @@ module subroutine swiftest_io_netcdf_open(self, param, readonly)
"swiftest_io_netcdf_open nf90_inq_varid Ip_varid" )
call netcdf_io_check( nf90_inq_varid(nc%id, nc%rot_varname, nc%rot_varid), &
"swiftest_io_netcdf_open nf90_inq_varid rot_varid" )


! rotphase may not be input by the user
status = nf90_inq_varid(nc%id, nc%rotphase_varname, nc%rotphase_varid)

! call netcdf_io_check( nf90_inq_varid(nc%id, nc%rotphase_varname, nc%rotphase_varid), &
! "swiftest_io_netcdf_open nf90_inq_varid rotphase_varid")

end if

! if (param%ltides) then
Expand Down Expand Up @@ -1515,7 +1525,16 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier
end do

! Set initial central body angular momentum for bookkeeping
cb%L0(:) = cb%Ip(3) * cb%mass * cb%R0**2 * cb%rot(:)
cb%L0(:) = cb%Ip(3) * cb%mass * cb%R0**2 * cb%rot(:)

! rotphase may not be input by the user
status = nf90_inq_varid(nc%id, nc%rotphase_varname, nc%rotphase_varid)
if (status == NF90_NOERR) then
call netcdf_io_check( nf90_get_var(nc%id, nc%rotphase_varid, cb%rotphase, start=[tslot]), &
"netcdf_io_read_frame_system nf90_getvar rotphase_varid" )
else
cb%rotphase = 0.0_DP
end if
end if

! if (param%ltides) then
Expand Down Expand Up @@ -2104,9 +2123,10 @@ module subroutine swiftest_io_netcdf_write_frame_cb(self, nc, param)
call netcdf_io_check( nf90_put_var(nc%id, nc%rot_varid, self%rot(:) * RAD2DEG, start=[1, idslot, tslot], &
count=[NDIM,1,1]), &
"swiftest_io_netcdf_write_frame_cb nf90_put_var cb rot_varid" )
! ADD
! call netcdf_io_check( nf90_put_var(nc%id, nc%rotphase_varid, self%rotphase(:), start = [1, idslot, tslot]), &
! "swiftest_io_netcdf_write_frame_cb nf90_put_var cb rotphase")

! Following the template of j2rp2
call netcdf_io_check( nf90_put_var(nc%id, nc%rotphase_varid, self%rotphase, start = [tslot]), & ! start = [1, idslot, tslot]), &
"swiftest_io_netcdf_write_frame_cb nf90_put_var cb rotphase")
end if

status = nf90_inq_varid(nc%id, nc%c_lm_varname, nc%c_lm_varid)
Expand Down

0 comments on commit bcbf96b

Please sign in to comment.