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

Commit

Permalink
Testing making the nbody_system object a coarray variable
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Mar 28, 2023
1 parent 27fcda6 commit 066e085
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/swiftest/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ program swiftest_driver
use swiftest
implicit none

#ifdef COARRAY
class(swiftest_nbody_system), allocatable :: nbody_system[:] !! Polymorphic object containing the nbody system to be integrated
#else
class(swiftest_nbody_system), allocatable :: nbody_system !! Polymorphic object containing the nbody system to be integrated
#endif
type(swiftest_parameters) :: param !! Run configuration parameters
character(len=:), allocatable :: integrator !! Integrator type code (see globals for symbolic names)
character(len=:), allocatable :: param_file_name !! Name of the file containing user-defined parameters
Expand Down Expand Up @@ -77,6 +81,12 @@ program swiftest_driver
!$ write(param%display_unit,'(a)') ' ------------------'
!$ write(param%display_unit,'(a,i3,/)') ' Number of threads = ', nthreads
!$ if (param%log_output) write(*,'(a,i3)') ' OpenMP: Number of threads = ',nthreads
#ifdef COARRAY
if (this_image() == 1) then
write(param%display_unit,'(a)') ' Coarray parameters:'
write(param%display_unit,'(a)') ' -------------------'
write(param%display_unit,'(a)') ' Number of images = ', num_images()
#endif

call nbody_system%initialize(param)

Expand Down Expand Up @@ -138,6 +148,9 @@ program swiftest_driver
call nbody_system%display_run_information(param, integration_timer, phase="last")

end associate
#ifdef COARRAY
end if ! this_image() == 1
#endif
end associate

call base_util_exit(SUCCESS)
Expand Down
8 changes: 6 additions & 2 deletions src/swiftest/swiftest_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,12 @@ end subroutine swiftest_util_setup_body

module subroutine swiftest_util_setup_construct_system(nbody_system, param)
implicit none
class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system !! Swiftest nbody_system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
#ifdef COARRAY
class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system[:] !! Swiftest nbody_system object
#else
class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system !! Swiftest nbody_system object
#endif
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine swiftest_util_setup_construct_system

module subroutine swiftest_util_setup_initialize_particle_info_system(self, param)
Expand Down
29 changes: 23 additions & 6 deletions src/swiftest/swiftest_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2694,22 +2694,29 @@ module subroutine swiftest_util_set_rhill_approximate(self,cb)
return
end subroutine swiftest_util_set_rhill_approximate


module subroutine swiftest_util_setup_construct_system(nbody_system, param)
!! author: David A. Minton
!!
!! Constructor for a Swiftest nbody system. Creates the nbody system object based on the user-input integrator
!!
implicit none
! Arguments
class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system !! Swiftest nbody_system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
#ifdef COARRAY
class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system[:] !! Swiftest nbody_system object
#else
class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system !! Swiftest nbody_system object
#endif
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters

select case(param%integrator)
case (INT_BS)
write(*,*) 'Bulirsch-Stoer integrator not yet enabled'
case (INT_HELIO)
case (INT_HELIO)
#ifdef COARRAY
allocate(helio_nbody_system :: nbody_system[*])
#else
allocate(helio_nbody_system :: nbody_system)
#endif
select type(nbody_system)
class is (helio_nbody_system)
allocate(helio_cb :: nbody_system%cb)
Expand All @@ -2723,7 +2730,11 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param)
case (INT_TU4)
write(*,*) 'INT_TU4 integrator not yet enabled'
case (INT_WHM)
#ifdef COARRAY
allocate(whm_nbody_system :: nbody_system[*])
#else
allocate(whm_nbody_system :: nbody_system)
#endif
select type(nbody_system)
class is (whm_nbody_system)
allocate(whm_cb :: nbody_system%cb)
Expand All @@ -2733,7 +2744,11 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param)
end select
param%collision_model = "MERGE"
case (INT_RMVS)
#ifdef COARRAY
allocate(rmvs_nbody_system :: nbody_system[*])
#else
allocate(rmvs_nbody_system :: nbody_system)
#endif
select type(nbody_system)
class is (rmvs_nbody_system)
allocate(rmvs_cb :: nbody_system%cb)
Expand All @@ -2743,7 +2758,11 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param)
end select
param%collision_model = "MERGE"
case (INT_SYMBA)
#ifdef COARRAY
allocate(symba_nbody_system :: nbody_system[*])
#else
allocate(symba_nbody_system :: nbody_system)
#endif
select type(nbody_system)
class is (symba_nbody_system)
allocate(symba_cb :: nbody_system%cb)
Expand All @@ -2768,10 +2787,8 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param)

allocate(swiftest_particle_info :: nbody_system%cb%info)


nbody_system%t = param%tstart


return
end subroutine swiftest_util_setup_construct_system

Expand Down

0 comments on commit 066e085

Please sign in to comment.