Opened 8 years ago
Closed 8 years ago
#737 closed upgrade (Done)
Important: Improved ROMS Error Handling
Reported by: | arango | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | Release ROMS/TOMS 3.7 |
Component: | Nonlinear | Version: | 3.7 |
Keywords: | Cc: |
Description
This update changed several files to improve the error handling in ROMS.
- The check error statements:
IF (exit_flag.ne.NoError) RETURN IF (status.ne.nf90_noerr) THEN ... END IF
were changed to:IF (FoundError(exit_flag, NoError, __LINE__, & & __FILE__)) RETURN IF (FoundError(status, nf90_noerr, __LINE__, & & __FILE__)) THEN ... END IF
The logical function FoundError was added to the string_mod module (ROMS/Utility/string.F):USE strings_mod, ONLY : FoundError
- The function FindError prints the line and source code where the error occurred, if any:
FUNCTION FoundError (flag, NoErr, line, routine) RESULT (foundit) ! !======================================================================= ! ! ! This logical function checks ROMS execution flag against no-error ! ! code and issue a message if they are not equal. ! ! ! ! On Input: ! ! ! ! flag ROMS execution flag (integer) ! ! NoErr No Error code (integer) ! ! line Calling model routine line (integer) ! ! routine Calling model routine (string) ! ! ! ! On Output: ! ! ! ! foundit The value of the result is TRUE/FALSE if the ! ! execution flag is in error. ! ! ! !======================================================================= ! USE mod_iounits, ONLY : stdout USE mod_parallel, ONLY : Master ! Imported variable declarations. ! integer, intent(in) :: flag, NoErr, line character (len=*), intent(in) :: routine ! ! Local variable declarations. ! logical :: foundit character (len=5) :: lstr ! !----------------------------------------------------------------------- ! Scan array for requested string. !----------------------------------------------------------------------- ! foundit=.FALSE. IF (flag.ne.NoErr) THEN foundit=.TRUE. IF (Master) THEN WRITE (lstr,'(i5)') line WRITE (stdout,10) flag, ADJUSTL(TRIM(lstr)), TRIM(routine) 10 FORMAT (' Found Error: ', i2.2, t20, 'Line: ', a, & & t35, 'Source: ', a) END IF END IF RETURN END FUNCTION FoundError
- I used a Perl script to make this substitution in the entire code. We get more information for error, for example:
NETCDF_PUT_FVAR_1D - error while writing variable: tide_period in input file: r10/doppio_har.nc call from: ROMS/Utility/wrt_tides.F Found Error: 03 Line: 93 Source: ROMS/Utility/wrt_tides.F ERROR: Abnormal termination: NetCDF OUTPUT. REASON: NetCDF: Variable not found
Notice that the line number is in the original *.F code instead of the compiled file *.f90 because we are using the __LINE__ and __FILE__ C-preprocessing macros that operate in the original source code.
Note:
See TracTickets
for help on using tickets.