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

Commit

Permalink
Improved handling of mass conservation error halting. Failed output i…
Browse files Browse the repository at this point in the history
…nfo is now saved in a time slot after the present one in order to prevent overwriting of the bin.nc with bad data
  • Loading branch information
daminton committed Nov 15, 2021
1 parent 1a8d18f commit 966dc06
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,20 @@ module subroutine io_conservation_report(self, param, lterminal)
if (lterminal) write(*, EGYTERMFMT) Lerror, Ecoll_error, Etotal_error, Merror
if (abs(Merror) > 100 * epsilon(Merror)) then
write(*,*) "Severe error! Mass not conserved! Halting!"
call pl%xv2el(cb)
call self%write_hdr(param%nciu, param)
call cb%write_frame(param%nciu, param)
call pl%write_frame(param%nciu, param)
call param%nciu%close()
if ((param%out_type == REAL4_TYPE) .or. (param%out_type == REAL8_TYPE)) then
write(*,*) "Merror = ", Merror
write(*,*) "GMtot_now : ",GMtot_now
write(*,*) "GMtot_orig: ",system%GMtot_orig
write(*,*) "Difference: ",GMtot_now - system%GMtot_orig
else if ((param%out_type == NETCDF_FLOAT_TYPE) .or. (param%out_type == NETCDF_DOUBLE_TYPE)) then
! Save the frame of data to the bin file in the slot just after the present one for diagnostics
param%ioutput = param%ioutput + 1_I8B
call pl%xv2el(cb)
call self%write_hdr(param%nciu, param)
call cb%write_frame(param%nciu, param)
call pl%write_frame(param%nciu, param)
call param%nciu%close()
end if
call util_exit(FAILURE)
end if
end if
Expand Down

0 comments on commit 966dc06

Please sign in to comment.