1 | !********************************************************************** |
---|
2 | ! Copyright 2016 * |
---|
3 | ! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, * |
---|
4 | ! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, * |
---|
5 | ! Harald Sodemann * |
---|
6 | ! * |
---|
7 | ! This file is part of FLEXPART-NorESM * |
---|
8 | ! * |
---|
9 | ! FLEXPART-NorESM is free software: you can redistribute it * |
---|
10 | ! and/or modify * |
---|
11 | ! it under the terms of the GNU General Public License as published by* |
---|
12 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
13 | ! (at your option) any later version. * |
---|
14 | ! * |
---|
15 | ! FLEXPART-NorESM is distributed in the hope that it will be useful, * |
---|
16 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
17 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
18 | ! GNU General Public License for more details. * |
---|
19 | ! * |
---|
20 | ! You should have received a copy of the GNU General Public License * |
---|
21 | ! along with FLEXPART-NorESM. * |
---|
22 | ! If not, see <http://www.gnu.org/licenses/>. * |
---|
23 | !********************************************************************** |
---|
24 | |
---|
25 | |
---|
26 | SUBROUTINE CALDATE(JULDATE,YYYYMMDD,HHMISS) |
---|
27 | !c i o o |
---|
28 | ! |
---|
29 | !* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
---|
30 | !* * |
---|
31 | !* Calculates a pseudo-Gregorian date (from year zero) using the * |
---|
32 | !* juldate varaiable * |
---|
33 | !* juldate actually contains days from arbitrary origin date (yearorigin) * |
---|
34 | !* using no leap calendar * |
---|
35 | !* Author: * |
---|
36 | !* M. Cassiani 2016 * |
---|
37 | !* * |
---|
38 | !* * |
---|
39 | ! * |
---|
40 | !* * |
---|
41 | !* * |
---|
42 | ! Variables: * |
---|
43 | !* DD Day * |
---|
44 | !* HH Hour * |
---|
45 | !* HHMISS Hour, Minute, Second * |
---|
46 | !* JA,JB,JC,JD,JE help variables * |
---|
47 | !* JALPHA help variable * |
---|
48 | !* JULDATE Julian Date * |
---|
49 | !* JULDAY help variable * |
---|
50 | !* MI Minute * |
---|
51 | !* MM Month * |
---|
52 | !* SS Seconds * |
---|
53 | !* YYYY Year * |
---|
54 | !* YYYYMMDD Year, Month, Day * |
---|
55 | !* * |
---|
56 | !* Constants: * |
---|
57 | !* IGREG help constant * |
---|
58 | !* * |
---|
59 | !* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
---|
60 | use par_mod |
---|
61 | IMPLICIT NONE |
---|
62 | |
---|
63 | INTEGER YYYYMMDD,YYYY,MM,DD,HHMISS,HH,MI,SS |
---|
64 | INTEGER JULDAY,JA,JB,JC,JD,JE,IGREG,JALPHA,DAYS,ddpm |
---|
65 | DOUBLE PRECISION JULDATE |
---|
66 | INTEGER daysannozero |
---|
67 | |
---|
68 | |
---|
69 | YYYY=INT(JULDATE)/365 |
---|
70 | |
---|
71 | |
---|
72 | JULDAY=INT(JULDATE) |
---|
73 | DAYS=JULDAY-YYYY*365 |
---|
74 | if (DAYS.gt.59) then |
---|
75 | MM=int((((DAYS-0.1-59.)*5.)-2.)/153.) |
---|
76 | ddpm=((153*MM)+2)/5 |
---|
77 | DD=DAYS-ddpm-59 |
---|
78 | else |
---|
79 | MM=int((((DAYS-0.1+306.)*5.)-2.)/153.) |
---|
80 | ddpm=((153*MM)+2)/5 |
---|
81 | DD=DAYS+306-ddpm |
---|
82 | end if |
---|
83 | |
---|
84 | if (MM.le.9) then |
---|
85 | MM=MM+3 |
---|
86 | else |
---|
87 | MM=MM-9 |
---|
88 | end if |
---|
89 | |
---|
90 | YYYY=YYYY+yearorigin |
---|
91 | if (YYYY.ge.0.and.DAYS.ne.0) YYYY=YYYY+1 |
---|
92 | |
---|
93 | |
---|
94 | YYYYMMDD=10000*YYYY+100*MM+DD |
---|
95 | |
---|
96 | HH=INT(24.*(JULDATE-FLOAT(JULDAY))) |
---|
97 | MI=INT(1440.*(JULDATE-FLOAT(JULDAY))-60.*FLOAT(HH)) |
---|
98 | SS=NINT(86400.*(JULDATE-FLOAT(JULDAY))-3600.*FLOAT(HH)) & |
---|
99 | -60.*FLOAT(MI) |
---|
100 | IF (SS.EQ.60) THEN ! 60 seconds = 1 minute |
---|
101 | SS=0 |
---|
102 | MI=MI+1 |
---|
103 | ENDIF |
---|
104 | IF (MI.EQ.60) THEN |
---|
105 | MI=0 |
---|
106 | HH=HH+1 |
---|
107 | ENDIF |
---|
108 | HHMISS=10000*HH+100*MI+SS |
---|
109 | |
---|
110 | END |
---|