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

Commit

Permalink
Started fleshing out the write_frame method for collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 9, 2022
1 parent 876f2b7 commit 9af252d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
42 changes: 40 additions & 2 deletions src/fraggle/fraggle_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module subroutine fraggle_io_initialize_output(self, param)
dfill = ieee_value(dfill, IEEE_QUIET_NAN)
sfill = ieee_value(sfill, IEEE_QUIET_NAN)


select case (param%out_type)
case("NETCDF_FLOAT")
self%out_type = NF90_FLOAT
Expand All @@ -50,7 +49,6 @@ module subroutine fraggle_io_initialize_output(self, param)
close(unit=LUN, status="delete")
end if


call check( nf90_create(nc%file_name, NF90_NETCDF4, nc%id), "fraggle_io_initialize nf90_create" )

! Dimensions
Expand Down Expand Up @@ -146,10 +144,50 @@ end subroutine fraggle_io_initialize_output


module subroutine fraggle_io_write_frame(self, nc, param)
!! author: David A. Minton
!!
!! Write a frame of output of a collision result
use netcdf
implicit none
! Arguments
class(fraggle_encounter_snapshot), intent(in) :: self !! Swiftest encounter structure
class(encounter_io_parameters), intent(inout) :: nc !! Parameters used to identify a particular encounter io NetCDF dataset
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: i, tslot, idslot, old_mode, npl
character(len=NAMELEN) :: charstring

tslot = param%ioutput
associate(pl => self%pl, colliders => self%colliders, fragments => self%fragments)

call check( nf90_set_fill(nc%id, nf90_nofill, old_mode), "fraggle_io_write_frame nf90_set_fill" )

call check( nf90_put_var(nc%id, nc%time_varid, self%t, start=[tslot]), "fraggle_io_write_frame nf90_put_var time_varid" )
call check( nf90_put_var(nc%id, nc%loop_varid, int(self%iloop,kind=I4B), start=[tslot]), "fraggle_io_write_frame nf90_put_var pl loop_varid" )

! npl = pl%nbody
! do i = 1, npl
! idslot = pl%id(i)
! call check( nf90_put_var(nc%id, nc%id_varid, pl%id(i), start=[idslot]), "fraggle_io_write_frame nf90_put_var pl id_varid" )
! call check( nf90_put_var(nc%id, nc%rh_varid, pl%rh(:,i), start=[1,idslot,tslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl rh_varid" )
! call check( nf90_put_var(nc%id, nc%vh_varid, pl%vh(:,i), start=[1,idslot,tslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl vh_varid" )
! call check( nf90_put_var(nc%id, nc%Gmass_varid, pl%Gmass(i), start=[idslot, tslot]), "fraggle_io_write_frame nf90_put_var pl Gmass_varid" )

! if (param%lclose) call check( nf90_put_var(nc%id, nc%radius_varid, pl%radius(i), start=[idslot, tslot]), "fraggle_io_write_frame nf90_put_var pl radius_varid" )

! if (param%lrotation) then
! call check( nf90_put_var(nc%id, nc%Ip_varid, pl%Ip(:,i), start=[1, idslot, tslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl Ip_varid" )
! call check( nf90_put_var(nc%id, nc%rot_varid, pl%rot(:,i), start=[1,idslot, tslot], count=[NDIM,1,1]), "fraggle_io_write_frame nf90_put_var pl rotx_varid" )
! end if

! charstring = trim(adjustl(pl%info(i)%name))
! call check( nf90_put_var(nc%id, nc%name_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "fraggle_io_write_frame nf90_put_var pl name_varid" )
! charstring = trim(adjustl(pl%info(i)%particle_type))
! call check( nf90_put_var(nc%id, nc%ptype_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "fraggle_io_write_frame nf90_put_var pl particle_type_varid" )
! end do

call check( nf90_set_fill(nc%id, old_mode, old_mode) )
end associate

return
end subroutine fraggle_io_write_frame
Expand Down
1 change: 0 additions & 1 deletion src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ module encounter_classes

!> NetCDF dimension and variable names for the enounter save object
type, extends(netcdf_parameters) :: encounter_io_parameters
integer(I4B) :: ienc_frame = 1 !! Current frame number for the encounter history
character(NAMELEN) :: loop_varname = "loopnum" !! Loop number for encounter
integer(I4B) :: loop_varid !! ID for the recursion level variable
integer(I4B) :: time_dimsize = 0 !! Number of time values in snapshot
Expand Down

0 comments on commit 9af252d

Please sign in to comment.