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

Commit

Permalink
Another round of reorgainzing. This time to modules modules and inter…
Browse files Browse the repository at this point in the history
…faces in the same folders. Also worked on improving the consistency of file names.
  • Loading branch information
daminton committed Dec 21, 2022
1 parent a26e615 commit 5fd08e6
Show file tree
Hide file tree
Showing 31 changed files with 55 additions and 62 deletions.
71 changes: 36 additions & 35 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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})

Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 6 additions & 12 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, ' // &
Expand All @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/modules/swiftest.f90 → src/swiftest/swiftest_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/symba/symba_step.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 5fd08e6

Please sign in to comment.