diff --git a/cmake/Modules/SetSwiftestFlags.cmake b/cmake/Modules/SetSwiftestFlags.cmake index d49f42245..cf8b67827 100644 --- a/cmake/Modules/SetSwiftestFlags.cmake +++ b/cmake/Modules/SetSwiftestFlags.cmake @@ -412,21 +412,19 @@ IF (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "TESTING" ) SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-Wno-unused-dummy-argument" # GNU ) - # Tells the compiler to issue compile-time messages for nonstandard language elements (Fortran 2018). - SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fstd=f2018" # GNU - ) # Traceback SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-fbacktrace" # GNU (gfortran) ) # Sanitize - SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fsanitize=address, undefined" # Gnu - ) - SET_COMPILE_FLAG(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" - C "-fsanitize=address, undefined" # Gnu - ) + IF (NOT APPLE) + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran "-fsanitize=address, undefined" # Gnu + ) + SET_COMPILE_FLAG(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" + C "-fsanitize=address, undefined" # Gnu + ) + ENDIF() # Check everything SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-fcheck=all" # GNU diff --git a/pyproject.toml b/pyproject.toml index 0424270c9..db94e4c3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "swiftest" -version = "2023.10.3" +version = "2023.11.0" authors=[ {name = 'David A. Minton', email='daminton@purdue.edu'}, {name = 'Carlisle Wishard'}, @@ -48,6 +48,7 @@ Repository = 'https://github.itap.purdue.edu/MintonGroup/swiftest' requires = [ "scikit-build-core", "cython>=3.0.0", + "pyproject_metadata", "pytest", ] build-backend = "scikit_build_core.build" diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index d1a466d29..7485c19ec 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "2023.10.3" !! Swiftest version + character(*), parameter :: VERSION = "2023.11.0" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR" diff --git a/src/rmvs/rmvs_step.f90 b/src/rmvs/rmvs_step.f90 index 098622037..bf8f9cb88 100644 --- a/src/rmvs/rmvs_step.f90 +++ b/src/rmvs/rmvs_step.f90 @@ -28,7 +28,7 @@ module subroutine rmvs_step_system(self, param, t, dt) logical :: lencounter, lfirstpl real(DP), dimension(:,:), allocatable :: rbeg, rend, vbeg - if (self%tp%nbody == 0) then + if ((self%tp%nbody == 0) .or. (self%pl%nbody == 0)) then call whm_step_system(self, param, t, dt) else select type(cb => self%cb) diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index 94813be38..1881c996d 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -19,13 +19,19 @@ module subroutine swiftest_util_append_arr_info(arr, source, nold, lsource_mask) !! author: David A. Minton !! - !! Append a single array of particle information type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. + !! Append a single array of particle information type onto another. If the destination array is not allocated, or is not big + !! enough, this will allocate space for it. implicit none ! Arguments type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used. - logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + integer(I4B), intent(in), optional :: nold !! Extent of original array. + !! If passed, the source array + !! will begin at arr(nold+1). + !! Otherwise, the size of arr + !! will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which + !! elements to append to ! Internals integer(I4B) :: nnew, nsrc, nend_orig, i integer(I4B), dimension(:), allocatable :: idx @@ -68,13 +74,18 @@ end subroutine swiftest_util_append_arr_info module subroutine swiftest_util_append_arr_kin(arr, source, nold, lsource_mask) !! author: David A. Minton !! - !! Append a single array of kinship type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. + !! Append a single array of kinship type onto another. If the destination array is not allocated, or is not big enough, this + !! will allocate space for it. implicit none ! Arguments type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Destination array type(swiftest_kinship), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used. - logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + integer(I4B), intent(in), optional :: nold !! Extent of original array. + !! If passed, the source array will + !! begin at arr(nold+1). Otherwise, + !! the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which + !! elements to append to ! Internals integer(I4B) :: nnew, nsrc, nend_orig @@ -584,8 +595,10 @@ module subroutine swiftest_util_copy_particle_info_arr(source, dest, idx) !! Copies contents from an array of one particle information objects to another. implicit none class(swiftest_particle_info), dimension(:), intent(in) :: source !! Source object to copy into - class(swiftest_particle_info), dimension(:), intent(inout) :: dest !! Swiftest body object with particle metadata information object - integer(I4B), dimension(:), intent(in), optional :: idx !! Optional array of indices to draw the source object + class(swiftest_particle_info), dimension(:), intent(inout) :: dest !! Swiftest body object with particle metadata + !! information object + integer(I4B), dimension(:), intent(in), optional :: idx !! Optional array of indices to draw the source + !! object ! Internals integer(I4B) :: i, j, n, nsource, ndest @@ -867,7 +880,8 @@ module subroutine swiftest_util_fill_arr_info(keeps, inserts, lfill_list) ! Arguments type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into + !! the keeps ! Internals integer(I4B), dimension(:), allocatable :: insert_idx integer(I4B) :: i, nkeep, ninsert @@ -1090,7 +1104,8 @@ end subroutine swiftest_util_flatten_eucl_k_to_ij module subroutine swiftest_util_flatten_eucl_plpl(self, param) !! author: Jacob R. Elliott and David A. Minton !! - !! Turns i,j indices into k index for use in the Euclidean distance matrix for pl-pl interactions for a Swiftest massive body object + !! Turns i,j indices into k index for use in the Euclidean distance matrix for pl-pl interactions for a Swiftest massive body + !! object !! !! Reference: !! @@ -1111,7 +1126,8 @@ module subroutine swiftest_util_flatten_eucl_plpl(self, param) if (param%lflatten_interactions) then if (allocated(self%k_plpl)) deallocate(self%k_plpl) ! Reset the index array if it's been set previously allocate(self%k_plpl(2, nplpl), stat=err) - if (err /=0) then ! An error occurred trying to allocate this big array. This probably means it's too big to fit in memory, and so we will force the run back into triangular mode + if (err /=0) then ! An error occurred trying to allocate this big array. This probably means it's too big to fit in + ! memory, and so we will force the run back into triangular mode param%lflatten_interactions = .false. else #ifdef DOCONLOC @@ -1258,7 +1274,8 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) end if if (param%lflatten_interactions) then - call swiftest_util_get_potential_energy(npl, pl%nplpl, pl%k_plpl, pl%lmask, cb%Gmass, pl%Gmass, pl%mass, pl%rb, nbody_system%pe) + call swiftest_util_get_potential_energy(npl, pl%nplpl, pl%k_plpl, pl%lmask, cb%Gmass, pl%Gmass, pl%mass, pl%rb, & + nbody_system%pe) else call swiftest_util_get_potential_energy(npl, pl%lmask, cb%Gmass, pl%Gmass, pl%mass, pl%rb, nbody_system%pe) end if @@ -1495,10 +1512,12 @@ module subroutine swiftest_util_index_array(ind_arr, n) !! author: David A. Minton !! !! Creates or resizes an index array of size n where ind_arr = [1, 2, ... n]. - !! This subroutine swiftest_assumes that if ind_arr is already allocated, it is a pre-existing index array of a different size. + !! This subroutine swiftest_assumes that if ind_arr is already allocated, it is a pre-existing index array of a different size implicit none ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: ind_arr !! Index array. Input is a pre-existing index array where n /= size(ind_arr). Output is a new index array ind_arr = [1, 2, ... n] + integer(I4B), dimension(:), allocatable, intent(inout) :: ind_arr !! Index array. Input is a pre-existing index array where + !! n /= size(ind_arr). Output is a new index array + !! ind_arr = [1, 2, ... n] integer(I4B), intent(in) :: n !! The new size of the index array ! Internals integer(I4B) :: nold, i @@ -1551,7 +1570,8 @@ end subroutine swiftest_util_index_map_storage module subroutine swiftest_util_make_impactors_pl(self, idx) !! author: David A. Minton !! - !! This is a simple wrapper function that is used to make a type-bound procedure using a subroutine whose interface is in the collision module, which must be defined first + !! This is a simple wrapper function that is used to make a type-bound procedure using a subroutine whose interface is in the + !! collision module, which must be defined first implicit none class(swiftest_pl), intent(inout) :: self !! Massive body object integer(I4B), dimension(:), intent(in) :: idx !! Array holding the indices of the two bodies involved in the collision) @@ -1628,7 +1648,8 @@ module subroutine swiftest_util_peri_body(self, nbody_system, param) if (param%qmin_coord == "HELIO") then call swiftest_util_peri(self%nbody, self%mu, self%rh, self%vh, self%atp, self%peri, self%isperi) else - call swiftest_util_peri(self%nbody, [(nbody_system%Gmtot,i=1,self%nbody)], self%rb, self%vb, self%atp, self%peri, self%isperi) + call swiftest_util_peri(self%nbody, [(nbody_system%Gmtot,i=1,self%nbody)], self%rb, self%vb, self%atp, self%peri, & + self%isperi) end if return @@ -1776,28 +1797,41 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) if (allocated(lmask)) deallocate(lmask) allocate(lmask(nencmin)) nenc_old = nencmin - if (any(nbody_system%plpl_encounter%index1(1:nencmin) == 0) .or. any(nbody_system%plpl_encounter%index2(1:nencmin) == 0)) then - lmask(:) = nbody_system%plpl_encounter%index1(1:nencmin) /= 0 .and. nbody_system%plpl_encounter%index2(1:nencmin) /= 0 + if (any(nbody_system%plpl_encounter%index1(1:nencmin) == 0) .or. & + any(nbody_system%plpl_encounter%index2(1:nencmin) == 0)) then + lmask(:) = nbody_system%plpl_encounter%index1(1:nencmin) /= 0 .and. & + nbody_system%plpl_encounter%index2(1:nencmin) /= 0 else return end if nencmin = count(lmask(:)) nbody_system%plpl_encounter%nenc = nencmin if (nencmin > 0_I8B) then - nbody_system%plpl_encounter%index1(1:nencmin) = pack(nbody_system%plpl_encounter%index1(1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%index2(1:nencmin) = pack(nbody_system%plpl_encounter%index2(1:nenc_old), lmask(1:nenc_old)) + nbody_system%plpl_encounter%index1(1:nencmin) = pack(nbody_system%plpl_encounter%index1(1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%index2(1:nencmin) = pack(nbody_system%plpl_encounter%index2(1:nenc_old), & + lmask(1:nenc_old)) nbody_system%plpl_encounter%id1(1:nencmin) = pack(nbody_system%plpl_encounter%id1(1:nenc_old), lmask(1:nenc_old)) nbody_system%plpl_encounter%id2(1:nencmin) = pack(nbody_system%plpl_encounter%id2(1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%lvdotr(1:nencmin) = pack(nbody_system%plpl_encounter%lvdotr(1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%lclosest(1:nencmin) = pack(nbody_system%plpl_encounter%lclosest(1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%status(1:nencmin) = pack(nbody_system%plpl_encounter%status(1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%tcollision(1:nencmin) = pack(nbody_system%plpl_encounter%tcollision(1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%level(1:nencmin) = pack(nbody_system%plpl_encounter%level(1:nenc_old), lmask(1:nenc_old)) + nbody_system%plpl_encounter%lvdotr(1:nencmin) = pack(nbody_system%plpl_encounter%lvdotr(1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%lclosest(1:nencmin) = pack(nbody_system%plpl_encounter%lclosest(1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%status(1:nencmin) = pack(nbody_system%plpl_encounter%status(1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%tcollision(1:nencmin) = pack(nbody_system%plpl_encounter%tcollision(1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%level(1:nencmin) = pack(nbody_system%plpl_encounter%level(1:nenc_old), & + lmask(1:nenc_old)) do i = 1, NDIM - nbody_system%plpl_encounter%r1(i, 1:nencmin) = pack(nbody_system%plpl_encounter%r1(i, 1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%r2(i, 1:nencmin) = pack(nbody_system%plpl_encounter%r2(i, 1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%v1(i, 1:nencmin) = pack(nbody_system%plpl_encounter%v1(i, 1:nenc_old), lmask(1:nenc_old)) - nbody_system%plpl_encounter%v2(i, 1:nencmin) = pack(nbody_system%plpl_encounter%v2(i, 1:nenc_old), lmask(1:nenc_old)) + nbody_system%plpl_encounter%r1(i, 1:nencmin) = pack(nbody_system%plpl_encounter%r1(i, 1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%r2(i, 1:nencmin) = pack(nbody_system%plpl_encounter%r2(i, 1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%v1(i, 1:nencmin) = pack(nbody_system%plpl_encounter%v1(i, 1:nenc_old), & + lmask(1:nenc_old)) + nbody_system%plpl_encounter%v2(i, 1:nencmin) = pack(nbody_system%plpl_encounter%v2(i, 1:nenc_old), & + lmask(1:nenc_old)) end do end if end if @@ -1811,12 +1845,14 @@ end subroutine swiftest_util_rearray_pl module subroutine swiftest_util_rescale_system(self, param, mscale, dscale, tscale) !! author: David A. Minton !! - !! Rescales an nbody system to a new set of units. Inputs are the multipliers on the mass (mscale), distance (dscale), and time units (tscale). - !! Rescales all united quantities in the nbody_system, as well as the mass conversion factors, gravitational constant, and Einstein's constant in the parameter object. + !! Rescales an nbody system to a new set of units. Inputs are the multipliers on the mass (mscale), distance (dscale), and + !! time units (tscale). Rescales all united quantities in the nbody_system, as well as the mass conversion factors, + !! gravitational constant, and Einstein's constant in the parameter object. implicit none class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters. Returns with new values of the scale vactors and GU - real(DP), intent(in) :: mscale, dscale, tscale !! Scale factors for mass, distance, and time units, respectively. + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters. Returns with new values of the + !! scale vactors and GU + real(DP), intent(in) :: mscale, dscale, tscale !! Scale factors for mass, distance, and time units ! Internals real(DP) :: vscale @@ -1884,13 +1920,15 @@ end subroutine swiftest_util_reset_kinship_pl module subroutine swiftest_util_resize_arr_info(arr, nnew) !! author: David A. Minton !! - !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. Passing nnew = 0 will deallocate. + !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. + !! Passing nnew = 0 will deallocate. implicit none ! Arguments type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Array to resize integer(I4B), intent(in) :: nnew !! New size ! Internals - type(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + type(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already + !! allocated integer(I4B) :: nold !! Old size if (nnew < 0) return @@ -1924,13 +1962,15 @@ end subroutine swiftest_util_resize_arr_info module subroutine swiftest_util_resize_arr_kin(arr, nnew) !! author: David A. Minton !! - !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. Passing nnew = 0 will deallocate. + !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. + !! Passing nnew = 0 will deallocate. implicit none ! Arguments type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Array to resize integer(I4B), intent(in) :: nnew !! New size ! Internals - type(swiftest_kinship), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + type(swiftest_kinship), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already + !! allocated integer(I4B) :: nold !! Old size if (nnew < 0) return @@ -2112,7 +2152,9 @@ module subroutine swiftest_util_set_msys(self) ! Arguments class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nobdy nbody_system object - self%Gmtot = self%cb%Gmass + sum(self%pl%Gmass(1:self%pl%nbody), self%pl%status(1:self%pl%nbody) /= INACTIVE) + self%Gmtot = self%cb%Gmass + if (self%pl%nbody > 0) self%Gmtot = self%Gmtot + sum(self%pl%Gmass(1:self%pl%nbody), & + self%pl%status(1:self%pl%nbody) /= INACTIVE) return end subroutine swiftest_util_set_msys @@ -2149,8 +2191,8 @@ module subroutine swiftest_util_set_mu_tp(self, cb) end subroutine swiftest_util_set_mu_tp - module subroutine swiftest_util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, origin_rh,& - origin_vh, discard_time, discard_rh, discard_vh, discard_body_id) + module subroutine swiftest_util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, & + origin_rh, origin_vh, discard_time, discard_rh, discard_vh, discard_body_id) !! author: David A. Minton !! !! Sets one or more values of the particle information metadata object @@ -2158,17 +2200,26 @@ module subroutine swiftest_util_set_particle_info(self, name, particle_type, sta ! Arguments class(swiftest_particle_info), intent(inout) :: self character(len=*), intent(in), optional :: name !! Non-unique name - character(len=*), intent(in), optional :: particle_type !! String containing a description of the particle type (e.g. Central Body, Massive Body, Test Particle) - character(len=*), intent(in), optional :: status !! Particle status description: ACTIVE, MERGED, FRAGMENTED, etc. - character(len=*), intent(in), optional :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) + character(len=*), intent(in), optional :: particle_type !! String containing a description of the particle + !! type (Central Body, Massive Body, Test Particle) + character(len=*), intent(in), optional :: status !! Particle status description: ACTIVE, MERGED, + !! FRAGMENTED, etc. + character(len=*), intent(in), optional :: origin_type !! String containing a description of the origin of + !! the particle (e.g. Initial Conditions, + !! Supercatastrophic, Disruption, etc.) real(DP), intent(in), optional :: origin_time !! The time of the particle's formation integer(I4B), intent(in), optional :: collision_id !! The ID fo the collision that formed the particle - real(DP), dimension(:), intent(in), optional :: origin_rh !! The heliocentric distance vector at the time of the particle's formation - real(DP), dimension(:), intent(in), optional :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation + real(DP), dimension(:), intent(in), optional :: origin_rh !! The heliocentric distance vector at the time of + !! the particle's formation + real(DP), dimension(:), intent(in), optional :: origin_vh !! The heliocentric velocity vector at the time of + !! the particle's formation real(DP), intent(in), optional :: discard_time !! The time of the particle's discard - real(DP), dimension(:), intent(in), optional :: discard_rh !! The heliocentric distance vector at the time of the particle's discard - real(DP), dimension(:), intent(in), optional :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard - integer(I4B), intent(in), optional :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved) + real(DP), dimension(:), intent(in), optional :: discard_rh !! The heliocentric distance vector at the time of + !! the particle's discard + real(DP), dimension(:), intent(in), optional :: discard_vh !! The heliocentric velocity vector at the time of + !! the particle's discard + integer(I4B), intent(in), optional :: discard_body_id !! The id of the other body involved in the discard + !! (0 if no other body involved) ! Internals character(len=NAMELEN) :: lenstr character(len=:), allocatable :: fmtlabel @@ -2655,15 +2706,17 @@ module subroutine swiftest_util_snapshot_system(self, param, nbody_system, t, ar !! Takes a snapshot of the nbody_system for later file storage implicit none ! Arguments - class(swiftest_storage), intent(inout) :: self !! Swiftest storage object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store - real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time - character(*), intent(in), optional :: arg !! Optional argument (needed for extended storage type used in collision snapshots) + class(swiftest_storage), intent(inout) :: self !! Swiftest storage object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store + real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time + character(*), intent(in), optional :: arg !! Optional argument (needed for extended storage type used + !! in collision snapshots) ! Internals class(swiftest_nbody_system), allocatable :: snapshot - ! To allow for runs to be restarted in a bit-identical way, we'll need to run the same coordinate conversion routines we would run upon restarting + ! To allow for runs to be restarted in a bit-identical way, we'll need to run the same coordinate conversion routines we would + ! run upon restarting select type(pl => nbody_system%pl) class is (whm_pl) call pl%h2j(nbody_system%cb) @@ -2748,7 +2801,8 @@ module subroutine swiftest_util_sort_body(self, sortby, ascending) ! Arguments class(swiftest_body), intent(inout) :: self !! Swiftest body object character(*), intent(in) :: sortby !! Sorting attribute - logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order + logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending + !! or descending order ! Internals integer(I4B), dimension(:), allocatable :: ind integer(I4B) :: direction @@ -2783,7 +2837,7 @@ module subroutine swiftest_util_sort_body(self, sortby, ascending) call util_sort(direction * body%peri(1:n), ind) case("atp") call util_sort(direction * body%atp(1:n), ind) - case("info", "lfirst", "nbody", "ldiscard", "lcollision", "lencounter", "rh", "vh", "rb", "vb", "ah", "aobl", "atide", "agr","isperi") + case("info","lfirst","nbody","ldiscard","lcollision","lencounter","rh","vh","rb","vb","ah","aobl","atide","agr","isperi") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not found!' @@ -2807,7 +2861,8 @@ module subroutine swiftest_util_sort_pl(self, sortby, ascending) ! Arguments class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object character(*), intent(in) :: sortby !! Sorting attribute - logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order + logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or + !! descending order ! Internals integer(I4B), dimension(:), allocatable :: ind integer(I4B) :: direction @@ -2866,7 +2921,8 @@ module subroutine swiftest_util_sort_tp(self, sortby, ascending) ! Arguments class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object character(*), intent(in) :: sortby !! Sorting attribute - logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order + logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or + !! descending order ! Internals integer(I4B), dimension(:), allocatable :: ind integer(I4B) :: direction @@ -2904,7 +2960,8 @@ module subroutine swiftest_util_sort_rearrange_body(self, ind) implicit none ! Arguments class(swiftest_body), intent(inout) :: self !! Swiftest body object - integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) + integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body + !! (should contain all 1:n index values in the desired order) associate(n => self%nbody) call util_sort_rearrange(self%id, ind, n) @@ -2947,9 +3004,9 @@ module subroutine swiftest_util_sort_rearrange_arr_info(arr, ind, n) ! Arguments type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange + integer(I4B), intent(in) :: n !! Number of elements in arr & ind to rearrange ! Internals - type(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + type(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation if (.not. allocated(arr) .or. n <= 0) return allocate(tmp, mold=arr) @@ -2971,7 +3028,7 @@ pure module subroutine swiftest_util_sort_rearrange_arr_kin(arr, ind, n) integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange ! Internals - type(swiftest_kinship), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + type(swiftest_kinship), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation integer(I4B) :: i,j if (.not. allocated(arr) .or. n <= 0) return @@ -2996,7 +3053,8 @@ module subroutine swiftest_util_sort_rearrange_pl(self, ind) !! This is a helper utility used to make polymorphic sorting work on Swiftest structures. implicit none class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) + integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body + !! (should contain all 1:n index values in the desired order) associate(pl => self, npl => self%nbody) call util_sort_rearrange(pl%mass, ind, npl) @@ -3034,7 +3092,8 @@ module subroutine swiftest_util_sort_rearrange_tp(self, ind) implicit none ! Arguments class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) + integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body + !! (should contain all 1:n index values in the desired order) associate(tp => self, ntp => self%nbody) call util_sort_rearrange(tp%nplenc, ind, ntp) @@ -3057,8 +3116,11 @@ module subroutine swiftest_util_spill_arr_info(keeps, discards, lspill_list, lde ! Arguments type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill + !! into the discardss + logical, intent(in) :: ldestructive !! Logical flag indicating whether or + !! not this operation should alter the + !! keeps array or not ! Internals integer(I4B) :: i, nspill, nkeep, nlist integer(I4B), dimension(:), allocatable :: idx @@ -3106,8 +3168,11 @@ module subroutine swiftest_util_spill_arr_kin(keeps, discards, lspill_list, ldes ! Arguments type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the + !! discardss + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not + !! this operation should alter the keeps + !! array or not ! Internals integer(I4B) :: nspill, nkeep, nlist type(swiftest_kinship), dimension(:), allocatable :: tmp @@ -3150,7 +3215,8 @@ module subroutine swiftest_util_spill_body(self, discards, lspill_list, ldestruc class(swiftest_body), intent(inout) :: self !! Swiftest generic body object class(swiftest_body), intent(inout) :: discards !! Discarded object logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter body by removing the discard list + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter + !! body by removing the discard list ! Internals integer(I4B) :: nbody_old @@ -3207,10 +3273,11 @@ module subroutine swiftest_util_spill_pl(self, discards, lspill_list, ldestructi class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_body), intent(inout) :: discards !! Discarded object logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter body by removing the discard list + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter + !! body by removing the discard list associate(keeps => self) - select type (discards) ! The standard requires us to select the type of both arguments in order to access all the components + select type (discards) !The standard requires us to select the type of both arguments in order to access all the components class is (swiftest_pl) !> Spill components specific to the massive body class call util_spill(keeps%mass, discards%mass, lspill_list, ldestructive) @@ -3251,10 +3318,11 @@ module subroutine swiftest_util_spill_tp(self, discards, lspill_list, ldestructi !! Adapted from David E. Kaufmann's Swifter routine whm_discard_spill.f90 implicit none ! Arguments - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - class(swiftest_body), intent(inout) :: discards !! Discarded object - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardse - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter body by removing the discard list + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + class(swiftest_body), intent(inout) :: discards !! Discarded object + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardse + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter + !! body by removing the discard list associate(keeps => self, ntp => self%nbody) select type(discards) diff --git a/version.txt b/version.txt index e668262f6..82ba9e59f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2023.10.3 \ No newline at end of file +2023.11.0 \ No newline at end of file