NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3fs15.f
Go to the documentation of this file.
1C> @file
2C> @brief Updating office note 85 date/time word.
3C> @author Ralph Jones @date 1987-02-09
4
5C> Updates or backdates a fullword date/time word (o.n. 84) by a specified
6C> number of hours.
7C>
8C> ### Program History Log:
9C> Date | Programmer | Comments
10C> -----|------------|---------
11C> Unknown | Robert Allard | Initial.
12C> 1987-02-19 | Ralph Jones | Clean up code
13C> 1987-02-19 | Ralph Jones | Change to microsoft fortran 4.10
14C> 1989-05-12 | Ralph Jones | Correct order of bytes in date word for pc
15C> 1989-08-04 | Ralph Jones | Clean up code, get rid of assign, correction for memory set to indefinite.
16C> 1989-10-25 | Ralph Jones | Change to cray cft77 fortran
17C> 1995-11-15 | Ralph Jones | Add save statement
18C> 2002-10-15 | Boi Vuong | Replaced function ichar with mova2i
19C>
20C> @param[in] IDATE Packed binary date/time as follows:
21C> Byte | Variable | Range
22C> -----|----------|------
23C> Byte 1 | is year of century | 00-99
24C> Byte 2 | is month | 01-12
25C> Byte 3 | is day of month | 01-31
26C> Byte 4 | is hour | 00-23
27C> Subroutine takes advantage of fortran address passing, IDATE and NDATE may
28C> be a character*1 array of four, the left 32 bits of 64 bit integer word.
29C> An office note 85 label can be stored in 4 integer words. If integer the
30C> 2nd word is used. Output is stored in left 32 bits. for a office note 84
31C> label the 7th word is in the 4th cray 64 bit integer, the left 32 bits.
32C> @param[in] JTAU Number of hours to update (if positive) or backdate (if negative)
33C> @param[out] NDATE New date/time word returned in the same format as 'IDATE'.
34C> 'NDATE' and 'IDATE' may be the same variable.
35C>
36C> @note This routine is valid only for the 20th century.
37C>
38C> @note The format of the date/time word is the same as the seventh word of
39C> the packed data field label (see o.n. 84) and the third word of a binary
40C> data set label (see o.n. 85).
41C>
42C> Exit states: An error found by out of range tests on the given date/time
43C> information will be indicated by returning a binary zero word in 'NDATE'.
44C>
45C> @author Ralph Jones @date 1987-02-09
46 SUBROUTINE w3fs15(IDATE,JTAU,NDATE)
47C
48 INTEGER ITABYR(13)
49 INTEGER LPTB(13)
50 INTEGER NOLPTB(13)
51C
52 CHARACTER*1 IDATE(4)
53 CHARACTER*1 NDATE(4)
54C
55 SAVE
56C
57 DATA lptb /0000,0744,1440,2184,2904,3648,4368,5112,
58 & 5856,6576,7320,8040,8784/
59 DATA nolptb/0000,0744,1416,2160,2880,3624,4344,5088,
60 & 5832,6552,7296,8016,8760/
61 DATA icenty/1900/
62C
63C ...WHERE ICENTY IS FOR THE 20TH CENTURY ASSUMED FOR THE GIVEN
64C ... YEAR WITHIN THE CENTURY
65C
66 iyr = mova2i(idate(1))
67 imonth = mova2i(idate(2))
68 iday = mova2i(idate(3))
69 ihour = mova2i(idate(4))
70C
71 IF (iyr .GT. 99) GO TO 1600
72 IF (imonth .LE. 0) GO TO 1600
73 IF (imonth .GT. 12) GO TO 1600
74 IF (iday .LE. 0) GO TO 1600
75 IF (iday .GT. 31) GO TO 1600
76 IF (ihour .LT. 0) GO TO 1600
77 IF (ihour .GT. 24) GO TO 1600
78 IF (jtau .NE. 0) GO TO 100
79C
80 ndate(1) = idate(1)
81 ndate(2) = idate(2)
82 ndate(3) = idate(3)
83 ndate(4) = idate(4)
84 RETURN
85C
86 100 CONTINUE
87 jahr = iyr + icenty
88 kabul = 1
89 GO TO 900
90C
91C ...WHERE 900 IS SUBROUTINE TO INITIALIZE ITABYR
92C ...AND RETURN THRU KABUL
93C
94 200 CONTINUE
95 ihryr = ihour + 24 * (iday - 1) + itabyr(imonth)
96 ihryr2 = ihryr + jtau
97C
98C ...TO TEST FOR BACKDATED INTO PREVIOUS YEAR...
99C
100 300 CONTINUE
101 IF (ihryr2 .LT. 0) GO TO 700
102C
103 DO 400 m = 2,13
104 IF (ihryr2 .LT. itabyr(m)) GO TO 600
105 400 CONTINUE
106C
107C ...IF IT FALLS THRU LOOP TO HERE, IT IS INTO NEXT YEAR...
108C
109 jahr = jahr + 1
110 ihryr2 = ihryr2 - itabyr(13)
111 kabul = 2
112 GO TO 900
113C
114 600 CONTINUE
115 monat = m - 1
116 ihrmo = ihryr2 - itabyr(monat)
117 nodays = ihrmo / 24
118 itag = nodays + 1
119 iuhr = ihrmo - nodays * 24
120 GO TO 1500
121C
122C ...ALL FINISHED. RETURN TO CALLING PROGRAM.......................
123C ...COMES TO 700 IF NEG TOTAL HRS. BACK UP INTO PREVIOUS YEAR
124C
125 700 CONTINUE
126 jahr = jahr - 1
127 kabul = 3
128 GO TO 900
129C
130C ...WHICH IS CALL TO INITIALIZE ITABYR AND RETURN THRU KABUL
131C
132 800 CONTINUE
133 ihryr2 = itabyr(13) + ihryr2
134 GO TO 300
135C
136C ...SUBROUTINE INITYR...
137C ...CALLED BY GO TO 900 AFTER ASSIGNING RETURN NO. TO KABUL...
138C ...ITABYR HAS MONTHLY ACCUMULATING TOTAL HRS REL TO BEGIN OF YR.
139C ...DEPENDS ON WHETHER JAHR IS LEAP YEAR OR NOT.
140C
141 900 CONTINUE
142 iquot = jahr / 4
143 irmndr = jahr - 4 * iquot
144 IF (irmndr .NE. 0) GO TO 1000
145C
146C ...WAS MODULO 4, SO MOST LIKELY A LEAP YEAR,
147C
148 iquot = jahr / 100
149 irmndr = jahr - 100 * iquot
150 IF (irmndr .NE. 0) GO TO 1200
151C
152C ...COMES THIS WAY IF A CENTURY YEAR...
153C
154 iquot = jahr / 400
155 irmndr = jahr - 400 * iquot
156 IF (irmndr .EQ. 0) GO TO 1200
157C
158C ...COMES TO 1000 IF NOT A LEAP YEAR...
159C
160 1000 CONTINUE
161 DO 1100 i = 1,13
162 itabyr(i) = nolptb(i)
163 1100 CONTINUE
164 GO TO 1400
165C
166C ...COMES TO 1200 IF LEAP YEAR
167C
168 1200 CONTINUE
169 DO 1300 i = 1,13
170 itabyr(i) = lptb(i)
171 1300 CONTINUE
172C
173 1400 CONTINUE
174 GO TO (200,300,800) kabul
175C
176 1500 CONTINUE
177 jahr = mod(jahr,100)
178 ndate(1) = char(jahr)
179 ndate(2) = char(monat)
180 ndate(3) = char(itag)
181 ndate(4) = char(iuhr)
182 RETURN
183C
184 1600 CONTINUE
185 ndate(1) = char(0)
186 ndate(2) = char(0)
187 ndate(3) = char(0)
188 ndate(4) = char(0)
189C
190C ...WHICH FLAGS AN ERROR CONDITION ...
191C
192 RETURN
193 END
integer function mova2i(a)
This Function copies a bit string from a Character*1 variable to an integer variable.
Definition mova2i.f:25
subroutine w3fs15(idate, jtau, ndate)
Updates or backdates a fullword date/time word (o.n.
Definition w3fs15.f:47