source: flexpart.git/src/caldate.f90

10.4.1_peseibugfixes+enhancementsrelease-10.4.1scaling-bug
Last change on this file was 17c3c47, checked in by Ignacio Pisso <ip@…>, 4 years ago

modify caldate.f90 in order to compile 477a094

  • Property mode set to 100644
File size: 3.5 KB
Line 
1! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt
2! SPDX-License-Identifier: GPL-3.0-or-later
3
4subroutine caldate(juldate,yyyymmdd,hhmiss)
5  !                      i       o       o
6  !*****************************************************************************
7  !                                                                            *
8  !     Calculates the Gregorian date from the Julian date                     *
9  !                                                                            *
10  !     AUTHOR: Andreas Stohl (21 January 1994), adapted from Numerical Recipes*
11  !                                                                            *
12  !     Variables:                                                             *
13  !     dd             Day                                                     *
14  !     hh             Hour                                                    *
15  !     hhmiss         Hour, Minute, Second                                    *
16  !     ja,jb,jc,jd,je help variables                                          *
17  !     jalpha         help variable                                           *
18  !     juldate        Julian Date                                             *
19  !     julday         help variable                                           *
20  !     mi             Minute                                                  *
21  !     mm             Month                                                   *
22  !     ss             Seconds                                                 *
23  !     yyyy           Year                                                    *
24  !     yyyymmdd       Year, Month, Day                                        *
25  !                                                                            *
26  !     Constants:                                                             *
27  !     igreg          help constant                                           *
28  !                                                                            *
29  !     PS 2020-07-27: add a check to avoid giving back 240000 for hhmiss      *
30  !                                                                            *
31  !*****************************************************************************
32
33  use par_mod, only: dp
34
35  implicit none
36
37  integer           :: yyyymmdd,yyyy,mm,dd,hhmiss,hh,mi,ss
38  integer           :: julday,ja,jb,jc,jd,je,jalpha
39  real(kind=dp)     :: juldate
40  integer,parameter :: igreg=2299161
41
42  julday=int(juldate)
43! PS check to avoid 240000 as hhmiss: 
44  if ((juldate-julday)*86400._dp .ge. 86399.5_dp) then
45    juldate = juldate + juldate-julday-86399.5_dp/86400._dp
46    julday=int(juldate)
47  endif
48  if(julday.ge.igreg)then
49    jalpha=int(((julday-1867216)-0.25)/36524.25)
50    ja=julday+1+jalpha-int(0.25*jalpha)
51  else
52    ja=julday
53  endif
54  jb=ja+1524
55  jc=int(6680.+((jb-2439870)-122.1)/365.25)
56  jd=365*jc+int(0.25*jc)
57  je=int((jb-jd)/30.6001)
58  dd=jb-jd-int(30.6001*je)
59  mm=je-1
60  if (mm.gt.12) mm=mm-12
61  yyyy=jc-4715
62  if (mm.gt.2) yyyy=yyyy-1
63  if (yyyy.le.0) yyyy=yyyy-1
64
65  yyyymmdd=10000*yyyy+100*mm+dd
66  hh=int(24._dp*(juldate-real(julday,kind=dp)))
67  mi=int(1440._dp*(juldate-real(julday,kind=dp))-60._dp*real(hh,kind=dp))
68  ss=nint(86400._dp*(juldate-real(julday,kind=dp))-3600._dp*real(hh,kind=dp)- &
69       60._dp*real(mi,kind=dp))
70  if (ss.eq.60) then  ! 60 seconds = 1 minute
71    ss=0
72    mi=mi+1
73  endif
74  if (mi.eq.60) then
75    mi=0
76    hh=hh+1
77  endif
78  hhmiss=10000*hh+100*mi+ss
79
80end subroutine caldate
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG