diff --git a/src/encounter/encounter_io.f90 b/src/encounter/encounter_io.f90 index 9ab5947b1..33915313d 100644 --- a/src/encounter/encounter_io.f90 +++ b/src/encounter/encounter_io.f90 @@ -12,7 +12,7 @@ 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. @@ -20,12 +20,21 @@ module subroutine encounter_io_dump_storage_list(self, param, system) ! 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 @@ -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) @@ -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 diff --git a/src/modules/encounter_classes.f90 b/src/modules/encounter_classes.f90 index b3d913f02..585992384 100644 --- a/src/modules/encounter_classes.f90 +++ b/src/modules/encounter_classes.f90 @@ -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 @@ -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)