From 5827b34998015e7a8dae28cf55a8e43792e96de8 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 1 Dec 2022 12:04:55 -0500 Subject: [PATCH] Fixed output cadence variable bug --- src/io/io.f90 | 20 ++++++++++++++++++++ src/main/swiftest_driver.f90 | 5 +---- src/modules/swiftest_classes.f90 | 8 ++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/io/io.f90 b/src/io/io.f90 index a92b32780..43489e4b0 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -269,6 +269,26 @@ module subroutine io_dump_system(self, param) return end subroutine io_dump_system + module subroutine io_dump_system_storage(self, param) + !! author: David A. Minton + !! + !! Dumps the time history of the simulation to file + implicit none + ! Arguments + 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 + + iloop_start = param%iloop - param%istep_out * param%dump_cadence + 1_I8B + do i = 1_I8B, param%dump_cadence + param%ioutput = int(iloop_start / param%istep_out, kind=I8B) + i + call self%frame(i)%system%write_frame(param) + end do + + return + end subroutine io_dump_system_storage + module subroutine io_get_args(integrator, param_file_name, display_style) !! author: David A. Minton diff --git a/src/main/swiftest_driver.f90 b/src/main/swiftest_driver.f90 index 42dfcd059..14b06485b 100644 --- a/src/main/swiftest_driver.f90 +++ b/src/main/swiftest_driver.f90 @@ -133,10 +133,7 @@ program swiftest_driver if (idump == 0) then call nbody_system%dump(param) - do iframe = 1_I8B, dump_cadence - ioutput = int((iloop - dump_cadence - 1_I8B + iframe) / istep_out, kind=I8B) - call system_history%frame(iframe)%system%write_frame(param) - end do + call system_history%dump(param) idump = dump_cadence end if diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 5883adc44..14f0e3369 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -429,6 +429,7 @@ module swiftest_classes !! A class that that is used to store simulation history data between file output type(storage_frame), dimension(nframes) :: frame contains + procedure :: dump => io_dump_system_storage end type swiftest_storage abstract interface @@ -624,6 +625,13 @@ module subroutine io_dump_system(self, param) class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine io_dump_system + + module subroutine io_dump_system_storage(self, param) + implicit none + class(swiftest_storage(*)), intent(inout) :: self !! Swiftest simulation history storage object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + end subroutine io_dump_system_storage + module subroutine io_get_args(integrator, param_file_name, display_style) implicit none character(len=:), allocatable, intent(inout) :: integrator !! Symbolic code of the requested integrator