45 real(
double),
intent(in) :: dd
46 integer,
intent(in) :: yy,mm
49 integer :: y,m,a,b,greg
56 if(y.gt.1582) greg = 1
59 if((m.eq.10).and.(d.ge.15)) greg = 1
71 b = 2 - a + floor(a/4.d0)
74 cal2jd = floor(365.25d0*(y+4716)) + floor(30.6001d0*(m+1)) + d + b - 1524.5d0
89 elemental subroutine jd2cal(jd, yy,mm,dd)
93 real(
double),
intent(in) :: jd
94 integer,
intent(out) :: yy,mm
95 real(
double),
intent(out) :: dd
97 integer(long) :: z,a,b,c,d,e,alpha
100 if(jd.gt.abs(huge(jd))*0.1_dbl)
then
110 if(z.lt.2299161)
then
113 alpha = floor((z-1867216.25d0)/36524.25d0)
114 a = z + 1 + alpha - floor(alpha/4.d0)
118 c = floor((b - 122.1d0)/365.25d0)
119 d = floor(365.25d0*c)
120 e = floor((b-d)/30.6001d0)
121 dd = b - d - floor(30.6001d0*e) + f
89 elemental subroutine jd2cal(jd, yy,mm,dd)
…
153 real(
double),
intent(in) :: year
161 if(year .gt. 1582.d0+278.d0/365.25d0)
then
163 b = 2 - a + floor(a/4.d0)
166 year2jd = floor(365.25d0*(y+4716)) + floor(30.6001d0*14) + b - 1523.5d0
189 real(
double),
intent(in) :: jd
190 integer,
intent(out) :: yy,mm,d,h,m
191 real(
double),
intent(out) :: s
197 if(yy.eq.0.and.mm.eq.0)
then
206 tm = (dd - dble(d))*24.d0
208 m = floor((tm-h)*60.d0)
209 s = (tm-h-m/60.d0)*3600.d0
225 real(
double),
intent(in) :: jd
230 call jd2cal(jd, yr,mnt,day)
231 write(
jd2datestr,
'(I0,A1,2(I2.2,A1))') yr,
'-',mnt,
'-',floor(day)
247 real(
double),
intent(in) :: jd
252 jd2time = (dd - floor(dd))*24.d0
269 real(
double),
intent(in) :: jd
277 dy = (jd-jd0) / (jd1-jd0)
299 real(
double),
intent(in) :: jd
300 real(
double),
intent(out) :: time
301 integer,
intent(out) :: year,month,day
304 call jd2cal(jd, year,month,dd)
306 time = (dd - dble(day))*24.d0
329 integer,
intent(in) :: yy,mmo,dd,h,m
330 real(
double),
intent(in) :: s
338 d = dble(dd) + dble(h)/24.d0 + dble(m)/1440.d0 + s/86400.d0
360 integer,
intent(inout) :: year,month,day, hour,minute
361 real(
double),
intent(inout) :: second
364 jd =
ymdhms2jd(year,month,day, hour,minute,second)
365 call jd2ymdhms(jd, year,month,day, hour,minute,second)
384 integer,
intent(in) :: yy,mo,dd
385 real(
double),
intent(in) :: time
388 d = dble(dd) + time/24.d0
408 real(
double),
intent(in) :: tm
409 integer,
intent(out) :: h,m
412 m = nint((tm-dble(h))*60)
435 real(
double),
intent(in) :: tm
436 integer,
intent(out) :: h
437 real(
double),
intent(out) :: m
460 real(
double),
intent(in) :: tm
461 integer,
intent(out) :: h,m,s
464 m = floor((tm-dble(h))*60)
465 s = nint((tm - dble(h) - dble(m)/60.d0)*3600)
494 real(
double),
intent(in) :: tm
495 integer,
intent(out) :: h,m
496 real(
double),
intent(out) :: s
499 m = floor((tm-dble(h))*60)
500 s = (tm - dble(h) - dble(m)/60.d0)*3600
524 real(
double),
intent(in) :: jd0
528 jd = dble(nint(jd0)) - 0.5d0
529 x = (jd + 1.5d0)/7.d0
531 dow_ut = nint(jd + 1.5d0 - floor(x)*7.d0)
547 real(
double),
intent(in) :: jd0
563 elemental function doy(jd0)
567 real(
double),
intent(in) :: jd0
568 integer ::
doy,yr,mon
571 call jd2cal(jd0, yr,mon,dy)
592 integer,
intent(in) :: yr,mon,dy
596 jd0 =
cal2jd(yr,mon,dble(dy))
615 elemental subroutine doy2md(doy,yr, mon,dy)
619 integer,
intent(in) ::
doy,yr
620 integer,
intent(out) :: mon,dy
625 call jd2cal(jd1,yr1,mon,dy1)
643 integer,
intent(in) :: yr
664 real(
double),
intent(in) :: jd
665 real(
double),
intent(in),
optional :: tz
667 integer :: dy,yr,mon, hr,mn,se, tzhr,tzmn
668 real(
double) :: day, time, ltz
671 if(
present(tz)) ltz = tz
673 call jd2cal(jd + ltz/24.d0, yr,mon,day)
675 time = (day - dble(dy)) * 24.d0
676 call tm2hms(time, hr,mn,se)
677 call tm2hm(abs(ltz), tzhr,tzmn)
680 if(ltz.lt.0.d0) tzsign =
'-'
682 write(
jd2iso8601,
'(I0, 7(A1,I2.2) )') yr,
'-',mon,
'-',dy,
'T',hr,
':',mn,
':',se, tzsign,tzhr,
':',tzmn
700 real(
double),
intent(in) :: jd
701 real(
double),
intent(in),
optional :: tz
703 integer :: dy,yr,mon, hr,mn,se, tzhr,tzmn
704 real(
double) :: day, time, ltz
707 character,
parameter :: endys(0:6)*(3) = [
'Sun',
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat']
708 character,
parameter :: enmntsb(12)*(3) = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec']
711 if(
present(tz)) ltz = tz
713 call jd2cal(jd + ltz/24.d0, yr,mon,day)
715 time = (day - dble(dy)) * 24.d0
716 call tm2hms(time, hr,mn,se)
717 call tm2hm(abs(ltz), tzhr,tzmn)
720 if(ltz.lt.0.d0) tzsign =
'-'
722 write(
jd2rfc822,
'(A,I2.2, A,I5, I3.2,2(A1,I2.2), 1x,A1,2I2.2)') trim(endys(
dow_ut(jd+tz/24.d0)))//
', ',dy,
' '//enmntsb(mon), yr, &
723 hr,
':',mn,
':',se, tzsign,tzhr,tzmn
742 real(
double),
intent(in) :: jd
746 jd1980 =
cal2jd(1980,1,6.d0)
747 jd2gps = (jd - jd1980)*86400.d0
750 write(0,*)
'Warning: Leap seconds are not taken into account when computing GPS time before 1980-01-06.'
753 if(jd.ge.
cal2jd(1981,7,1.d0)) nleap = nleap + 1
754 if(jd.ge.
cal2jd(1982,7,1.d0)) nleap = nleap + 1
755 if(jd.ge.
cal2jd(1983,7,1.d0)) nleap = nleap + 1
756 if(jd.ge.
cal2jd(1985,7,1.d0)) nleap = nleap + 1
757 if(jd.ge.
cal2jd(1988,1,1.d0)) nleap = nleap + 1
758 if(jd.ge.
cal2jd(1990,1,1.d0)) nleap = nleap + 1
759 if(jd.ge.
cal2jd(1991,1,1.d0)) nleap = nleap + 1
760 if(jd.ge.
cal2jd(1992,7,1.d0)) nleap = nleap + 1
761 if(jd.ge.
cal2jd(1993,7,1.d0)) nleap = nleap + 1
762 if(jd.ge.
cal2jd(1994,7,1.d0)) nleap = nleap + 1
763 if(jd.ge.
cal2jd(1996,1,1.d0)) nleap = nleap + 1
764 if(jd.ge.
cal2jd(1997,7,1.d0)) nleap = nleap + 1
765 if(jd.ge.
cal2jd(1999,1,1.d0)) nleap = nleap + 1
766 if(jd.ge.
cal2jd(2006,1,1.d0)) nleap = nleap + 1
767 if(jd.ge.
cal2jd(2009,1,1.d0)) nleap = nleap + 1
768 if(jd.ge.
cal2jd(2012,7,1.d0)) nleap = nleap + 1
769 if(jd.ge.
cal2jd(2015,7,1.d0)) nleap = nleap + 1
770 if(jd.ge.
cal2jd(2017,1,1.d0)) nleap = nleap + 1
791 real(
double),
intent(in) :: gpstime
795 jd1980 =
cal2jd(1980,1,6.d0)
796 gps2jd = gpstime/86400.d0 + jd1980
798 if(
gps2jd.lt.jd1980)
write(0,*)
'Warning: Leap seconds are not taken into account when computing GPS time before 1980-01-06.'
837 real(
double),
intent(in) :: jd
840 jd2unix = (jd - 2440587.5d0)*86400
856 real(
double),
intent(in) :: unixtime
859 unix2jd = unixtime/86400.d0 + 2440587.5d0
886 integer,
intent(out),
optional :: year,month,day, hour,minute, ms
887 real(double),
intent(out),
optional :: second, tz
892 if(
present(year)) year = dt(1)
893 if(
present(month)) month = dt(2)
894 if(
present(day)) day = dt(3)
896 if(
present(hour)) hour = dt(5)
897 if(
present(minute)) minute = dt(6)
900 if(
present(second)) second = dble(dt(7))
903 if(
present(second)) second = dble(dt(7)) + dble(dt(8))*1.d-3
906 if(
present(tz)) tz = dble(dt(4))/60.d0
Procedures for manipulation of date and time.
elemental real(double) function ymdhms2jd(yy, mmo, dd, h, m, s)
Convert date and time (y,m,d, h,m,s) to JD. Input and output in UT.
elemental integer function dow_iso(jd0)
Calculates ISO day of week (1 = Monday, ..., 7 = Sunday). Output for timezone of input - call dow_ut(...
elemental character function, dimension(30) jd2iso8601(jd, tz)
Return JD as date and time in ISO_8601 format (e.g. 2014-03-24T20:48:01+00:00)
elemental subroutine jd2datetime(jd, year, month, day, time)
Convert a Julian day to a date (y,m,d) and time (UT, h)
elemental real(double) function dtm2jd(yy, mo, dd, time)
Convert date and time (h) to a Julian day - input in UT.
elemental integer function ymd2doy(yr, mon, dy)
Calculate day of year (1-366) from year,month,day.
elemental real(double) function jd2year(jd)
Convert a Julian day to decimal year (e.g. 2000.0)
elemental integer function leapyr(yr)
Calculate whether year is leap (1) or not (0). The number of days in February is then given by 28 + l...
real(double) function gps2jd(gpstime)
Convert a GPS time to Julian day (UT)
elemental subroutine tm2hmss(tm, h, m, s)
Convert time (h) to hours, minutes and (decimal) seconds.
elemental character function, dimension(15) jd2datestr(jd)
Convert a Julian day to a date string (yyyy-mm-dd)
elemental subroutine jd2cal(jd, yy, mm, dd)
Convert a Julian day to a calendar date (fractional day) - in UT.
subroutine system_clock_2_ymdhms(year, month, day, hour, minute, second, ms, tz)
Return system-clock date and time in (year, month, ..., minute, second and tz)
elemental integer function doy(jd0)
Calculate day of year (1-366) from JD.
elemental character function, dimension(35) jd2rfc822(jd, tz)
Return JD as date and time in RFC-822 format (e.g. Sat, 07 Sep 2002 23:12:01 +0100)
elemental subroutine consistent_date_time(year, month, day, hour, minute, second)
Ensure date and time are consistent after manipulation (0<month<13, 0<=minute<60, etc....
elemental real(double) function jd2time(jd)
Convert a Julian day to time (UT, h)
elemental real(double) function jd2unix(jd)
Convert a Julian day (UT) to Unix time (seconds since 1970-01-01)
elemental subroutine tm2hms(tm, h, m, s)
Convert time (h) to hours, minutes and (integer) seconds.
elemental real(double) function unix2jd(unixtime)
Convert UNIX time stamp to Julian day.
elemental subroutine tm2hm(tm, h, m)
Convert time (h) to hours and (integer) minutes.
elemental real(double) function year2jd(year)
Convert a year (with decimals) to a JD. Input and output in UT.
elemental subroutine tm2hmm(tm, h, m)
Convert time (h) to hours and (decimal) minutes.
elemental subroutine doy2md(doy, yr, mon, dy)
Calculate month and day from day of year and year.
elemental integer function dow_ut(jd0)
Calculates day of week (0 = Sunday, ..., 6 = Saturday). Output for timezone of input - call dow_ut(jd...
real(double) function jd2gps(jd)
Convert a Julian day (UT) to a GPS time (seconds since 1980-01-06 - 2000-01-01 = 630720013....
elemental subroutine jd2ymdhms(jd, yy, mm, d, h, m, s)
Convert a Julian day to date and time (h,m,s, UT)
elemental real(double) function cal2jd(yy, mm, dd)
Convert a calendar date to JD. Input and output in UT.
Module containing dummy variables for all kinds.
character, dimension(99) dumstr99
Dummy string of length 99.
Provides kinds and related constants/routines.
integer, parameter double
Double-precision float. Precision = 15, range = 307.
integer, parameter dbl
Double-precision float. Precision = 15, range = 307.
integer, parameter long
Long integer.