WAVEWATCH III  beta 0.0.1
scrip_errormod Module Reference

Functions/Subroutines

subroutine, public scrip_errorset (errorCode, rtnName, errorMsg)
 
logical(scrip_logical) function, public scrip_errorcheck (errorCode, rtnName, errorMsg)
 
subroutine, public scrip_errorprint (printTask)
 

Variables

integer(scrip_i4), parameter, public scrip_success = 0
 
integer(scrip_i4), parameter, public scrip_fail = -1
 

Function/Subroutine Documentation

◆ scrip_errorcheck()

logical (scrip_logical) function, public scrip_errormod::scrip_errorcheck ( integer (scrip_i4), intent(in)  errorCode,
character (*), intent(in)  rtnName,
character (*), intent(in)  errorMsg 
)

Definition at line 143 of file scrip_errormod.f90.

143 
144  ! !DESCRIPTION:
145  ! This function checks an error code and adds a message to the error
146  ! log for later printing. It is a more compact form of the ErrorSet
147  ! routine that is especially useful for checking an error code after
148  ! returning from a routine or function. If the errorCode is the
149  ! failure code SCRIP\_Fail, it returns a logical true value so that
150  ! it can be used in a typical call like:
151  ! \begin{verbatim}
152  ! if (SCRIP_ErrorCheck(errorCode, rtnName, errorMsg)) return
153  ! \end{verbatim}
154  !
155  ! !REVISION HISTORY:
156  ! same as module
157 
158  ! !OUTPUT PARAMETERS:
159 
160  logical (SCRIP_logical) :: &
161  SCRIP_ErrorCheck
162 
163  ! !INPUT PARAMETERS:
164 
165  integer (SCRIP_i4), intent(in) :: &
166  errorCode ! Error code to check
167 
168  character (*), intent(in) :: &
169  rtnName, &! name of calling routine
170  errorMsg ! message to add to error log for printing
171 
172  !EOP
173  !BOC
174  !-----------------------------------------------------------------------
175  !
176  ! local variables
177  !
178  !-----------------------------------------------------------------------
179 
180  character (SCRIP_charLength) :: &
181  logErrorMsg ! constructed error message with routine name
182 
183  !-----------------------------------------------------------------------
184  !
185  ! If the error code is success, set the return value to false.
186  !
187  !-----------------------------------------------------------------------
188 
189  if (errorcode == scrip_success) then
190  scrip_errorcheck = .false.
191 
192  !-----------------------------------------------------------------------
193  !
194  ! If the error code is a fail, set the return value to true and
195  ! add the error message to the log.
196  !
197  !-----------------------------------------------------------------------
198 
199  else
200  scrip_errorcheck = .true.
201 
202  scrip_errormsgcount = scrip_errormsgcount + 1
203 
204  if (scrip_errormsgcount <= scrip_errorlogdepth) then
205  write(logerrormsg,'(a,a2,a)') rtnname,': ',errormsg
206  scrip_errorlog(scrip_errormsgcount) = logerrormsg
207  endif
208  endif
209 
210  !-----------------------------------------------------------------------
211  !EOC
212 

References scrip_success.

Referenced by scrip_grids::grid_init(), scrip_remap_write::write_remap(), and scrip_remap_write::write_remap_ww3().

◆ scrip_errorprint()

subroutine, public scrip_errormod::scrip_errorprint ( integer (scrip_i4), intent(in), optional  printTask)

Definition at line 221 of file scrip_errormod.f90.

221 
222  ! !DESCRIPTION:
223  ! This routine prints all messages in the error log. If a printTask
224  ! is specified, only the message log on that task will be printed.
225  !
226  ! !REVISION HISTORY:
227  ! same as module
228 
229  ! !INPUT PARAMETERS:
230 
231  ! integer (SCRIP_i4), intent(in) :: &
232  ! errorCode ! input error code to check success/fail
233 
234  !*** currently this has no meaning, but will be used in parallel
235  !*** SCRIP version
236  integer (SCRIP_i4), intent(in), optional :: &
237  printTask ! Task from which to print error log
238 
239  !EOP
240  !BOC
241  !-----------------------------------------------------------------------
242  !
243  ! local variables
244  !
245  !-----------------------------------------------------------------------
246 
247  integer (SCRIP_i4) :: n
248 
249  !-----------------------------------------------------------------------
250  !
251  ! Print all error messages to stdout
252  !
253  !-----------------------------------------------------------------------
254 
255  if (present(printtask)) then
256 
257  !*** parallel SCRIP not yet supported
258  !if (SCRIP_myTask == printTask) then
259 
260  write(scrip_stdout,scrip_blankformat)
261  write(scrip_stdout,scrip_delimformat)
262  write(scrip_stdout,scrip_blankformat)
263 
264  if (scrip_errormsgcount == 0) then ! no errors
265 
266  write(scrip_stdout,'(a34)') &
267  'Successful completion of SCRIP model'
268 
269  else
270 
271  write(scrip_stdout,'(a14)') 'SCRIP Exiting...'
272 
273  do n=1,min(scrip_errormsgcount,scrip_errorlogdepth)
274  write(scrip_stderr,'(a)') trim(scrip_errorlog(n))
275  if (scrip_stdout /= scrip_stderr) then
276  write(scrip_stdout,'(a)') trim(scrip_errorlog(n))
277  endif
278  end do
279 
280  if (scrip_errormsgcount > scrip_errorlogdepth) then
281  write(scrip_stderr,'(a23)') 'Too many error messages'
282  if (scrip_stdout /= scrip_stderr) then
283  write(scrip_stdout,'(a23)') 'Too many error messages'
284  endif
285  endif
286 
287  endif
288 
289  write(scrip_stdout,scrip_blankformat)
290  write(scrip_stdout,scrip_delimformat)
291  write(scrip_stdout,scrip_blankformat)
292 
293  !endif
294 
295  else
296 
297  write(scrip_stdout,scrip_blankformat)
298  write(scrip_stdout,scrip_delimformat)
299  write(scrip_stdout,scrip_blankformat)
300 
301  if (scrip_errormsgcount == 0) then ! no errors
302 
303  write(scrip_stdout,'(a34)') 'Successful completion of SCRIP'
304 
305  else
306 
307  write(scrip_stdout,'(a14)') 'SCRIP Exiting...'
308 
309  do n=1,min(scrip_errormsgcount,scrip_errorlogdepth)
310  write(scrip_stderr,'(a)') trim(scrip_errorlog(n))
311  if (scrip_stdout /= scrip_stderr) then
312  write(scrip_stdout,'(a)') trim(scrip_errorlog(n))
313  endif
314  end do
315 
316  if (scrip_errormsgcount > scrip_errorlogdepth) then
317  write(scrip_stderr,'(a23)') 'Too many error messages'
318  if (scrip_stdout /= scrip_stderr) then
319  write(scrip_stdout,'(a23)') 'Too many error messages'
320  endif
321  endif
322 
323  endif
324 
325  write(scrip_stdout,scrip_blankformat)
326  write(scrip_stdout,scrip_delimformat)
327  write(scrip_stdout,scrip_blankformat)
328 
329  endif
330 
331  !-----------------------------------------------------------------------
332  !EOC
333 

References scrip_iounitsmod::scrip_blankformat, scrip_iounitsmod::scrip_delimformat, scrip_iounitsmod::scrip_stderr, and scrip_iounitsmod::scrip_stdout.

◆ scrip_errorset()

subroutine, public scrip_errormod::scrip_errorset ( integer (scrip_i4), intent(out)  errorCode,
character (*), intent(in)  rtnName,
character (*), intent(in)  errorMsg 
)

Definition at line 81 of file scrip_errormod.f90.

81 
82  ! !DESCRIPTION:
83  ! This routine sets an error code to SCRIP\_Fail and adds a message to
84  ! the error log for later printing.
85  !
86  ! !REVISION HISTORY:
87  ! same as module
88 
89  ! !OUTPUT PARAMETERS:
90 
91  integer (SCRIP_i4), intent(out) :: &
92  errorCode ! Error code to set to fail
93 
94  ! !INPUT PARAMETERS:
95 
96  character (*), intent(in) :: &
97  rtnName, &! name of calling routine
98  errorMsg ! message to add to error log for printing
99 
100  !EOP
101  !BOC
102  !-----------------------------------------------------------------------
103  !
104  ! Local variables
105  !
106  !-----------------------------------------------------------------------
107 
108  character(SCRIP_charLength) :: &
109  logErrorMsg ! constructed error message with routine name
110 
111  !-----------------------------------------------------------------------
112  !
113  ! Set error code to fail
114  !
115  !-----------------------------------------------------------------------
116 
117  errorcode = scrip_fail
118 
119  !-----------------------------------------------------------------------
120  !
121  ! Add error message to error log
122  !
123  !-----------------------------------------------------------------------
124 
125  scrip_errormsgcount = scrip_errormsgcount + 1
126 
127  if (scrip_errormsgcount <= scrip_errorlogdepth) then
128  write(logerrormsg,'(a,a2,a)') rtnname,': ',errormsg
129  scrip_errorlog(scrip_errormsgcount) = logerrormsg
130  endif
131 
132  !-----------------------------------------------------------------------
133  !EOC
134 

References scrip_fail.

Referenced by scrip_interface::scrip(), scrip_netcdfmod::scrip_netcdferrorcheck(), scrip_remap_write::write_remap(), and scrip_remap_write::write_remap_ww3().

Variable Documentation

◆ scrip_fail

integer (scrip_i4), parameter, public scrip_errormod::scrip_fail = -1

Definition at line 42 of file scrip_errormod.f90.

Referenced by scrip_errorset().

◆ scrip_success

integer (scrip_i4), parameter, public scrip_errormod::scrip_success = 0