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

Commit

Permalink
Fixed bad io error checking in writing encounter files
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Aug 12, 2021
1 parent 2cc6398 commit 2114f46
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1302,9 +1302,13 @@ module subroutine io_write_encounter(self, pl, encbody, param)

if (param%enc_out == "" .or. self%nenc == 0) return

open(unit = LUN, file = param%enc_out, status = 'OLD', position = 'APPEND', form = 'UNFORMATTED', err = 667, iomsg = errmsg)
if ((ierr /= 0) .and. lfirst) then
open(unit = LUN, file = param%enc_out, status = 'NEW', form = 'UNFORMATTED', err = 667, iomsg = errmsg)
open(unit = LUN, file = param%enc_out, status = 'OLD', position = 'APPEND', form = 'UNFORMATTED', iostat = ierr, iomsg = errmsg)
if (ierr /= 0) then
if (lfirst) then
open(unit = LUN, file = param%enc_out, status = 'NEW', form = 'UNFORMATTED', err = 667, iomsg = errmsg)
else
goto 667
end if
end if
lfirst = .false.

Expand Down Expand Up @@ -1335,7 +1339,7 @@ module subroutine io_write_encounter(self, pl, encbody, param)

return
667 continue
write(*,*) "Error writing discard file: " // trim(adjustl(errmsg))
write(*,*) "Error writing encounter file: " // trim(adjustl(errmsg))
call util_exit(FAILURE)
end subroutine io_write_encounter

Expand Down

0 comments on commit 2114f46

Please sign in to comment.