diff --git a/src/io/io.f90 b/src/io/io.f90 index 5e1d69767..a92b32780 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -250,7 +250,7 @@ module subroutine io_dump_system(self, param) dump_param%in_netcdf = trim(adjustl(DUMP_NC_FILE(idx))) dump_param%nciu%id_chunk = self%pl%nbody + self%tp%nbody dump_param%nciu%time_chunk = 1 - dump_param%T0 = param%t + dump_param%tstart = param%t call dump_param%dump(param_file_name) @@ -461,7 +461,6 @@ module subroutine io_param_reader(self, unit, iotype, v_list, iostat, iomsg) integer, intent(out) :: iostat !! IO status code character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0 ! Internals - logical :: t0_set = .false. !! Is the initial time set in the input file? logical :: tstart_set = .false. !! Is the final time set in the input file? logical :: tstop_set = .false. !! Is the final time set in the input file? logical :: dt_set = .false. !! Is the step size set in the input file? @@ -489,9 +488,8 @@ module subroutine io_param_reader(self, unit, iotype, v_list, iostat, iomsg) select case (param_name) case ("T0") read(param_value, *, err = 667, iomsg = iomsg) param%t0 - t0_set = .true. case ("TSTART") - read(param_value, *, err = 667, iomsg = iomsg) param%t0 + read(param_value, *, err = 667, iomsg = iomsg) param%tstart tstart_set = .true. case ("TSTOP") read(param_value, *, err = 667, iomsg = iomsg) param%tstop @@ -652,7 +650,7 @@ module subroutine io_param_reader(self, unit, iotype, v_list, iostat, iomsg) iostat = 0 ! Do basic sanity checks on the input values - if ((.not. t0_set) .or. (.not. tstop_set) .or. (.not. dt_set)) then + if ((.not. tstart_set) .or. (.not. tstop_set) .or. (.not. dt_set)) then write(iomsg,*) 'Valid simulation time not set' iostat = -1 return @@ -863,6 +861,7 @@ module subroutine io_param_writer(self, unit, iotype, v_list, iostat, iomsg) associate(param => self) call io_param_writer_one("T0", param%t0, unit) + call io_param_writer_one("TSTART", param%tstart, unit) call io_param_writer_one("TSTOP", param%tstop, unit) call io_param_writer_one("DT", param%dt, unit) call io_param_writer_one("IN_TYPE", param%in_type, unit) diff --git a/src/main/swiftest_driver.f90 b/src/main/swiftest_driver.f90 index f0b9b5013..6bee4374b 100644 --- a/src/main/swiftest_driver.f90 +++ b/src/main/swiftest_driver.f90 @@ -23,10 +23,9 @@ program swiftest_driver 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(I4B) :: ierr !! I/O error code integer(I8B) :: idump !! Dump cadence counter integer(I8B) :: iout !! Output cadence counter - integer(I8B) :: ioutput_t0 !! The output frame counter at time 0 + integer(I8B) :: istart !! Starting index for loop counter integer(I8B) :: nloops !! Number of steps to take in the simulation real(DP) :: old_t_final = 0.0_DP !! Output time at which writing should start, in order to prevent duplicate lines being written for restarts type(walltimer) :: integration_timer !! Object used for computing elapsed wall time @@ -68,6 +67,7 @@ program swiftest_driver associate(t => param%t, & t0 => param%t0, & + tstart => param%tstart, & dt => param%dt, & tstop => param%tstop, & iloop => param%iloop, & @@ -78,13 +78,12 @@ program swiftest_driver display_unit => param%display_unit) call nbody_system%initialize(param) - t = t0 - iloop = 0 + t = tstart iout = istep_out idump = dump_cadence nloops = ceiling((tstop - t0) / dt, kind=I8B) - ioutput_t0 = int(t0 / dt / istep_out, kind=I8B) - ioutput = ioutput_t0 + istart = ceiling((tstart - t0) / dt, kind=I8B) + ioutput = int(istart / istep_out, kind=I8B) ! Prevent duplicate frames from being written if this is a restarted run if (param%lrestart) then old_t_final = nbody_system%get_old_t_final(param) @@ -104,7 +103,7 @@ program swiftest_driver write(*,*) "SWIFTEST START " // trim(adjustl(param%integrator)) call nbody_system%compact_output(param,integration_timer) end if - do iloop = 1, nloops + do iloop = istart, nloops !> Step the system forward in time call integration_timer%start() call nbody_system%step(param, t, dt) @@ -120,7 +119,7 @@ program swiftest_driver if (istep_out > 0) then iout = iout - 1 if (iout == 0) then - ioutput = ioutput_t0 + iloop / istep_out + ioutput = int(iloop / istep_out, kind=I8B) call nbody_system%write_frame(param) diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 33aa49d23..7952b28ac 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -36,8 +36,9 @@ module swiftest_classes character(STRMAX) :: param_file_name = "param.in" !! The default name of the parameter input file integer(I4B) :: maxid = -1 !! The current maximum particle id number integer(I4B) :: maxid_collision = 0 !! The current maximum collision id number - real(DP) :: t0 = -1.0_DP !! Integration start time + real(DP) :: t0 = 0.0_DP !! Integration reference time real(DP) :: t = -1.0_DP !! Integration current time + real(DP) :: tstart = -1.0_DP !! Integration start time 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