4 MODULE module_wrf_error
5 INTEGER :: wrf_debug_level = 0
6 CHARACTER*256 :: wrf_err_message
9 LOGICAL FUNCTION wrf_at_debug_level ( level )
11 INTEGER , INTENT(IN) :: level
12 wrf_at_debug_level = ( level .LE. wrf_debug_level )
14 END FUNCTION wrf_at_debug_level
16 SUBROUTINE init_module_wrf_error
17 END SUBROUTINE init_module_wrf_error
19 END MODULE module_wrf_error
21 SUBROUTINE wrf_message( str )
24 #if defined( DM_PARALLEL ) && ! defined( STUBMPI)
28 END SUBROUTINE wrf_message
30 ! intentionally write to stderr only
31 SUBROUTINE wrf_message2( str )
35 END SUBROUTINE wrf_message2
37 SUBROUTINE wrf_error_fatal3( file_str, line, str )
43 CHARACTER*(*) file_str
44 INTEGER , INTENT (IN) :: line ! only print file and line if line > 0
46 CHARACTER*256 :: line_str
48 write(line_str,'(i6)') line
49 #if defined( DM_PARALLEL ) && ! defined( STUBMPI )
50 CALL wrf_message( '-------------- FATAL CALLED ---------------' )
51 ! only print file and line if line is positive
53 CALL wrf_message( 'FATAL CALLED FROM FILE: '//file_str//' LINE: '//TRIM(line_str) )
55 CALL wrf_message( str )
56 CALL wrf_message( '-------------------------------------------' )
58 CALL wrf_message2( '-------------- FATAL CALLED ---------------' )
59 ! only print file and line if line is positive
61 CALL wrf_message( 'FATAL CALLED FROM FILE: '//file_str//' LINE: '//TRIM(line_str) )
63 CALL wrf_message2( str )
64 CALL wrf_message2( '-------------------------------------------' )
67 CALL esmf_finalize(terminationflag=ESMF_ABORT)
70 END SUBROUTINE wrf_error_fatal3
72 SUBROUTINE wrf_error_fatal( str )
76 CALL wrf_error_fatal3 ( ' ', 0, str )
77 END SUBROUTINE wrf_error_fatal
79 ! Check to see if expected value == actual value
80 ! If not, print message and exit.
81 SUBROUTINE wrf_check_error( expected, actual, str, file_str, line )
84 INTEGER , INTENT (IN) :: expected
85 INTEGER , INTENT (IN) :: actual
87 CHARACTER*(*) file_str
88 INTEGER , INTENT (IN) :: line
89 CHARACTER (LEN=512) :: rc_str
90 CHARACTER (LEN=512) :: str_with_rc
92 IF ( expected .ne. actual ) THEN
93 WRITE (rc_str,*) ' Routine returned error code = ',actual
94 str_with_rc = TRIM(str // rc_str)
95 CALL wrf_error_fatal3 ( file_str, line, str_with_rc )
97 END SUBROUTINE wrf_check_error