/[lmdze]/trunk/IOIPSL/Calendar/ymds2ju.f90
ViewVC logotype

Contents of /trunk/IOIPSL/Calendar/ymds2ju.f90

Parent Directory Parent Directory | Revision Log Revision Log


Revision 335 - (show annotations)
Thu Sep 12 21:22:46 2019 UTC (4 years, 9 months ago) by guez
File size: 2173 byte(s)
Julian dates be in double precision

`ConfigureCompilerFlags.cmake` and `TAGS.cmake` are now copied into
LMDZE, to avoid dependency on the environment.

Julian dates must be in double precision, to get time step precision.

Add optional attribute to argument sec of procedure ju2ymds. We do
not need sec in procedure dynredem0.

In procedure ju2ymds, by construction, sec cannot be > `un_jour`.

Remove useless intermediary variables in procedure ymds2ju.

1 module ymds2ju_m
2
3 implicit none
4
5 contains
6
7 SUBROUTINE ymds2ju(year, month, day, sec, julian)
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, ONLY: lock_unan, un_jour
29 USE ioconf_calendar_m, ONLY: mon_len, un_an
30
31 INTEGER, INTENT(IN):: year, month, day
32 REAL, INTENT(IN):: sec
33 double precision, INTENT(OUT):: julian
34
35 ! Local:
36 INTEGER jd, ml
37
38 !--------------------------------------------------------------------
39
40 lock_unan = .TRUE.
41
42 ! We deduce the calendar from the length of the year as it
43 ! is faster than an INDEX on the calendar variable.
44
45 ! Gregorian
46 IF ( (un_an > 365.0).AND.(un_an < 366.0) ) THEN
47 jd = (1461*(year+4800+INT(( month-14 )/12)))/4 &
48 +(367*(month-2-12*(INT(( month-14 )/12))))/12 &
49 -(3*((year+4900+INT((month-14)/12))/100))/4 &
50 +day-32075
51 jd = jd-2299160
52 ! No leap or All leap
53 ELSE IF (ABS(un_an-365.0) <= EPSILON(un_an) .OR. &
54 ABS(un_an-366.0) <= EPSILON(un_an)) THEN
55 ml = SUM(mon_len(1:month-1))
56 jd = year*INT(un_an)+ml+(day-1)
57 ! Calendar with regular month
58 ELSE
59 ml = INT(un_an)/12
60 jd = year*INT(un_an)+(month-1)*ml+(day-1)
61 ENDIF
62
63 julian = dble(jd) + sec / un_jour
64
65 END SUBROUTINE ymds2ju
66
67 end module ymds2ju_m

  ViewVC Help
Powered by ViewVC 1.1.21