From 378feef4c04cb60bc934d51d503c28caf4fb17d7 Mon Sep 17 00:00:00 2001 From: David Minton Date: Mon, 24 May 2021 15:17:23 -0400 Subject: [PATCH] Minor fixes to dump file management. Main thing is to not repeat the dump at the end, as it ends up making both sets of dump files identical. --- src/io/io_dump_pl.f90 | 9 ++++++--- src/main/swiftest_symba.f90 | 6 +----- src/modules/swiftest_globals.f90 | 5 +++-- src/user/user_dump_param.f90 | 9 +++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/io/io_dump_pl.f90 b/src/io/io_dump_pl.f90 index 35504aef2..9380e942d 100644 --- a/src/io/io_dump_pl.f90 +++ b/src/io/io_dump_pl.f90 @@ -48,7 +48,7 @@ SUBROUTINE io_dump_pl(npl, swiftest_plA, param) ! Internals INTEGER(I4B) :: ierr INTEGER(I4B), SAVE :: idx = 1 - integer(I4B),parameter :: LUN = 7 + integer(I4B),parameter :: LUN = 7 open(unit = LUN, file = DUMP_PL_FILE(idx), form = "UNFORMATTED", status = 'REPLACE', iostat = ierr) if (ierr /= 0) then @@ -68,8 +68,11 @@ SUBROUTINE io_dump_pl(npl, swiftest_plA, param) write(LUN) swiftest_plA%rot(:,1:npl) end if close(LUN) - idx = idx + 1 - if (idx > 2) idx = 1 + if (idx == 1) then + idx = 2 + else + idx = 1 + end if return diff --git a/src/main/swiftest_symba.f90 b/src/main/swiftest_symba.f90 index 580346b1c..ef39b7c90 100644 --- a/src/main/swiftest_symba.f90 +++ b/src/main/swiftest_symba.f90 @@ -164,7 +164,7 @@ program swiftest_symba do while ((t < tstop) .and. ((ntp0 == 0) .or. (ntp > 0))) call symba_step_eucl(t, dt, param,npl,ntp,symba_plA, symba_tpA, nplplenc, npltpenc,& plplenc_list, pltpenc_list, nmergeadd, nmergesub, mergeadd_list, mergesub_list) - + if (allocated(discard_l_pl)) deallocate(discard_l_pl) allocate(discard_l_pl(npl)) discard_l_pl(:) = .false. @@ -287,10 +287,6 @@ program swiftest_symba end do - call param%dump_to_file(t) - call io_dump_pl(npl, symba_plA%helio%swiftest, param) - call io_dump_tp(ntp, symba_tpA%helio%swiftest) - call symba_pl_deallocate(symba_plA) call symba_merger_deallocate(mergeadd_list) call symba_merger_deallocate(mergesub_list) diff --git a/src/modules/swiftest_globals.f90 b/src/modules/swiftest_globals.f90 index fa84e1fe4..789948fa1 100644 --- a/src/modules/swiftest_globals.f90 +++ b/src/modules/swiftest_globals.f90 @@ -109,8 +109,9 @@ module swiftest_globals !> Standard file names character(*), parameter :: DISCARD_FILE = "discard.out" - character(*), dimension(2), parameter :: DUMP_PL_FILE = (/ "dump_pl1.bin", "dump_pl2.bin" /) - character(*), dimension(2), parameter :: DUMP_TP_FILE = (/ "dump_tp1.bin", "dump_tp2.bin" /) + character(*), dimension(2), parameter :: DUMP_PL_FILE = ["dump_pl1.bin", "dump_pl2.bin"] + character(*), dimension(2), parameter :: DUMP_TP_FILE = ["dump_tp1.bin", "dump_tp2.bin"] + character(*), dimension(2), parameter :: DUMP_PARAM_FILE = ["dump_param1.dat", "dump_param2.dat" ] !! Dump file names character(*), parameter :: ENERGY_FILE = "energy.out" character(*), parameter :: pl_outfile = "pl_out.dat" character(*), parameter :: tp_outfile = "tp_out.dat" diff --git a/src/user/user_dump_param.f90 b/src/user/user_dump_param.f90 index 0814f3e14..76b10aa10 100644 --- a/src/user/user_dump_param.f90 +++ b/src/user/user_dump_param.f90 @@ -16,7 +16,6 @@ integer(I4B) :: ierr !! Error code integer(I4B), save :: idx = 1 !! Index of current dump file. Output flips between 2 files for extra security !! in case the program halts during writing - character(*), dimension(2), parameter :: DUMP_PARAM_FILE = (/ "dump_param1.dat", "dump_param2.dat" /) !! Dump file names character(STRMAX) :: error_message !! Error message in UDIO procedure param_dump = param @@ -29,15 +28,17 @@ write(*,*) ' Could not open dump file: ',trim(adjustl(DUMP_PARAM_FILE(idx))) call util_exit(FAILURE) end if - !! todo: Currently this procedure does not work in user-defined derived-type input mode !! due to compiler incompatabilities !write(LUN,'(DT)') param_dump call param_dump%udio_writer(LUN, iotype="none",v_list=(/0/),iostat=ierr,iomsg=error_message) - idx = idx + 1 - if (idx > 2) idx = 1 + if (idx == 2) then + idx = 1 + else + idx = 2 + end if close(LUN)