1 |
C $Header: /u/gcmpack/development/heimbach/ecco_env/pkg/cal/cal_checkdate.F,v 1.5 2001/02/02 16:57:22 heimbach Exp $ |
2 |
|
3 |
#include "CAL_CPPOPTIONS.h" |
4 |
|
5 |
subroutine cal_CheckDate( |
6 |
I date, |
7 |
O valid, |
8 |
O calerr, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cal_CheckDate |
14 |
c ================================================================== |
15 |
c |
16 |
c o Check whether the array date conforms with the required format. |
17 |
c |
18 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
19 |
c |
20 |
c changed: Christian Eckert eckert@mit.edu 29-Dec-1999 |
21 |
c |
22 |
c - restructured the original version in order to have a |
23 |
c better interface to the MITgcmUV. |
24 |
c |
25 |
c Christian Eckert eckert@mit.edu 03-Feb-2000 |
26 |
c |
27 |
c - Introduced new routine and function names, cal_<NAME>, |
28 |
c for verion 0.1.3. |
29 |
c |
30 |
c ================================================================== |
31 |
c SUBROUTINE cal_CheckDate |
32 |
c ================================================================== |
33 |
|
34 |
implicit none |
35 |
|
36 |
c == global variables == |
37 |
|
38 |
#include "cal.h" |
39 |
|
40 |
c == routine arguments == |
41 |
|
42 |
integer date(4) |
43 |
logical valid |
44 |
integer calerr |
45 |
integer mythid |
46 |
|
47 |
c == local variables == |
48 |
|
49 |
integer yy,mm,dd |
50 |
integer nsecs |
51 |
integer lp,wd |
52 |
integer hhmmss |
53 |
integer yymmdd |
54 |
integer fac |
55 |
integer check_sign_1 |
56 |
integer check_sign_2 |
57 |
|
58 |
c == end of interface == |
59 |
|
60 |
valid = .true. |
61 |
hhmmss = 0 |
62 |
calerr = 0 |
63 |
fac = 1 |
64 |
|
65 |
if (date(4) .le. 0) then |
66 |
if (date(4) .ne. -1) then |
67 |
calerr = 1801 |
68 |
else |
69 |
if (date(3) .ne. 0) then |
70 |
calerr = 1802 |
71 |
else |
72 |
check_sign_1 = sign(1,date(1)) |
73 |
check_sign_2 = sign(1,date(2)) |
74 |
if (check_sign_1*check_sign_2 .lt. 0) then |
75 |
calerr = 1803 |
76 |
else |
77 |
call cal_ConvDate(date,yy,mm,dd,nsecs,lp,wd,mythid) |
78 |
if (nsecs .lt. 0) fac = -1 |
79 |
hhmmss = fac*nsecs/secondsperminute |
80 |
hhmmss = hhmmss/minutesperhour*10000 + |
81 |
& mod(hhmmss,minutesperhour)*100 + |
82 |
& mod(fac*nsecs,secondsperminute) |
83 |
hhmmss = fac*hhmmss |
84 |
if (date(2) .ne. hhmmss) then |
85 |
calerr = 1804 |
86 |
endif |
87 |
endif |
88 |
endif |
89 |
endif |
90 |
else |
91 |
if (date(4) .gt. 8) then |
92 |
calerr = 1805 |
93 |
else |
94 |
if ((date(3) .ne. 1) .and. |
95 |
& (date(3) .ne. 2)) then |
96 |
calerr = 1806 |
97 |
else |
98 |
check_sign_1 = sign(1,date(1)) |
99 |
check_sign_2 = sign(1,date(2)) |
100 |
if (check_sign_1*check_sign_2 .lt. 0) then |
101 |
calerr = 1803 |
102 |
else |
103 |
call cal_ConvDate( date,yy,mm,dd,nsecs,lp,wd,mythid ) |
104 |
if (date(1) .lt. refdate(1)) then |
105 |
calerr = 1807 |
106 |
else |
107 |
hhmmss = nsecs/secondsperminute |
108 |
hhmmss = hhmmss/minutesperhour*10000 + |
109 |
& mod(hhmmss,minutesperhour)*100 + |
110 |
& mod(nsecs,secondsperminute) |
111 |
endif |
112 |
if (date(2) .ne. hhmmss) then |
113 |
calerr = 1804 |
114 |
endif |
115 |
yymmdd = yy*10000 + mm*100 + dd |
116 |
if (date(1) .ne. yymmdd) then |
117 |
calerr = 1808 |
118 |
endif |
119 |
endif |
120 |
endif |
121 |
endif |
122 |
endif |
123 |
|
124 |
if (calerr .ne. 0) valid = .not. valid |
125 |
|
126 |
return |
127 |
end |
128 |
|