67 use sufr_kinds,
only: double
71 integer,
intent(in) :: year,month,day, hour,minute
72 real(double),
intent(in) :: second
98 use sufr_kinds,
only: double
102 integer,
intent(out) :: year,month,day, hour,minute
103 real(double),
intent(out) :: second
124 use sufr_date_and_time,
only: system_clock_2_ymdhms, consistent_date_time
128 logical,
optional,
intent(in) :: ut
162 subroutine ut2lt_ymdhms(year,month,dy, hour,minute,second, tz, tz0,dsttp)
163 use sufr_kinds,
only: double
164 use sufr_date_and_time,
only: ymdhms2jd, consistent_date_time
167 integer,
intent(inout) :: year,month,dy, hour,minute
168 real(double),
intent(inout) :: second
169 real(double),
intent(out) :: tz
170 integer,
intent(in) :: dsttp
171 real(double),
intent(in) :: tz0
175 jd = ymdhms2jd(year,month,dy, hour,minute,second)
176 tz =
gettz(jd, tz0,dsttp)
177 hour = hour + nint(tz)
179 call consistent_date_time(year,month,dy, hour,minute,second)
213 use sufr_kinds,
only: double
214 use sufr_date_and_time,
only: cal2jd
215 use sufr_numerics,
only: dne
219 real(double),
intent(out) :: ut,jd,jde
220 real(double) :: lt, oldtz
230 if(dne(
tz, oldtz))
then
236 jde = jd +
deltat/86400.d0
253 use sufr_kinds,
only: double
254 use sufr_constants,
only: jd2000
255 use sufr_angles,
only: rev
259 real(double),
intent(in) :: jd
260 real(double),
intent(in),
optional ::
deltat
261 real(double) ::
calc_gmst, djd,djd2,djd4, gmst, deltatl
270 gmst = 4.89496121042905d0 + 6.30038809894828323d0*djd + 5.05711849d-15*djd2 - 4.378d-28*djd2*djd - 8.1601415d-29*djd4 &
271 - 2.7445d-36*djd4*djd + 7.0855723730d-12*deltatl
288 use sufr_kinds,
only: double
289 use sufr_constants,
only: jd2000
290 use sufr_angles,
only: rev
293 real(double),
intent(in) :: jd
294 real(double) ::
gmst_meeus, djd,tjc,tjc2, gmst
300 gmst = 4.89496121273579229d0 + 6.3003880989849575d0*djd + 6.77070812713916d-6*tjc2 - 4.5087296615715d-10*tjc2*tjc
318 use sufr_kinds,
only: double
319 use sufr_date_and_time,
only: cal2jd
323 real(double),
intent(out) :: jd
324 real(double) :: lt,ut
352 use sufr_kinds,
only: double
353 use sufr_date_and_time,
only: jd2cal
354 use sufr_numerics,
only: deq0
359 real(double),
intent(in) :: jd
360 logical,
intent(in),
optional :: force_recompute
364 logical :: force_recompute_l
375 force_recompute_l = .false.
376 if(
present(force_recompute)) force_recompute_l = force_recompute
383 call jd2cal(jd, y,m,d)
408 use sufr_kinds,
only: double
409 use sufr_numerics,
only: deq
413 integer,
intent(in) :: y,m
414 real(double),
intent(in) :: d
415 logical,
intent(in),
optional :: force_recompute
419 real(double),
save :: calc_deltat_old, y0_old
420 logical :: force_recompute_l
430 force_recompute_l = .false.
431 if(
present(force_recompute)) force_recompute_l = force_recompute
435 y0 = (dble(m-1)+((d-1)/31.d0))/12.d0 + y
438 if(deq(y0,y0_old) .and. .not. force_recompute_l)
then
447 if(y.ge.yr1.and.y.le.yr2)
then
486 use sufr_kinds,
only: double
491 integer,
intent(in) :: y
492 real(double),
intent(in) :: y0
494 real(double) :: dt0,dt,yr0,yr,a
506 a = (dt-dt0)/dble(yr-yr0)
521 use sufr_kinds,
only: double
525 real(double),
intent(in) :: jd
548 use sufr_kinds,
only: double, dbl
549 use sufr_system,
only: quit_program_error
550 use sufr_constants,
only: mlen
551 use sufr_date_and_time,
only: jd2cal, leapyr
555 real(double),
intent(in) :: jd
556 integer,
intent(out) :: yy,mm,d,h,m
557 real(double),
intent(out) :: s
558 real(double) :: dd,tm
560 call jd2cal(jd +
tz/24.d0, yy,mm,dd)
561 if(mm.lt.1 .or. mm.gt.12)
call quit_program_error(
'libTheSky: jd2dtm(): something went wrong in the jd2cal() call: month must be between 1 and 12.', 1)
564 if(yy.eq.0.and.mm.eq.0)
then
573 mlen(2) = 28 + leapyr(yy)
576 tm = (dd - dble(d))*24.d0
578 m = int((tm-h)*60.d0)
579 s = (tm-h-m/60.d0)*3600.d0
593 if(d.gt.mlen(mm))
then
617 use sufr_kinds,
only: double
618 use sufr_system,
only: quit_program_error
619 use sufr_constants,
only: mlen
620 use sufr_date_and_time,
only: jd2cal, leapyr
624 real(double),
intent(in) :: jd
625 integer,
intent(out) :: yy,mm,d,h,m
626 real(double) :: dd,tm
628 call jd2cal(jd+
tz/24.d0, yy,mm,dd)
629 if(mm.lt.1 .or. mm.gt.12)
call quit_program_error(
'libTheSky: jd2dthm(): something went wrong in the jd2cal() call: month must be between 1 and 12.', 1)
632 if(yy.eq.0 .and. m.eq.0)
then
639 mlen(2) = 28 + leapyr(yy)
642 tm = (dd - dble(d))*24
654 if(d.gt.mlen(mm))
then
675 use sufr_kinds,
only: double
676 use sufr_date_and_time,
only: jd2cal
680 real(double),
intent(in) :: jd0
685 call jd2cal(jd1,yy,mm,dd)
707 use sufr_kinds,
only: double
709 real(double),
intent(in) :: jd
710 real(double),
intent(in),
optional :: jde
712 if(
present(jde))
then
729 use sufr_kinds,
only: double
730 use sufr_date_and_time,
only: jd2cal
733 real(double),
intent(in) :: jd
734 real(double),
intent(in),
optional :: jde
735 real(double) :: dd,tm,s
736 integer :: d,mm,yy,h,m
738 call jd2cal(jd+1.d-10, yy,mm,dd)
742 tm = (dd - dble(d))*24.d0
744 m = int((tm-h)*60.d0)
745 s = (tm-h-m/60.d0)*3600.d0
747 if(s.gt.59.999d0)
then
760 write(*,
'(A,F0.6)', advance=
'no')
' JD: ', jd
761 if(
present(jde))
write(*,
'(A,F0.6)', advance=
'no')
' JDE: ', jde
762 write(*,
'(A,I0,2I3.2, A,2I3.2,F7.3,A)', advance=
'no')
' date: ',yy,mm,d,
' time: ',h,m,s,
' UT'
777 subroutine dls(yr, jdb,jde)
778 use sufr_kinds,
only: double
779 use sufr_date_and_time,
only: cal2jd
782 integer,
intent(in) :: yr
783 real(double),
intent(out) :: jdb,jde
784 real(double) :: d1,d2
794 d1 = d1 - dble(
dow(cal2jd(lyr,m1,d1)))
795 jdb = cal2jd(lyr,m1,d1)
796 d2 = d2 - dble(
dow(cal2jd(lyr,m2,d2)))
797 jde = cal2jd(lyr,m2,d2)
821 use sufr_kinds,
only: double
822 use sufr_system,
only: warn
823 use sufr_date_and_time,
only: jd2cal, cal2jd
828 real(double),
intent(in) :: jd
829 real(double),
intent(in),
optional ::
tz0
830 integer,
intent(in),
optional ::
dsttp
832 real(double) ::
gettz,dd,jd0,d0
837 if(
present(
tz0)) ltz0 =
tz0
841 call jd2cal(jd,y,m,dd)
843 if(ldsttp.lt.0.or.ldsttp.gt.2)
then
845 call warn(
'gettz(): (l)ldsttp must be 0-2; resetting to 1 (Europe)')
857 if(m.gt.m1.and.m.le.m2)
gettz = 1.d0
859 if(m.eq.m1.or.m.eq.m2)
then
860 jd0 = cal2jd(y,m,31.d0) + (m2 - 10)
861 d0 = 31.d0 - dble(
dow(jd0)) + (m2 - 10)
862 jd0 = cal2jd(y,m,d0+1.d0/24.d0)
863 if(m.eq.m1.and.jd.gt.jd0)
gettz = 1.d0
864 if(m.eq.m2.and.jd.gt.jd0)
gettz = 0.d0
880 call warn(
'DST rules not implemented prior to 2007!')
886 if(m.gt.m1.and.m.lt.m2)
gettz = 1.d0
889 jd0 = cal2jd(y,m,1.999999d0)
890 d0 = dble(14 -
dow(jd0-1))
891 jd0 = cal2jd(y,m,d0+(2.d0-
tz)/24.d0)
892 if(jd.gt.jd0)
gettz = 1.d0
896 jd0 = cal2jd(y,m,1.999999d0)
897 d0 = dble(7 -
dow(jd0-1))
898 jd0 = cal2jd(y,m,d0+(2.d0-
tz)/24.d0)
899 if(jd.lt.jd0)
gettz = 1.d0
933 use sufr_kinds,
only: double
934 use sufr_constants,
only: r2d,r2h, endays,enmonths
935 use sufr_time2string,
only: hms_sss
936 use sufr_text,
only: d2s
938 use thesky_local,
only:
year,
month,
day,
hour,
minute,
second,
tz,
lat0,
lon0,
height,
deltat
942 integer,
intent(in),
optional :: op, nlbef,nlaf
943 real(double),
intent(out),
optional :: ut,jd,jde
944 character,
intent(in),
optional :: locname*(*),tzname*(*)
945 integer :: il, opl, nlbefl,nlafl
946 real(double) :: gmst, lt, utl,jdl,jdel
947 character :: locnamel*(999),tznamel*(99)
951 if(
present(op)) opl = op
953 if(
present(nlbef)) nlbefl = nlbef
955 if(
present(nlaf)) nlafl = nlaf
957 if(
present(locname)) locnamel = trim(locname)
959 if(
present(tzname)) tznamel = trim(tzname)//
','
975 write(opl,
'(A20,3A,I3,A1,I5, A9,A13,2x,A, A13,2(A4,A), A4,A,A1)') &
976 'LOCAL: Date: ',trim(endays(
dow(jdl))),
' ', trim(enmonths(
month)),nint(
day),
',',
year, &
977 'Time:',hms_sss(lt),
'tz: '//trim(tznamel)//
' '//d2s(
tz,1), &
978 'Location:',
'l: ',d2s(
lon0*r2d,4),
'b: ',d2s(
lat0*r2d,4),
'h: ',d2s(
height,1),
'm'
980 write(opl,
'(A17,A13, A5,F15.6, A10,F0.2,A1, A6,F15.6, A7,F8.4, 5x,A)') &
981 'UNIVERSAL: UT:',hms_sss(utl),
'JD:',jdl,
'DeltaT: ',
deltat,
's', &
982 'JDE:',jdel,
'GMST:',gmst, trim(locnamel)
989 if(
present(ut)) ut = utl
990 if(
present(jd)) jd = jdl
991 if(
present(jde)) jde = jdel
1007 use sufr_kinds,
only: double
1011 real(double),
intent(in) :: jd0
1013 real(double) :: jd,jw
1015 jd = dble(nint(jd0+
tz/24.d0))-0.5d0
1016 jw = (jd + 1.5d0)/7.d0
1017 dow = nint(jd + 1.5d0 - floor(jw)*7)
1034 use sufr_kinds,
only: double
1035 use sufr_date_and_time,
only: doy
1038 real(double),
intent(in) :: jd
1041 woy = int(dble(doy(jd) + 7 -
dow(jd))/7.d0)
1064 integer,
intent(in) :: year
1065 integer,
intent(out) :: month, day
1066 integer :: a,b,c, k,p,q, M,N, d,e
1068 a = modulo(year, 19)
1073 k = floor(year / 100.d0)
1074 p = floor((13 + 8*k) / 25.d0)
1076 m = modulo(15 + k - p - q, 30)
1077 n = modulo( 4 + k - q, 7)
1083 d = modulo(19*a + m, 30)
1084 e = modulo(2*b + 4*c + 6*d + n, 7)
1091 if((d.eq.29) .and. (e.eq.6))
then
1093 else if( (d.eq.28) .and. (e.eq.6) .and. (a.gt.10) )
then
1095 else if(day.gt.31)
then
1125 use sufr_kinds,
only: double
1128 integer,
intent(in) :: year
1129 integer,
intent(out) :: month, day
1130 integer :: C,S, a,b, j
1131 real(double) :: Q, r
1133 if(year.lt.1583)
then
1136 c = floor(year / 100.d0)
1137 s = floor((3*c - 5)/4.d0)
1140 a = modulo(12*year + 12, 19)
1143 q = -1.904412361576d0 + 1.554241796621d0*a + 0.25d0*b - 0.003177794022d0*year + s
1144 j = modulo(floor(q) + 3*year + 5*b + 2 - s, 7)
1148 if(j.eq.2 .or. j.eq.4 .or. j.eq.6)
then
1150 else if(j.eq.1 .and. a.gt.6 .and. r.gt.0.632870370d0)
then
1152 else if(j.eq.0 .and. a.gt.11 .and. r.gt.0.897723765d0)
then
Constants used in libTheSky.
real(double) deltat_forced
Forced value for DeltaT, overriding computation.
real(double) deltat_accel
Acceleration for DeltaT parabola.
integer deltat_minyr
Start year of DeltaT measurements.
real(double) deltat_change
Change for DeltaT parabola.
real(double) jd1820
JD of 1820.0, for DeltaT.
real(double), dimension(deltat_nmax) deltat_values
Values of DeltaT.
integer deltat_n
Actual number of DeltaT measurements.
real(double) deltat_0
Zero point for DeltaT parabola.
real(double), dimension(deltat_nmax) deltat_years
Years for DeltaT values.
integer deltat_maxyr
End year of DeltaT measurements.
Date and time procedures.
subroutine set_date_and_time(year, month, day, hour, minute, second)
Set global date/time variables (year, month, ..., minute, second in TheSky_local) to specified values...
real(double) function calc_gmst(jd, deltat)
Calculate Greenwich Mean Sidereal Time for any instant, in radians.
subroutine passover_gauss(year, month, day)
Calculate the date of Passover or Pesach (Jewish Easter) using Gauss' method.
subroutine ut2lt_ymdhms(year, month, dy, hour, minute, second, tz, tz0, dsttp)
Convert date/time in ymdhms from UT to local time.
real(double) function find_deltat_in_range(y, y0)
Find a precise value for DeltaT through linear interpolation of the two adjacent tabulated values.
subroutine calctime(ut, jd, jde)
Compute UT, JD, JDE, DeltaT and TZ, using the date and (local) time and TZ stored in the module TheSk...
real(double) function gettz(jd, tz0, dsttp)
Returns time zone: tz0 (standard time) or tz0+1 (daylight-savings time)
subroutine get_date_and_time(year, month, day, hour, minute, second)
Retrieve the current global date/time variables (year, month, ..., minute, second,...
subroutine easter_gauss(year, month, day)
Calculate the date of Easter using Gauss' method.
subroutine set_date_and_time_to_jd2000()
Set global date/time variables (year, month, ..., minute, second in TheSky_local) to JD2000....
integer function dow(jd0)
Calculates day of week (0 - Sunday, ..., 6=Saturday)
real(double) function calc_deltat_ymd(y, m, d, force_recompute)
Compute DeltaT for given y,m,d.
subroutine dls(yr, jdb, jde)
Find the two Julian days of the beginning and the end of daylight-savings time in the EU for a given ...
subroutine set_date_and_time_to_system_clock(ut)
Set global date/time variables (year, month, ..., minute, second in TheSky_local) to system clock.
real(double) function calc_deltat(jd, force_recompute)
Compute DeltaT for a given JD.
subroutine jd2dthm(jd, yy, mm, d, h, m)
Convert a Julian day (UT) to LOCAL date and time (h,m - no seconds)
real(double) function jd2ltime(jd0)
Convert a Julian day (UT) to a local time (LT, h)
real(double) function calc_deltat_approx(jd)
Compute DeltaT for given JD, using a simple parabolic approximation.
subroutine print_date_time_and_location(op, nlbef, nlaf, ut, jd, jde, locname, tzname)
Display a banner with date, time and location of calculation. Computes and returns UT,...
subroutine printdate1(jd, jde)
Prints date/time of a given Julian day (UT) to standard output, but without a newline.
real(double) function gmst_meeus(jd)
Calculate Greenwich Mean Sidereal Time for any instant, in radians, using Meeus.
subroutine localtime2jd(jd)
Computes JD, DeltaT and TZ, from date/time variables in module TheSky_local.
subroutine jd2dtm(jd, yy, mm, d, h, m, s)
Convert a Julian day (UT) to LOCAL date and time (h,m,s)
integer function woy(jd)
Calculate the week-of-year number.
subroutine printdate(jd, jde)
Prints date/time of a given Julian day (UT) to standard output.
Local parameters for libTheSky: location, date, time.
real(double) second
Seconds of time of current instant.
integer month
Month of year of current instant.
integer minute
Minute of time of current instant.
real(double) tz
Current value of time zone, taking into account DST (hours; >0 is east of Greenwich)
real(double) height
Altitude of the observer above sea level (m)
real(double) tz0
Standard value of time zone, without DST ("winter time"; hours; >0 is east of Greenwich)
real(double) lon0
Longitude of the observer (rad)
real(double) deltat
Current value of DeltaT (s)
real(double) lat0
Latitude of the observer (rad)
integer hour
Hour of time of current instant.
real(double) day
Day of month of current instant, with decimals if desired.
integer dsttp
DST type for current location (0: none, 1: EU, 2: USA+Canada (after 2007)
integer year
Year CE of current instant.