From 2114f46d6d1a4ac8153a518c3064404c6747840f Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 12 Aug 2021 12:26:30 -0400 Subject: [PATCH] Fixed bad io error checking in writing encounter files --- src/io/io.f90 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/io/io.f90 b/src/io/io.f90 index c5519975f..933bcbdfb 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -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. @@ -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