1 | !********************************************************************** |
---|
2 | ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 * |
---|
3 | ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, * |
---|
4 | ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann * |
---|
5 | ! * |
---|
6 | ! This file is part of FLEXPART. * |
---|
7 | ! * |
---|
8 | ! FLEXPART is free software: you can redistribute it and/or modify * |
---|
9 | ! it under the terms of the GNU General Public License as published by* |
---|
10 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
11 | ! (at your option) any later version. * |
---|
12 | ! * |
---|
13 | ! FLEXPART is distributed in the hope that it will be useful, * |
---|
14 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
15 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
16 | ! GNU General Public License for more details. * |
---|
17 | ! * |
---|
18 | ! You should have received a copy of the GNU General Public License * |
---|
19 | ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. * |
---|
20 | !********************************************************************** |
---|
21 | |
---|
22 | subroutine caldate(juldate,yyyymmdd,hhmiss) |
---|
23 | ! i o o |
---|
24 | !***************************************************************************** |
---|
25 | ! * |
---|
26 | ! Calculates the Gregorian date from the Julian date * |
---|
27 | ! * |
---|
28 | ! AUTHOR: Andreas Stohl (21 January 1994), adapted from Numerical Recipes* |
---|
29 | ! * |
---|
30 | ! Variables: * |
---|
31 | ! dd Day * |
---|
32 | ! hh Hour * |
---|
33 | ! hhmiss Hour, Minute, Second * |
---|
34 | ! ja,jb,jc,jd,je help variables * |
---|
35 | ! jalpha help variable * |
---|
36 | ! juldate Julian Date * |
---|
37 | ! julday help variable * |
---|
38 | ! mi Minute * |
---|
39 | ! mm Month * |
---|
40 | ! ss Seconds * |
---|
41 | ! yyyy Year * |
---|
42 | ! yyyymmdd Year, Month, Day * |
---|
43 | ! * |
---|
44 | ! Constants: * |
---|
45 | ! igreg help constant * |
---|
46 | ! * |
---|
47 | !***************************************************************************** |
---|
48 | |
---|
49 | use par_mod, only: dp |
---|
50 | |
---|
51 | implicit none |
---|
52 | |
---|
53 | integer :: yyyymmdd,yyyy,mm,dd,hhmiss,hh,mi,ss |
---|
54 | integer :: julday,ja,jb,jc,jd,je,jalpha |
---|
55 | real(kind=dp) :: juldate |
---|
56 | integer,parameter :: igreg=2299161 |
---|
57 | |
---|
58 | julday=int(juldate) |
---|
59 | if(julday.ge.igreg)then |
---|
60 | jalpha=int(((julday-1867216)-0.25)/36524.25) |
---|
61 | ja=julday+1+jalpha-int(0.25*jalpha) |
---|
62 | else |
---|
63 | ja=julday |
---|
64 | endif |
---|
65 | jb=ja+1524 |
---|
66 | jc=int(6680.+((jb-2439870)-122.1)/365.25) |
---|
67 | jd=365*jc+int(0.25*jc) |
---|
68 | je=int((jb-jd)/30.6001) |
---|
69 | dd=jb-jd-int(30.6001*je) |
---|
70 | mm=je-1 |
---|
71 | if (mm.gt.12) mm=mm-12 |
---|
72 | yyyy=jc-4715 |
---|
73 | if (mm.gt.2) yyyy=yyyy-1 |
---|
74 | if (yyyy.le.0) yyyy=yyyy-1 |
---|
75 | |
---|
76 | yyyymmdd=10000*yyyy+100*mm+dd |
---|
77 | hh=int(24._dp*(juldate-real(julday,kind=dp))) |
---|
78 | mi=int(1440._dp*(juldate-real(julday,kind=dp))-60._dp*real(hh,kind=dp)) |
---|
79 | ss=nint(86400._dp*(juldate-real(julday,kind=dp))-3600._dp*real(hh,kind=dp)- & |
---|
80 | 60._dp*real(mi,kind=dp)) |
---|
81 | if (ss.eq.60) then ! 60 seconds = 1 minute |
---|
82 | ss=0 |
---|
83 | mi=mi+1 |
---|
84 | endif |
---|
85 | if (mi.eq.60) then |
---|
86 | mi=0 |
---|
87 | hh=hh+1 |
---|
88 | endif |
---|
89 | hhmiss=10000*hh+100*mi+ss |
---|
90 | |
---|
91 | end subroutine caldate |
---|