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

Commit

Permalink
Finished removing cruft (unused variables)
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 25, 2022
1 parent 748ab48 commit 79a6e83
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 121 deletions.
3 changes: 1 addition & 2 deletions src/discard/discard.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module subroutine discard_system(self, param)
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
logical :: lany_discards, lpl_discards, ltp_discards, lpl_check, ltp_check
logical :: lpl_discards, ltp_discards, lpl_check, ltp_check

lpl_check = allocated(self%pl_discards)
ltp_check = allocated(self%tp_discards)
Expand Down Expand Up @@ -180,7 +180,6 @@ subroutine discard_peri_tp(tp, system, param)
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameterss
! Internals
logical, save :: lfirst = .true.
integer(I4B) :: i, j, ih
real(DP) :: r2
real(DP), dimension(NDIM) :: dx
Expand Down
4 changes: 2 additions & 2 deletions src/drift/drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ module subroutine drift_all(mu, x, v, n, param, dt, lmask, iflag)
where(lmask(1:n)) dtp(1:n) = dt
end if

!$omp simd
!!$omp simd ! SIMD does not yet work
do i = 1, n
if (lmask(i)) call drift_one(mu(i), x(1,i), x(2,i), x(3,i), v(1,i), v(2,i), v(3,i), dtp(i), iflag(i))
end do
!$omp end simd
!!$omp end simd

deallocate(dtp)

Expand Down
29 changes: 7 additions & 22 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module subroutine encounter_check_all_plpl(param, npl, x, v, renc, dt, &
logical, save :: lfirst = .true.
logical, save :: skipit = .false. ! This will be used to ensure that the sort & sweep subroutine gets called at least once before timing it so that the extent array is nearly sorted when it is timed
integer(I8B) :: nplpl = 0_I8B
integer(I8B) :: k

if (param%ladaptive_encounters_plpl .and. (.not. skipit)) then
nplpl = (npl * (npl - 1) / 2)
Expand Down Expand Up @@ -91,8 +90,7 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, xplm, vplm, xplt,
logical, save :: lfirst = .true.
logical, save :: skipit = .false.
integer(I8B) :: nplplm = 0_I8B
integer(I4B) :: npl, i
integer(I8B) :: k
integer(I4B) :: npl
logical, dimension(:), allocatable :: plmplt_lvdotr !! Logical flag indicating the sign of v .dot. x in the plm-plt group
integer(I4B), dimension(:), allocatable :: plmplt_index1 !! List of indices for body 1 in each encounter in the plm-plt group
integer(I4B), dimension(:), allocatable :: plmplt_index2 !! List of indices for body 2 in each encounter in the plm-lt group
Expand Down Expand Up @@ -254,10 +252,9 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, x, v, renc, dt, nenc, in
integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! List of indices for body 2 in each encounter
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
integer(I4B) :: i, dim, n
integer(I4B) :: dim, n
integer(I4B), save :: npl_last = 0
type(encounter_bounding_box), save :: boundingbox
logical, dimension(:), allocatable :: lencounter
integer(I2B), dimension(npl) :: vshift_min, vshift_max

if (npl == 0) return
Expand Down Expand Up @@ -316,12 +313,10 @@ subroutine encounter_check_all_sort_and_sweep_plplm(nplm, nplt, xplm, vplm, xplt
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
type(encounter_bounding_box), save :: boundingbox
integer(I4B) :: i, dim, n, ntot
integer(I4B) :: dim, n, ntot
integer(I4B), save :: ntot_last = 0
logical, dimension(:), allocatable :: lencounter
integer(I2B), dimension(nplm) :: vplmshift_min, vplmshift_max
integer(I2B), dimension(nplt) :: vpltshift_min, vpltshift_max
logical, save :: lfirst=.true.

! If this is the first time through, build the index lists
if ((nplm == 0) .or. (nplt == 0)) return
Expand Down Expand Up @@ -390,9 +385,8 @@ subroutine encounter_check_all_sort_and_sweep_pltp(npl, ntp, xpl, vpl, xtp, vtp,
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
type(encounter_bounding_box), save :: boundingbox
integer(I4B) :: i, dim, n, ntot
integer(I4B) :: dim, n, ntot
integer(I4B), save :: ntot_last = 0
logical, dimension(:), allocatable :: lencounter
integer(I2B), dimension(npl) :: vplshift_min, vplshift_max
integer(I2B), dimension(ntp) :: vtpshift_min, vtpshift_max
real(DP), dimension(ntp) :: renctp
Expand Down Expand Up @@ -467,7 +461,6 @@ pure subroutine encounter_check_all_sweep_one(i, n, xi, yi, zi, vxi, vyi, vzi, x
logical, dimension(:), allocatable, intent(inout) :: lvdotr !! v.dot.r direction array
! Internals
integer(I4B) :: j
integer(I8B) :: k
real(DP) :: xr, yr, zr, vxr, vyr, vzr, renc12
logical, dimension(n) :: lencounteri, lvdotri

Expand Down Expand Up @@ -515,7 +508,7 @@ pure subroutine encounter_check_all_triangular_one(i, n, xi, yi, zi, vxi, vyi, v
type(encounter_list), intent(out) :: lenci !! Output encounter lists containing number of encounters, the v.dot.r direction array, and the index list of encountering bodies
! Internals
integer(I4B) :: j
integer(I8B) :: k, nenci
integer(I8B) :: nenci
real(DP) :: xr, yr, zr, vxr, vyr, vzr, renc12
logical, dimension(n) :: lencounteri, lvdotri

Expand Down Expand Up @@ -559,9 +552,7 @@ subroutine encounter_check_all_triangular_plpl(npl, x, v, renc, dt, nenc, index1
integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! List of indices for body 2 in each encounter
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
integer(I4B) :: i, j, k, nenci, j0, j1
real(DP) :: xr, yr, zr, vxr, vyr, vzr, renc12
logical, dimension(npl) :: lencounteri, lvdotri
integer(I4B) :: i
integer(I4B), dimension(:), allocatable, save :: ind_arr
type(encounter_list), dimension(npl) :: lenc

Expand Down Expand Up @@ -609,7 +600,6 @@ subroutine encounter_check_all_triangular_plplm(nplm, nplt, xplm, vplm, xplt, vp
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
integer(I4B) :: i
logical, dimension(nplt) :: lencounteri, lvdotri
integer(I4B), dimension(:), allocatable, save :: ind_arr
type(encounter_list), dimension(nplm) :: lenc

Expand Down Expand Up @@ -656,7 +646,6 @@ subroutine encounter_check_all_triangular_pltp(npl, ntp, xpl, vpl, xtp, vtp, ren
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
integer(I4B) :: i
logical, dimension(ntp) :: lencounteri, lvdotri
integer(I4B), dimension(:), allocatable, save :: ind_arr
type(encounter_list), dimension(npl) :: lenc
real(DP), dimension(ntp) :: renct
Expand Down Expand Up @@ -914,15 +903,11 @@ module subroutine encounter_check_sweep_aabb_double_list(self, n1, n2, x1, v1, x
integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! List of indices for body 2 in each encounter candidate pair
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical array indicating which pairs are approaching
! Internals
integer(I4B) :: ii, i, j, ntot, nbox, dim
integer(I8B) :: k
integer(I4B) :: ii, i, ntot, nbox, dim
logical, dimension(n1+n2) :: loverlap
logical, dimension(SWEEPDIM,n1+n2) :: loverlap_by_dimension
integer(I4B), dimension(SWEEPDIM) :: noverlap
integer(I4B), dimension(SWEEPDIM,n1+n2) :: nbox_arr
logical, dimension(SWEEPDIM,2*(n1+n2)) :: llist1
integer(I4B), dimension(SWEEPDIM,2*(n1+n2)) :: ext_ind
integer(I4B), dimension(:), allocatable :: x_ind
type(encounter_list), dimension(n1+n2) :: lenc !! Array of encounter lists (one encounter list per body)
integer(I4B), dimension(:), allocatable, save :: ind_arr
integer(I8B) :: ibeg, iend
Expand Down
6 changes: 2 additions & 4 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module subroutine fraggle_generate_fragments(self, colliders, system, param, lfa
end do

call frag%get_energy_and_momentum(colliders, system, param, lbefore=.false.)
call frag%set_budgets(colliders)
call frag%set_budgets()

call fraggle_generate_spins(frag, f_spin, lfailure)
if (lfailure) then
Expand Down Expand Up @@ -300,10 +300,9 @@ subroutine fraggle_generate_tan_vel(frag, lfailure)
real(DP), parameter :: TOL_INIT = 1e-14_DP
real(DP), parameter :: VNOISE_MAG = 1e-3_DP !! Magnitude of the noise to apply to initial conditions to help minimizer find a solution in case of failure
integer(I4B), parameter :: MAXLOOP = 10
real(DP) :: tol, ke_remainder
real(DP) :: tol
real(DP), dimension(:), allocatable :: v_t_initial
real(DP), dimension(frag%nbody) :: kefrag, vnoise
type(lambda_obj) :: spinfunc
type(lambda_obj_err) :: objective_function
real(DP), dimension(NDIM) :: Li, L_remainder, L_frag_tot
character(len=STRMAX) :: message
Expand Down Expand Up @@ -479,7 +478,6 @@ subroutine fraggle_generate_rad_vel(frag, lfailure)
real(DP) :: ke_radial, tol
integer(I4B) :: i
real(DP), dimension(:), allocatable :: v_r_initial
real(DP), dimension(:,:), allocatable :: v_r
real(DP), dimension(frag%nbody) :: vnoise
type(lambda_obj) :: objective_function
character(len=STRMAX) :: message
Expand Down
5 changes: 2 additions & 3 deletions src/fraggle/fraggle_regime.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ module subroutine fraggle_regime_colliders(self, frag, system, param)
class(swiftest_nbody_system), intent(in) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current Swiftest run configuration parameters
! Internals
integer(I4B) :: jtarg, jproj, regime
integer(I4B) :: jtarg, jproj
real(DP), dimension(2) :: radius_si, mass_si, density_si
real(DP) :: min_mfrag_si, Mcb_si
real(DP), dimension(NDIM) :: x1_si, v1_si, x2_si, v2_si
real(DP) :: mlr, mslr, mtot, dentot, msys, msys_new, Qloss, impact_parameter
logical :: fileExists
real(DP) :: mlr, mslr, mtot, dentot

associate(colliders => self)
! Convert all quantities to SI units and determine which of the pair is the projectile vs. target before sending them to the regime determination subroutine
Expand Down
5 changes: 2 additions & 3 deletions src/fraggle/fraggle_set.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
use swiftest
contains

module subroutine fraggle_set_budgets_fragments(self, colliders)
module subroutine fraggle_set_budgets_fragments(self)
!! author: David A. Minton
!!
!! Sets the energy and momentum budgets of the fragments based on the collider values and the before/after values of energy and momentum
implicit none
! Arguments
class(fraggle_fragments), intent(inout) :: self !! Fraggle fragment system object
class(fraggle_colliders), intent(inout) :: colliders !! Fraggle collider system object
! Internals
real(DP) :: dEtot
real(DP), dimension(NDIM) :: dL
Expand Down Expand Up @@ -162,7 +161,7 @@ module subroutine fraggle_set_coordinate_system(self, colliders)
class(fraggle_colliders), intent(inout) :: colliders !! Fraggle collider system object
! Internals
integer(I4B) :: i
real(DP), dimension(NDIM) :: x_cross_v, delta_r, delta_v, Ltot
real(DP), dimension(NDIM) :: delta_r, delta_v, Ltot
real(DP) :: r_col_norm, v_col_norm, L_mag
real(DP), dimension(NDIM, self%nbody) :: L_sigma

Expand Down
6 changes: 0 additions & 6 deletions src/fraggle/fraggle_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ module subroutine fraggle_util_get_energy_momentum(self, colliders, system, para
class(swiftest_parameters), intent(inout) :: param !! Current swiftest run configuration parameters
logical, intent(in) :: lbefore !! Flag indicating that this the "before" state of the system, with colliders included and fragments excluded or vice versa
! Internals
integer(I4B) :: i, nplm
logical, dimension(:), allocatable :: lexclude
logical :: lk_plpl
logical, save :: ladd_frags
class(swiftest_nbody_system), allocatable, save :: tmpsys
class(swiftest_parameters), allocatable, save :: tmpparam
integer(I4B) :: npl_before, npl_after
Expand Down Expand Up @@ -214,10 +211,7 @@ module subroutine fraggle_util_restructure(self, colliders, try, f_spin, r_max_s
real(DP), intent(inout) :: f_spin !! Fraction of energy/momentum that goes into spin. This decreases ater a failed attempt
real(DP), intent(inout) :: r_max_start !! The maximum radial distance that the position calculation starts with. This increases after a failed attempt
! Internals
integer(I4B) :: i
real(DP), save :: ke_tot_deficit, r_max_start_old, ke_avg_deficit_old
real(DP), dimension(:), allocatable :: m_frag_new, rad_frag_new
real(DP), dimension(:,:), allocatable :: xb_frag_new, vb_frag_new, Ip_frag_new, rot_frag_new
real(DP) :: delta_r, delta_r_max, ke_avg_deficit
real(DP), parameter :: ke_avg_deficit_target = 0.0_DP

Expand Down
18 changes: 4 additions & 14 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ module subroutine io_dump_base(self, param)
class(swiftest_base), intent(inout) :: self !! Swiftest base object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: ierr !! Error code
integer(I4B) :: iu = LUN
character(len=:), allocatable :: dump_file_name
character(STRMAX) :: errmsg
Expand Down Expand Up @@ -951,13 +950,6 @@ module subroutine io_param_writer(self, unit, iotype, v_list, iostat, iomsg)
character(*),parameter :: Ifmt = '(I0)' !! Format label for integer values
character(*),parameter :: Rfmt = '(ES25.17)' !! Format label for real values
character(*),parameter :: Lfmt = '(L1)' !! Format label for logical values
character(len=NAMELEN) :: param_name
character(LEN=STRMAX) :: param_value, v1, v2, v3
type character_array
character(25) :: value
end type character_array
type(character_array), dimension(:), allocatable :: param_array
integer(I4B) :: i

associate(param => self)
call io_param_writer_one("T0", param%t0, unit)
Expand Down Expand Up @@ -1244,8 +1236,6 @@ module subroutine io_read_in_base(self,param)
implicit none
class(swiftest_base), intent(inout) :: self !! Swiftest base object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: ierr !! Error code: returns 0 if the read is successful

if ((param%in_type == NETCDF_FLOAT_TYPE) .or. (param%in_type == NETCDF_DOUBLE_TYPE)) return ! This method is not used in NetCDF mode, as reading is done for the whole system, not on individual particle types

Expand Down Expand Up @@ -1276,9 +1266,9 @@ subroutine io_read_in_body(self, param)
integer(I4B) :: i, nbody
logical :: is_ascii
character(len=:), allocatable :: infile
real(DP) :: t
character(STRMAX) :: errmsg
integer(I4B) :: ierr
! Internals
integer(I4B) :: ierr !! Error code: returns 0 if the read is successful

! Select the appropriate polymorphic class (test particle or massive body)

Expand Down Expand Up @@ -1337,7 +1327,7 @@ subroutine io_read_in_cb(self, param)
! Internals
integer(I4B) :: iu = LUN
character(len=STRMAX) :: errmsg
integer(I4B) :: ierr, idold
integer(I4B) :: ierr
character(len=NAMELEN) :: name

if (param%in_type == 'ASCII') then
Expand Down Expand Up @@ -1843,7 +1833,7 @@ module subroutine io_read_particle_info_system(self, param)
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I4B) :: i, id, idx
integer(I4B) :: id, idx
logical :: lmatch
character(STRMAX) :: errmsg
type(swiftest_particle_info), allocatable :: tmpinfo
Expand Down
3 changes: 1 addition & 2 deletions src/modules/fraggle_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ module subroutine fraggle_regime_colliders(self, frag, system, param)
class(swiftest_parameters), intent(in) :: param !! Current Swiftest run configuration parameters
end subroutine fraggle_regime_colliders

module subroutine fraggle_set_budgets_fragments(self, colliders)
module subroutine fraggle_set_budgets_fragments(self)
implicit none
class(fraggle_fragments), intent(inout) :: self !! Fraggle fragment system object
class(fraggle_colliders), intent(inout) :: colliders !! Fraggle collider system object
end subroutine fraggle_set_budgets_fragments

module subroutine fraggle_set_coordinate_system(self, colliders)
Expand Down
Loading

0 comments on commit 79a6e83

Please sign in to comment.