/[MITgcm]/MITgcm/pkg/cal/cal_checkdate.F
ViewVC logotype

Contents of /MITgcm/pkg/cal/cal_checkdate.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download)
Sat Apr 7 16:20:07 2012 UTC (12 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.4: +68 -64 lines
- avoid overwritring 1rst error code with one less relevant
- print a msg if called before pkg/cal parameters were set

1 C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_checkdate.F,v 1.4 2003/10/09 04:19:19 edhill Exp $
2 C $Name: $
3
4 #include "CAL_OPTIONS.h"
5
6 SUBROUTINE CAL_CHECKDATE(
7 I date,
8 O valid,
9 O calerr,
10 I myThid )
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 changed: Christian Eckert eckert@mit.edu 29-Dec-1999
20 C - restructured the original version in order to have a
21 C better interface to the MITgcmUV.
22 C Christian Eckert eckert@mit.edu 03-Feb-2000
23 C - Introduced new routine and function names, cal_<NAME>,
24 C for verion 0.1.3.
25 C 21-Sep-2003: fixed check_sign logic to work with
26 C negative intervals (menemenlis@jpl.nasa.gov)
27 C
28 C ==================================================================
29 C SUBROUTINE cal_CheckDate
30 C ==================================================================
31
32 IMPLICIT NONE
33
34 C == global variables ==
35 #include "EEPARAMS.h"
36 #include "cal.h"
37
38 C == routine arguments ==
39 INTEGER date(4)
40 LOGICAL valid
41 INTEGER calerr
42 INTEGER myThid
43
44 C == local variables ==
45 C msgBuf :: Informational/error message buffer
46 INTEGER yy,mm,dd
47 INTEGER nsecs
48 INTEGER lp,wd
49 INTEGER hhmmss
50 INTEGER yymmdd
51 INTEGER fac
52 LOGICAL check_sign
53 CHARACTER*(MAX_LEN_MBUF) msgBuf
54 C == end of interface ==
55
56 valid = .true.
57 hhmmss = 0
58 calerr = 0
59 fac = 1
60
61 check_sign = ( (date(1).lt.0) .and. date(2).gt.0 )
62 & .OR. ( (date(1).gt.0) .and. date(2).lt.0 )
63
64 if (date(4) .le. 0) then
65 if (date(4) .ne. -1) then
66 calerr = 1801
67 else
68 if (date(3) .ne. 0) then
69 calerr = 1802
70 else
71 if ( check_sign ) then
72 calerr = 1803
73 ELSEIF ( cal_setStatus .LT. 1 ) THEN
74 WRITE( msgBuf,'(2A,4I9)') 'CAL_CHECKDATE: ',
75 & 'date=',date(1),date(2),date(3),date(4)
76 CALL PRINT_ERROR( msgBuf, myThid )
77 WRITE( msgBuf,'(2A,I2,A)') 'CAL_CHECKDATE: ',
78 & 'called too early (cal_setStatus=',cal_setStatus,' )'
79 CALL PRINT_ERROR( msgBuf, myThid )
80 else
81 call cal_ConvDate(date,yy,mm,dd,nsecs,lp,wd,myThid)
82 if (nsecs .lt. 0) fac = -1
83 hhmmss = fac*nsecs/secondsperminute
84 hhmmss = hhmmss/minutesperhour*10000 +
85 & mod(hhmmss,minutesperhour)*100 +
86 & mod(fac*nsecs,secondsperminute)
87 hhmmss = fac*hhmmss
88 if (date(2) .ne. hhmmss) then
89 calerr = 1804
90 endif
91 endif
92 endif
93 endif
94 else
95 if (date(4) .gt. 8) then
96 calerr = 1805
97 else
98 if ((date(3) .ne. 1) .and.
99 & (date(3) .ne. 2)) then
100 calerr = 1806
101 else
102 if ( check_sign ) then
103 calerr = 1803
104 else
105 call cal_ConvDate( date,yy,mm,dd,nsecs,lp,wd,myThid )
106 if (date(1) .lt. refdate(1)) then
107 calerr = 1807
108 ELSEIF ( cal_setStatus .LT. 1 ) THEN
109 WRITE( msgBuf,'(2A,4I9)') 'CAL_CHECKDATE: ',
110 & 'date=',date(1),date(2),date(3),date(4)
111 CALL PRINT_ERROR( msgBuf, myThid )
112 WRITE( msgBuf,'(2A,I2,A)') 'CAL_CHECKDATE: ',
113 & 'called too early (cal_setStatus=',cal_setStatus,' )'
114 CALL PRINT_ERROR( msgBuf, myThid )
115 else
116 hhmmss = nsecs/secondsperminute
117 hhmmss = hhmmss/minutesperhour*10000 +
118 & mod(hhmmss,minutesperhour)*100 +
119 & mod(nsecs,secondsperminute)
120 if (date(2) .ne. hhmmss) then
121 calerr = 1804
122 endif
123 endif
124 yymmdd = yy*10000 + mm*100 + dd
125 if (date(1) .ne. yymmdd) then
126 calerr = 1808
127 endif
128 endif
129 endif
130 endif
131 endif
132
133 if (calerr .ne. 0) valid = .FALSE.
134
135 RETURN
136 END

  ViewVC Help
Powered by ViewVC 1.1.22