diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92784193d..aaec591d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,31 +12,39 @@ ######################################## # Add the source files +SET(STRICT_MATH_FILES + ${SRC}/swiftest/swiftest_kick.f90 + ${SRC}/helio/helio_kick.f90 + ${SRC}/rmvs/rmvs_kick.f90 + ${SRC}/symba/symba_kick.f90 + ${SRC}/whm/whm_kick.f90 +) + SET(FAST_MATH_FILES - ${SRC}/modules/globals.f90 - ${SRC}/modules/base.f90 - ${SRC}/modules/encounter.f90 - ${SRC}/modules/collision.f90 - ${SRC}/modules/fraggle.f90 - ${SRC}/modules/lambda_function.f90 - ${SRC}/modules/operators.f90 - ${SRC}/modules/walltime.f90 - ${SRC}/modules/io_progress_bar.f90 - ${SRC}/modules/swiftest.f90 - ${SRC}/modules/whm.f90 - ${SRC}/modules/rmvs.f90 - ${SRC}/modules/helio.f90 - ${SRC}/modules/symba.f90 - ${SRC}/swiftest_procedures/swiftest_discard.f90 - ${SRC}/swiftest_procedures/swiftest_io.f90 - ${SRC}/swiftest_procedures/swiftest_obl.f90 - ${SRC}/swiftest_procedures/swiftest_util.f90 - ${SRC}/swiftest_procedures/swiftest_drift.f90 - ${SRC}/swiftest_procedures/swiftest_io_netcdf.f90 - ${SRC}/swiftest_procedures/swiftest_orbel.f90 - ${SRC}/swiftest_procedures/swiftest_gr.f90 - ${SRC}/swiftest_procedures/swiftest_kick.f90 - ${SRC}/swiftest_procedures/swiftest_setup.f90 + ${SRC}/globals/globals_module.f90 + ${SRC}/base/base_module.f90 + ${SRC}/misc/lambda_function_module.f90 + ${SRC}/misc/io_progress_bar_module.f90 + ${SRC}/encounter/encounter_module.f90 + ${SRC}/collision/collision_module.f90 + ${SRC}/fraggle/fraggle_module.f90 + ${SRC}/operator/operator_module.f90 + ${SRC}/walltime/walltime_module.f90 + ${SRC}/swiftest/swiftest_module.f90 + ${SRC}/whm/whm_module.f90 + ${SRC}/rmvs/rmvs_module.f90 + ${SRC}/helio/helio_module.f90 + ${SRC}/symba/symba_module.f90 + ${SRC}/swiftest/swiftest_discard.f90 + ${SRC}/swiftest/swiftest_io.f90 + ${SRC}/swiftest/swiftest_obl.f90 + ${SRC}/swiftest/swiftest_util.f90 + ${SRC}/swiftest/swiftest_drift.f90 + ${SRC}/swiftest/swiftest_io_netcdf.f90 + ${SRC}/swiftest/swiftest_orbel.f90 + ${SRC}/swiftest/swiftest_gr.f90 + ${SRC}/swiftest/swiftest_kick.f90 + ${SRC}/swiftest/swiftest_setup.f90 ${SRC}/collision/collision_check.f90 ${SRC}/collision/collision_regime.f90 ${SRC}/collision/collision_setup.f90 @@ -58,9 +66,9 @@ SET(FAST_MATH_FILES ${SRC}/helio/helio_setup.f90 ${SRC}/helio/helio_step.f90 ${SRC}/helio/helio_util.f90 - ${SRC}/operators/operator_cross.f90 - ${SRC}/operators/operator_mag.f90 - ${SRC}/operators/operator_unit.f90 + ${SRC}/operator/operator_cross.f90 + ${SRC}/operator/operator_mag.f90 + ${SRC}/operator/operator_unit.f90 ${SRC}/rmvs/rmvs_discard.f90 ${SRC}/rmvs/rmvs_encounter_check.f90 ${SRC}/rmvs/rmvs_setup.f90 @@ -84,16 +92,9 @@ SET(FAST_MATH_FILES ${SRC}/whm/whm_setup.f90 ${SRC}/whm/whm_step.f90 ${SRC}/whm/whm_util.f90 - ${SRC}/main/swiftest_driver.f90 + ${SRC}/swiftest/swiftest_driver.f90 ) -SET(STRICT_MATH_FILES - ${SRC}/swiftest_procedures/swiftest_kick.f90 - ${SRC}/helio/helio_kick.f90 - ${SRC}/rmvs/rmvs_kick.f90 - ${SRC}/symba/symba_kick.f90 - ${SRC}/whm/whm_kick.f90 -) set(SWIFTEST_src ${FAST_MATH_FILES} ${STRICT_MATH_FILES}) diff --git a/src/modules/base.f90 b/src/base/base_module.f90 similarity index 100% rename from src/modules/base.f90 rename to src/base/base_module.f90 diff --git a/src/modules/collision.f90 b/src/collision/collision_module.f90 similarity index 100% rename from src/modules/collision.f90 rename to src/collision/collision_module.f90 diff --git a/src/encounter/encounter_check.f90 b/src/encounter/encounter_check.f90 index 9aad9cfdb..cccb0bfe9 100644 --- a/src/encounter/encounter_check.f90 +++ b/src/encounter/encounter_check.f90 @@ -11,8 +11,7 @@ use swiftest contains - module subroutine encounter_check_all_plpl(param, npl, x, v, renc, dt, & - nenc, index1, index2, lvdotr) + module subroutine encounter_check_all_plpl(param, npl, x, v, renc, dt, nenc, index1, index2, lvdotr) !! author: David A. Minton !! !! Check for encounters between massive bodies. Choose between the standard triangular or the Sort & Sweep method based on user inputs @@ -72,8 +71,7 @@ module subroutine encounter_check_all_plpl(param, npl, x, v, renc, dt, & end subroutine encounter_check_all_plpl - module subroutine encounter_check_all_plplm(param, nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, & - nenc, index1, index2, lvdotr) + module subroutine encounter_check_all_plplm(param, nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, nenc, index1, index2, lvdotr) !! author: David A. Minton !! !! Check for encounters between fully interacting massive bodies partially interacting massive bodies. Choose between the standard triangular or the Sort & Sweep method based on user inputs @@ -138,8 +136,7 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, xplm, vplm, xplt, ! call encounter_check_all_sort_and_sweep_plplm(nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, & ! plmplt_nenc, plmplt_index1, plmplt_index2, plmplt_lvdotr) ! else - call encounter_check_all_triangular_plplm(nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, & - plmplt_nenc, plmplt_index1, plmplt_index2, plmplt_lvdotr) + call encounter_check_all_triangular_plplm(nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, plmplt_nenc, plmplt_index1, plmplt_index2, plmplt_lvdotr) ! end if ! if (skipit) then @@ -179,8 +176,7 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, xplm, vplm, xplt, end subroutine encounter_check_all_plplm - module subroutine encounter_check_all_pltp(param, npl, ntp, xpl, vpl, xtp, vtp, renc, dt, & - nenc, index1, index2, lvdotr) + module subroutine encounter_check_all_pltp(param, npl, ntp, xpl, vpl, xtp, vtp, renc, dt, nenc, index1, index2, lvdotr) !! author: David A. Minton !! !! Check for encounters between massive bodies and test particles. Choose between the standard triangular or the Sort & Sweep method based on user inputs @@ -297,8 +293,7 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, x, v, renc, dt, nenc, in end subroutine encounter_check_all_sort_and_sweep_plpl - subroutine encounter_check_all_sort_and_sweep_plplm(nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, & - nenc, index1, index2, lvdotr) + subroutine encounter_check_all_sort_and_sweep_plplm(nplm, nplt, xplm, vplm, xplt, vplt, rencm, renct, dt, nenc, index1, index2, lvdotr) !! author: David A. Minton !! !! Check for encounters between massive bodies and test particles. @@ -370,8 +365,7 @@ subroutine encounter_check_all_sort_and_sweep_plplm(nplm, nplt, xplm, vplm, xplt end subroutine encounter_check_all_sort_and_sweep_plplm - subroutine encounter_check_all_sort_and_sweep_pltp(npl, ntp, xpl, vpl, xtp, vtp, rencpl, dt, & - nenc, index1, index2, lvdotr) + subroutine encounter_check_all_sort_and_sweep_pltp(npl, ntp, xpl, vpl, xtp, vtp, rencpl, dt, nenc, index1, index2, lvdotr) !! author: David A. Minton !! !! Check for encounters between massive bodies and test particles. diff --git a/src/modules/encounter.f90 b/src/encounter/encounter_module.f90 similarity index 100% rename from src/modules/encounter.f90 rename to src/encounter/encounter_module.f90 diff --git a/src/modules/fraggle.f90 b/src/fraggle/fraggle_module.f90 similarity index 100% rename from src/modules/fraggle.f90 rename to src/fraggle/fraggle_module.f90 diff --git a/src/modules/globals.f90 b/src/globals/globals_module.f90 similarity index 100% rename from src/modules/globals.f90 rename to src/globals/globals_module.f90 diff --git a/src/modules/helio.f90 b/src/helio/helio_module.f90 similarity index 100% rename from src/modules/helio.f90 rename to src/helio/helio_module.f90 diff --git a/src/modules/io_progress_bar.f90 b/src/misc/io_progress_bar_module.f90 similarity index 94% rename from src/modules/io_progress_bar.f90 rename to src/misc/io_progress_bar_module.f90 index 1e1067da7..470863f31 100644 --- a/src/modules/io_progress_bar.f90 +++ b/src/misc/io_progress_bar_module.f90 @@ -9,7 +9,7 @@ module io_progress_bar character(len=1),parameter, private :: barchar = "#" !! The progress bar character - type :: pbar + type :: progress_bar !! author: David A. Minton !! !! Implements a class for a simple progress bar that can print on the screen. @@ -22,7 +22,7 @@ module io_progress_bar contains procedure :: reset => io_progress_bar_reset !! Resets the progress bar to the beginning procedure :: update => io_progress_bar_update !! Updates the progress bar with new values - end type pbar + end type progress_bar contains @@ -32,7 +32,7 @@ subroutine io_progress_bar_reset(self, loop_length) !! Resets the progress bar to the beginning implicit none ! Arguments - class(pbar),intent(inout) :: self !! The progress bar object + class(progress_bar),intent(inout) :: self !! The progress bar object integer(I8B), intent(in) :: loop_length !! The length of the loop that the progress bar is attached to ! Internals character(len=2) :: numchar @@ -62,7 +62,7 @@ subroutine io_progress_bar_update(self,i,message) !! Updates the progress bar with new values implicit none ! Arguments - class(pbar), intent(inout) :: self !! Progres bar object + class(progress_bar), intent(inout) :: self !! Progres bar object integer(I8B), intent(in) :: i !! The current loop index of the progress loop character(len=*), intent(in), optional :: message !! An optional message to display to the right of the progress bar ! Internals diff --git a/src/modules/lambda_function.f90 b/src/misc/lambda_function_module.f90 similarity index 100% rename from src/modules/lambda_function.f90 rename to src/misc/lambda_function_module.f90 diff --git a/src/operators/operator_cross.f90 b/src/operator/operator_cross.f90 similarity index 100% rename from src/operators/operator_cross.f90 rename to src/operator/operator_cross.f90 diff --git a/src/operators/operator_mag.f90 b/src/operator/operator_mag.f90 similarity index 100% rename from src/operators/operator_mag.f90 rename to src/operator/operator_mag.f90 diff --git a/src/modules/operators.f90 b/src/operator/operator_module.f90 similarity index 100% rename from src/modules/operators.f90 rename to src/operator/operator_module.f90 diff --git a/src/operators/operator_unit.f90 b/src/operator/operator_unit.f90 similarity index 100% rename from src/operators/operator_unit.f90 rename to src/operator/operator_unit.f90 diff --git a/src/modules/rmvs.f90 b/src/rmvs/rmvs_module.f90 similarity index 100% rename from src/modules/rmvs.f90 rename to src/rmvs/rmvs_module.f90 diff --git a/src/swiftest_procedures/swiftest_discard.f90 b/src/swiftest/swiftest_discard.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_discard.f90 rename to src/swiftest/swiftest_discard.f90 diff --git a/src/swiftest_procedures/swiftest_drift.f90 b/src/swiftest/swiftest_drift.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_drift.f90 rename to src/swiftest/swiftest_drift.f90 diff --git a/src/main/swiftest_driver.f90 b/src/swiftest/swiftest_driver.f90 similarity index 97% rename from src/main/swiftest_driver.f90 rename to src/swiftest/swiftest_driver.f90 index 2b2229a3a..6b64fcdb2 100644 --- a/src/main/swiftest_driver.f90 +++ b/src/swiftest/swiftest_driver.f90 @@ -16,6 +16,7 @@ program swiftest_driver !! Adapted from Swifter by David E. Kaufmann's Swifter driver programs swifter_[bs,helio,ra15,rmvs,symba,tu4,whm].f90 !! Adapted from Hal Levison and Martin Duncan's Swift driver programs use swiftest + use symba implicit none class(swiftest_nbody_system), allocatable :: system !! Polymorphic object containing the nbody system to be integrated @@ -29,7 +30,7 @@ program swiftest_driver integer(I4B) :: idump !! Dump cadence counter type(walltimer) :: integration_timer !! Object used for computing elapsed wall time real(DP) :: tfrac !! Fraction of total simulation time completed - type(pbar) :: pbar !! Object used to print out a progress bar + type(progress_bar) :: pbar !! Object used to print out a progress bar character(*), parameter :: statusfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, ' // & '"; Number of active pl, tp = ", I6, ", ", I6)' character(*), parameter :: symbastatfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, ' // & @@ -43,12 +44,7 @@ program swiftest_driver call io_get_args(integrator, param_file_name, display_style) !> Read in the user-defined parameters file and the initial conditions of the system - select case(integrator) - case(symba) - allocate(base_parameters :: param) - case default - allocate(base_parameters :: param) - end select + allocate(swiftest_parameters :: param) param%integrator = trim(adjustl(integrator)) call param%set_display(display_style) call param%read_in(param_file_name) diff --git a/src/swiftest_procedures/swiftest_gr.f90 b/src/swiftest/swiftest_gr.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_gr.f90 rename to src/swiftest/swiftest_gr.f90 diff --git a/src/swiftest_procedures/swiftest_io.f90 b/src/swiftest/swiftest_io.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_io.f90 rename to src/swiftest/swiftest_io.f90 diff --git a/src/swiftest_procedures/swiftest_io_netcdf.f90 b/src/swiftest/swiftest_io_netcdf.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_io_netcdf.f90 rename to src/swiftest/swiftest_io_netcdf.f90 diff --git a/src/swiftest_procedures/swiftest_kick.f90 b/src/swiftest/swiftest_kick.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_kick.f90 rename to src/swiftest/swiftest_kick.f90 diff --git a/src/modules/swiftest.f90 b/src/swiftest/swiftest_module.f90 similarity index 99% rename from src/modules/swiftest.f90 rename to src/swiftest/swiftest_module.f90 index 01afd9134..e7925944a 100644 --- a/src/modules/swiftest.f90 +++ b/src/swiftest/swiftest_module.f90 @@ -313,8 +313,8 @@ module swiftest class(swiftest_pl), allocatable :: pl_discards !! Discarded massive body particle data structure class(swiftest_pl), allocatable :: pl_adds !! List of added bodies in mergers or collisions class(swiftest_tp), allocatable :: tp_adds !! List of added bodies in mergers or collisions - class(collision_list_pltp), allocatable :: pltp_encounter !! List of massive body-test particle encounters in a single step - class(collision_list_plpl), allocatable :: plpl_encounter !! List of massive body-massive body encounters in a single step + class(encounter_list), allocatable :: pltp_encounter !! List of massive body-test particle encounters in a single step + class(encounter_list), allocatable :: plpl_encounter !! List of massive body-massive body encounters in a single step class(collision_list_plpl), allocatable :: plpl_collision !! List of massive body-massive body collisions in a single step class(collision_list_plpl), allocatable :: pltp_collision !! List of massive body-massive body collisions in a single step class(collision_system), allocatable :: collision_system !! Collision system object diff --git a/src/swiftest_procedures/swiftest_obl.f90 b/src/swiftest/swiftest_obl.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_obl.f90 rename to src/swiftest/swiftest_obl.f90 diff --git a/src/swiftest_procedures/swiftest_orbel.f90 b/src/swiftest/swiftest_orbel.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_orbel.f90 rename to src/swiftest/swiftest_orbel.f90 diff --git a/src/swiftest_procedures/swiftest_setup.f90 b/src/swiftest/swiftest_setup.f90 similarity index 99% rename from src/swiftest_procedures/swiftest_setup.f90 rename to src/swiftest/swiftest_setup.f90 index 0f3a274fb..a69d62299 100644 --- a/src/swiftest_procedures/swiftest_setup.f90 +++ b/src/swiftest/swiftest_setup.f90 @@ -74,9 +74,11 @@ module subroutine swiftest_setup_construct_system(system, param) allocate(symba_cb :: system%cb) allocate(symba_pl :: system%pl) allocate(symba_tp :: system%tp) + allocate(symba_tp :: system%tp_discards) allocate(symba_pl :: system%pl_adds) allocate(symba_pl :: system%pl_discards) + allocate(collision_list_pltp :: system%pltp_encounter) allocate(collision_list_plpl :: system%plpl_encounter) allocate(collision_list_plpl :: system%plpl_collision) diff --git a/src/swiftest_procedures/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 similarity index 100% rename from src/swiftest_procedures/swiftest_util.f90 rename to src/swiftest/swiftest_util.f90 diff --git a/src/modules/symba.f90 b/src/symba/symba_module.f90 similarity index 100% rename from src/modules/symba.f90 rename to src/symba/symba_module.f90 diff --git a/src/symba/symba_step.f90 b/src/symba/symba_step.f90 index 0c4ff41f2..af010a328 100644 --- a/src/symba/symba_step.f90 +++ b/src/symba/symba_step.f90 @@ -34,7 +34,7 @@ module subroutine symba_step_system(self, param, t, dt) class is (symba_tp) select type(param) class is (swiftest_parameters) - associate(encounter_history => param%encounter_history) + associate(encounter_history => self%encounter_history) call self%reset(param) lencounter = pl%encounter_check(param, self, dt, 0) .or. tp%encounter_check(param, self, dt, 0) if (lencounter) then @@ -190,7 +190,7 @@ recursive module subroutine symba_step_recur_system(self, param, t, ireci) class is (symba_tp) associate(system => self, plpl_encounter => self%plpl_encounter, pltp_encounter => self%pltp_encounter, & lplpl_collision => self%plpl_encounter%lcollision, lpltp_collision => self%pltp_encounter%lcollision, & - encounter_history => param%encounter_history) + encounter_history => self%encounter_history) system%irec = ireci dtl = param%dt / (NTENC**ireci) dth = 0.5_DP * dtl diff --git a/src/modules/walltime.f90 b/src/walltime/walltime_module.f90 similarity index 100% rename from src/modules/walltime.f90 rename to src/walltime/walltime_module.f90 diff --git a/src/modules/whm.f90 b/src/whm/whm_module.f90 similarity index 100% rename from src/modules/whm.f90 rename to src/whm/whm_module.f90