1 | SUBROUTINE greg2jul( ksec, kmin, khour, kday, kmonth, kyear, pjulian, & |
---|
2 | & krefdate ) |
---|
3 | !!----------------------------------------------------------------------- |
---|
4 | !! |
---|
5 | !! *** ROUTINE greg2jul *** |
---|
6 | !! |
---|
7 | !! ** Purpose : Produce the time relative to the current date and time. |
---|
8 | !! |
---|
9 | !! ** Method : The units are days, so hours and minutes transform to |
---|
10 | !! fractions of a day. |
---|
11 | !! |
---|
12 | !! Reference date : 19500101 |
---|
13 | !! ** Action : |
---|
14 | !! |
---|
15 | !! History : |
---|
16 | !! ! 06-04 (A. Vidard) Original |
---|
17 | !! ! 06-04 (A. Vidard) Reformatted |
---|
18 | !! ! 06-10 (A. Weaver) Cleanup |
---|
19 | !!----------------------------------------------------------------------- |
---|
20 | |
---|
21 | ! * Arguments |
---|
22 | INTEGER, INTENT(IN) :: & |
---|
23 | & ksec, & |
---|
24 | & kmin, & |
---|
25 | & khour, & |
---|
26 | & kday, & |
---|
27 | & kmonth, & |
---|
28 | & kyear |
---|
29 | REAL(KIND=dp), INTENT(OUT) :: & |
---|
30 | & pjulian |
---|
31 | INTEGER, INTENT(IN), OPTIONAL :: & |
---|
32 | & krefdate |
---|
33 | |
---|
34 | !! * Local declarations |
---|
35 | INTEGER, PARAMETER :: & |
---|
36 | & jpgreg = 15 + 31 * ( 10 + 12 * 1582 ), & ! Gregorian calendar introduction date |
---|
37 | & jporef = 2433283, & ! Julian reference date: 19500101 |
---|
38 | & jparef = 2415021, & ! Julian reference date: 19000101 |
---|
39 | & jpgref = 2299161 ! Julian reference date start of Gregorian calender |
---|
40 | INTEGER :: & |
---|
41 | & ija, & |
---|
42 | & ijy, & |
---|
43 | & ijm, & |
---|
44 | & ijultmp, & |
---|
45 | & ijyear, & |
---|
46 | & iref |
---|
47 | CHARACTER(len=200) :: & |
---|
48 | & cerr |
---|
49 | |
---|
50 | IF ( PRESENT( krefdate ) ) THEN |
---|
51 | SELECT CASE ( krefdate ) |
---|
52 | |
---|
53 | CASE( 0 ) |
---|
54 | iref = jpgref |
---|
55 | |
---|
56 | CASE( 19500101 ) |
---|
57 | iref = jporef |
---|
58 | |
---|
59 | CASE( 19000101 ) |
---|
60 | iref = jparef |
---|
61 | |
---|
62 | CASE DEFAULT |
---|
63 | WRITE(cerr,'(A,I8.8)')'greg2jul: Unknown krefdate:', krefdate |
---|
64 | CALL ctl_stop( cerr ) |
---|
65 | |
---|
66 | END SELECT |
---|
67 | |
---|
68 | ELSE |
---|
69 | iref = jporef |
---|
70 | ENDIF |
---|
71 | |
---|
72 | ! Main computation |
---|
73 | ijyear = kyear |
---|
74 | IF ( ijyear < 0 ) ijyear = ijyear + 1 |
---|
75 | IF ( kmonth > 2 ) THEN |
---|
76 | ijy = ijyear |
---|
77 | ijm = kmonth + 1 |
---|
78 | ELSE |
---|
79 | ijy = ijyear - 1 |
---|
80 | ijm = kmonth + 13 |
---|
81 | ENDIF |
---|
82 | ijultmp = INT( 365.25 * ijy ) + INT( 30.6001 * ijm ) + kday + 1720995 |
---|
83 | IF ( kday + 31 * ( kmonth + 12 * ijyear ) >= jpgreg ) THEN |
---|
84 | ija = INT( 0.01 * ijy ) |
---|
85 | ijultmp = ijultmp + 2 - ija + INT( 0.25 * ija ) |
---|
86 | ENDIF |
---|
87 | pjulian = ( ijultmp - iref ) + ( ( 60 * khour + kmin ) * 60 + ksec ) / 86400. |
---|
88 | |
---|
89 | END SUBROUTINE greg2jul |
---|