1 subroutine geth_newdate (ndate, odate, idts)
4 !**********************************************************************
6 ! purpose - from old date ('YYYY-MM-DD*HH:MM:SS') and time in
7 ! seconds, compute the new date.
9 ! on entry - odate - the old hdate.
10 ! idts - the change in time in seconds.
12 ! on exit - ndate - the new hdate.
13 ! idts - the change in time in seconds.
15 !**********************************************************************
18 character*(*) ndate, odate
24 ! yrold - indicates the year associated with "odate"
25 ! moold - indicates the month associated with "odate"
26 ! dyold - indicates the day associated with "odate"
27 ! hrold - indicates the hour associated with "odate"
28 ! miold - indicates the minute associated with "odate"
29 ! scold - indicates the second associated with "odate"
31 ! yrnew - indicates the year associated with "ndate"
32 ! monew - indicates the month associated with "ndate"
33 ! dynew - indicates the day associated with "ndate"
34 ! hrnew - indicates the hour associated with "ndate"
35 ! minew - indicates the minute associated with "ndate"
36 ! scnew - indicates the second associated with "ndate"
38 ! mday - a list assigning the number of days in each month
40 ! dth - the number of hours represented by "idts"
42 ! nday - the integer number of days represented by "idts"
43 ! nhour - the integer number of hours in "idts" after taking out
45 ! nmin - the integer number of minutes in "idts" after taking out
46 ! all the whole days and whole hours.
47 ! nsec - the integer number of minutes in "idts" after taking out
48 ! all the whole days, whole hours, and whole minutes.
51 integer yrnew, monew, dynew, hrnew, minew, scnew
52 integer yrold, moold, dyold, hrold, miold, scold
53 integer mday(12), nday, nhour, nmin, nsec, i
57 !************************* Subroutine Begin *************************
60 ! Assign the number of days in a months
77 ! Break down old hdate into parts
84 read(odate(1:4), '(I4)') yrold
85 read(odate(6:7), '(I2)') moold
86 read(odate(9:10), '(I2)') dyold
88 read(odate(12:13),'(I2)') hrold
90 read(odate(15:16),'(I2)') miold
92 read(odate(18:19),'(I2)') scold
97 ! Set the number of days in February for that year.
100 if (mod(yrold,4).eq.0) then
102 if (mod(yrold,100).eq.0) then
104 if (mod(yrold,400).eq.0) then
110 ! Check that ODATE makes sense.
114 ! Check that the month of ODATE makes sense.
116 if ((moold.gt.12).or.(moold.lt.1)) then
117 print*, 'GETH_NEWDATE: Month of ODATE = ', moold
121 ! Check that the day of ODATE makes sense.
123 if ((dyold.gt.mday(moold)).or.(dyold.lt.1)) then
124 print*, 'GET_NEWDATE: Day of ODATE = ', dyold
128 ! Check that the hour of ODATE makes sense.
130 if ((hrold.gt.23).or.(hrold.lt.0)) then
131 print*, 'GET_NEWDATE: Hour of ODATE = ', hrold
135 ! Check that the minute of ODATE makes sense.
137 if ((miold.gt.59).or.(miold.lt.0)) then
138 print*, 'GET_NEWDATE: Minute of ODATE = ', miold
142 ! Check that the second of ODATE makes sense.
144 if ((scold.gt.59).or.(scold.lt.0)) then
145 print*, 'GET_NEWDATE: Second of ODATE = ', scold
150 print*, 'Crazy ODATE: ', odate(1:olen), olen
155 ! Date Checks are completed. Continue.
159 ! Compute the number of days, hours, minutes, and seconds in idts
161 nday = idts/86400 ! Integer number of days in delta-time
162 nhour = mod(idts,86400)/3600
163 nmin = mod(idts,3600)/60
167 if (scnew .ge. 60) then
172 if (minew .ge. 60) then
176 hrnew = hrold + nhour
177 if (hrnew .ge. 24) then
187 if (dynew.gt.mday(monew)) then
188 dynew = dynew - mday(monew)
190 if (monew .gt. 12) then
195 if (mod(yrnew,4).eq.0) then
197 if (mod(yrnew,100).eq.0) then
199 if (mod(yrnew,400).eq.0) then
209 ! Now construct the new mdate
214 write(ndate,19) yrnew, monew, dynew, hrnew, minew, scnew
215 19 format(I4,'-',I2.2,'-',I2.2,'_',I2.2,':',I2.2,':',I2.2)
217 else if (nlen.eq.16) then
218 write(ndate,16) yrnew, monew, dynew, hrnew, minew
219 16 format(I4,'-',I2.2,'-',I2.2,'_',I2.2,':',I2.2)
221 else if (nlen.eq.13) then
222 write(ndate,13) yrnew, monew, dynew, hrnew
223 13 format(I4,'-',I2.2,'-',I2.2,'_',I2.2)
225 else if (nlen.eq.10) then
226 write(ndate,10) yrnew, monew, dynew
227 10 format(I4,'-',I2.2,'-',I2.2)
231 !************************** Subroutine End **************************