/[lmdze]/trunk/IOIPSL/Calendar/ymds2ju_internal.f
ViewVC logotype

Contents of /trunk/IOIPSL/Calendar/ymds2ju_internal.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92 - (show annotations)
Wed Mar 26 18:16:05 2014 UTC (10 years, 2 months ago) by guez
File size: 2205 byte(s)
Extracted procedures that were in module calendar into separate files.

1 module ymds2ju_internal_m
2
3 implicit none
4
5 contains
6
7 SUBROUTINE ymds2ju_internal (year, month, day, sec, julian_day, julian_sec)
8
9 ! Converts year, month, day and seconds into a julian day
10
11 ! In 1968 in a letter to the editor of Communications of the ACM
12 ! (CACM, volume 11, number 10, October 1968, p.657) Henry F. Fliegel
13 ! and Thomas C. Van Flandern presented such an algorithm.
14
15 ! See also: http://www.magnet.ch/serendipity/hermetic/cal_stud/jdn.htm
16
17 ! In the case of the Gregorian calendar we have chosen to use
18 ! the Lilian day numbers. This is the day counter which starts
19 ! on the 15th October 1582.
20 ! This is the day at which Pope Gregory XIII introduced the
21 ! Gregorian calendar.
22 ! Compared to the true Julian calendar, which starts some
23 ! 7980 years ago, the Lilian days are smaler and are dealt with
24 ! easily on 32 bit machines. With the true Julian days you can only
25 ! the fraction of the day in the real part to a precision of
26 ! a 1/4 of a day with 32 bits.
27
28 use calendar
29
30 INTEGER, INTENT(IN):: year, month, day
31 REAL, INTENT(IN):: sec
32
33 INTEGER, INTENT(OUT):: julian_day
34 REAL, INTENT(OUT):: julian_sec
35
36 INTEGER:: jd, m, y, d, ml
37 !--------------------------------------------------------------------
38 lock_unan = .TRUE.
39
40 m = month
41 y = year
42 d = day
43
44 ! We deduce the calendar from the length of the year as it
45 ! is faster than an INDEX on the calendar variable.
46
47 ! Gregorian
48 IF ( (un_an > 365.0).AND.(un_an < 366.0) ) THEN
49 jd = (1461*(y+4800+INT(( m-14 )/12)))/4 &
50 & +(367*(m-2-12*(INT(( m-14 )/12))))/12 &
51 & -(3*((y+4900+INT((m-14)/12))/100))/4 &
52 & +d-32075
53 jd = jd-2299160
54 ! No leap or All leap
55 ELSE IF (ABS(un_an-365.0) <= EPSILON(un_an) .OR. &
56 & ABS(un_an-366.0) <= EPSILON(un_an)) THEN
57 ml = SUM(mon_len(1:m-1))
58 jd = y*INT(un_an)+ml+(d-1)
59 ! Calendar with regular month
60 ELSE
61 ml = INT(un_an)/12
62 jd = y*INT(un_an)+(m-1)*ml+(d-1)
63 ENDIF
64
65 julian_day = jd
66 julian_sec = sec
67
68 END SUBROUTINE ymds2ju_internal
69
70 end module ymds2ju_internal_m

  ViewVC Help
Powered by ViewVC 1.1.21