1 |
C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_printerror.F,v 1.4 2004/04/19 23:25:15 mlosch Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CAL_OPTIONS.h" |
5 |
|
6 |
subroutine cal_PrintError( |
7 |
I calerr, |
8 |
I mythid |
9 |
& ) |
10 |
|
11 |
c ================================================================== |
12 |
c SUBROUTINE cal_PrintError |
13 |
c ================================================================== |
14 |
c |
15 |
c Purpose: Use the MITgcmuvs print routines to document errors that |
16 |
c occured during the execution of the calendar tool. |
17 |
c |
18 |
c o Calling this routine allows to print out an error message for |
19 |
c several errors that might occur. |
20 |
c |
21 |
c The error codes for the calendar tool are specified by a four |
22 |
c digit integer: |
23 |
c RRCC |
24 |
c |
25 |
c The RR digits identify the routine that detected the error. |
26 |
c The CC digits identify the specific error in the routine that |
27 |
c detected the error. |
28 |
c |
29 |
c RR translates to routines in the following way: |
30 |
c |
31 |
c cal_Init 0 |
32 |
c cal_Set 1 |
33 |
c cal_GetDate 2 |
34 |
c cal_FullDate 3 |
35 |
c cal_IsLeap 4 |
36 |
c cal_TimePassed 5 |
37 |
c cal_AddTime 6 |
38 |
c cal_TimeInterval 7 |
39 |
c cal_SubDates 8 |
40 |
c cal_ConvDate 9 |
41 |
c cal_ToSeconds 10 |
42 |
c cal_StepsPerDay 11 |
43 |
c cal_DaysPerMonth 12 |
44 |
c cal_MonthsPerYear 13 |
45 |
c cal_IntYears 14 |
46 |
c cal_IntMonths 15 |
47 |
c cal_IntDays 16 |
48 |
c cal_nStepDay 17 |
49 |
c cal_CheckDate 18 |
50 |
c cal_PrintError 19 |
51 |
c cal_PrintDate 20 |
52 |
c cal_NumInts 25 |
53 |
c |
54 |
c |
55 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
56 |
c |
57 |
c changed: Christian Eckert eckert@mit.edu 29-Dec-1999 |
58 |
c |
59 |
c Christian Eckert eckert@mit.edu 10-Jan-2000 |
60 |
c |
61 |
c - Corrected the print statement for error code 104. |
62 |
c It contained more than 72 characters in one line. |
63 |
c |
64 |
c Christian Eckert eckert@mit.edu 03-Feb-2000 |
65 |
c |
66 |
c - Introduced new routine and function names, cal_<NAME>, |
67 |
c for verion 0.1.3. |
68 |
c |
69 |
c Christian Eckert eckert@mit.edu 24-Feb-2000 |
70 |
c |
71 |
c - Included cal_NumInts error code. |
72 |
c |
73 |
c ================================================================== |
74 |
c SUBROUTINE cal_PrintError |
75 |
c ================================================================== |
76 |
|
77 |
implicit none |
78 |
|
79 |
c == global variables == |
80 |
|
81 |
#include "EEPARAMS.h" |
82 |
#include "SIZE.h" |
83 |
#include "PARAMS.h" |
84 |
|
85 |
c == routine arguments == |
86 |
|
87 |
c mythid - thread number for this instance of the routine. |
88 |
c calerr - error code |
89 |
|
90 |
integer mythid |
91 |
integer calerr |
92 |
|
93 |
c == local variables == |
94 |
|
95 |
integer nroutine |
96 |
integer nerrcode |
97 |
logical missingerrcode |
98 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
99 |
|
100 |
c == end of interface == |
101 |
|
102 |
nerrcode = mod(calerr,100) |
103 |
nroutine = (calerr - nerrcode)/100 |
104 |
missingerrcode = .false. |
105 |
|
106 |
if (nroutine .eq. 0) then |
107 |
c Error in cal_Init |
108 |
|
109 |
if (nerrcode .eq. 1) then |
110 |
WRITE(msgBuf,'(A)') |
111 |
& ' cal_Init: Unable to open calendar parameter file' |
112 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
113 |
CALL PRINT_ERROR( msgBuf , 1) |
114 |
WRITE(msgBuf,'(A)') |
115 |
& ' file "data.calendar".' |
116 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
117 |
CALL PRINT_ERROR( msgBuf , 1) |
118 |
endif |
119 |
|
120 |
else if (nroutine .eq. 1) then |
121 |
c Error in cal_Set |
122 |
|
123 |
if (nerrcode .eq. 1) then |
124 |
WRITE(msgBuf,'(A)') |
125 |
& ' cal_Set: No appropriate calendar has been specified.' |
126 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
127 |
CALL PRINT_ERROR( msgBuf , 1) |
128 |
else if (nerrcode .eq. 2) then |
129 |
WRITE(msgBuf,'(A)') |
130 |
& ' cal_Set: The time step specified is not valid.' |
131 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
132 |
CALL PRINT_ERROR( msgBuf , 1) |
133 |
else if (nerrcode .eq. 3) then |
134 |
WRITE(msgBuf,'(A)') |
135 |
& ' cal_Set: The time step is less than a second.' |
136 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
137 |
CALL PRINT_ERROR( msgBuf , 1) |
138 |
else if (nerrcode .eq. 4) then |
139 |
WRITE(msgBuf,'(A)') |
140 |
& ' cal_Set: The time step contains fractions of a second.' |
141 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
142 |
CALL PRINT_ERROR( msgBuf , 1) |
143 |
else if (nerrcode .eq. 5) then |
144 |
WRITE(msgBuf,'(A)') |
145 |
& ' cal_Set: Less than one time step per calendar day.' |
146 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
147 |
CALL PRINT_ERROR( msgBuf , 1) |
148 |
else if (nerrcode .eq. 6) then |
149 |
WRITE(msgBuf,'(A)') |
150 |
& ' cal_Set: The specifications are incomplete. Please' |
151 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
152 |
CALL PRINT_ERROR( msgBuf , 1) |
153 |
WRITE(msgBuf,'(A)') |
154 |
& ' refer to the documentation.' |
155 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
156 |
CALL PRINT_ERROR( msgBuf , 1) |
157 |
else if (nerrcode .eq. 7) then |
158 |
WRITE(msgBuf,'(A)') |
159 |
& ' cal_Set: The final date of integration is before its' |
160 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
161 |
CALL PRINT_ERROR( msgBuf , 1) |
162 |
WRITE(msgBuf,'(A)') |
163 |
& ' start date.' |
164 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
165 |
CALL PRINT_ERROR( msgBuf , 1) |
166 |
else if (nerrcode .eq. 10) then |
167 |
WRITE(msgBuf,'(A)') |
168 |
& ' cal_Set: The Julian Calendar is not implemented yet.' |
169 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
170 |
CALL PRINT_ERROR( msgBuf , 1) |
171 |
else if (nerrcode .eq. 11) then |
172 |
WRITE(msgBuf,'(A)') |
173 |
& ' cal_Set: The No Calendar case is not implemented yet.' |
174 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
175 |
CALL PRINT_ERROR( msgBuf , 1) |
176 |
else if ( nerrcode .eq. 12) then |
177 |
WRITE(msgBuf,'(A)') |
178 |
& ' cal_Set: modelstart .ne. startTime ... please check.' |
179 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
180 |
CALL PRINT_ERROR( msgBuf , 1) |
181 |
else if ( nerrcode .eq. 13 ) then |
182 |
WRITE(msgBuf,'(A)') |
183 |
& ' cal_Set: modelend .ne. endTime ... please check.' |
184 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
185 |
CALL PRINT_ERROR( msgBuf , 1) |
186 |
else if ( nerrcode .eq. 14 ) then |
187 |
WRITE(msgBuf,'(A)') |
188 |
& ' cal_Set: modelstep .ne. deltaTclock ... please check.' |
189 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
190 |
CALL PRINT_ERROR( msgBuf , 1) |
191 |
else if ( nerrcode .eq. 15 ) then |
192 |
WRITE(msgBuf,'(A)') |
193 |
& ' cal_Set: modeliter0 .ne. nIter0 ... please check.' |
194 |
else if ( nerrcode .eq. 16 ) then |
195 |
WRITE(msgBuf,'(A)') |
196 |
& ' cal_Set: modeliterend .ne. nEndIter ... please check.' |
197 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
198 |
CALL PRINT_ERROR( msgBuf , 1) |
199 |
else if ( nerrcode .eq. 17 ) then |
200 |
WRITE(msgBuf,'(A)') |
201 |
& ' cal_Set: modelintsteps .ne. nTimeSteps' |
202 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
203 |
CALL PRINT_ERROR( msgBuf , 1) |
204 |
else |
205 |
missingerrcode = .true. |
206 |
endif |
207 |
|
208 |
else if (nroutine .eq. 2) then |
209 |
c Error in cal_GetDate |
210 |
|
211 |
missingerrcode = .true. |
212 |
|
213 |
else if (nroutine .eq. 3) then |
214 |
c Error in cal_FullDate |
215 |
|
216 |
missingerrcode = .true. |
217 |
|
218 |
else if (nroutine .eq. 4) then |
219 |
c Error in cal_IsLeap |
220 |
|
221 |
missingerrcode = .true. |
222 |
|
223 |
else if (nroutine .eq. 5) then |
224 |
c Error in cal_TimePassed |
225 |
|
226 |
if (nerrcode .eq. 1) then |
227 |
WRITE(msgBuf,'(A)') |
228 |
& 'cal_TimePassed: cal and timeinterval cannot be compared' |
229 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
230 |
CALL PRINT_ERROR( msgBuf , 1) |
231 |
else |
232 |
missingerrcode = .true. |
233 |
endif |
234 |
|
235 |
else if (nroutine .eq. 6) then |
236 |
c Error in cal_AddTime |
237 |
|
238 |
if (nerrcode .eq. 1) then |
239 |
WRITE(msgBuf,'(A)') |
240 |
& ' cal_AddTime: not a valid time interval.' |
241 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
242 |
CALL PRINT_ERROR( msgBuf , 1) |
243 |
else |
244 |
missingerrcode = .true. |
245 |
endif |
246 |
|
247 |
else if (nroutine .eq. 7) then |
248 |
c Error in cal_TimeInterval |
249 |
|
250 |
if (nerrcode .eq. 1) then |
251 |
WRITE(msgBuf,'(A)') |
252 |
& ' cal_TimeInterval: not a valid time unit.' |
253 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
254 |
CALL PRINT_ERROR( msgBuf , 1) |
255 |
else |
256 |
missingerrcode = .true. |
257 |
endif |
258 |
|
259 |
else if (nroutine .eq. 8) then |
260 |
c Error in cal_SubDates |
261 |
|
262 |
if (nerrcode .eq. 1) then |
263 |
WRITE(msgBuf,'(A)') |
264 |
& ' cal_SubDates: Not a valid combination of calendar dates' |
265 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
266 |
CALL PRINT_ERROR( msgBuf , 1) |
267 |
WRITE(msgBuf,'(A)') |
268 |
& ' or time intervals.' |
269 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
270 |
CALL PRINT_ERROR( msgBuf , 1) |
271 |
else |
272 |
missingerrcode = .true. |
273 |
endif |
274 |
|
275 |
else if (nroutine .eq. 9) then |
276 |
c Error in cal_ConvDate |
277 |
|
278 |
if (nerrcode .eq. 1) then |
279 |
WRITE(msgBuf,'(A)') |
280 |
& ' cal_ConvDate: date specification has mixed signs.' |
281 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
282 |
CALL PRINT_ERROR( msgBuf , 1) |
283 |
else |
284 |
missingerrcode = .true. |
285 |
endif |
286 |
|
287 |
else if (nroutine .eq. 10) then |
288 |
c Error in cal_ToSeconds |
289 |
|
290 |
if (nerrcode .eq. 1) then |
291 |
WRITE(msgBuf,'(A)') |
292 |
& ' cal_ToSeconds: input not a time interval array.' |
293 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
294 |
CALL PRINT_ERROR( msgBuf , 1) |
295 |
else |
296 |
missingerrcode = .true. |
297 |
endif |
298 |
|
299 |
else if (nroutine .eq. 11) then |
300 |
c Error in cal_StepsPerDay |
301 |
|
302 |
if (nerrcode .eq. 1) then |
303 |
WRITE(msgBuf,'(A)') |
304 |
& ' cal_StepsPerDay: nothing else to do.' |
305 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
306 |
CALL PRINT_ERROR( msgBuf , 1) |
307 |
else |
308 |
missingerrcode = .true. |
309 |
endif |
310 |
|
311 |
else if (nroutine .eq. 12) then |
312 |
c Error in cal_DaysPerMonth |
313 |
|
314 |
if (nerrcode .eq. 1) then |
315 |
WRITE(msgBuf,'(A)') |
316 |
& ' cal_DaysPerMonth: current year after final year.' |
317 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
318 |
CALL PRINT_ERROR( msgBuf , 1) |
319 |
else |
320 |
missingerrcode = .true. |
321 |
endif |
322 |
|
323 |
else if (nroutine .eq. 13) then |
324 |
c Error in cal_MonthsPerYear |
325 |
|
326 |
missingerrcode = .true. |
327 |
|
328 |
else if (nroutine .eq. 14) then |
329 |
c Error in cal_IntYears |
330 |
|
331 |
missingerrcode = .true. |
332 |
|
333 |
else if (nroutine .eq. 15) then |
334 |
c Error in cal_IntMonths |
335 |
|
336 |
missingerrcode = .true. |
337 |
|
338 |
else if (nroutine .eq. 16) then |
339 |
c Error in cal_IntDays |
340 |
|
341 |
missingerrcode = .true. |
342 |
|
343 |
else if (nroutine .eq. 17) then |
344 |
c Error in cal_nStepDay |
345 |
|
346 |
missingerrcode = .true. |
347 |
|
348 |
else if (nroutine .eq. 18) then |
349 |
c Error in cal_CheckDate |
350 |
|
351 |
if (nerrcode .eq. 0) then |
352 |
WRITE(msgBuf,'(A)') |
353 |
& ' cal_CheckDate: A valid date specification!' |
354 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
355 |
CALL PRINT_ERROR( msgBuf , 1) |
356 |
WRITE(msgBuf,'(A)') |
357 |
& ' --> This only means that the format is ok!' |
358 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
359 |
CALL PRINT_ERROR( msgBuf , 1) |
360 |
else if (nerrcode .eq. 1) then |
361 |
WRITE(msgBuf,'(A)') |
362 |
& ' cal_CheckDate: Last component of array not valid!' |
363 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
364 |
CALL PRINT_ERROR( msgBuf , 1) |
365 |
else if (nerrcode .eq. 2) then |
366 |
WRITE(msgBuf,'(A)') |
367 |
& ' cal_CheckDate: Third component of interval array not 0' |
368 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
369 |
CALL PRINT_ERROR( msgBuf , 1) |
370 |
else if (nerrcode .eq. 3) then |
371 |
WRITE(msgBuf,'(A)') |
372 |
& ' cal_CheckDate: Signs of first two components unequal!' |
373 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
374 |
CALL PRINT_ERROR( msgBuf , 1) |
375 |
else if (nerrcode .eq. 4) then |
376 |
WRITE(msgBuf,'(A)') |
377 |
& ' cal_CheckDate: Second component not in hhmmss format!' |
378 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
379 |
CALL PRINT_ERROR( msgBuf , 1) |
380 |
else if (nerrcode .eq. 5) then |
381 |
WRITE(msgBuf,'(A)') |
382 |
& ' cal_CheckDate: Weekday indentifier not correct!' |
383 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
384 |
CALL PRINT_ERROR( msgBuf , 1) |
385 |
else if (nerrcode .eq. 6) then |
386 |
WRITE(msgBuf,'(A)') |
387 |
& ' cal_CheckDate: Leap year identifier not correct!' |
388 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
389 |
CALL PRINT_ERROR( msgBuf , 1) |
390 |
else if (nerrcode .eq. 7) then |
391 |
WRITE(msgBuf,'(A)') |
392 |
& 'cal_CheckDate: Calendar date before predef. reference date' |
393 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
394 |
CALL PRINT_ERROR( msgBuf , 1) |
395 |
else if (nerrcode .eq. 8) then |
396 |
WRITE(msgBuf,'(A)') |
397 |
& ' cal_CheckDate: First component not in yymmdd format!' |
398 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
399 |
CALL PRINT_ERROR( msgBuf , 1) |
400 |
else |
401 |
missingerrcode = .true. |
402 |
endif |
403 |
|
404 |
else if (nroutine .eq. 19) then |
405 |
c Error in cal_PrintError |
406 |
|
407 |
missingerrcode = .true. |
408 |
|
409 |
else if (nroutine .eq. 20) then |
410 |
c Error in cal_PrintDate |
411 |
|
412 |
if (nerrcode .eq. 1) then |
413 |
WRITE(msgBuf,'(A)') |
414 |
& ' cal_PrintDate: date not a legal calendar array.' |
415 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
416 |
CALL PRINT_ERROR( msgBuf , 1) |
417 |
else |
418 |
missingerrcode = .true. |
419 |
endif |
420 |
|
421 |
else if (nroutine .eq. 21) then |
422 |
c Error in cal_PrintError |
423 |
|
424 |
missingerrcode = .true. |
425 |
|
426 |
else if (nroutine .eq. 25) then |
427 |
c Error in cal_NumInts |
428 |
|
429 |
if (nerrcode .eq. 1) then |
430 |
WRITE(msgBuf,'(A)') |
431 |
& ' cal_NumInts: Expected a time interval as third argument.' |
432 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
433 |
CALL PRINT_ERROR( msgBuf , 1) |
434 |
else |
435 |
missingerrcode = .true. |
436 |
endif |
437 |
|
438 |
else |
439 |
missingerrcode = .true. |
440 |
endif |
441 |
|
442 |
if (missingerrcode) then |
443 |
print*,' cal_PrintError: routine called by an undefined' |
444 |
print*,' error code.' |
445 |
print*,' cal_PrintError: error code = ',calerr |
446 |
stop ' stopped in cal_PrintError.' |
447 |
endif |
448 |
|
449 |
return |
450 |
end |
451 |
|