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

Commit

Permalink
Added template for a new write_frame method for encounter list objects
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 2, 2022
1 parent 88489cb commit 41e353e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
15 changes: 14 additions & 1 deletion src/encounter/encounter_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module subroutine encounter_io_open_file(self, param, readonly)
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
logical, optional, intent(in) :: readonly !! Logical flag indicating that this should be open read only
! Internals
integer(I4B) :: mode, status
integer(I4B) :: mode
character(len=STRMAX) :: errmsg

mode = NF90_WRITE
Expand Down Expand Up @@ -133,4 +133,17 @@ module subroutine encounter_io_open_file(self, param, readonly)
return
end subroutine encounter_io_open_file

module subroutine encounter_io_write_frame(self, iu, param)
!! author: David A. Minton
!!
!! Write a frame of output of an encounter list structure.
implicit none
! Arguments
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

return
end subroutine encounter_io_write_frame

end submodule s_encounter_io
32 changes: 20 additions & 12 deletions src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ module encounter_classes
real(DP), dimension(:,:), allocatable :: v2 !! the velocity of body 2 in the encounter
real(DP), dimension(:), allocatable :: t !! Time of encounter
contains
procedure :: setup => encounter_setup_list !! A constructor that sets the number of encounters and allocates and initializes all arrays
procedure :: append => encounter_util_append_list !! Appends elements from one structure to another
procedure :: copy => encounter_util_copy_list !! Copies elements from the source encounter list into self.
procedure :: dealloc => encounter_util_dealloc_list !! Deallocates all allocatables
procedure :: spill => encounter_util_spill_list !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: resize => encounter_util_resize_list !! Checks the current size of the encounter list against the required size and extends it by a factor of 2 more than requested if it is too small.
final :: encounter_util_final_list !! Finalize the encounter list - deallocates all allocatables
procedure :: setup => encounter_setup_list !! A constructor that sets the number of encounters and allocates and initializes all arrays
procedure :: append => encounter_util_append_list !! Appends elements from one structure to another
procedure :: copy => encounter_util_copy_list !! Copies elements from the source encounter list into self.
procedure :: dealloc => encounter_util_dealloc_list !! Deallocates all allocatables
procedure :: spill => encounter_util_spill_list !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: resize => encounter_util_resize_list !! Checks the current size of the encounter list against the required size and extends it by a factor of 2 more than requested if it is too small.
procedure :: write_frame => encounter_io_write_frame !! Writes a frame of encounter data to file
final :: encounter_util_final_list !! Finalize the encounter list - deallocates all allocatables
end type encounter_list

type, extends(swiftest_storage) :: encounter_storage
Expand All @@ -48,11 +49,11 @@ module encounter_classes
end type encounter_storage

!! NetCDF dimension and variable names for the enounter save object
character(*), parameter :: ENCID_DIMNAME = "encounter" !! The index of the encountering pair in the encounter list
character(*), parameter :: COLLIDER_DIMNAME = "collider" !! Dimension that defines the colliding bodies (bodies 1 and 2 are at dimension coordinates 1 and 2, respectively)
integer(I4B), parameter :: COLLIDER_DIM_SIZE = 2 !! Size of collider dimension
character(*), parameter :: NENC_VARNAME = "nenc" !! Total number of encounters
character(*), parameter :: LEVEL_VARNAME = "level" !! Recursion depth
character(*), parameter :: ENCID_DIMNAME = "encounter" !! The index of the encountering pair in the encounter list
character(*), parameter :: COLLIDER_DIMNAME = "collider" !! Dimension that defines the colliding bodies (bodies 1 and 2 are at dimension coordinates 1 and 2, respectively)
integer(I4B), parameter :: COLLIDER_DIM_SIZE = 2 !! Size of collider dimension
character(*), parameter :: NENC_VARNAME = "nenc" !! Total number of encounters
character(*), parameter :: LEVEL_VARNAME = "level" !! Recursion depth

type, extends(netcdf_parameters) :: encounter_io_parameters
character(STRMAX) :: outfile = "encounter.nc" !! Encounter output file name
Expand Down Expand Up @@ -219,6 +220,13 @@ module subroutine encounter_io_open_file(self, param, readonly)
logical, optional, intent(in) :: readonly !! Logical flag indicating that this should be open read only
end subroutine encounter_io_open_file

module subroutine encounter_io_write_frame(self, iu, param)
implicit none
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
end subroutine encounter_io_write_frame

module subroutine encounter_setup_aabb(self, n, n_last)
implicit none
class(encounter_bounding_box), intent(inout) :: self !! Swiftest encounter structure
Expand Down

0 comments on commit 41e353e

Please sign in to comment.