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

Commit

Permalink
New parameter parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 6, 2022
1 parent 3425a42 commit 8616c1f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ module symba_classes
real(DP), private, parameter :: RSHELL = 0.48075_DP

type, extends(swiftest_parameters) :: symba_parameters
real(DP) :: GMTINY = -1.0_DP !! Smallest G*mass that is fully gravitating
real(DP) :: min_GMfrag = -1.0_DP !! Smallest G*mass that can be produced in a fragmentation event
integer(I4B), dimension(:), allocatable :: seed !! Random seeds
logical :: lfragmentation = .false. !! Do fragmentation modeling instead of simple merger.
character(STRMAX) :: encounter_save = "NONE" !! Indicate how encounter and/or fragmentation data should be saved
real(DP) :: GMTINY = -1.0_DP !! Smallest G*mass that is fully gravitating
real(DP) :: min_GMfrag = -1.0_DP !! Smallest G*mass that can be produced in a fragmentation event
integer(I4B), dimension(:), allocatable :: seed !! Random seeds
logical :: lfragmentation = .false. !! Do fragmentation modeling instead of simple merger.
character(STRMAX) :: encounter_save = "NONE" !! Indicate if and how encounter data should be saved
character(STRMAX) :: fragmentation_save = "NONE" !! Indicate if and how fragmentation data should be saved
contains
procedure :: reader => symba_io_param_reader
procedure :: writer => symba_io_param_writer
Expand Down Expand Up @@ -428,7 +429,7 @@ end subroutine symba_io_encounter_initialize_output
module subroutine symba_io_encounter_write_frame(self, nc, param)
implicit none
class(symba_encounter_snapshot), intent(in) :: self !! Swiftest encounter structure
class(symba_io_encounter_parameters), intent(inout) :: nc !! Parameters used to identify a particular encounter io NetCDF dataset
class(symba_io_encounter_parameters), intent(inout) :: nc !! Parameters used to identify a particular encounter io NetCDF dataset
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine symba_io_encounter_write_frame

Expand Down
14 changes: 12 additions & 2 deletions src/symba/symba_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ module subroutine symba_io_param_reader(self, unit, iotype, v_list, iostat, ioms
case ("ENCOUNTER_SAVE")
call io_toupper(param_value)
read(param_value, *) param%encounter_save
case ("FRAGMENTATION_SAVE")
call io_toupper(param_value)
read(param_value, *) param%fragmentation_save
case("SEED")
read(param_value, *) nseeds_from_file
! Because the number of seeds can vary between compilers/systems, we need to make sure we can handle cases in which the input file has a different
Expand Down Expand Up @@ -285,9 +288,16 @@ module subroutine symba_io_param_reader(self, unit, iotype, v_list, iostat, ioms
! All reporting of collision information in SyMBA (including mergers) is now recorded in the Fraggle logfile
call io_log_start(param, FRAGGLE_LOG_OUT, "Fraggle logfile")

if ((param%encounter_save /= "NONE") .and. (param%encounter_save /= "ALL") .and. (param%encounter_save /= "FRAGMENTATION")) then
if ((param%encounter_save /= "NONE") .and. (param%encounter_save /= "TRAJECTORY") .and. (param%encounter_save /= "CLOSEST")) then
write(iomsg,*) 'Invalid encounter_save parameter: ',trim(adjustl(param%out_type))
write(iomsg,*) 'Valid options are NONE, ALL, or FRAGMENTATION'
write(iomsg,*) 'Valid options are NONE, TRAJECTORY, or CLOSEST'
iostat = -1
return
end if

if ((param%fragmentation_save /= "NONE") .and. (param%fragmentation_save /= "TRAJECTORY") .and. (param%fragmentation_save /= "CLOSEST")) then
write(iomsg,*) 'Invalid fragmentation_save parameter: ',trim(adjustl(param%out_type))
write(iomsg,*) 'Valid options are NONE, TRAJECTORY, or CLOSEST'
iostat = -1
return
end if
Expand Down

0 comments on commit 8616c1f

Please sign in to comment.