1 subroutine da_atotime(date_char, st)
3 !-----------------------------------------------------------------------
4 ! Purpose: Input a date character string in WRF format (CCYY-MM-DD_hh:mm:ss)
5 ! Output the number of seconds since Dec 31, 1999, 00:00:00
6 !-----------------------------------------------------------------------
10 character(len=*), intent(in) :: date_char
11 real, intent(out) :: st
13 integer :: ccyy,mo,dd,hh,mi,ss,i
14 integer, dimension(12) :: mmday
15 integer :: dayssince2000
17 mmday=(/31,28,31,30,31,30,31,31,30,31,30,31/)
19 read(date_char(1:19),'(i4,1x,4(i2,1x),i2)') &
20 ccyy, mo, dd, hh, mi, ss
22 if (mod(ccyy,4) == 0) then
24 if (mod(ccyy,400) == 0) then
26 else if (mod(ccyy,100) == 0) then
33 ! This set of if statements sets "dayssince2000" to the number of days from the beginning of
34 ! the year 2000 to the beginning of the current year (for example, 2000 returns "0",
35 ! 2001 returns 366, 2012 returns 4018, 1999 returns -365, etc.)
38 dayssince2000 = dayssince2000 - 365
40 !If statements to cover leap year cases
41 if (mod(i,4) == 0) then
42 dayssince2000 = dayssince2000 - 1
43 if (mod(i,100) == 0) then
44 dayssince2000 = dayssince2000 + 1
45 if (mod(i,400) == 0) then
46 dayssince2000 = dayssince2000 - 1
51 else if (ccyy > 2000) then
53 dayssince2000 = dayssince2000 + 365
55 !If statements to cover leap year cases
56 if (mod(i,4) == 0) then
57 dayssince2000 = dayssince2000 + 1
58 if (mod(i,100) == 0) then
59 dayssince2000 = dayssince2000 - 1
60 if (mod(i,400) == 0) then
61 dayssince2000 = dayssince2000 + 1
74 st = real(ss) + 60.0*(real(mi) + 60.0*(real(hh) + 24.0* real(dd)))
76 end subroutine da_atotime