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

Commit

Permalink
Moved initialize_system from io to setup where it belongs
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jul 23, 2021
1 parent 2107b34 commit 95af487
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 42 deletions.
20 changes: 0 additions & 20 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -976,26 +976,6 @@ function io_read_hdr(iu, t, npl, ntp, out_form, out_type) result(ierr)
return
end function io_read_hdr

module subroutine io_read_initialize_system(self, param)
!! author: David A. Minton
!!
!! Wrapper method to initialize a basic Swiftest nbody system from files
!!
implicit none
! Arguments
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters

call self%cb%initialize(param)
call self%pl%initialize(param)
if (.not.param%lrhill_present) call self%pl%set_rhill(self%cb)
call self%tp%initialize(param)
call self%set_msys()
call self%pl%set_mu(self%cb)
call self%tp%set_mu(self%cb)

end subroutine io_read_initialize_system

module subroutine io_toupper(string)
!! author: David A. Minton
!!
Expand Down
32 changes: 16 additions & 16 deletions src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ module swiftest_classes
public :: eucl_dist_index_plpl, eucl_dist_index_pltp, eucl_irij3_plpl
public :: gr_getaccb_ns_body, gr_p4_pos_kick, gr_pseudovel2vel, gr_vel2pseudovel
public :: io_dump_param, io_dump_swiftest, io_dump_system, io_get_args, io_get_token, io_param_reader, io_param_writer, io_read_body_in, &
io_read_cb_in, io_read_param_in, io_read_frame_body, io_read_frame_cb, io_read_frame_system, io_read_initialize_system, &
io_read_cb_in, io_read_param_in, io_read_frame_body, io_read_frame_cb, io_read_frame_system, &
io_toupper, io_write_discard, io_write_encounter, io_write_frame_body, io_write_frame_cb, io_write_frame_system
public :: kickvh_body
public :: obl_acc_body, obl_acc_pl, obl_acc_tp
public :: orbel_el2xv_vec, orbel_xv2el_vec, orbel_scget, orbel_xv2aeq, orbel_xv2aqt
public :: setup_body, setup_construct_system, setup_pl, setup_tp
public :: setup_body, setup_construct_system, setup_initialize_system, setup_pl, setup_tp
public :: tides_getacch_pl, tides_step_spin_system
public :: user_getacch_body
public :: util_coord_b2h_pl, util_coord_b2h_tp, util_coord_h2b_pl, util_coord_h2b_tp, util_exit, util_fill_body, util_fill_pl, util_fill_tp, &
Expand Down Expand Up @@ -288,14 +288,14 @@ module swiftest_classes
procedure(abstract_step_system), public, deferred :: step

! Concrete classes that are common to the basic integrator (only test particles considered for discard)
procedure, public :: discard => discard_system !! Perform a discard step on the system
procedure, public :: dump => io_dump_system !! Dump the state of the system to a file
procedure, public :: initialize => io_read_initialize_system !! Initialize the system from an input file
procedure, public :: read_frame => io_read_frame_system !! Append a frame of output data to file
procedure, public :: write_discard => io_write_discard !! Append a frame of output data to file
procedure, public :: write_frame => io_write_frame_system !! Append a frame of output data to file
procedure, public :: step_spin => tides_step_spin_system !! Steps the spins of the massive & central bodies due to tides.
procedure, public :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies.
procedure, public :: discard => discard_system !! Perform a discard step on the system
procedure, public :: dump => io_dump_system !! Dump the state of the system to a file
procedure, public :: initialize => setup_initialize_system !! Initialize the system from input files
procedure, public :: read_frame => io_read_frame_system !! Append a frame of output data to file
procedure, public :: write_discard => io_write_discard !! Append a frame of output data to file
procedure, public :: write_frame => io_write_frame_system !! Append a frame of output data to file
procedure, public :: step_spin => tides_step_spin_system !! Steps the spins of the massive & central bodies due to tides.
procedure, public :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies.
end type swiftest_nbody_system

abstract interface
Expand Down Expand Up @@ -565,12 +565,6 @@ module subroutine io_read_frame_system(self, iu, param, form, ierr)
integer(I4B), intent(out) :: ierr !! Error code
end subroutine io_read_frame_system

module subroutine io_read_initialize_system(self, param)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine io_read_initialize_system

module subroutine io_write_discard(self, param)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object
Expand Down Expand Up @@ -680,6 +674,12 @@ module subroutine setup_construct_system(system, param)
type(swiftest_parameters), intent(in) :: param !! Swiftest parameters
end subroutine setup_construct_system

module subroutine setup_initialize_system(self, param)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine setup_initialize_system

module subroutine setup_pl(self,n)
implicit none
class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object
Expand Down
23 changes: 22 additions & 1 deletion src/setup/setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ module subroutine setup_construct_system(system, param)
return
end subroutine setup_construct_system


module subroutine setup_initialize_system(self, param)
!! author: David A. Minton
!!
!! Wrapper method to initialize a basic Swiftest nbody system from files
!!
implicit none
! Arguments
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters

call self%cb%initialize(param)
call self%pl%initialize(param)
if (.not.param%lrhill_present) call self%pl%set_rhill(self%cb)
call self%tp%initialize(param)
call self%set_msys()
call self%pl%set_mu(self%cb)
call self%tp%set_mu(self%cb)
call self%pl%eucl_index()
return
end subroutine setup_initialize_system

module subroutine setup_body(self,n)
!! author: David A. Minton
!!
Expand All @@ -83,7 +105,6 @@ module subroutine setup_body(self,n)
if (n <= 0) return
self%lfirst = .true.

!write(*,*) 'Allocating the basic Swiftest particle'
allocate(self%id(n))
allocate(self%name(n))
allocate(self%status(n))
Expand Down
8 changes: 4 additions & 4 deletions src/symba/symba_encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lencount

associate(pl => self, npl => self%nbody)
lencounter = .false.
do concurrent(j = 1:npl, .not.pl%lmtiny(j))
do i = 1, npl
!do concurrent(j = 1:npl, .not.pl%lmtiny(j))
! do i = 1, npl
rcrit = (pl%rhill(i) + pl%rhill(j)) * RHSCALE * (RSHELL**(irec))
r2crit = r2crit**2
xr(:) = pl%xh(:, j) - pl%xh(:, i)
Expand All @@ -29,8 +29,8 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lencount
vdotr = dot_product(vr(:), xr(:))
lflag = rmvs_chk_ind(r2, v2, vdotr, dt, r2crit)
if (lflag) lencounter = .true.
end do
end do
! end do
!end do
end associate
return
end function symba_encounter_check_pl
Expand Down
2 changes: 1 addition & 1 deletion src/whm/whm_setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module subroutine whm_setup_system(self, param)
class(whm_nbody_system), intent(inout) :: self !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters

call io_read_initialize_system(self, param)
call setup_initialize_system(self, param)
! Make sure that the discard list gets allocated initially
call self%tp_discards%setup(self%tp%nbody)
call self%pl%set_mu(self%cb)
Expand Down

0 comments on commit 95af487

Please sign in to comment.