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

Commit

Permalink
More updates to encounter write methods
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 2, 2022
1 parent 9bb2bda commit 8b431a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
28 changes: 22 additions & 6 deletions src/encounter/encounter_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@
use netcdf
contains

module subroutine encounter_io_dump_storage_list(self, param, system)
module subroutine encounter_io_dump_storage_list(self, param)
!! author: David A. Minton
!!
!! Dumps the time history of an encounter to file.
implicit none
! Arguments
class(encounter_storage(*)), intent(inout) :: self !! Encounter storage object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
class(swiftest_nbody_system), intent(in), optional :: system !! Swiftest nbody system object
! Internals
integer(I4B) :: i

! Most of this is just temporary test code just to get something working. Eventually this should get cleaned up.


call self%nciu%initialize(param)
do i = 1, self%nframes
if (allocated(self%frame(i)%item)) then
select type(plplenc_list => self%frame(i)%item)
class is (symba_plplenc)
self%nciu%ienc_frame = i
call plplenc_list%write_frame(self%nciu,param)
end select
end if
end do
call self%nciu%close()


return
Expand All @@ -42,12 +51,10 @@ module subroutine encounter_io_initialize_output(self, param)
class(encounter_io_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: nvar, varid, vartype
real(DP) :: dfill
real(SP) :: sfill
logical :: fileExists
character(len=STRMAX) :: errmsg
integer(I4B) :: ndims

dfill = ieee_value(dfill, IEEE_QUIET_NAN)
sfill = ieee_value(sfill, IEEE_QUIET_NAN)
Expand Down Expand Up @@ -151,6 +158,15 @@ module subroutine encounter_io_write_frame(self, iu, param)
class(encounter_list), intent(in) :: self !! Swiftest encounter structure
class(encounter_io_parameters), intent(inout) :: iu !! Parameters used to identify a particular encounter io NetCDF dataset
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: i,old_mode, n

i = iu%ienc_frame
n = int(self%nenc, kind=I4B)
call check( nf90_set_fill(iu%ncid, nf90_nofill, old_mode), "encounter_io_write_frame_base nf90_set_fill" )
call check( nf90_put_var(iu%ncid, iu%time_varid, self%t, start=[i]), "netcdf_write_hdr_system nf90_put_var time_varid" )
call check( nf90_put_var(iu%ncid, iu%xhx_varid, self%x1(1, 1), start=[1, 1, i]), "netcdf_write_frame_base nf90_put_var xhx_varid" )


return
end subroutine encounter_io_write_frame
Expand Down
4 changes: 2 additions & 2 deletions src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module encounter_classes
integer(I4B) :: encid_varid !! NetCDF ID for the encounter pair index variable
integer(I4B) :: nenc_varid !! NetCDF ID for the number of encounters variable
integer(I4B) :: level_varid !! NetCDF ID for the recursion level variable
integer(I4B) :: ienc_frame !! Current frame number for the encounter history
contains
procedure :: initialize => encounter_io_initialize_output !! Initialize a set of parameters used to identify a NetCDF output object
procedure :: open => encounter_io_open_file !! Opens a NetCDF file
Expand Down Expand Up @@ -207,11 +208,10 @@ module subroutine encounter_check_sweep_aabb_single_list(self, n, x, v, renc, dt
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical array indicating which pairs are approaching
end subroutine encounter_check_sweep_aabb_single_list

module subroutine encounter_io_dump_storage_list(self, param, system)
module subroutine encounter_io_dump_storage_list(self, param)
implicit none
class(encounter_storage(*)), intent(inout) :: self !! Encounter storage object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
class(swiftest_nbody_system), intent(in), optional :: system !! Swiftest nbody system object
end subroutine encounter_io_dump_storage_list

module subroutine encounter_io_initialize_output(self, param)
Expand Down

0 comments on commit 8b431a0

Please sign in to comment.