source: flexpart.git/src/caldate.f90 @ 92fab65

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bug
Last change on this file since 92fab65 was 92fab65, checked in by Ignacio Pisso <ip@…>, 4 years ago

add SPDX-License-Identifier to all .f90 files

  • Property mode set to 100644
File size: 3.1 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  !*****************************************************************************
30
31  use par_mod, only: dp
32
33  implicit none
34
35  integer           :: yyyymmdd,yyyy,mm,dd,hhmiss,hh,mi,ss
36  integer           :: julday,ja,jb,jc,jd,je,jalpha
37  real(kind=dp)     :: juldate
38  integer,parameter :: igreg=2299161
39
40  julday=int(juldate)
41  if(julday.ge.igreg)then
42    jalpha=int(((julday-1867216)-0.25)/36524.25)
43    ja=julday+1+jalpha-int(0.25*jalpha)
44  else
45    ja=julday
46  endif
47  jb=ja+1524
48  jc=int(6680.+((jb-2439870)-122.1)/365.25)
49  jd=365*jc+int(0.25*jc)
50  je=int((jb-jd)/30.6001)
51  dd=jb-jd-int(30.6001*je)
52  mm=je-1
53  if (mm.gt.12) mm=mm-12
54  yyyy=jc-4715
55  if (mm.gt.2) yyyy=yyyy-1
56  if (yyyy.le.0) yyyy=yyyy-1
57
58  yyyymmdd=10000*yyyy+100*mm+dd
59  hh=int(24._dp*(juldate-real(julday,kind=dp)))
60  mi=int(1440._dp*(juldate-real(julday,kind=dp))-60._dp*real(hh,kind=dp))
61  ss=nint(86400._dp*(juldate-real(julday,kind=dp))-3600._dp*real(hh,kind=dp)- &
62       60._dp*real(mi,kind=dp))
63  if (ss.eq.60) then  ! 60 seconds = 1 minute
64    ss=0
65    mi=mi+1
66  endif
67  if (mi.eq.60) then
68    mi=0
69    hh=hh+1
70  endif
71  hhmiss=10000*hh+100*mi+ss
72
73end subroutine caldate
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG