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

Commit

Permalink
Switched frame counter variables to I4B to simplify the code, as it r…
Browse files Browse the repository at this point in the history
…eally doesn't need to be I8B
  • Loading branch information
daminton committed Dec 1, 2022
1 parent 910e8e9 commit 1dbe336
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
11 changes: 6 additions & 5 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module subroutine io_conservation_report(self, param, lterminal)
if (abs(system%Mtot_error) > 100 * epsilon(system%Mtot_error)) then
write(*,*) "Severe error! Mass not conserved! Halting!"
! Save the frame of data to the bin file in the slot just after the present one for diagnostics
param%ioutput = param%ioutput + 1_I8B
param%ioutput = param%ioutput + 1
call self%write_frame(param%nciu, param)
call param%nciu%close()
call util_exit(FAILURE)
Expand Down Expand Up @@ -282,12 +282,13 @@ module subroutine io_dump_system_storage(self, param)
class(swiftest_storage(*)), intent(inout) :: self !! Swiftest simulation history storage object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
! Internals
integer(I8B) :: i, iloop_start
integer(I4B) :: i
integer(I8B) :: iloop_start

iloop_start = param%iloop - param%istep_out * param%dump_cadence + 1_I8B
do i = 1_I8B, param%dump_cadence
iloop_start = param%iloop - int(param%istep_out * param%dump_cadence + 1, kind=I8B)
do i = 1, param%dump_cadence
if (allocated(self%frame(i)%system)) then
param%ioutput = int(iloop_start / param%istep_out, kind=I8B) + i
param%ioutput = int(iloop_start / param%istep_out, kind=I4B) + i
call self%frame(i)%system%write_frame(param)
deallocate(self%frame(i)%system)
end if
Expand Down
22 changes: 11 additions & 11 deletions src/main/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ program swiftest_driver
use swiftest
implicit none

class(swiftest_nbody_system), allocatable :: nbody_system !! Polymorphic object containing the nbody system to be integrated
class(swiftest_parameters), allocatable :: param !! Run configuration parameters
character(len=:), allocatable :: integrator !! Integrator type code (see swiftest_globals for symbolic names)
character(len=:),allocatable :: param_file_name !! Name of the file containing user-defined parameters
character(len=:), allocatable :: display_style !! Style of the output display {"STANDARD", "COMPACT", "PROGRESS"}). Default is "STANDARD"
integer(I8B) :: idump !! Dump cadence counter
integer(I8B) :: iout !! Output cadence counter
integer(I8B) :: istart !! Starting index for loop counter
integer(I8B) :: nloops !! Number of steps to take in the simulation
integer(I8B) :: iframe !! System history frame cindex
class(swiftest_nbody_system), allocatable :: nbody_system !! Polymorphic object containing the nbody system to be integrated
class(swiftest_parameters), allocatable :: param !! Run configuration parameters
character(len=:), allocatable :: integrator !! Integrator type code (see swiftest_globals for symbolic names)
character(len=:),allocatable :: param_file_name !! Name of the file containing user-defined parameters
character(len=:), allocatable :: display_style !! Style of the output display {"STANDARD", "COMPACT", "PROGRESS"}). Default is "STANDARD"
integer(I8B) :: istart !! Starting index for loop counter
integer(I8B) :: nloops !! Number of steps to take in the simulation
integer(I4B) :: iout !! Output cadence counter
integer(I4B) :: idump !! Dump cadence counter
integer(I4B) :: iframe !! System history frame cindex
type(walltimer) :: integration_timer !! Object used for computing elapsed wall time
real(DP) :: tfrac
type(progress_bar) :: pbar !! Object used to print out a progress bar
Expand Down Expand Up @@ -83,7 +83,7 @@ program swiftest_driver
iout = istep_out
nloops = ceiling((tstop - t0) / dt, kind=I8B)
istart = ceiling((tstart - t0) / dt + 1, kind=I8B)
ioutput = int(istart / istep_out, kind=I8B)
ioutput = int(istart / istep_out, kind=I4B)

! Set up system storage for intermittent file dumps
if (dump_cadence == 0) dump_cadence = ceiling(nloops / (1.0_DP * istep_out), kind=I8B)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module swiftest_classes
real(DP) :: tstop = -1.0_DP !! Integration stop time
real(DP) :: dt = -1.0_DP !! Time step
integer(I8B) :: iloop = 0_I8B !! Main loop counter
integer(I8B) :: ioutput = 0_I8B !! Output counter
integer(I4B) :: ioutput = 0 !! Output counter
character(STRMAX) :: incbfile = CB_INFILE !! Name of input file for the central body
character(STRMAX) :: inplfile = PL_INFILE !! Name of input file for massive bodies
character(STRMAX) :: intpfile = TP_INFILE !! Name of input file for test particles
Expand Down Expand Up @@ -425,7 +425,7 @@ module swiftest_classes
end type

type, extends(swiftest_base) :: swiftest_storage(nframes)
integer(I8B), len :: nframes
integer(I4B), len :: nframes
!! A class that that is used to store simulation history data between file output
type(storage_frame), dimension(nframes) :: frame
contains
Expand Down
8 changes: 4 additions & 4 deletions src/netcdf/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ module function netcdf_read_frame_system(self, iu, param) result(ierr)
call pl%setup(npl, param)
call tp%setup(ntp, param)

tslot = int(param%ioutput, kind=I4B) + 1
tslot = param%ioutput + 1

call check( nf90_inquire_dimension(iu%ncid, iu%id_dimid, len=idmax), "netcdf_read_frame_system nf90_inquire_dimension id_dimid" )
allocate(rtemp(idmax))
Expand Down Expand Up @@ -791,7 +791,7 @@ module subroutine netcdf_read_hdr_system(self, iu, param)
logical, dimension(:), allocatable :: plmask, tpmask, plmmask


tslot = int(param%ioutput, kind=I4B) + 1
tslot = param%ioutput + 1
call check( nf90_inquire_dimension(iu%ncid, iu%id_dimid, len=idmax), "netcdf_read_frame_system nf90_inquire_dimension id_dimid" )
call check( nf90_get_var(iu%ncid, iu%time_varid, self%t, start=[tslot]), "netcdf_read_hdr_system nf90_getvar time_varid" )

Expand Down Expand Up @@ -1185,7 +1185,7 @@ module subroutine netcdf_write_frame_base(self, iu, param)

call self%write_particle_info(iu, param)

tslot = int(param%ioutput, kind=I4B) + 1
tslot = param%ioutput + 1

call check( nf90_set_fill(iu%ncid, nf90_nofill, old_mode), "netcdf_write_frame_base nf90_set_fill" )
select type(self)
Expand Down Expand Up @@ -1426,7 +1426,7 @@ module subroutine netcdf_write_hdr_system(self, iu, param)
! Internals
integer(I4B) :: tslot

tslot = int(param%ioutput, kind=I4B) + 1
tslot = param%ioutput + 1

call check( nf90_put_var(iu%ncid, iu%time_varid, self%t, start=[tslot]), "netcdf_write_hdr_system nf90_put_var time_varid" )
call check( nf90_put_var(iu%ncid, iu%npl_varid, self%pl%nbody, start=[tslot]), "netcdf_write_hdr_system nf90_put_var npl_varid" )
Expand Down

0 comments on commit 1dbe336

Please sign in to comment.