From 95af4879534d78b60ffc94639b9a745737b114c8 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 22 Jul 2021 23:18:40 -0400 Subject: [PATCH] Moved initialize_system from io to setup where it belongs --- src/io/io.f90 | 20 ------------------ src/modules/swiftest_classes.f90 | 32 ++++++++++++++--------------- src/setup/setup.f90 | 23 ++++++++++++++++++++- src/symba/symba_encounter_check.f90 | 8 ++++---- src/whm/whm_setup.f90 | 2 +- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/io/io.f90 b/src/io/io.f90 index e74255466..cf4772a8f 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -976,26 +976,6 @@ function io_read_hdr(iu, t, npl, ntp, out_form, out_type) result(ierr) return end function io_read_hdr - module subroutine io_read_initialize_system(self, param) - !! author: David A. Minton - !! - !! Wrapper method to initialize a basic Swiftest nbody system from files - !! - implicit none - ! Arguments - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - - call self%cb%initialize(param) - call self%pl%initialize(param) - if (.not.param%lrhill_present) call self%pl%set_rhill(self%cb) - call self%tp%initialize(param) - call self%set_msys() - call self%pl%set_mu(self%cb) - call self%tp%set_mu(self%cb) - - end subroutine io_read_initialize_system - module subroutine io_toupper(string) !! author: David A. Minton !! diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index d07f39f5a..85986fec4 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -11,12 +11,12 @@ module swiftest_classes public :: eucl_dist_index_plpl, eucl_dist_index_pltp, eucl_irij3_plpl public :: gr_getaccb_ns_body, gr_p4_pos_kick, gr_pseudovel2vel, gr_vel2pseudovel public :: io_dump_param, io_dump_swiftest, io_dump_system, io_get_args, io_get_token, io_param_reader, io_param_writer, io_read_body_in, & - io_read_cb_in, io_read_param_in, io_read_frame_body, io_read_frame_cb, io_read_frame_system, io_read_initialize_system, & + io_read_cb_in, io_read_param_in, io_read_frame_body, io_read_frame_cb, io_read_frame_system, & io_toupper, io_write_discard, io_write_encounter, io_write_frame_body, io_write_frame_cb, io_write_frame_system public :: kickvh_body public :: obl_acc_body, obl_acc_pl, obl_acc_tp public :: orbel_el2xv_vec, orbel_xv2el_vec, orbel_scget, orbel_xv2aeq, orbel_xv2aqt - public :: setup_body, setup_construct_system, setup_pl, setup_tp + public :: setup_body, setup_construct_system, setup_initialize_system, setup_pl, setup_tp public :: tides_getacch_pl, tides_step_spin_system public :: user_getacch_body public :: util_coord_b2h_pl, util_coord_b2h_tp, util_coord_h2b_pl, util_coord_h2b_tp, util_exit, util_fill_body, util_fill_pl, util_fill_tp, & @@ -288,14 +288,14 @@ module swiftest_classes procedure(abstract_step_system), public, deferred :: step ! Concrete classes that are common to the basic integrator (only test particles considered for discard) - procedure, public :: discard => discard_system !! Perform a discard step on the system - procedure, public :: dump => io_dump_system !! Dump the state of the system to a file - procedure, public :: initialize => io_read_initialize_system !! Initialize the system from an input file - procedure, public :: read_frame => io_read_frame_system !! Append a frame of output data to file - procedure, public :: write_discard => io_write_discard !! Append a frame of output data to file - procedure, public :: write_frame => io_write_frame_system !! Append a frame of output data to file - procedure, public :: step_spin => tides_step_spin_system !! Steps the spins of the massive & central bodies due to tides. - procedure, public :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies. + procedure, public :: discard => discard_system !! Perform a discard step on the system + procedure, public :: dump => io_dump_system !! Dump the state of the system to a file + procedure, public :: initialize => setup_initialize_system !! Initialize the system from input files + procedure, public :: read_frame => io_read_frame_system !! Append a frame of output data to file + procedure, public :: write_discard => io_write_discard !! Append a frame of output data to file + procedure, public :: write_frame => io_write_frame_system !! Append a frame of output data to file + procedure, public :: step_spin => tides_step_spin_system !! Steps the spins of the massive & central bodies due to tides. + procedure, public :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies. end type swiftest_nbody_system abstract interface @@ -565,12 +565,6 @@ module subroutine io_read_frame_system(self, iu, param, form, ierr) integer(I4B), intent(out) :: ierr !! Error code end subroutine io_read_frame_system - module subroutine io_read_initialize_system(self, param) - implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - end subroutine io_read_initialize_system - module subroutine io_write_discard(self, param) implicit none class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object @@ -680,6 +674,12 @@ module subroutine setup_construct_system(system, param) type(swiftest_parameters), intent(in) :: param !! Swiftest parameters end subroutine setup_construct_system + module subroutine setup_initialize_system(self, param) + implicit none + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + end subroutine setup_initialize_system + module subroutine setup_pl(self,n) implicit none class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object diff --git a/src/setup/setup.f90 b/src/setup/setup.f90 index dab78a875..0c89d613b 100644 --- a/src/setup/setup.f90 +++ b/src/setup/setup.f90 @@ -69,6 +69,28 @@ module subroutine setup_construct_system(system, param) return end subroutine setup_construct_system + + module subroutine setup_initialize_system(self, param) + !! author: David A. Minton + !! + !! Wrapper method to initialize a basic Swiftest nbody system from files + !! + implicit none + ! Arguments + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + + call self%cb%initialize(param) + call self%pl%initialize(param) + if (.not.param%lrhill_present) call self%pl%set_rhill(self%cb) + call self%tp%initialize(param) + call self%set_msys() + call self%pl%set_mu(self%cb) + call self%tp%set_mu(self%cb) + call self%pl%eucl_index() + return + end subroutine setup_initialize_system + module subroutine setup_body(self,n) !! author: David A. Minton !! @@ -83,7 +105,6 @@ module subroutine setup_body(self,n) if (n <= 0) return self%lfirst = .true. - !write(*,*) 'Allocating the basic Swiftest particle' allocate(self%id(n)) allocate(self%name(n)) allocate(self%status(n)) diff --git a/src/symba/symba_encounter_check.f90 b/src/symba/symba_encounter_check.f90 index 4e71bf648..633973dba 100644 --- a/src/symba/symba_encounter_check.f90 +++ b/src/symba/symba_encounter_check.f90 @@ -19,8 +19,8 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lencount associate(pl => self, npl => self%nbody) lencounter = .false. - do concurrent(j = 1:npl, .not.pl%lmtiny(j)) - do i = 1, npl + !do concurrent(j = 1:npl, .not.pl%lmtiny(j)) + ! do i = 1, npl rcrit = (pl%rhill(i) + pl%rhill(j)) * RHSCALE * (RSHELL**(irec)) r2crit = r2crit**2 xr(:) = pl%xh(:, j) - pl%xh(:, i) @@ -29,8 +29,8 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lencount vdotr = dot_product(vr(:), xr(:)) lflag = rmvs_chk_ind(r2, v2, vdotr, dt, r2crit) if (lflag) lencounter = .true. - end do - end do + ! end do + !end do end associate return end function symba_encounter_check_pl diff --git a/src/whm/whm_setup.f90 b/src/whm/whm_setup.f90 index 50f0618bb..1f098df26 100644 --- a/src/whm/whm_setup.f90 +++ b/src/whm/whm_setup.f90 @@ -81,7 +81,7 @@ module subroutine whm_setup_system(self, param) class(whm_nbody_system), intent(inout) :: self !! Swiftest system object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - call io_read_initialize_system(self, param) + call setup_initialize_system(self, param) ! Make sure that the discard list gets allocated initially call self%tp_discards%setup(self%tp%nbody) call self%pl%set_mu(self%cb)