source: trunk/src/juldate.f90 @ 28

Last change on this file since 28 was 4, checked in by mlanger, 11 years ago
File size: 4.1 KB
Line 
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
22function juldate(yyyymmdd,hhmiss)
23
24  !*****************************************************************************
25  !                                                                            *
26  !     Calculates the Julian date                                             *
27  !                                                                            *
28  !     AUTHOR: Andreas Stohl (15 October 1993)                                *
29  !                                                                            *
30  !     Variables:                                                             *
31  !     dd             Day                                                     *
32  !     hh             Hour                                                    *
33  !     hhmiss         Hour, minute + second                                   *
34  !     ja,jm,jy       help variables                                          *
35  !     juldate        Julian Date                                             *
36  !     julday         help variable                                           *
37  !     mi             Minute                                                  *
38  !     mm             Month                                                   *
39  !     ss             Second                                                  *
40  !     yyyy           Year                                                    *
41  !     yyyymmddhh     Date and Time                                           *
42  !                                                                            *
43  !     Constants:                                                             *
44  !     igreg          help constant                                           *
45  !                                                                            *
46  !*****************************************************************************
47
48  use par_mod, only: dp
49
50  implicit none
51
52  integer           :: yyyymmdd,yyyy,mm,dd,hh,mi,ss,hhmiss
53  integer           :: julday,jy,jm,ja
54  integer,parameter :: igreg=15+31*(10+12*1582)
55  real(kind=dp)     :: juldate
56
57  yyyy=yyyymmdd/10000
58  mm=(yyyymmdd-10000*yyyy)/100
59  dd=yyyymmdd-10000*yyyy-100*mm
60  hh=hhmiss/10000
61  mi=(hhmiss-10000*hh)/100
62  ss=hhmiss-10000*hh-100*mi
63
64  if (yyyy.eq.0) then
65     print*, 'there is no year zero.'
66     stop
67  end if
68  if (yyyy.lt.0) yyyy=yyyy+1
69  if (mm.gt.2) then
70    jy=yyyy
71    jm=mm+1
72  else
73    jy=yyyy-1
74    jm=mm+13
75  endif
76  julday=int(365.25*jy)+int(30.6001*jm)+dd+1720995
77  if (dd+31*(mm+12*yyyy).ge.igreg) then
78    ja=int(0.01*jy)
79    julday=julday+2-ja+int(0.25*ja)
80  endif
81
82  juldate=real(julday,kind=dp)   + real(hh,kind=dp)/24._dp + &
83       real(mi,kind=dp)/1440._dp  + real(ss,kind=dp)/86400._dp
84
85end function juldate
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG