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

Commit

Permalink
Replaced istep_dump parameter variable with dump_cadence. This specif…
Browse files Browse the repository at this point in the history
…ies the number of output steps between file dumps
  • Loading branch information
daminton committed Dec 1, 2022
1 parent fe4f44c commit 13acd7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ module subroutine io_param_reader(self, unit, iotype, v_list, iostat, iomsg)
call io_toupper(param_value)
param%out_stat = param_value
case ("DUMP_CADENCE")
read(param_value, *, err = 667, iomsg = iomsg) param%istep_dump
read(param_value, *, err = 667, iomsg = iomsg) param%dump_cadence
case ("CHK_CLOSE")
call io_toupper(param_value)
if (param_value == "YES" .or. param_value == 'T') param%lclose = .true.
Expand Down Expand Up @@ -672,8 +672,13 @@ module subroutine io_param_reader(self, unit, iotype, v_list, iostat, iomsg)
iostat = -1
return
end if
if ((param%istep_out <= 0) .and. (param%istep_dump <= 0)) then
write(iomsg,*) 'Invalid istep'
if (param%istep_out <= 0) then
write(iomsg,*) 'Invalid ISTEP_OUT. Must be a positive integer'
iostat = -1
return
end if
if (param%dump_cadence < 0) then
write(iomsg,*) 'Invalid DUMP_CADENCE. Must be a positive integer or 0.'
iostat = -1
return
end if
Expand Down Expand Up @@ -870,7 +875,7 @@ module subroutine io_param_writer(self, unit, iotype, v_list, iostat, iomsg)
end if

call io_param_writer_one("IN_FORM", param%in_form, unit)
if (param%istep_dump > 0) call io_param_writer_one("ISTEP_DUMP",param%istep_dump, unit)
if (param%dump_cadence > 0) call io_param_writer_one("DUMP_CADENCE",param%dump_cadence, unit)
if (param%istep_out > 0) then
call io_param_writer_one("ISTEP_OUT", param%istep_out, unit)
call io_param_writer_one("BIN_OUT", param%outfile, unit)
Expand Down Expand Up @@ -1503,7 +1508,7 @@ module subroutine io_write_frame_system(self, param)
logical :: fileExists

param%nciu%id_chunk = self%pl%nbody + self%tp%nbody
param%nciu%time_chunk = max(param%istep_dump / param%istep_out, 1)
param%nciu%time_chunk = max(param%dump_cadence / param%istep_out, 1)
if (lfirst) then
inquire(file=param%outfile, exist=fileExists)

Expand Down
9 changes: 5 additions & 4 deletions src/main/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ program swiftest_driver
tstop => param%tstop, &
iloop => param%iloop, &
istep_out => param%istep_out, &
istep_dump => param%istep_dump, &
dump_cadence => param%dump_cadence, &
ioutput => param%ioutput, &
display_style => param%display_style, &
display_unit => param%display_unit)
Expand All @@ -81,7 +81,7 @@ program swiftest_driver
t = t0
iloop = 0
iout = istep_out
idump = istep_dump
idump = dump_cadence
nloops = ceiling((tstop - t0) / dt, kind=I8B)
ioutput_t0 = int(t0 / dt / istep_out, kind=I8B)
ioutput = ioutput_t0
Expand Down Expand Up @@ -123,6 +123,7 @@ program swiftest_driver
ioutput = ioutput_t0 + iloop / istep_out
call nbody_system%write_frame(param)


tfrac = (param%t - param%t0) / (param%tstop - param%t0)

select type(pl => nbody_system%pl)
Expand All @@ -148,11 +149,11 @@ program swiftest_driver
end if

!> If the loop counter is at the dump cadence value, dump the state of the system to a file in case it needs to be restarted
if (istep_dump > 0) then
if (dump_cadence > 0) then
idump = idump - 1
if (idump == 0) then
call nbody_system%dump(param)
idump = istep_dump
idump = dump_cadence
end if
end if
end do
Expand Down

0 comments on commit 13acd7e

Please sign in to comment.