source: lmdz_wrf/WRFV3/frame/module_wrf_error.F @ 1

Last change on this file since 1 was 1, checked in by lfita, 10 years ago
  • -- --- Opening of the WRF+LMDZ coupling repository --- -- -

WRF: version v3.3
LMDZ: version v1818

More details in:

File size: 2.8 KB
Line 
1!WRF:DRIVER_LAYER:UTIL
2!
3
4MODULE module_wrf_error
5  INTEGER           :: wrf_debug_level = 0
6  CHARACTER*256     :: wrf_err_message
7!$OMP THREADPRIVATE (wrf_err_message)
8CONTAINS
9
10  LOGICAL FUNCTION wrf_at_debug_level ( level )
11    IMPLICIT NONE
12    INTEGER , INTENT(IN) :: level
13    wrf_at_debug_level = ( level .LE. wrf_debug_level )
14    RETURN
15  END FUNCTION wrf_at_debug_level
16
17  SUBROUTINE init_module_wrf_error
18  END SUBROUTINE init_module_wrf_error
19
20END MODULE module_wrf_error
21
22SUBROUTINE wrf_message( str )
23  IMPLICIT NONE
24  CHARACTER*(*) str
25#if defined( DM_PARALLEL ) && ! defined( STUBMPI)
26  write(0,*) TRIM(str)
27# ifdef _WIN32
28  FLUSH(0)
29# endif
30#endif
31  print*, TRIM(str)
32END SUBROUTINE wrf_message
33
34! intentionally write to stderr only
35SUBROUTINE wrf_message2( str )
36  IMPLICIT NONE
37  CHARACTER*(*) str
38  write(0,*) str
39# ifdef _WIN32
40  FLUSH(0)
41# endif
42END SUBROUTINE wrf_message2
43
44SUBROUTINE wrf_error_fatal3( file_str, line, str )
45  USE module_wrf_error
46#ifdef ESMFIO
47  USE ESMF_Mod
48#endif
49  IMPLICIT NONE
50  CHARACTER*(*) file_str
51  INTEGER , INTENT (IN) :: line  ! only print file and line if line > 0
52  CHARACTER*(*) str
53  CHARACTER*256 :: line_str
54
55  write(line_str,'(i6)') line
56#if defined( DM_PARALLEL ) && ! defined( STUBMPI )
57  CALL wrf_message( '-------------- FATAL CALLED ---------------' )
58  ! only print file and line if line is positive
59  IF ( line > 0 ) THEN
60    CALL wrf_message( 'FATAL CALLED FROM FILE:  '//file_str//'  LINE:  '//TRIM(line_str) )
61  ENDIF
62  CALL wrf_message( str )
63  CALL wrf_message( '-------------------------------------------' )
64#else
65  CALL wrf_message2( '-------------- FATAL CALLED ---------------' )
66  ! only print file and line if line is positive
67  IF ( line > 0 ) THEN
68    CALL wrf_message( 'FATAL CALLED FROM FILE:  '//file_str//'  LINE:  '//TRIM(line_str) )
69  ENDIF
70  CALL wrf_message2( str )
71  CALL wrf_message2( '-------------------------------------------' )
72#endif
73#ifdef ESMFIO
74  CALL esmf_finalize(terminationflag=ESMF_ABORT)
75#endif
76  CALL wrf_abort
77END SUBROUTINE wrf_error_fatal3
78
79SUBROUTINE wrf_error_fatal( str )
80  USE module_wrf_error
81  IMPLICIT NONE
82  CHARACTER*(*) str
83  CALL wrf_error_fatal3 ( ' ', 0, str )
84END SUBROUTINE wrf_error_fatal
85
86! Check to see if expected value == actual value
87! If not, print message and exit. 
88SUBROUTINE wrf_check_error( expected, actual, str, file_str, line )
89  USE module_wrf_error
90  IMPLICIT NONE
91  INTEGER , INTENT (IN) :: expected
92  INTEGER , INTENT (IN) :: actual
93  CHARACTER*(*) str
94  CHARACTER*(*) file_str
95  INTEGER , INTENT (IN) :: line
96  CHARACTER (LEN=512)   :: rc_str
97  CHARACTER (LEN=512)   :: str_with_rc
98
99  IF ( expected .ne. actual ) THEN
100    WRITE (rc_str,*) '  Routine returned error code = ',actual
101    str_with_rc = TRIM(str // rc_str)
102    CALL wrf_error_fatal3 ( file_str, line, str_with_rc )
103  ENDIF
104END SUBROUTINE wrf_check_error
105
106
Note: See TracBrowser for help on using the repository browser.