da_julian_day.inc

References to this file elsewhere.
1 subroutine da_julian_day(NY,NM,ND,JD,METHOD) 
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    ! method = 1: input ---- ny, nm, nd.  output ---- jd                         
6    ! method = 2: input ---- ny, jd.      output ---- nm, nd            
7    !----------------------------------------------------------------------- 
8     
9    implicit none
10 
11    integer,  intent(in)    :: METHOD, NY
12    integer,  intent(inout) :: NM, ND, JD
13 
14    integer                 :: LOOP
15    integer, dimension(12)  :: MDAY = (/31,28,31,30,31,30,31,31,30,31,30,31/)
16 
17    if (MOD(NY,4) == 0) then
18       MDAY(2)=29      
19       if (MOD(NY,100) == 0) then
20          MDAY(2)=28
21          if (MOD(NY,400) == 0) then
22             MDAY(2)=29
23          end if
24       end if
25    end if
26 
27    if (METHOD == 1) then                  
28       JD=ND
29       JuDAY: do LOOP=1,NM-1                  
30          JD=JD+MDAY(LOOP)                
31       end do JuDAY                           
32    else if (METHOD == 2) then             
33       NM=1                               
34       ND=JD
35       do LOOP=1,11                    
36          if (ND <= MDAY(LOOP)) exit
37 
38          ND=ND-MDAY(LOOP)     
39          NM=NM+1                      
40       end do
41    end if                                
42 
43 end subroutine da_julian_day
44 
45