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

Commit

Permalink
Added time-varying status variable to output. This should help to sel…
Browse files Browse the repository at this point in the history
…ect bodies that are valid at any given time step in the output
  • Loading branch information
daminton committed Jan 5, 2023
1 parent bcce9ea commit 825c2d9
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 47 deletions.
12 changes: 4 additions & 8 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2950,17 +2950,13 @@ def clean(self):
old_files = [self.simdir / self.param['BIN_OUT'],
self.simdir / "fraggle.log",
self.simdir / "swiftest.log",
self.simdir / "collisions.log",
self.simdir / "collisions.nc",
self.simdir / "encounters.nc",
self.simdir / "param.restart.in",
]
glob_files = [self.simdir.glob("**/dump_param?.in")] \
+ [self.simdir.glob("**/dump_bin?.nc")] \
+ [self.simdir.glob("**/encounter_*.nc")] \
+ [self.simdir.glob("**/collision_*.nc")]

for f in old_files:
if f.exists():
os.remove(f)
for g in glob_files:
for f in g:
if f.exists():
os.remove(f)
return
3 changes: 2 additions & 1 deletion src/collision/collision_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ module subroutine collision_io_netcdf_initialize_output(self, param)
call netcdf_io_check( nf90_def_var_fill(nc%id, varid, NO_FILL, 0), "collision_io_netcdf_initialize_output nf90_def_var_fill NF90_CHAR" )
end select
end do

! Take the file out of define mode
call netcdf_io_check( nf90_enddef(nc%id), "collision_io_netcdf_initialize_output nf90_enddef" )

Expand Down Expand Up @@ -368,7 +369,7 @@ module subroutine collision_io_netcdf_write_frame_snapshot(self, history, param)
select type(nc => history%nc)
class is (collision_netcdf_parameters)
associate(collider => self%collider, impactors => self%collider%impactors, fragments => self%collider%fragments, eslot => self%collider%collision_id)
call netcdf_io_check( nf90_set_fill(nc%id, nf90_nofill, old_mode), "collision_io_netcdf_write_frame_snapshot nf90_set_fill" )
call netcdf_io_check( nf90_set_fill(nc%id, NF90_NOFILL, old_mode), "collision_io_netcdf_write_frame_snapshot nf90_set_fill" )

call netcdf_io_check( nf90_put_var(nc%id, nc%collision_id_varid, eslot, start=[eslot]), "collision_io_netcdf_write_frame_snapshot nf90_put_var collision_id_varid" )
call netcdf_io_check( nf90_put_var(nc%id, nc%time_varid, self%t, start=[eslot]), "collision_io_netcdf_write_frame_snapshot nf90_put_var time_varid" )
Expand Down
2 changes: 1 addition & 1 deletion src/encounter/encounter_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ module subroutine encounter_io_netcdf_write_frame_snapshot(self, history, param)
select type (nc => history%nc)
class is (encounter_netcdf_parameters)
associate(tslot => nc%tslot)
call netcdf_io_check( nf90_set_fill(nc%id, nf90_nofill, old_mode), "encounter_io_netcdf_write_frame_snapshot nf90_set_fill" )
call netcdf_io_check( nf90_set_fill(nc%id, NF90_NOFILL, old_mode), "encounter_io_netcdf_write_frame_snapshot nf90_set_fill" )

call netcdf_io_check( nf90_put_var(nc%id, nc%time_varid, self%t, start=[tslot]), "encounter_io_netcdf_write_frame_snapshot nf90_put_var time_varid" )

Expand Down
2 changes: 1 addition & 1 deletion src/netcdf_io/netcdf_io_implementations.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module subroutine netcdf_io_check(status, call_identifier)
integer, intent (in) :: status !! The status code returned by a NetCDF function
character(len=*), intent(in), optional :: call_identifier !! String that indicates which calling function caused the error for diagnostic purposes

if(status /= nf90_noerr) then
if(status /= NF90_NOERR) then
if (present(call_identifier)) write(*,*) "NetCDF error in ",trim(call_identifier)
write(*,*) trim(nf90_strerror(status))
call util_exit(FAILURE)
Expand Down
2 changes: 2 additions & 0 deletions src/netcdf_io/netcdf_io_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module netcdf_io
! Non-dimension ids and variable names
character(NAMELEN) :: id_varname = "id" !! name of the particle id variable
integer(I4B) :: id_varid !! ID for the id variable
character(NAMELEN) :: status_varname = "status" !! name of the particle status variable
integer(I4B) :: status_varid !! ID for the status variable
character(NAMELEN) :: ptype_varname = "particle_type" !! name of the particle type variable
integer(I4B) :: ptype_varid !! ID for the particle type variable
character(NAMELEN) :: npl_varname = "npl" !! name of the number of active massive bodies variable
Expand Down
Loading

0 comments on commit 825c2d9

Please sign in to comment.