MOM6
mom_error_handler Module Reference

Detailed Description

Routines for error handling and I/O management.

Functions/Subroutines

logical function, public is_root_pe ()
 This returns .true. if the current PE is the root PE.
 
subroutine, public mom_mesg (message, verb, all_print)
 This provides a convenient interface for writing an informative comment. More...
 
subroutine, public mom_error (level, message, all_print)
 This provides a convenient interface for writing an mpp_error message with run-time filter based on a verbosity. More...
 
subroutine, public mom_set_verbosity (verb)
 This subroutine sets the level of verbosity filtering MOM error messages. More...
 
integer function, public mom_get_verbosity ()
 This subroutine gets the level of verbosity filtering MOM error messages.
 
logical function, public mom_verbose_enough (verb)
 This tests whether the level of verbosity filtering MOM error messages is sufficient to write a message of verbosity level verb. More...
 
logical function, public calltree_showquery ()
 Returns True, if the verbosity>=6 indicating to show the call tree.
 
subroutine, public calltree_enter (mesg, n)
 Writes a message about entering a subroutine if call tree reporting is active. More...
 
subroutine, public calltree_leave (mesg)
 Writes a message about leaving a subroutine if call tree reporting is active. More...
 
subroutine, public calltree_waypoint (mesg, n)
 Writes a message about reaching a milestone if call tree reporting is active. More...
 
subroutine, public assert (logical_arg, msg)
 Issues a FATAL error if the assertion fails, i.e. the first argument is false. More...
 

Variables

integer verbosity = 6
 Verbosity level: 0 - FATAL messages only 1 - FATAL + WARNING messages only 2 - FATAL + WARNING + NOTE messages only [default] 3 - above + informational 4 - 5 - 6 - above + call tree 7 - 8 - 9 - anything and everything (also set with DEBUG=True)
 
integer calltreeindentlevel = 0
 The level of calling within the call tree.
 

Function/Subroutine Documentation

◆ assert()

subroutine, public mom_error_handler::assert ( logical, intent(in)  logical_arg,
character(len=*), intent(in)  msg 
)

Issues a FATAL error if the assertion fails, i.e. the first argument is false.

Parameters
[in]logical_argIf false causes a FATAL error
[in]msgMessage to issue in case of failed assertion

Definition at line 182 of file MOM_error_handler.F90.

182  logical, intent(in) :: logical_arg !< If false causes a FATAL error
183  character(len=*), intent(in) :: msg !< Message to issue in case of failed assertion
184 
185  if (.not. logical_arg) then
186  call mom_error(fatal, msg)
187  endif
188 

◆ calltree_enter()

subroutine, public mom_error_handler::calltree_enter ( character(len=*), intent(in)  mesg,
integer, intent(in), optional  n 
)

Writes a message about entering a subroutine if call tree reporting is active.

Parameters
[in]mesgMessage to write
[in]nAn optional integer to write at end of message

Definition at line 130 of file MOM_error_handler.F90.

130  character(len=*), intent(in) :: mesg !< Message to write
131  integer, optional, intent(in) :: n !< An optional integer to write at end of message
132  ! Local variables
133  character(len=8) :: nAsString
134  calltreeindentlevel = calltreeindentlevel + 1
135  if (verbosity<6) return
136  if (is_root_pe()) then
137  nasstring = ''
138  if (present(n)) then
139  write(nasstring(1:8),'(i8)') n
140  call mpp_error(note, 'callTree: '// &
141  repeat(' ',calltreeindentlevel-1)//'loop '//trim(mesg)//trim(nasstring))
142  else
143  call mpp_error(note, 'callTree: '// &
144  repeat(' ',calltreeindentlevel-1)//'---> '//trim(mesg))
145  endif
146  endif

◆ calltree_leave()

subroutine, public mom_error_handler::calltree_leave ( character(len=*)  mesg)

Writes a message about leaving a subroutine if call tree reporting is active.

Parameters
mesgMessage to write

Definition at line 151 of file MOM_error_handler.F90.

151  character(len=*) :: mesg !< Message to write
152  if (calltreeindentlevel<1) write(0,*) 'callTree_leave: error callTreeIndentLevel=',calltreeindentlevel,trim(mesg)
153  calltreeindentlevel = calltreeindentlevel - 1
154  if (verbosity<6) return
155  if (is_root_pe()) call mpp_error(note, 'callTree: '// &
156  repeat(' ',calltreeindentlevel)//'<--- '//trim(mesg))

◆ calltree_waypoint()

subroutine, public mom_error_handler::calltree_waypoint ( character(len=*), intent(in)  mesg,
integer, intent(in), optional  n 
)

Writes a message about reaching a milestone if call tree reporting is active.

Parameters
[in]mesgMessage to write
[in]nAn optional integer to write at end of message

Definition at line 161 of file MOM_error_handler.F90.

161  character(len=*), intent(in) :: mesg !< Message to write
162  integer, optional, intent(in) :: n !< An optional integer to write at end of message
163  ! Local variables
164  character(len=8) :: nAsString
165  if (calltreeindentlevel<0) write(0,*) 'callTree_waypoint: error callTreeIndentLevel=',calltreeindentlevel,trim(mesg)
166  if (verbosity<6) return
167  if (is_root_pe()) then
168  nasstring = ''
169  if (present(n)) then
170  write(nasstring(1:8),'(i8)') n
171  call mpp_error(note, 'callTree: '// &
172  repeat(' ',calltreeindentlevel)//'loop '//trim(mesg)//trim(nasstring))
173  else
174  call mpp_error(note, 'callTree: '// &
175  repeat(' ',calltreeindentlevel)//'o '//trim(mesg))
176  endif
177  endif

◆ mom_error()

subroutine, public mom_error_handler::mom_error ( integer, intent(in)  level,
character(len=*), intent(in)  message,
logical, intent(in), optional  all_print 
)

This provides a convenient interface for writing an mpp_error message with run-time filter based on a verbosity.

Parameters
[in]levelThe verbosity level of this message
[in]messageA message to write out
[in]all_printIf present and true, any PEs are able to write this message.

Definition at line 72 of file MOM_error_handler.F90.

72  integer, intent(in) :: level !< The verbosity level of this message
73  character(len=*), intent(in) :: message !< A message to write out
74  logical, optional, intent(in) :: all_print !< If present and true, any PEs are
75  !! able to write this message.
76  ! This provides a convenient interface for writing an mpp_error message
77  ! with run-time filter based on a verbosity.
78  logical :: write_msg
79 
80  write_msg = is_root_pe()
81  if (present(all_print)) write_msg = write_msg .or. all_print
82 
83  select case (level)
84  case (note)
85  if (write_msg.and.verbosity>=2) call mpp_error(note, message)
86  case (warning)
87  if (write_msg.and.verbosity>=1) call mpp_error(warning, message)
88  case (fatal)
89  if (verbosity>=0) call mpp_error(fatal, message)
90  case default
91  call mpp_error(level, message)
92  end select

◆ mom_mesg()

subroutine, public mom_error_handler::mom_mesg ( character(len=*), intent(in)  message,
integer, intent(in), optional  verb,
logical, intent(in), optional  all_print 
)

This provides a convenient interface for writing an informative comment.

Parameters
[in]messageA message to write out
[in]verbA level of verbosity for this message
[in]all_printIf present and true, any PEs are able to write this message.

Definition at line 53 of file MOM_error_handler.F90.

53  character(len=*), intent(in) :: message !< A message to write out
54  integer, optional, intent(in) :: verb !< A level of verbosity for this message
55  logical, optional, intent(in) :: all_print !< If present and true, any PEs are
56  !! able to write this message.
57  ! This provides a convenient interface for writing an informative comment.
58  integer :: verb_msg
59  logical :: write_msg
60 
61  write_msg = is_root_pe()
62  if (present(all_print)) write_msg = write_msg .or. all_print
63 
64  verb_msg = 2 ; if (present(verb)) verb_msg = verb
65  if (write_msg .and. (verbosity >= verb_msg)) call mpp_error(note, message)
66 

◆ mom_set_verbosity()

subroutine, public mom_error_handler::mom_set_verbosity ( integer, intent(in)  verb)

This subroutine sets the level of verbosity filtering MOM error messages.

Parameters
[in]verbA level of verbosity to set

Definition at line 97 of file MOM_error_handler.F90.

97  integer, intent(in) :: verb !< A level of verbosity to set
98  character(len=80) :: msg
99  if (verb>0 .and. verb<10) then
100  verbosity=verb
101  else
102  write(msg(1:80),'("Attempt to set verbosity outside of range (0-9). verb=",I0)') verb
103  call mom_error(fatal,msg)
104  endif

◆ mom_verbose_enough()

logical function, public mom_error_handler::mom_verbose_enough ( integer, intent(in)  verb)

This tests whether the level of verbosity filtering MOM error messages is sufficient to write a message of verbosity level verb.

Parameters
[in]verbA level of verbosity to test

Definition at line 116 of file MOM_error_handler.F90.

116  integer, intent(in) :: verb !< A level of verbosity to test
117  logical :: MOM_verbose_enough
118  mom_verbose_enough = (verbosity >= verb)