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

Commit

Permalink
Merge branch 'debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 14, 2021
2 parents 6caaa8d + dc3a9f9 commit 2947fef
Show file tree
Hide file tree
Showing 23 changed files with 984 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/discard/discard.f90
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ module subroutine discard_tp(self, system, param)
integer(I4B) :: npl, ntp

associate(tp => self, cb => system%cb, pl => system%pl)
if ((ntp == 0) .or. (npl ==0)) return
ntp = tp%nbody
npl = pl%nbody
if ((ntp == 0) .or. (npl ==0)) return

if ((param%rmin >= 0.0_DP) .or. (param%rmax >= 0.0_DP) .or. &
(param%rmaxu >= 0.0_DP) .or. ((param%qmin >= 0.0_DP) .and. (param%qmin_coord == "BARY"))) then
Expand Down
5 changes: 5 additions & 0 deletions src/drift/drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module subroutine drift_body(self, system, param, dt)
end if
end associate

deallocate(iflag)

return
end subroutine drift_body

Expand Down Expand Up @@ -77,12 +79,15 @@ module subroutine drift_all(mu, x, v, n, param, dt, lmask, iflag)
else
where(lmask(1:n)) dtp(1:n) = dt
end if

!$omp simd
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

deallocate(dtp)

return
end subroutine drift_all

Expand Down
2 changes: 1 addition & 1 deletion src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, x, v, renc, dt, lvdotr,
call encounter_check_all(nenc, index1, index2, x, v, x, v, renc, renc, dt, lencounter, lvdotr)

call encounter_check_reduce_broadphase(npl, nenc, index1, index2, lencounter, lvdotr)
deallocate(lencounter)
end if

return
Expand Down Expand Up @@ -837,7 +838,6 @@ module subroutine encounter_check_collapse_ragged_list(ragged_list, n1, nenc, in
end associate
if (nenc == 0) return


allocate(index1(nenc))
allocate(index2(nenc))
if (present(lvdotr)) allocate(lvdotr(nenc))
Expand Down
68 changes: 68 additions & 0 deletions src/encounter/encounter_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,74 @@ module subroutine encounter_util_copy_list(self, source)
end subroutine encounter_util_copy_list


module subroutine encounter_util_dealloc_aabb(self)
!! author: David A. Minton
!!
!! Deallocates all allocatables
implicit none
! Arguments
class(encounter_bounding_box_1D), intent(inout) :: self

if (allocated(self%ind)) deallocate(self%ind)
if (allocated(self%ibeg)) deallocate(self%ibeg)
if (allocated(self%iend)) deallocate(self%iend)

return
end subroutine encounter_util_dealloc_aabb


module subroutine encounter_util_dealloc_list(self)
!! author: David A. Minton
!!
!! Deallocates all allocatables
implicit none
! Arguments
class(encounter_list), intent(inout) :: self

if (allocated(self%lvdotr)) deallocate(self%lvdotr)
if (allocated(self%status)) deallocate(self%status)
if (allocated(self%index1)) deallocate(self%index1)
if (allocated(self%index2)) deallocate(self%index2)
if (allocated(self%id1)) deallocate(self%id1)
if (allocated(self%id2)) deallocate(self%id2)
if (allocated(self%x1)) deallocate(self%x1)
if (allocated(self%x2)) deallocate(self%x2)
if (allocated(self%v1)) deallocate(self%v1)
if (allocated(self%v2)) deallocate(self%v2)
if (allocated(self%t)) deallocate(self%t)

return
end subroutine encounter_util_dealloc_list


module subroutine encounter_util_final_aabb(self)
!! author: David A. Minton
!!
!! Finalize the axis aligned bounding box (1D) - deallocates all allocatables
implicit none
! Arguments
type(encounter_bounding_box_1D), intent(inout) :: self

call self%dealloc()

return
end subroutine encounter_util_final_aabb


module subroutine encounter_util_final_list(self)
!! author: David A. Minton
!!
!! Finalize the encounter list - deallocates all allocatables
implicit none
! Arguments
type(encounter_list), intent(inout) :: self

call self%dealloc()

return
end subroutine encounter_util_final_list


module subroutine encounter_util_resize_list(self, nnew)
!! author: David A. Minton
!!
Expand Down
3 changes: 2 additions & 1 deletion src/helio/helio_drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module subroutine helio_drift_body(self, system, param, dt)
integer(I4B) :: i !! Loop counter
real(DP) :: rmag, vmag2, energy
integer(I4B), dimension(:),allocatable :: iflag !! Vectorized error code flag
real(DP), dimension(:), allocatable :: dtp, mu
real(DP), dimension(:), allocatable :: mu

if (self%nbody == 0) return

Expand All @@ -37,6 +37,7 @@ module subroutine helio_drift_body(self, system, param, dt)
end if
end associate

deallocate(iflag, mu)
return
end subroutine helio_drift_body

Expand Down
46 changes: 46 additions & 0 deletions src/helio/helio_util.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
submodule(helio_classes) s_helio_util
use swiftest
contains

module subroutine helio_util_final_pl(self)
!! author: David A. Minton
!!
!! Finalize the Helio massive body object - deallocates all allocatables
implicit none
! Arguments
type(helio_pl), intent(inout) :: self !! Helio massive body object

call self%dealloc()

return
end subroutine helio_util_final_pl


module subroutine helio_util_final_system(self)
!! author: David A. Minton
!!
!! Finalize the Helio nbody system object - deallocates all allocatables
implicit none
! Arguments
type(helio_nbody_system), intent(inout) :: self !! Helio nbody system object

call self%dealloc()

return
end subroutine helio_util_final_system


module subroutine helio_util_final_tp(self)
!! author: David A. Minton
!!
!! Finalize the Helio test particle object - deallocates all allocatables
implicit none
! Arguments
type(helio_tp), intent(inout) :: self !! Helio test particle object

call self%dealloc()

return
end subroutine helio_util_final_tp

end submodule s_helio_util
4 changes: 1 addition & 3 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ module subroutine io_dump_system(self, param)
call self%tp%write_frame(dump_param%nciu, dump_param)
call dump_param%nciu%close()
! Syncrhonize the disk and memory buffer of the NetCDF file (e.g. commit the frame files stored in memory to disk)
call param%nciu%sync()
call param%nciu%flush(param)
end if

idx = idx + 1
Expand Down Expand Up @@ -2130,8 +2130,6 @@ module subroutine io_write_frame_system(self, param)
end select

lfirst = .false.
else
!call param%nciu%open(param)
end if
end if

Expand Down
38 changes: 31 additions & 7 deletions src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ module encounter_classes
real(DP), dimension(:,:), allocatable :: v2 !! the velocity of body 2 in the encounter
real(DP), dimension(:), allocatable :: t !! Time of encounter
contains
procedure :: setup => encounter_setup_list !! A constructor that sets the number of encounters and allocates and initializes all arrays
procedure :: append => encounter_util_append_list !! Appends elements from one structure to another
procedure :: copy => encounter_util_copy_list !! Copies elements from the source encounter list into self.
procedure :: spill => encounter_util_spill_list !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: resize => encounter_util_resize_list !! Checks the current size of the encounter list against the required size and extends it by a factor of 2 more than requested if it is too small.
procedure :: write => encounter_io_write_list !! Write close encounter data to output binary file
procedure :: setup => encounter_setup_list !! A constructor that sets the number of encounters and allocates and initializes all arrays
procedure :: append => encounter_util_append_list !! Appends elements from one structure to another
procedure :: copy => encounter_util_copy_list !! Copies elements from the source encounter list into self.
procedure :: dealloc => encounter_util_dealloc_list !! Deallocates all allocatables
procedure :: spill => encounter_util_spill_list !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
procedure :: resize => encounter_util_resize_list !! Checks the current size of the encounter list against the required size and extends it by a factor of 2 more than requested if it is too small.
procedure :: write => encounter_io_write_list !! Write close encounter data to output binary file
final :: encounter_util_final_list !! Finalize the encounter list - deallocates all allocatables
end type encounter_list

type encounter_bounding_box_1D
Expand All @@ -38,6 +40,8 @@ module encounter_classes
integer(I4B), dimension(:), allocatable :: iend !! Ending index for box
contains
procedure :: sort => encounter_check_sort_aabb_1D !! Sorts the bounding box extents along a single dimension prior to the sweep phase
procedure :: dealloc => encounter_util_dealloc_aabb !! Deallocates all allocatables
final :: encounter_util_final_aabb !! Finalize the axis-aligned bounding box (1D) - deallocates all allocatables
end type

type encounter_bounding_box
Expand Down Expand Up @@ -209,10 +213,30 @@ module subroutine encounter_util_copy_list(self, source)
class(encounter_list), intent(in) :: source !! Source object to copy into
end subroutine encounter_util_copy_list

module subroutine encounter_util_dealloc_aabb(self)
implicit none
class(encounter_bounding_box_1D), intent(inout) :: self !!Bounding box structure along a single dimension
end subroutine encounter_util_dealloc_aabb

module subroutine encounter_util_dealloc_list(self)
implicit none
class(encounter_list), intent(inout) :: self !! Swiftest encounter list object
end subroutine encounter_util_dealloc_list

module subroutine encounter_util_final_aabb(self)
implicit none
type(encounter_bounding_box_1D), intent(inout) :: self !!Bounding box structure along a single dimension
end subroutine encounter_util_final_aabb

module subroutine encounter_util_final_list(self)
implicit none
type(encounter_list), intent(inout) :: self !! Swiftest encounter list object
end subroutine encounter_util_final_list

module subroutine encounter_util_resize_list(self, nnew)
implicit none
class(encounter_list), intent(inout) :: self !! Swiftest encounter list
integer(I4B), intent(in) :: nnew !! New size of list needed
integer(I4B), intent(in) :: nnew !! New size of list needed
end subroutine encounter_util_resize_list

module subroutine encounter_util_spill_list(self, discards, lspill_list, ldestructive)
Expand Down
18 changes: 18 additions & 0 deletions src/modules/helio_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module helio_classes
contains
procedure :: step => helio_step_system !! Advance the Helio nbody system forward in time by one step
procedure :: initialize => helio_setup_initialize_system !! Performs Helio-specific initilization steps, including converting to DH coordinates
final :: helio_util_final_system !! Finalizes the Helio system object - deallocates all allocatables
end type helio_nbody_system

!********************************************************************************************************************************
Expand All @@ -43,6 +44,7 @@ module helio_classes
procedure :: accel => helio_kick_getacch_pl !! Compute heliocentric accelerations of massive bodies
procedure :: kick => helio_kick_vb_pl !! Kicks the barycentric velocities
procedure :: step => helio_step_pl !! Steps the body forward one stepsize
final :: helio_util_final_pl !! Finalizes the Helio massive body object - deallocates all allocatables
end type helio_pl

!********************************************************************************************************************************
Expand All @@ -59,6 +61,7 @@ module helio_classes
procedure :: accel => helio_kick_getacch_tp !! Compute heliocentric accelerations of massive bodies
procedure :: kick => helio_kick_vb_tp !! Kicks the barycentric velocities
procedure :: step => helio_step_tp !! Steps the body forward one stepsize
final :: helio_util_final_tp !! Finalizes the Helio test particle object - deallocates all allocatables
end type helio_tp

interface
Expand Down Expand Up @@ -213,6 +216,21 @@ module subroutine helio_step_tp(self, system, param, t, dt)
real(DP), intent(in) :: dt !! Stepsizee
end subroutine helio_step_tp

module subroutine helio_util_final_pl(self)
implicit none
type(helio_pl), intent(inout) :: self !! Helio massive body object
end subroutine helio_util_final_pl

module subroutine helio_util_final_system(self)
implicit none
type(helio_nbody_system), intent(inout) :: self !! Helio nbody system object
end subroutine helio_util_final_system

module subroutine helio_util_final_tp(self)
implicit none
type(helio_tp), intent(inout) :: self !! Helio test particle object
end subroutine helio_util_final_tp

end interface

end module helio_classes
Loading

0 comments on commit 2947fef

Please sign in to comment.