[5f2e8f6] | 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, Ignacio Pisso * |
---|
| 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 | DOUBLE PRECISION FUNCTION juldate(YYYYMMDD,HHMISS) |
---|
| 26 | !* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
---|
| 27 | !* * |
---|
| 28 | !* Calculates days from a starting date using a no leap calendar * |
---|
| 29 | !* NOTE this is not really a julian date but we kept the name of * |
---|
| 30 | !* the original FLEXPART routine, see commennts below if * |
---|
| 31 | !* one needs it to be a real julian date routine * |
---|
| 32 | !* NOTE: read comments below if one wants to include leap years * |
---|
| 33 | !* NOTE: read comments below if one wants to a real juldate with * |
---|
| 34 | !* gregorian calndar |
---|
| 35 | !* * |
---|
| 36 | !* AUTHOR: Massimo Cassiani 2016 * |
---|
| 37 | !* * |
---|
| 38 | !* Variables: * |
---|
| 39 | !* DD Day * |
---|
| 40 | !* HH Hour * |
---|
| 41 | !* HHMISS Hour, minute + second * |
---|
| 42 | !* JA,JM,JY help variables * |
---|
| 43 | !* juldate "julian date" from arbitrary starting date yearzer * |
---|
| 44 | !* JULDAY help variable * |
---|
| 45 | !* MI Minute * |
---|
| 46 | !* MM Month * |
---|
| 47 | !* SS Second * |
---|
| 48 | !* YYYY Year * |
---|
| 49 | !* YYYYMMDDHH Date and Time * |
---|
| 50 | !* * |
---|
| 51 | !* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
---|
| 52 | use par_mod |
---|
| 53 | IMPLICIT NONE |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | INTEGER YYYYMMDD,YYYY,MM,DD,HH,MI,SS,HHMISS |
---|
| 57 | INTEGER JULDAY,JY,JM,JA,IGREG,YYYY1,MM1 |
---|
| 58 | INTEGER AP,MP,DPM,YAP |
---|
| 59 | ! DOUBLE PRECISION juldate |
---|
| 60 | ! PARAMETER (IGREG=15+31*(10+12*1582)) |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | YYYY=YYYYMMDD/10000 |
---|
| 64 | !YYYY1=YYYYMMDD/10000 |
---|
| 65 | MM=(YYYYMMDD-10000*YYYY)/100 |
---|
| 66 | !MM1=(YYYYMMDD-10000*YYYY)/100 |
---|
| 67 | DD=YYYYMMDD-10000*YYYY-100*MM |
---|
| 68 | HH=HHMISS/10000 |
---|
| 69 | MI=(HHMISS-10000*HH)/100 |
---|
| 70 | SS=HHMISS-10000*HH-100*MI |
---|
| 71 | IF (YYYY.EQ.0) PAUSE & |
---|
| 72 | 'There is Year ZERO? then modify JULDATE_NOLEAP routine!!!' |
---|
| 73 | AP= (14- MM)/12 ! will result in a 1 for January (month 1) and February (month 2). The result is 0 for the other 10 months. |
---|
| 74 | MP=MM +12*AP-3 ! results in a 10 for January, 11 for February, 0 for March, 1 for April, ..., and a 9 for December |
---|
| 75 | DPM=(153*MP+2)/5 ! will give the number of days in the previous months starting from month zero |
---|
| 76 | YAP= YYYY - yearorigin - AP !adds yearorigin to the year so that we will start counting years from the year (yearorigin=-YYYY) |
---|
| 77 | !note that year 1 corresponds to 1 CE, year 0 corresponds to 1 BCE, year 1 corresponds to 2 BCE, and so onThere is no year between 1 CE and 1 BCE |
---|
| 78 | JULDAY=DD+DPM+365*YAP !+ YAP/4-YAP/100+YAP/400 !add this part if you want to count leap year: |
---|
| 79 | !-32405 !!NOTE, subtract this further number and put origin to 4800 BCE if you want true julian date starting at 4713 BCE (24 nov 4714BC). The -32045 comes from (4800-4712)*365+22 (leap years) - (6+31)(nov+dec) - (31+29) (jan+feb_leap) |
---|
| 80 | JULDAY=JULDAY+59-365 !-59 for correcting from starting 1 of march see MP. -365 because we consider that there is no zero year. |
---|
| 81 | !NOte put this correction to zero i.e. JULDAY=JULDAY and look comments just above if you want true julian date from gregorian calendar with no zero. |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | juldate=DBLE((JULDAY))+DBLE(DBLE(HH)/24.)+ & |
---|
| 85 | DBLE(DBLE(MI)/1440.)+DBLE(DBLE(SS)/86400.) |
---|
| 86 | |
---|
| 87 | RETURN |
---|
| 88 | END |
---|