From f1b80c9e72f327eb4ffb95bf4cd7344a80bc2f83 Mon Sep 17 00:00:00 2001 From: Carlisle Wishard Date: Mon, 28 Jun 2021 14:10:43 -0400 Subject: [PATCH] added new variables to dump files so that restarting from dump works --- Makefile | 1 - src/main/swiftest_symba.f90 | 4 +- src/modules/io.f90 | 1 - src/modules/module_interfaces.f90 | 7 -- src/modules/swiftest.f90 | 1 - src/modules/swiftest_data_structures.f90 | 112 ++++++++++++++++++++- src/modules/user.f90 | 121 ----------------------- src/tool/tool_encounter_read.f90 | 4 +- src/user/user_dump_param.f90 | 9 +- src/user/user_get_token.f90 | 2 +- src/user/user_read_param_in.f90 | 9 +- src/user/user_udio_reader.f90 | 40 +++++++- src/user/user_udio_writer.f90 | 15 ++- 13 files changed, 178 insertions(+), 148 deletions(-) delete mode 100644 src/modules/user.f90 diff --git a/Makefile b/Makefile index 4be91714d..61017994f 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,6 @@ #****************************************************************************** SWIFTEST_MODULES = swiftest_globals.f90 \ - user.f90 \ swiftest_data_structures.f90 \ lambda_function.f90\ module_swifter.f90 \ diff --git a/src/main/swiftest_symba.f90 b/src/main/swiftest_symba.f90 index 931171d53..e271720de 100644 --- a/src/main/swiftest_symba.f90 +++ b/src/main/swiftest_symba.f90 @@ -82,7 +82,7 @@ program swiftest_symba 100 format(a) inparfile = trim(adjustl(inparfile)) ! read in the param.in file and get simulation parameters - call param%read_from_file(inparfile) + call param%read_from_file(inparfile, symba_plA%helio%swiftest) param%lmtiny = .true. ! Turn this on for SyMBA ! reads in initial conditions of all massive bodies from input file @@ -216,7 +216,7 @@ program swiftest_symba finish = clock_count / (count_rate * 1.0_DP) write(*,walltimefmt) finish - start, wallperstep - call param%dump_to_file(t) + call param%dump_to_file(t, symba_plA%helio%swiftest) call io_dump_pl_symba(npl, symba_plA, param) call io_dump_tp(ntp, symba_tpA%helio%swiftest) idump = istep_dump diff --git a/src/modules/io.f90 b/src/modules/io.f90 index 79ab37ee1..b8a2d2249 100644 --- a/src/modules/io.f90 +++ b/src/modules/io.f90 @@ -5,7 +5,6 @@ module io !! Module containing all input/output subroutine interface blocks use swiftest_globals use swiftest_data_structures - use user interface diff --git a/src/modules/module_interfaces.f90 b/src/modules/module_interfaces.f90 index c26078b60..785372cbd 100644 --- a/src/modules/module_interfaces.f90 +++ b/src/modules/module_interfaces.f90 @@ -26,7 +26,6 @@ MODULE module_interfaces use swiftest_globals use swiftest_data_structures - use user IMPLICIT NONE @@ -1148,7 +1147,6 @@ SUBROUTINE symba_step(t, dt, param,npl, ntp,symba_plA, symba_tpA, & USE swiftest_data_structures USE module_helio USE module_symba - use user IMPLICIT NONE TYPE(user_input_parameters), INTENT(INOUT) :: param ! Derived type containing user defined parameters INTEGER(I4B), INTENT(IN) :: npl, ntp @@ -1205,7 +1203,6 @@ SUBROUTINE symba_step_interp(t, npl, nplm, ntp, symba_plA, symba_tpA, & USE swiftest_data_structures USE module_helio USE module_symba - use user IMPLICIT NONE INTEGER(I4B), INTENT(IN) :: npl, nplm, ntp, nplplenc, npltpenc INTEGER(I4B), INTENT(INOUT) :: nmergeadd, nmergesub @@ -1226,7 +1223,6 @@ RECURSIVE SUBROUTINE symba_step_recur(t, ireci, npl, nplm, ntp, symba_plA, symba USE swiftest_data_structures USE module_helio USE module_symba - use user IMPLICIT NONE INTEGER(I4B), INTENT(IN) :: ireci, npl, nplm, ntp, nplplenc, npltpenc INTEGER(I4B), INTENT(INOUT) :: nmergeadd, nmergesub @@ -1345,7 +1341,6 @@ SUBROUTINE symba_step_eucl(t,dt,param,npl, ntp,symba_plA, symba_tpA, & USE swiftest_data_structures USE module_helio USE module_symba - use user IMPLICIT NONE TYPE(user_input_parameters), INTENT(INOUT) :: param ! Derived type containing user defined parameters INTEGER(I4B), INTENT(IN) :: npl, ntp @@ -1367,7 +1362,6 @@ SUBROUTINE symba_step_interp_eucl(t, npl, nplm, ntp, symba_plA, symba_tpA,& USE swiftest_globals USE swiftest_data_structures USE module_symba - USE user IMPLICIT NONE INTEGER(I4B), INTENT(IN) :: npl, nplm, ntp, nplplenc, npltpenc INTEGER(I4B), INTENT(INOUT) :: nmergeadd, nmergesub @@ -1402,7 +1396,6 @@ function symba_mergeadd_eoffset(npl, symba_plA, mergeadd_list, mergesub_list, ad USE swiftest_globals USE swiftest_data_structures USE module_symba - USE user implicit none integer(I4B), intent(in) :: npl type(symba_pl), intent(in) :: symba_plA diff --git a/src/modules/swiftest.f90 b/src/modules/swiftest.f90 index 1e1652690..a8f7cbe1b 100644 --- a/src/modules/swiftest.f90 +++ b/src/modules/swiftest.f90 @@ -6,7 +6,6 @@ module swiftest use swiftest_globals use swiftest_data_structures use io - use user use lambda_function !$ use omp_lib implicit none diff --git a/src/modules/swiftest_data_structures.f90 b/src/modules/swiftest_data_structures.f90 index 9d4cef58c..bb94f9bcf 100644 --- a/src/modules/swiftest_data_structures.f90 +++ b/src/modules/swiftest_data_structures.f90 @@ -4,7 +4,6 @@ module swiftest_data_structures !! Definition of data and structures generic to all integrators. !! Adapted from David E. Kaufmann's Swifter modules: module_swifter.f90 use swiftest_globals - use user implicit none type swiftest_particle_info @@ -61,6 +60,72 @@ module swiftest_data_structures procedure :: read_from_file => swiftest_read_pl_in end type swiftest_pl + type, public :: user_input_parameters + real(DP) :: t0 = 0.0_DP !! Integration start time + real(DP) :: tstop = 0.0_DP !! Integration stop time + real(DP) :: dt = 0.0_DP !! Time step + character(STRMAX) :: inplfile = '' !! Name of input file for planets + character(STRMAX) :: intpfile = '' !! Name of input file for test particles + character(STRMAX) :: in_type = 'ASCII' !! Format of input data files + integer(I4B) :: istep_out = -1 !! Number of time steps between binary outputs + character(STRMAX) :: outfile = '' !! Name of output binary file + character(STRMAX) :: particle_file = '' !! Name of output particle information file + character(STRMAX) :: out_type = REAL4_TYPE!! Binary format of output file + character(STRMAX) :: out_form = 'XV' !! Data to write to output file + character(STRMAX) :: out_stat = 'NEW' !! Open status for output binary file + integer(I4B) :: istep_dump = -1 !! Number of time steps between dumps + real(DP) :: j2rp2 = 0.0_DP !! J2 * R**2 for the Sun + real(DP) :: j4rp4 = 0.0_DP !! J4 * R**4 for the Sun + real(DP) :: rmin = -1.0_DP !! Minimum heliocentric radius for test particle + real(DP) :: rmax = -1.0_DP !! Maximum heliocentric radius for test particle + real(DP) :: rmaxu = -1.0_DP !! Maximum unbound heliocentric radius for test particle + real(DP) :: qmin = -1.0_DP !! Minimum pericenter distance for test particle + character(STRMAX) :: qmin_coord = 'HELIO' !! Coordinate frame to use for qmin + real(DP) :: qmin_alo = -1.0_DP !! Minimum semimajor axis for qmin + real(DP) :: qmin_ahi = -1.0_DP !! Maximum semimajor axis for qmin + character(STRMAX) :: encounter_file = '' !! Name of output file for encounters + real(DP) :: mtiny = 0.0_DP !! Smallest mass that is fully gravitating + character(STRMAX) :: ring_outfile = '' !! Name of output file in ring moons + real(DP) :: MU2KG = -1.0_DP !! Converts mass units to grams + real(DP) :: TU2S = -1.0_DP !! Converts time units to seconds + real(DP) :: DU2M = -1.0_DP !! Converts distance unit to centimeters + integer(I4B), dimension(:), allocatable :: seed !! Random seeds + + + !Logical flags to turn on or off various features of the code + logical :: lextra_force = .false. !! User defined force function turned on + logical :: lbig_discard = .false. !! Save big bodies on every discard + logical :: lrhill_present = .false. !! Hill's radius is in input file + logical :: lclose = .false. !! Turn on close encounters + logical :: lfragmentation = .false. !! Do fragmentation modeling instead of simple merger. + logical :: lmtiny = .false. !! Use the MTINY variable (Automatically set if running SyMBA) + logical :: lrotation = .false. !! Include rotation states of big bodies + logical :: ltides = .false. !! Include tidal dissipation + logical :: lringmoons = .false. !! Turn on the ringmoons code + logical :: lenergy = .false. !! Track the total energy of the system + logical :: lfirstenergy = .true. + real(DP) :: Eorbit_orig = 0.0_DP + real(DP) :: Mtot_orig = 0.0_DP + real(DP) :: Lmag_orig = 0.0_DP + real(DP), dimension(NDIM) :: Ltot_orig = 0.0_DP + real(DP), dimension(NDIM) :: Lorbit_orig = 0.0_DP + real(DP), dimension(NDIM) :: Lspin_orig = 0.0_DP + logical :: lfirstkick = .true. !! Initiate the first kick in a symplectic step + + ! Future features not implemented or in development + logical :: lgr = .false. !! Turn on GR + logical :: lyarkovsky = .false. !! Turn on Yarkovsky effect + logical :: lyorp = .false. !! Turn on YORP effect + contains + procedure :: read_from_file => user_read_param_in + procedure :: dump_to_file => user_dump_param + procedure :: udio_reader => user_udio_reader + procedure :: udio_writer => user_udio_writer + !TODO: Figure out if user-defined derived-type io can be made to work properly + !generic :: read(formatted) => udio_reader + !generic :: write(formatted) => udio_writer + end type user_input_parameters + interface module subroutine swiftest_read_pl_in(self, param) @@ -72,6 +137,51 @@ module subroutine swiftest_read_tp_in(self, param) class(swiftest_tp), intent(inout) :: self !! Swiftest data structure to store massive body initial conditions type(user_input_parameters), intent(inout) :: param !! Input collection of user-defined parameters end subroutine swiftest_read_tp_in + + module function user_get_token(buffer, ifirst, ilast, ierr) result(token) + character(len=*), intent(in) :: buffer !! Input string buffer + integer(I4B), intent(inout) :: ifirst !! Index of the buffer at which to start the search for a token + integer(I4B), intent(out) :: ilast !! Index of the buffer at the end of the returned token + integer(I4B), intent(out) :: ierr !! Error code + character(len=:),allocatable :: token !! Returned token string + end function user_get_token + + !> Interface for type-bound procedure to read in the input parameters from a file + module subroutine user_read_param_in(param, inparfile, swiftest_plA) + class(user_input_parameters),intent(out) :: param !! Input collection of user-defined parameters + character(*), intent(in) :: inparfile !! Parameter input file name (i.e. param.in) + type(swiftest_pl), intent(inout) :: swiftest_plA + end subroutine user_read_param_in + + !> Interface for type-bound procedure to write out the user parameters into a dump file in case the run needs to be restarted + module subroutine user_dump_param(param, t, swiftest_plA) + class(user_input_parameters),intent(in) :: param !! Output collection of user-defined parameters + real(DP),intent(in) :: t !! Current simulation time + type(swiftest_pl), intent(inout) :: swiftest_plA + end subroutine user_dump_param + + !> Interface for type-bound procedure for user-defined derived-type IO for reading + module subroutine user_udio_reader(param, unit, iotype, v_list, iostat, iomsg, swiftest_plA) + class(user_input_parameters),intent(inout) :: param !! Input collection of user-defined parameters + integer, intent(in) :: unit + character(len=*), intent(in) :: iotype + integer, intent(in) :: v_list(:) + integer, intent(out) :: iostat + character(len=*), intent(inout) :: iomsg + type(swiftest_pl), intent(inout) :: swiftest_plA + end subroutine user_udio_reader + + !> Interface for type-bound procedure for user-defined derived-type IO for writing + module subroutine user_udio_writer(param, unit, iotype, v_list, iostat, iomsg, swiftest_plA) + class(user_input_parameters),intent(in) :: param !! Output collection of user-defined parameters + integer, intent(in) :: unit + character(len=*), intent(in) :: iotype + integer, intent(in) :: v_list(:) + integer, intent(out) :: iostat + character(len=*), intent(inout) :: iomsg + type(swiftest_pl), intent(inout) :: swiftest_plA + end subroutine user_udio_writer + end interface contains diff --git a/src/modules/user.f90 b/src/modules/user.f90 deleted file mode 100644 index 2f7bf92e9..000000000 --- a/src/modules/user.f90 +++ /dev/null @@ -1,121 +0,0 @@ -module user - !! author: David A. Minton - !! todo: Replace XDR with HDF5 - !! - !! Module containing all input/output subroutine interface blocks - use swiftest_globals - - !> User defined input parameters that are read in from param.in - type, public :: user_input_parameters - real(DP) :: t0 = 0.0_DP !! Integration start time - real(DP) :: tstop = 0.0_DP !! Integration stop time - real(DP) :: dt = 0.0_DP !! Time step - character(STRMAX) :: inplfile = '' !! Name of input file for planets - character(STRMAX) :: intpfile = '' !! Name of input file for test particles - character(STRMAX) :: in_type = 'ASCII' !! Format of input data files - integer(I4B) :: istep_out = -1 !! Number of time steps between binary outputs - character(STRMAX) :: outfile = '' !! Name of output binary file - character(STRMAX) :: particle_file = '' !! Name of output particle information file - character(STRMAX) :: out_type = REAL4_TYPE!! Binary format of output file - character(STRMAX) :: out_form = 'XV' !! Data to write to output file - character(STRMAX) :: out_stat = 'NEW' !! Open status for output binary file - integer(I4B) :: istep_dump = -1 !! Number of time steps between dumps - real(DP) :: j2rp2 = 0.0_DP !! J2 * R**2 for the Sun - real(DP) :: j4rp4 = 0.0_DP !! J4 * R**4 for the Sun - real(DP) :: rmin = -1.0_DP !! Minimum heliocentric radius for test particle - real(DP) :: rmax = -1.0_DP !! Maximum heliocentric radius for test particle - real(DP) :: rmaxu = -1.0_DP !! Maximum unbound heliocentric radius for test particle - real(DP) :: qmin = -1.0_DP !! Minimum pericenter distance for test particle - character(STRMAX) :: qmin_coord = 'HELIO' !! Coordinate frame to use for qmin - real(DP) :: qmin_alo = -1.0_DP !! Minimum semimajor axis for qmin - real(DP) :: qmin_ahi = -1.0_DP !! Maximum semimajor axis for qmin - character(STRMAX) :: encounter_file = '' !! Name of output file for encounters - real(DP) :: mtiny = 0.0_DP !! Smallest mass that is fully gravitating - character(STRMAX) :: ring_outfile = '' !! Name of output file in ring moons - real(DP) :: MU2KG = -1.0_DP !! Converts mass units to grams - real(DP) :: TU2S = -1.0_DP !! Converts time units to seconds - real(DP) :: DU2M = -1.0_DP !! Converts distance unit to centimeters - integer(I4B), dimension(:), allocatable :: seed !! Random seeds - - - !Logical flags to turn on or off various features of the code - logical :: lextra_force = .false. !! User defined force function turned on - logical :: lbig_discard = .false. !! Save big bodies on every discard - logical :: lrhill_present = .false. !! Hill's radius is in input file - logical :: lclose = .false. !! Turn on close encounters - logical :: lfragmentation = .false. !! Do fragmentation modeling instead of simple merger. - logical :: lmtiny = .false. !! Use the MTINY variable (Automatically set if running SyMBA) - logical :: lrotation = .false. !! Include rotation states of big bodies - logical :: ltides = .false. !! Include tidal dissipation - logical :: lringmoons = .false. !! Turn on the ringmoons code - logical :: lenergy = .false. !! Track the total energy of the system - logical :: lfirstenergy = .true. - real(DP) :: Eorbit_orig = 0.0_DP - real(DP) :: Mtot_orig = 0.0_DP - real(DP) :: Lmag_orig = 0.0_DP - real(DP), dimension(NDIM) :: Ltot_orig = 0.0_DP - real(DP), dimension(NDIM) :: Lorbit_orig = 0.0_DP - real(DP), dimension(NDIM) :: Lspin_orig = 0.0_DP - logical :: lfirstkick = .true. !! Initiate the first kick in a symplectic step - - ! Future features not implemented or in development - logical :: lgr = .false. !! Turn on GR - logical :: lyarkovsky = .false. !! Turn on Yarkovsky effect - logical :: lyorp = .false. !! Turn on YORP effect - contains - procedure :: read_from_file => user_read_param_in - procedure :: dump_to_file => user_dump_param - procedure :: udio_reader => user_udio_reader - procedure :: udio_writer => user_udio_writer - !TODO: Figure out if user-defined derived-type io can be made to work properly - !generic :: read(formatted) => udio_reader - !generic :: write(formatted) => udio_writer - end type user_input_parameters - - interface - - module function user_get_token(buffer, ifirst, ilast, ierr) result(token) - character(len=*), intent(in) :: buffer !! Input string buffer - integer(I4B), intent(inout) :: ifirst !! Index of the buffer at which to start the search for a token - integer(I4B), intent(out) :: ilast !! Index of the buffer at the end of the returned token - integer(I4B), intent(out) :: ierr !! Error code - character(len=:),allocatable :: token !! Returned token string - end function user_get_token - - !> Interface for type-bound procedure to read in the input parameters from a file - module subroutine user_read_param_in(param,inparfile) - class(user_input_parameters),intent(out) :: param !! Input collection of user-defined parameters - character(*), intent(in) :: inparfile !! Parameter input file name (i.e. param.in) - end subroutine user_read_param_in - - !> Interface for type-bound procedure to write out the user parameters into a dump file in case the run needs to be restarted - module subroutine user_dump_param(param,t) - class(user_input_parameters),intent(in) :: param !! Output collection of user-defined parameters - real(DP),intent(in) :: t !! Current simulation time - end subroutine user_dump_param - - !> Interface for type-bound procedure for user-defined derived-type IO for reading - module subroutine user_udio_reader(param, unit, iotype, v_list, iostat, iomsg) - class(user_input_parameters),intent(inout) :: param !! Input collection of user-defined parameters - integer, intent(in) :: unit - character(len=*), intent(in) :: iotype - integer, intent(in) :: v_list(:) - integer, intent(out) :: iostat - character(len=*), intent(inout) :: iomsg - end subroutine user_udio_reader - - !> Interface for type-bound procedure for user-defined derived-type IO for writing - module subroutine user_udio_writer(param, unit, iotype, v_list, iostat, iomsg) - class(user_input_parameters),intent(in) :: param !! Output collection of user-defined parameters - integer, intent(in) :: unit - character(len=*), intent(in) :: iotype - integer, intent(in) :: v_list(:) - integer, intent(out) :: iostat - character(len=*), intent(inout) :: iomsg - end subroutine user_udio_writer - - end interface - -end module user - - diff --git a/src/tool/tool_encounter_read.f90 b/src/tool/tool_encounter_read.f90 index f9b9d3bff..29fc01148 100644 --- a/src/tool/tool_encounter_read.f90 +++ b/src/tool/tool_encounter_read.f90 @@ -28,11 +28,13 @@ PROGRAM tool_encounter_read ! Modules USE swiftest USE module_interfaces + USE swiftest_data_structures use io IMPLICIT NONE ! Arguments type(user_input_parameters) :: param ! derived type containing user-defined parameters + type(swiftest_pl) :: swiftest_plA INTEGER(I4B) :: istep_out ! Time steps between binary outputs INTEGER(I4B) :: istep_dump ! Time steps between dumps REAL(DP) :: t0 ! Integration start time @@ -70,7 +72,7 @@ PROGRAM tool_encounter_read READ(*,100)inparfile 100 FORMAT(A) inparfile=TRIM(ADJUSTL(inparfile)) - call param%read_from_file(inparfile) + call param%read_from_file(inparfile, swiftest_plA) ! temporary until the conversion to the derived type argument list is complete t0 = param%t0 diff --git a/src/user/user_dump_param.f90 b/src/user/user_dump_param.f90 index a1505b978..5a8187ff8 100644 --- a/src/user/user_dump_param.f90 +++ b/src/user/user_dump_param.f90 @@ -1,6 +1,6 @@ -submodule(user) s_user_dump_param +submodule(swiftest_data_structures) s_user_dump_param contains - module subroutine user_dump_param(param,t) + module subroutine user_dump_param(param, t, swiftest_plA) !! author: David A. Minton !! !! Dump integration parameters to file @@ -12,7 +12,8 @@ module subroutine user_dump_param(param,t) ! Arguments class(user_input_parameters),intent(in) :: param !! Output collection of user-defined parameters - real(DP),intent(in) :: t !! Current simulation tim + real(DP),intent(in) :: t !! Current simulation tim + type(swiftest_pl), intent(inout) :: swiftest_plA ! Internals type(user_input_parameters) :: param_dump !! Data type of dumped parameter file @@ -38,7 +39,7 @@ module subroutine user_dump_param(param,t) !! todo: Currently this procedure does not work in user-defined derived-type input mode !! due to compiler incompatabilities !write(LUN,'(DT)') param_dump - call param_dump%udio_writer(LUN, iotype="none",v_list=(/0/),iostat=ierr,iomsg=error_message) + call param_dump%udio_writer(LUN, iotype="none",v_list=(/0/),iostat=ierr,iomsg=error_message, swiftest_plA=swiftest_plA) call random_seed(put = param_dump%seed) if (idx == 2) then diff --git a/src/user/user_get_token.f90 b/src/user/user_get_token.f90 index ec8ac3992..2bd14c188 100644 --- a/src/user/user_get_token.f90 +++ b/src/user/user_get_token.f90 @@ -1,4 +1,4 @@ -submodule(user) s_user_get_token +submodule(swiftest_data_structures) s_user_get_token contains module function user_get_token(buffer, ifirst, ilast, ierr) result(token) !! author: David A. Minton diff --git a/src/user/user_read_param_in.f90 b/src/user/user_read_param_in.f90 index b3400279f..c5c8f334e 100644 --- a/src/user/user_read_param_in.f90 +++ b/src/user/user_read_param_in.f90 @@ -1,6 +1,6 @@ -submodule (user) s_user_read_param_in +submodule (swiftest_data_structures) s_user_read_param_in contains - module subroutine user_read_param_in(param,inparfile) + module subroutine user_read_param_in(param, inparfile, swiftest_plA) !! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott !! !! Read in parameters for the integration @@ -13,7 +13,8 @@ module subroutine user_read_param_in(param,inparfile) ! Arguments class(user_input_parameters),intent(out) :: param !! Input collection of user-defined parameters - character(*), intent(in) :: inparfile !! Parameter input file name (i.e. param.in) + character(*), intent(in) :: inparfile !! Parameter input file name (i.e. param.in) + type(swiftest_pl), intent(inout) :: swiftest_plA ! Internals integer(I4B), parameter :: LUN = 7 !! Unit number of input file @@ -35,7 +36,7 @@ module subroutine user_read_param_in(param,inparfile) !! as the newline characters are ignored in the input file when compiled in ifort. !read(LUN,'(DT)', iostat= ierr, iomsg = error_message) param - call param%udio_reader(LUN,iotype="none",v_list=(/0/),iostat=ierr,iomsg=error_message) + call param%udio_reader(LUN,iotype="none",v_list=(/0/),iostat=ierr,iomsg=error_message, swiftest_plA=swiftest_plA) if (ierr /= 0) then write(*,*) 'Swiftest error reading ', trim(adjustl(inparfile)) write(*,*) ierr,trim(adjustl(error_message)) diff --git a/src/user/user_udio_reader.f90 b/src/user/user_udio_reader.f90 index add51bc2d..41011e670 100644 --- a/src/user/user_udio_reader.f90 +++ b/src/user/user_udio_reader.f90 @@ -1,6 +1,6 @@ -submodule (user) s_user_udio_reader +submodule (swiftest_data_structures) s_user_udio_reader contains - module subroutine user_udio_reader(param, unit, iotype, v_list, iostat, iomsg) + module subroutine user_udio_reader(param, unit, iotype, v_list, iostat, iomsg, swiftest_plA) !! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott !! !! Read in parameters for the integration @@ -22,6 +22,7 @@ module subroutine user_udio_reader(param, unit, iotype, v_list, iostat, iomsg) integer, intent(in) :: v_list(:) integer, intent(out) :: iostat character(len=*), intent(inout) :: iomsg + type(swiftest_pl), intent(inout) :: swiftest_plA ! Internals logical :: t0_set = .false. !! Is the initial time set in the input file? @@ -211,6 +212,41 @@ module subroutine user_udio_reader(param, unit, iotype, v_list, iostat, iomsg) param_value = user_get_token(line, ifirst, ilast, iostat) read(param_value, *) param%Lspin_orig(i) end do + case("LCB_INITIAL") + read(param_value, *) swiftest_plA%Lcb_initial(1) + do i = 2, NDIM + ifirst = ilast + 1 + param_value = user_get_token(line, ifirst, ilast, iostat) + read(param_value, *) swiftest_plA%Lcb_initial(i) + end do + case("DLCB") + read(param_value, *) swiftest_plA%dLcb(1) + do i = 2, NDIM + ifirst = ilast + 1 + param_value = user_get_token(line, ifirst, ilast, iostat) + read(param_value, *) swiftest_plA%dLcb(i) + end do + case("LESCAPE") + read(param_value, *) swiftest_plA%Lescape(1) + do i = 2, NDIM + ifirst = ilast + 1 + param_value = user_get_token(line, ifirst, ilast, iostat) + read(param_value, *) swiftest_plA%Lescape(i) + end do + case("MCB_INITIAL") + read(param_value, *) swiftest_plA%Mcb_initial + case("DMCB") + read(param_value, *) swiftest_plA%dMcb + case("MESCAPE") + read(param_value, *) swiftest_plA%Mescape + case("RCB_INITIAL") + read(param_value, *) swiftest_plA%Rcb_initial + case("DRCB") + read(param_value, *) swiftest_plA%dRcb + case("ECOLLISIONS") + read(param_value, *) swiftest_plA%Ecollisions + case("EUNTRACKED") + read(param_value, *) swiftest_plA%Euntracked case default write(iomsg,*) "Unknown parameter -> ",param_name iostat = -1 diff --git a/src/user/user_udio_writer.f90 b/src/user/user_udio_writer.f90 index d138ab584..90595ae93 100644 --- a/src/user/user_udio_writer.f90 +++ b/src/user/user_udio_writer.f90 @@ -1,6 +1,6 @@ -submodule(user) s_user_udio_writer +submodule(swiftest_data_structures) s_user_udio_writer contains - module subroutine user_udio_writer(param, unit, iotype, v_list, iostat, iomsg) + module subroutine user_udio_writer(param, unit, iotype, v_list, iostat, iomsg, swiftest_plA) !! author: David A. Minton !! !! Dump integration parameters to file @@ -17,6 +17,7 @@ module subroutine user_udio_writer(param, unit, iotype, v_list, iostat, iomsg) integer, intent(in) :: v_list(:) integer, intent(out) :: iostat character(len=*), intent(inout) :: iomsg + type(swiftest_pl), intent(inout) :: swiftest_plA ! Internals character(*),parameter :: Ifmt = '(I0)' !! Format label for integer values @@ -114,6 +115,16 @@ module subroutine user_udio_writer(param, unit, iotype, v_list, iostat, iomsg) write(unit, '("LTOT_ORIG ",3(1X,ES25.17))') param%Ltot_orig(:) write(unit, '("LORBIT_ORIG",3(1X,ES25.17))') param%Lorbit_orig(:) write(unit, '("LSPIN_ORIG ",3(1X,ES25.17))') param%Lspin_orig(:) + write(unit, '("LCB_INITIAL ",3(1X,ES25.17))') swiftest_pLA%Lcb_initial(:) + write(unit, '("DLCB ",3(1X,ES25.17))') swiftest_pLA%dLcb(:) + write(unit, '("LESCAPE ",3(1X,ES25.17))') swiftest_pLA%Lescape(:) + write(unit, '("MCB_INITIAL ",(1X,ES25.17))') swiftest_pLA%Mcb_initial + write(unit, '("DMCB ",(1X,ES25.17))') swiftest_pLA%dMcb + write(unit, '("MESCAPE ",(1X,ES25.17))') swiftest_pLA%Mescape + write(unit, '("RCB_INITIAL ",(1X,ES25.17))') swiftest_pLA%Rcb_initial + write(unit, '("DRCB ",(1X,ES25.17))') swiftest_pLA%dRcb + write(unit, '("ECOLLISIONS ",(1X,ES25.17))') swiftest_pLA%Ecollisions + write(unit, '("EUNTRACKED ",(1X,ES25.17))') swiftest_pLA%Euntracked end if write(param_name, Afmt) "FIRSTKICK"; write(param_value, Lfmt) param%lfirstkick; write(unit, Afmt) adjustl(param_name), adjustl(param_value)