1 |
C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_printerror.F,v 1.2 2003/10/09 04:19:19 edhill 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 |
|
83 |
c == routine arguments == |
84 |
|
85 |
c mythid - thread number for this instance of the routine. |
86 |
c calerr - error code |
87 |
|
88 |
integer mythid |
89 |
integer calerr |
90 |
|
91 |
c == local variables == |
92 |
|
93 |
integer nroutine |
94 |
integer nerrcode |
95 |
logical missingerrcode |
96 |
|
97 |
c == end of interface == |
98 |
|
99 |
nerrcode = mod(calerr,100) |
100 |
nroutine = (calerr - nerrcode)/100 |
101 |
missingerrcode = .false. |
102 |
|
103 |
if (nroutine .eq. 0) then |
104 |
c Error in cal_Init |
105 |
|
106 |
if (nerrcode .eq. 1) then |
107 |
print*, |
108 |
& ' cal_Init: Unable to open calendar parameter file' |
109 |
print*, |
110 |
& ' file "data.calendar".' |
111 |
endif |
112 |
|
113 |
else if (nroutine .eq. 1) then |
114 |
c Error in cal_Set |
115 |
|
116 |
if (nerrcode .eq. 1) then |
117 |
print*, |
118 |
& ' cal_Set: No appropriate calendar has been specified.' |
119 |
else if (nerrcode .eq. 2) then |
120 |
print*, |
121 |
& ' cal_Set: The time step specified is not valid.' |
122 |
else if (nerrcode .eq. 3) then |
123 |
print*, |
124 |
& ' cal_Set: The time step is less than a second.' |
125 |
else if (nerrcode .eq. 4) then |
126 |
print*, |
127 |
& ' cal_Set: The time step contains fractions of a', |
128 |
& ' second.' |
129 |
else if (nerrcode .eq. 5) then |
130 |
print*, |
131 |
& ' cal_Set: Less than one time step per calendar day.' |
132 |
else if (nerrcode .eq. 6) then |
133 |
print*, |
134 |
& ' cal_Set: The specifications are incomplete. Please' |
135 |
print*, |
136 |
& ' refer to the documentation.' |
137 |
else if (nerrcode .eq. 7) then |
138 |
print*, |
139 |
& ' cal_Set: The final date of integration is before its' |
140 |
print*, |
141 |
& ' start date.' |
142 |
else if (nerrcode .eq. 10) then |
143 |
print*, |
144 |
& ' cal_Set: The Julian Calendar is not implemented yet.' |
145 |
else if (nerrcode .eq. 11) then |
146 |
print*, |
147 |
& ' cal_Set: The No Calendar case is not implemented yet.' |
148 |
else if ( nerrcode .eq. 12) then |
149 |
print*, |
150 |
& ' cal_Set: modelstart .ne. startTime ... please check.' |
151 |
else if ( nerrcode .eq. 13 ) then |
152 |
print*, |
153 |
& ' cal_Set: modelend .ne. endTime ... please check.' |
154 |
else if ( nerrcode .eq. 14 ) then |
155 |
print*, |
156 |
& ' cal_Set: modelstep .ne. deltaTclock ... please check.' |
157 |
else if ( nerrcode .eq. 15 ) then |
158 |
print*, |
159 |
& ' cal_Set: modeliter0 .ne. nIter0 ... please check.' |
160 |
else if ( nerrcode .eq. 16 ) then |
161 |
print*, |
162 |
& ' cal_Set: modeliterend .ne. nEndIter ... please check.' |
163 |
else if ( nerrcode .eq. 17 ) then |
164 |
print*, |
165 |
& ' cal_Set: modelintsteps .ne. nTimeSteps', |
166 |
& ' ... please check.' |
167 |
else |
168 |
missingerrcode = .true. |
169 |
endif |
170 |
|
171 |
else if (nroutine .eq. 2) then |
172 |
c Error in cal_GetDate |
173 |
|
174 |
missingerrcode = .true. |
175 |
|
176 |
else if (nroutine .eq. 3) then |
177 |
c Error in cal_FullDate |
178 |
|
179 |
missingerrcode = .true. |
180 |
|
181 |
else if (nroutine .eq. 4) then |
182 |
c Error in cal_IsLeap |
183 |
|
184 |
missingerrcode = .true. |
185 |
|
186 |
else if (nroutine .eq. 5) then |
187 |
c Error in cal_TimePassed |
188 |
|
189 |
if (nerrcode .eq. 1) then |
190 |
print*, |
191 |
& ' cal_TimePassed: calendar and timeinterval cannot', |
192 |
& ' be compared.' |
193 |
else |
194 |
missingerrcode = .true. |
195 |
endif |
196 |
|
197 |
else if (nroutine .eq. 6) then |
198 |
c Error in cal_AddTime |
199 |
|
200 |
if (nerrcode .eq. 1) then |
201 |
print*, |
202 |
& ' cal_AddTime: not a valid time interval.' |
203 |
else |
204 |
missingerrcode = .true. |
205 |
endif |
206 |
|
207 |
else if (nroutine .eq. 7) then |
208 |
c Error in cal_TimeInterval |
209 |
|
210 |
if (nerrcode .eq. 1) then |
211 |
print*, |
212 |
& ' cal_TimeInterval: not a valid time unit.' |
213 |
else |
214 |
missingerrcode = .true. |
215 |
endif |
216 |
|
217 |
else if (nroutine .eq. 8) then |
218 |
c Error in cal_SubDates |
219 |
|
220 |
if (nerrcode .eq. 1) then |
221 |
print*, |
222 |
& ' cal_SubDates: Not a valid combination of calendar dates' |
223 |
print*, |
224 |
& ' or time intervals.' |
225 |
else |
226 |
missingerrcode = .true. |
227 |
endif |
228 |
|
229 |
else if (nroutine .eq. 9) then |
230 |
c Error in cal_ConvDate |
231 |
|
232 |
if (nerrcode .eq. 1) then |
233 |
print*, |
234 |
& ' cal_ConvDate: date specification has mixed signs.' |
235 |
else |
236 |
missingerrcode = .true. |
237 |
endif |
238 |
|
239 |
else if (nroutine .eq. 10) then |
240 |
c Error in cal_ToSeconds |
241 |
|
242 |
if (nerrcode .eq. 1) then |
243 |
print*, |
244 |
& ' cal_ToSeconds: input not a time interval array.' |
245 |
else |
246 |
missingerrcode = .true. |
247 |
endif |
248 |
|
249 |
else if (nroutine .eq. 11) then |
250 |
c Error in cal_StepsPerDay |
251 |
|
252 |
if (nerrcode .eq. 1) then |
253 |
print*, |
254 |
& ' cal_StepsPerDay: nothing else to do.' |
255 |
else |
256 |
missingerrcode = .true. |
257 |
endif |
258 |
|
259 |
else if (nroutine .eq. 12) then |
260 |
c Error in cal_DaysPerMonth |
261 |
|
262 |
if (nerrcode .eq. 1) then |
263 |
print*, |
264 |
& ' cal_DaysPerMonth: current year after final year.' |
265 |
else |
266 |
missingerrcode = .true. |
267 |
endif |
268 |
|
269 |
else if (nroutine .eq. 13) then |
270 |
c Error in cal_MonthsPerYear |
271 |
|
272 |
missingerrcode = .true. |
273 |
|
274 |
else if (nroutine .eq. 14) then |
275 |
c Error in cal_IntYears |
276 |
|
277 |
missingerrcode = .true. |
278 |
|
279 |
else if (nroutine .eq. 15) then |
280 |
c Error in cal_IntMonths |
281 |
|
282 |
missingerrcode = .true. |
283 |
|
284 |
else if (nroutine .eq. 16) then |
285 |
c Error in cal_IntDays |
286 |
|
287 |
missingerrcode = .true. |
288 |
|
289 |
else if (nroutine .eq. 17) then |
290 |
c Error in cal_nStepDay |
291 |
|
292 |
missingerrcode = .true. |
293 |
|
294 |
else if (nroutine .eq. 18) then |
295 |
c Error in cal_CheckDate |
296 |
|
297 |
if (nerrcode .eq. 0) then |
298 |
print*, |
299 |
& ' cal_CheckDate: A valid date specification!' |
300 |
print*, |
301 |
& ' --> This only means that the format is ok!' |
302 |
else if (nerrcode .eq. 1) then |
303 |
print*, |
304 |
& ' cal_CheckDate: Last component of array not valid!' |
305 |
else if (nerrcode .eq. 2) then |
306 |
print*, |
307 |
& ' cal_CheckDate: Third component of interval array', |
308 |
& ' not zero!' |
309 |
else if (nerrcode .eq. 3) then |
310 |
print*, |
311 |
& ' cal_CheckDate: Signs of first two components unequal!' |
312 |
else if (nerrcode .eq. 4) then |
313 |
print*, |
314 |
& ' cal_CheckDate: Second component not in hhmmss format!' |
315 |
else if (nerrcode .eq. 5) then |
316 |
print*, |
317 |
& ' cal_CheckDate: Weekday indentifier not correct!' |
318 |
else if (nerrcode .eq. 6) then |
319 |
print*, |
320 |
& ' cal_CheckDate: Leap year identifier not correct!' |
321 |
else if (nerrcode .eq. 7) then |
322 |
print*, |
323 |
& ' cal_CheckDate: Calendar date before predefined reference', |
324 |
& ' date!' |
325 |
else if (nerrcode .eq. 8) then |
326 |
print*, |
327 |
& ' cal_CheckDate: First component not in yymmdd format!' |
328 |
else |
329 |
missingerrcode = .true. |
330 |
endif |
331 |
|
332 |
else if (nroutine .eq. 19) then |
333 |
c Error in cal_PrintError |
334 |
|
335 |
missingerrcode = .true. |
336 |
|
337 |
else if (nroutine .eq. 20) then |
338 |
c Error in cal_PrintDate |
339 |
|
340 |
if (nerrcode .eq. 1) then |
341 |
print*, |
342 |
& ' cal_PrintDate: date not a legal calendar array.' |
343 |
else |
344 |
missingerrcode = .true. |
345 |
endif |
346 |
|
347 |
else if (nroutine .eq. 21) then |
348 |
c Error in cal_PrintError |
349 |
|
350 |
missingerrcode = .true. |
351 |
|
352 |
else if (nroutine .eq. 25) then |
353 |
c Error in cal_NumInts |
354 |
|
355 |
if (nerrcode .eq. 1) then |
356 |
print*, |
357 |
& ' cal_NumInts: Expected a time interval as third argument.' |
358 |
else |
359 |
missingerrcode = .true. |
360 |
endif |
361 |
|
362 |
else |
363 |
missingerrcode = .true. |
364 |
endif |
365 |
|
366 |
if (missingerrcode) then |
367 |
print*,' cal_PrintError: routine called by an undefined' |
368 |
print*,' error code.' |
369 |
print*,' cal_PrintError: error code = ',calerr |
370 |
stop ' stopped in cal_PrintError.' |
371 |
endif |
372 |
|
373 |
return |
374 |
end |
375 |
|