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

Commit

Permalink
Fixed problem where dicard file was being over-written each time a di…
Browse files Browse the repository at this point in the history
…scard was recorded
  • Loading branch information
daminton committed Aug 17, 2021
1 parent f7e90fa commit c8c805e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1235,13 +1235,18 @@ module subroutine io_write_discard(self, param)
character(*), parameter :: NPLFMT = '(I8)'
character(*), parameter :: PLNAMEFMT = '(I8, 2(1X, E23.16))'
class(swiftest_body), allocatable :: pltemp
character(len=STRMAX) :: errmsg
character(len=STRMAX) :: errmsg, out_stat

if (param%discard_out == "") return

associate(tp_discards => self%tp_discards, nsp => self%tp_discards%nbody, pl => self%pl, npl => self%pl%nbody)
if (nsp == 0) return
select case(param%out_stat)
if (lfirst) then
out_stat = param%out_stat
else
out_stat = 'APPEND'
end if
select case(out_stat)
case('APPEND')
open(unit = LUN, file = param%discard_out, status = 'OLD', position = 'APPEND', form = 'FORMATTED', err = 667, iomsg = errmsg)
case('NEW', 'REPLACE', 'UNKNOWN')
Expand Down
9 changes: 7 additions & 2 deletions src/symba/symba_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ module subroutine symba_io_write_discard(self, param)
character(*), parameter :: NPLFMT = '(I8)'
character(*), parameter :: PLNAMEFMT = '(I8, 2(1X, E23.16))'
class(swiftest_body), allocatable :: pltemp
character(STRMAX) :: errmsg
character(STRMAX) :: errmsg, out_stat

if (param%discard_out == "") return

Expand All @@ -338,7 +338,12 @@ module subroutine symba_io_write_discard(self, param)
select type(pl_discards => self%pl_discards)
class is (symba_merger)
if (pl_discards%nbody == 0) return
select case(param%out_stat)
if (lfirst) then
out_stat = param%out_stat
else
out_stat = 'APPEND'
end if
select case(out_stat)
case('APPEND')
open(unit = LUN, file = param%discard_out, status = 'OLD', position = 'APPEND', form = 'FORMATTED', err = 667, iomsg = errmsg)
case('NEW', 'REPLACE', 'UNKNOWN')
Expand Down

0 comments on commit c8c805e

Please sign in to comment.