82 subroutine riset(jd,pl, rt,tt,st, rh,ta,sh, rsAlt, for_night, ltime, cWarn, converge)
83 use sufr_kinds,
only: double
84 use sufr_constants,
only: pi2, d2r,am2r, r2h, enpname, earthr,au
85 use sufr_angles,
only: rev, rev2
86 use sufr_date_and_time,
only: cal2jd,jd2cal
87 use sufr_time2string,
only: hm
88 use sufr_numerics,
only: deq0, deq
96 integer,
intent(in) :: pl
97 real(double),
intent(in) :: jd, rsAlt
98 real(double),
intent(out) :: rt,tt,st,rh,ta,sh
99 logical,
intent(in),
optional :: for_night, ltime, cWarn
100 integer,
intent(out),
optional :: converge(3)
102 integer :: evi,iter,yr,mnt,tc,evMax, lconverge(3)
103 real(double) :: dy,day0, jd0,jd1,tmRad(3),tmhr(3), ra,dec
104 real(double) :: rsa,cosH0,h0,agst0,th0,dTmRad,accur, ha,alt,azAlt(3)
105 character :: event(3)*(13)
106 logical :: use_vsop, lfor_night, lltime, lcWarn
111 if(
present(for_night)) lfor_night = for_night
114 if(
present(ltime)) lltime = ltime
117 if(
present(cwarn)) lcwarn = cwarn
120 if(pl.ne.0.and.pl.ne.3)
then
121 call riset_ipol(jd,pl, rt,tt,st, rh,ta,sh, rsalt, for_night=lfor_night, ltime=lltime, cwarn=lcwarn)
126 alt=0.d0; ha=0.d0; h0=0.d0; azalt=0.d0; tmrad=0.d0
128 event = [
'Transit time ',
'Rise time ',
'Set time ']
130 if(abs(rsalt).gt.1.d-9)
then
134 if(pl.eq.3) rsa = rsa - 16.d0*am2r
135 if(pl.eq.0) rsa = 0.125d0*d2r
139 if(rsalt.gt.90.d0) evmax = 1
141 call jd2cal(jd, yr,mnt,dy)
142 day0 = dble(floor(dy))-
tz/24.d0
143 if(lfor_night) day0 = day0 + 0.5d0
144 jd0 = cal2jd(yr,mnt,day0)
154 rsa = asin(earthr/(
planpos(4)*au))*0.7275d0-0.5667d0*d2r
162 cosh0 = (sin(rsa)-sin(
lat0)*sin(dec)) / (cos(
lat0)*cos(dec))
163 if(abs(cosh0).gt.1.d0)
then
166 h0 = rev(2*acos(cosh0))/2.d0
171 tmrad(1) = rev(ra -
lon0 - agst0)
173 tmrad(2) = rev(tmrad(1) - h0)
174 tmrad(3) = rev(tmrad(1) + h0)
183 dtmrad = huge(dtmrad)
184 do while(abs(dtmrad).ge.accur .or. .not.use_vsop)
185 th0 = agst0 + 1.002737909350795d0*tmrad(evi)
186 jd1 = jd0 + tmrad(evi)/pi2 +
deltat/86400.d0
188 if(abs(dtmrad).le.accur)
then
203 ha = rev2(th0 +
lon0 - ra)
205 alt = asin(sin(
lat0)*sin(dec) + cos(
lat0)*cos(dec)*cos(ha))
211 dtmrad = (alt-rsa)/(cos(dec)*cos(
lat0)*sin(ha))
213 tmrad(evi) = tmrad(evi) + dtmrad
221 if(lcwarn .and. (pl.ne.3.or.nint(rsalt).ne.-18)) &
222 write(0,
'(A,F10.3,A)')
' * WARNING: riset(): Riset failed to '// &
223 'converge: '//trim(enpname(pl))//
' '//trim(event(evi)),rsalt,
'd *'
231 azalt(evi) = atan2(sin(ha),(cos(ha)*sin(
lat0)-tan(dec)*cos(
lat0)))
236 if(pl.eq.0 .and. tmrad(evi).gt.pi2)
then
250 if(pl.eq.0 .and. tmrad(evi).lt.0.d0)
then
255 lconverge(evi) = iter
264 where(deq(tmhr,12.d0)) tmhr = 0.d0
271 ta = azalt(1) +
refract(azalt(1))
277 if(
present(converge)) converge = lconverge
318 subroutine riset_ipol(jd,pl, rt,tt,st, rh,ta,sh, rsAlt, for_night, ltime, cWarn)
319 use sufr_kinds,
only: double
320 use sufr_constants,
only: pi,pi2, d2r,am2r, enpname, earthr,au
321 use sufr_system,
only: warn
322 use sufr_angles,
only: rev, rev2
323 use sufr_date_and_time,
only: cal2jd,jd2cal
324 use sufr_numerics,
only: deq0, deq
332 integer,
intent(in) :: pl
333 real(double),
intent(in) :: jd, rsAlt
334 real(double),
intent(out) :: rt,tt,st, rh,ta,sh
335 logical,
intent(in),
optional :: for_night, ltime, cWarn
337 integer :: evi,iter,yr,mnt,tc,evMax, indic
338 real(double) :: dy,day0, jd0,jd1,jd2, tmdy(3),dTmdy(3), tmhr(3)
339 real(double) :: ra0,dec0,ra1,dec1,ra2,dec2,ra,dec, rsa,cosH0,h0,agst0,th0,n,dtm,accur, ha,alt,azAlt(3)
340 character :: event(3)*(13)
341 logical :: lfor_night, lltime, lcWarn
347 if(
present(for_night)) lfor_night = for_night
350 if(
present(ltime)) lltime = ltime
353 if(
present(cwarn)) lcwarn = cwarn
355 if((pl.eq.0.or.pl.eq.3) .and. indic.ne.12345)
then
356 call warn(
"riset_ipol(): Don't use this routine for Sun or Moon - use riset() instead.", 0)
360 rt=0.d0; tt=0.d0; st=0.d0; rh=0.d0; ta=0.d0; sh=0.d0
361 alt = 0.d0; ha = 0.d0; dtmdy = 0.d0; h0 = 0.d0; dec = 0.d0
363 event = [
'Transit time ',
'Rise time ',
'Set time ']
369 if(pl.eq.3) rsa = rsa - 16.0d0*am2r
370 if(pl.eq.0) rsa = 0.125d0*d2r
372 if(abs(rsalt).gt.1.d-9) rsa = rsalt*d2r
374 call jd2cal(jd,yr,mnt,dy)
375 day0 = dble(floor(dy))-
tz/24.d0
376 if(lfor_night) day0 = day0 + 0.5d0
377 jd0 = cal2jd(yr,mnt,day0-1.d0)
378 jd1 = cal2jd(yr,mnt,day0)
379 jd2 = cal2jd(yr,mnt,day0+1.d0)
393 rsa = asin(earthr/(
planpos(4)*au))*0.7275d0-0.5667d0*d2r
403 if(abs(ra1-ra0).gt.2..or.abs(ra2-ra1).gt.2.)
then
404 if(ra0.ge.4.5.and.ra1.ge.4.5.and.ra2.le.2.) ra2 = ra2+2*pi
405 if(ra0.ge.4.5.and.ra1.le.2.and.ra2.le.2.) ra0 = ra0-2*pi
406 if(ra0.le.2.and.ra1.ge.4.5.and.ra2.ge.4.5) ra0 = ra0+2*pi
407 if(ra0.le.4.5.and.ra1.le.2.and.ra2.ge.4.5) ra2 = ra2-2*pi
411 cosh0 = (sin(rsa)-sin(
lat0)*sin(dec2)) / (cos(
lat0)*cos(dec2))
417 if(abs(cosh0).gt.1.d0)
then
420 h0 = rev(2*acos(cosh0))/2.d0
424 tmdy(1) = rev(ra2 -
lon0 - agst0)/pi2 + dtmdy(1)
426 tmdy(2) = rev(tmdy(1)*pi2 - h0)/pi2 + dtmdy(2)
427 tmdy(3) = rev(tmdy(1)*pi2 + h0)/pi2 + dtmdy(3)
431 do while(evi.le.evmax)
435 do while(abs(dtm).ge.accur)
436 th0 = agst0 + 6.300388092591991d0*tmdy(evi)
437 n = tmdy(evi) +
deltat/86400.d0
438 ra =
rsipol( ra0, ra1, ra2, n)
439 dec =
rsipol(dec0,dec1,dec2, n)
441 ha = rev2(th0 +
lon0 - ra)
442 alt = asin(sin(
lat0)*sin(dec) + cos(
lat0)*cos(dec)*cos(ha))
448 dtm = (alt-rsa)/(pi2*cos(dec)*cos(
lat0)*sin(ha))
450 tmdy(evi) = tmdy(evi) + dtm
458 if(lcwarn .and. (pl.ne.3.or.nint(rsalt).ne.-18)) &
459 write(0,
'(A,F10.3,A)')
' * WARNING: riset_ipol(): Riset failed '// &
460 'to converge: '//trim(enpname(min(pl,19)))//
' '//trim(event(evi)),rsalt,
'd'
468 azalt(evi) = atan2(sin(ha),(cos(ha)*sin(
lat0)-tan(dec)*cos(
lat0)))
475 if(tmdy(evi).lt.0.)
then
476 dtmdy(evi) = dtmdy(evi) + 1.d0
480 tmdy(1) = rev(ra2 -
lon0 - agst0)/pi2 + dtmdy(1)
482 tmdy(2) = rev(tmdy(1)*pi2 - h0)/pi2 + dtmdy(2)
483 tmdy(3) = rev(tmdy(1)*pi2 + h0)/pi2 + dtmdy(3)
488 if(tmdy(evi).gt.1.d0)
then
505 if(pl.eq.0 .and. tmdy(evi).lt.0.d0)
then
518 where(deq(tmhr,12.d0)) tmhr = 0.d0
526 ta = azalt(1) +
refract(azalt(1))
564 subroutine riset_ad(jd, ra,dec, rt,tt,st,rh,ta,sh, rsAlt, for_night, cWarn)
565 use sufr_kinds,
only: double
566 use sufr_constants,
only: pi2, d2r
567 use sufr_angles,
only: rev, rev2
568 use sufr_date_and_time,
only: cal2jd, jd2cal
569 use sufr_numerics,
only: deq0, deq
576 real(double),
intent(in) :: jd, ra,dec, rsAlt
577 real(double),
intent(out) :: rt,tt,st,rh,ta,sh
578 logical,
intent(in),
optional :: for_night, cWarn
580 integer :: evi,iter,yr,mnt,evMax
581 real(double) :: dy,day0,jd0, tmdy(3),tmhr(3), rsa,cosH0,h0,agst0,th0,dtm,accur, ha,alt,azAlt(3)
582 character :: event(3)*(13)
583 logical :: lfor_night, lcWarn
587 if(
present(for_night)) lfor_night = for_night
590 if(
present(cwarn)) lcwarn = cwarn
592 alt = 0.d0; ha = 0.d0; h0 = 0.d0
594 event = [
'Transit time ',
'Rise time ',
'Set time ']
598 if(rsalt.gt.90.d0) evmax = 1
600 call jd2cal(jd, yr,mnt,dy)
601 day0 = dble(floor(dy))-
tz/24.d0
602 if(lfor_night) day0 = day0 + 0.5d0
603 jd0 = cal2jd(yr,mnt,day0)
611 cosh0 = (sin(rsa)-sin(
lat0)*sin(dec))/(cos(
lat0)*cos(dec))
612 if(abs(cosh0).gt.1.d0)
then
615 h0 = rev(2*acos(cosh0))/2.d0
619 tmdy(1) = rev(ra -
lon0 - agst0)/pi2
621 tmdy(2) = rev(tmdy(1)*pi2 - h0)/pi2
622 tmdy(3) = rev(tmdy(1)*pi2 + h0)/pi2
629 do while(abs(dtm).ge.accur)
630 th0 = agst0 + 6.300388092591991d0*tmdy(evi)
632 ha = rev2(th0 +
lon0 - ra)
633 alt = asin(sin(
lat0)*sin(dec) + cos(
lat0)*cos(dec)*cos(ha))
639 dtm = (alt-rsa)/(pi2*cos(dec)*cos(
lat0)*sin(ha))
641 tmdy(evi) = tmdy(evi) + dtm
649 if(lcwarn)
write(0,
'(A,F10.3,A)')
' * WARNING: riset_ad(): Riset failed to converge: '//trim(event(evi)),rsalt,
'd *'
657 azalt(evi) = atan2(sin(ha),(cos(ha)*sin(
lat0)-tan(dec)*cos(
lat0)))
661 if(tmdy(evi).lt.0. .and. deq0(rsalt))
then
673 where(deq(tmhr,12.d0)) tmhr = 0.d0
703 use sufr_kinds,
only: double
704 use sufr_constants,
only: r2h
705 use sufr_angles,
only: rev,rv12
706 use sufr_date_and_time,
only: jd2cal
707 use sufr_numerics,
only: deq
715 real(double),
intent(in) :: jd00,ra0
716 integer,
intent(out) :: m,d
717 real(double) :: jd0,oldjd,z(nplanpos)
718 real(double) :: rt,stt,ott,st,rh,ta,sh,midnight,hh,dt,dd
726 do while(abs(dd).gt.0.5d0)
727 call riset(jd0,3, rt,stt,st,rh,ta,sh, 0.d0)
728 midnight = mod(stt+36.d0,24.d0)
733 hh = rev(z(44) - ra0)
735 dt = rv12(ott-midnight)
736 dd = dt/24.d0*365.25d0
737 jd0 = dble(nint(jd0 + dd + 0.5d0)) - 0.5d0
742 if(deq(jd0,oldjd))
exit
743 if(iter.gt.5 .and. abs(dd).lt.0.7d0)
exit
744 if(iter.gt.10 .and. abs(dd).lt.1.d0)
exit
751 call jd2cal(jd0, y,m,dd)
subroutine planet_position(jd, pl, lat, lon, hgt, lbaccur, raccur, ltime, aber, to_fk5, assume_jde, lunar_theory, nutat, magmdl, verbosity)
Compute the position, distance, etc of a planet.
subroutine riset_ipol(jd, pl, rt, tt, st, rh, ta, sh, rsalt, for_night, ltime, cwarn)
Old routine for rise, transit and set times for planets and asteroids - don't use this for Sun and Mo...
subroutine riset_ad(jd, ra, dec, rt, tt, st, rh, ta, sh, rsalt, for_night, cwarn)
Rise, transit and set times routine for an object with fixed ra & dec.
subroutine riset(jd, pl, rt, tt, st, rh, ta, sh, rsalt, for_night, ltime, cwarn, converge)
Rise, transit and set times routine for Sun, Moon, planets and asteroids. This version recomputes pos...