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

Commit

Permalink
Fixed some bad loop indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 5, 2022
1 parent f4fba0e commit e8f01d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ module subroutine io_dump_system(self, param)

dump_param%out_form = "XV"
dump_param%outfile = trim(adjustl(DUMP_NC_FILE(idx)))
dump_param%ioutput = 0
dump_param%ioutput = 1
call dump_param%nciu%initialize(dump_param)
call self%write_frame(dump_param%nciu, dump_param)
call dump_param%nciu%close()
Expand Down Expand Up @@ -285,7 +285,7 @@ module subroutine io_dump_storage(self, param)
integer(I4B) :: i
integer(I8B) :: iloop_start

iloop_start = param%iloop - int(param%istep_out * param%dump_cadence + 1, kind=I8B)
iloop_start = max(param%iloop - int(param%istep_out * param%dump_cadence, kind=I8B),1)
do i = 1, param%dump_cadence
param%ioutput = int(iloop_start / param%istep_out, kind=I4B) + i
if (allocated(self%frame(i)%item)) then
Expand Down
2 changes: 1 addition & 1 deletion src/main/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ program swiftest_driver
! Set up loop and output cadence variables
t = tstart
nloops = ceiling((tstop - t0) / dt, kind=I8B)
istart = ceiling((tstart - t0) / dt + 1, kind=I8B)
istart = ceiling((tstart - t0) / dt + 1.0_DP, kind=I8B)
ioutput = int(istart / istep_out, kind=I4B)

! Set up system storage for intermittent file dumps
Expand Down
2 changes: 1 addition & 1 deletion src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,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(I4B) :: ioutput = 0 !! Output counter
integer(I4B) :: ioutput = 1 !! 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
8 changes: 4 additions & 4 deletions src/netcdf/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr)
call pl%setup(npl, param)
call tp%setup(ntp, param)

tslot = param%ioutput + 1
tslot = param%ioutput

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


tslot = param%ioutput + 1
tslot = param%ioutput
call check( nf90_inquire_dimension(nciu%id, nciu%id_dimid, len=idmax), "netcdf_read_hdr_system nf90_inquire_dimension id_dimid" )
call check( nf90_get_var(nciu%id, nciu%time_varid, self%t, start=[tslot]), "netcdf_read_hdr_system nf90_getvar time_varid" )

Expand Down Expand Up @@ -1031,7 +1031,7 @@ module subroutine netcdf_write_frame_base(self, nciu, param)

call self%write_info(nciu, param)

tslot = param%ioutput + 1
tslot = param%ioutput

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

tslot = param%ioutput + 1
tslot = param%ioutput

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

0 comments on commit e8f01d5

Please sign in to comment.