da_change_date.inc

References to this file elsewhere.
1 subroutine da_change_date(ccyy, mm, dd, delta)
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !-----------------------------------------------------------------------
6 
7    implicit none
8 
9    integer, intent(inout) :: ccyy, mm, dd
10    integer, intent(in)    :: delta
11 
12    integer, dimension(12) :: mmday
13 
14    mmday = (/31,28,31,30,31,30,31,31,30,31,30,31/)
15 
16    mmday(2) = 28
17 
18    if (mod(ccyy,4) == 0) then
19       mmday(2) = 29
20 
21       if (mod(ccyy,100) == 0) then
22          mmday(2) = 28
23       end if
24 
25       if (mod(ccyy,400) == 0) then
26          mmday(2) = 29
27       end if
28    end if
29 
30    dd = dd + delta
31 
32    if (dd == 0) then
33       mm = mm - 1
34 
35       if (mm == 0) then
36          mm = 12
37          ccyy = ccyy - 1
38       end if
39 
40       dd = mmday(mm)
41    elseif (dd .gt. mmday(mm)) then
42       dd = 1
43       mm = mm + 1
44       if (mm > 12) then
45          mm = 1
46          ccyy = ccyy + 1
47       end if
48    end if
49 end subroutine da_change_date
50 
51