source: flexpart.git/src/caldate.f90 @ 3481cc1

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

move license from headers to a different file

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