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

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daminton committed May 24, 2021
1 parent 4ba2e65 commit 378feef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/io/io_dump_pl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 1 addition & 5 deletions src/main/swiftest_symba.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/modules/swiftest_globals.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 5 additions & 4 deletions src/user/user_dump_param.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 378feef

Please sign in to comment.