COSMOS v7.655  COSMOSv7655
(AirShowerMC)
kceles.f
Go to the documentation of this file.
1 ! ********************** kceles *********************************
2 ! this file containes programs for celestial
3 ! coordinate transformation routines.
4 ! 1) for subroutines which are related to the vernal equinox
5 ! position (implicitly or explicitly), the accuracy is kept within
6 ! the order of 1/100 degrees which is enough for our purpose.
7 ! for other subroutines, double precision accuracy is kept.
8 ! 3) the input/output parameters and function values are all
9 ! in double precision.
10 ! 4) many of subroutines use a block common $kcele where some
11 ! fundamental constants and common variables are defined.
12 ! $kcele is defined as a separate module and included by
13 ! include statement to each subroutine.
14 ! 5) many subroutines require that kcelei should have been called
15 ! before hand. kcelei should be called once for a particular
16 ! observation place.(*)
17 ! 6) for subroutines which are related to the a.s array
18 ! coordinate, kadthi should have been called.(*)
19 ! 7) the vernal equinox employed is a new one recommended by
20 ! iau.
21 ! 8) ut1 is approximated by utc=lst-dtgmt (local standard time
22 ! - difference from the greenwich time). the difference
23 ! ut1 - utc (nearly =) dut1 is not considered. it is at most
24 ! 1 sec.
25 ! 9) to improve the accuracy of the calculation for the apparent
26 ! position of stars, we have to introduce the equation of
27 ! equinoxes, dut1, nutaion, proper motion of stars, parallax, polar
28 ! motion etc. (@)
29 ! 10) one exceptional case for the correction of parallax is
30 ! the case of the apparent position of the moon. it is
31 ! considered in kmoont.
32 !
33 ! @) in conversion routines from b1950.0 to j2000 (kb50j2) or
34 ! j2000 to b1950.0 (kj2b50), neglecting the proper motion and
35 ! e-term results in an error of 5/100 degrees.
36 ! *) two initializations are managed by jreadi in tips,
37 ! so that the tips user need not worry about that.
38 !
39 ! call kcelei(lat, lon, dtgmt, height) inform place once.
40 ! latitude, longitude (deg), gmt
41 ! difference(hour), and height (m)
42 ! call kadthi(astox) inform a.s array x-axis angle
43 ! measured anticlockwise from south.
44 !
45 ! -----------------------------------------------------------------
46 ! kcosd : function to compute cos with argument in degree.
47 ! kadbp : to get arrival direction of a.s by plane front approx.
48 ! kadth : convert arrival direction in array system to
49 ! direction cos. in horizontal system.
50 ! kadthi: to initialize 'arrival direction to horizontal coord.
51 ! transformation' routine
52 ! kb50j2: convert (dec,ra)b1950.0 into those for j2000
53 ! kcelei: to initialize celestial coordinate conversion routines
54 ! kceleq: inquire current latitude, longitude, dtgmt, and height
55 ! kctoq : ecliptic to equatorial coordinate transformation
56 ! kdcmjd: decompose mjd into y,m,d,h,m,s
57 ! kdhtoh: for given declination and time from meridian,
58 ! get d.c in horizontal system at observation place.
59 ! kdifva: get vector angle difference
60 ! kdtoa : convert direction cosines into polar angles
61 ! kdtoe : convert equatorial coord. given in direction cos.
62 ! into equatorial declination and r.a.
63 ! (this can be used for latitude, longitude relation
64 ! in other coord. system such as ecliptic one).
65 ! kdtoh : convert horizontal coord. given in direction cos.
66 ! into height and azimuth.
67 ! kdzth2: from dec. and zenith, give time from meridian.
68 ! kdztoh: from dec. and zenith. angle, give time from
69 ! meridian. (see for diff. from kdzth2, program)
70 ! kedtgd: equatorial angle in direction cos to galactic angle
71 ! in direction cos
72 ! keqtog: equatorial angle to galactic angle conversion
73 ! ketod : inverse of kdtoe
74 ! ketoh : equatorial to horizontal coordinate transformation
75 ! kgcrc : compute coordinate of observation place in geocentric
76 ! rectangular system.
77 ! kgcttc: conversion from the geocentric to topocentric
78 ! coordinate (topocenter --> origin is at the
79 ! observation place)
80 ! kgdted: inverse of kedtgd.
81 ! kgtoeq: inverse of keqtog.
82 ! khtad : inverse of kadth.
83 ! khtod : inverse of kdtoh
84 ! khtoe : horizontal to equatorial coordinate transformation
85 ! kjtmjd: julian day to modified julian day conversion
86 ! kjxjy : position at j'x' is converted to that at j'y'
87 ! kj2b50: convert (dec,ra)j2000.0 into those for b1950.0
88 ! kj2j90: inverse of kj90j2.
89 ! kj2tox: convert equatorial vector in j2000 into those at
90 ! time x which has been specified by pij matrix
91 ! obtained in kpmtrx
92 ! kj90j2: convert dec, ra in 1990 japanese ephemeris into j2000
93 ! kmjd : get modified julian day
94 ! kmjdst: convert mjd into the mean local siderial time
95 ! kmjdtj: mjd to julian day conversion
96 ! kmjdym: functions the same as kdcmdj
97 ! kmobec: get mean obliquity of the ecliptic plane
98 ! (inclination angle of ecliptic plane)
99 ! kmoon : get ecliptic angle of the moon in geocentric coord.
100 ! kmoont: get topocentric equatorial coord. of the moon.
101 ! kmtoj2: mjd to time measured from j2000.0 conversion
102 ! knormv: normalize vector and get vector length
103 ! koangl: get opening angle between two (dec, ra)
104 ! komega: get solid angle around a source given by komeg0
105 ! for a given point in celestial coord.
106 ! komeg0: initialization for komega and komeg1
107 ! komeg1: get theta between a source given by komeg0 and
108 ! a given point in celestial coord.
109 ! kpmtrx: compute precession matrix from a given mjd.
110 ! kqtoc : equatorial to ecliptic coordinate transformation
111 ! ksided: to compute local mean siderial time
112 ! ksidet: to compute local mean siderial time.
113 ! kside0: to compute siderial time of greenwich at 0hut of a
114 ! given day
115 ! ksun : compute the sun position in ecliptic coord.
116 ! ksuneq: compute the sun position in equatorial coord.
117 ! ktu : to compute elapsed days form 1900/1/0 0h ut
118 ! to a given day
119 ! kxtoj2: from observed equatorial vector to j2000 vector
120 ! kvtoa : get polar angles from unnormalized 3-d vector
121 ! ksind : function to get sin with an argument in degree
122 ! ------------------------------------------------------------
123 !
124  subroutine kcelei(tlat, tlon, dtgmt, height)
125 !
126 ! tlat: input. latitude of the place in deg. (+for northern hemisph..
127 ! tlon: input. longitude of the place in deg. (+ for east, - for west
128 ! dtgmt: input. time difference from gmt of the place. in hour.
129 ! + for earlier time
130 ! height: input. height of the place above the sea level (m).
131 !
132  implicit real*8 (a-h, o-z)
133 #include "Zkcele.h"
134 !
135  tlons=tlon
136  tlats=tlat
137  coslat=cos(tlats*torad)
138  sinlat=sin(tlats*torad)
139 !
140  dtgmts=dtgmt
141  heighs=height
142 ! get geocentric rectangular coordinate of the
143 ! place. (ug, vg, wg)
144  call kgcrc(tlats, tlons, heighs, ug, vg, wg)
145 ! correction to geocenter (in japan)
146  ug=ug-136.
147  vg=vg+521.
148  wg=wg+681.
149  return
150  entry kceleq(tla, tlo, dt, h)
151 ! inquire current const for kcelei
152  tlo=tlons
153  tla=tlats
154  dt=dtgmts
155  h=heighs
156  return
157  end
158 ! compute coordinate of a given place
159 ! in the geocentric rectangular
160 ! system.
161  subroutine kgcrc(fai, al, h, u, v, w)
162 ! fai: input. latitude in deg.
163 ! al: input. longitude in deg.
164 ! h: input. height in m
165 ! u, v, w: output. coordinate of the place in the geocentric
166 ! rectangular system.
167 ! (in m).
168  implicit real*8 (a-h, o-z)
169  real*8 ksind, kcosd
170  real*8 n
171 ! besselian ellipsoid
172  data ae/6377.397155d03/
173  data e2/0.006674372230614d0/
174 !
175  sinf=ksind(fai)
176  n=ae/sqrt(1.d0 - e2*sinf**2)
177  cosf=kcosd(fai)
178  u=(n+h)*cosf * kcosd(al)
179  v=(n+h)*cosf * ksind(al)
180  w=(n*(1.d0-e2)+h) * sinf
181  end
182 ! *************************************************************
183 ! *
184 ! * ksidet: compute mean siderial time
185 ! * at a given longitude and time
186 ! *
187 ! *************************************************************
188 !
189 ! /usage/
190 ! call ksidet(year, month, day, time, st)
191 !
192 ! year: input. integer*4. say 87
193 ! month: input. // say 12
194 ! day: input. // say 23
195 ! time: input. local time of the place. in hour
196 ! 12h.25m.36s.21==>12.+25./60.+36.21/3600.
197 ! st: output. siderial time in degree.
198 ! at longitude tlong (common), at time time (hour)
199 !
200  subroutine ksidet(year, month, day, time, st)
201  implicit real*8 (a-h, o-z)
202 #include "Zkcele.h"
203  integer*4 year, month, day
204 !
205  call ktu(year, month, day, ed)
206  call kside0(ed, st0)
207 ! elapsed time from 0ut in deg.
208  et= (time-dtgmts)*15.d0
209  std= st0 + tlons + sidcor* et
210 ! mod(360)
211  st= mod(std, 360.d0)
212  end
213 ! ---------------- get modified julian day ----------
214 ! year:input like 87
215 ! month:input like 11
216 ! day: input like 23 these are integers
217 ! time: input like (hh + mm/60.d0+ sec/3600.d0)
218 ! mjd: output. modified julian days
219 !
220 ! **** kcelei should have been called before hand.
221 !
222  subroutine kmjd(year, month, day, time, mjd)
223  implicit real*8 (a-h, o-z)
224 #include "Zkcele.h"
225  integer*4 year, month, day
226  real*8 mjd
227  call ktu(year, month, day, ed)
228 ! get modified julian day
229  mjd=ed + (time-dtgmts)/24.d0 + 15019.5d0
230  end
231 ! *************************************************************
232 ! *
233 ! * ksided: compute mean siderial time
234 ! * at a given longitude and time
235 ! *
236 ! *************************************************************
237 !
238 ! /usage/
239 ! call ksided(time, st0, st)
240 !
241 ! time: input. local time of the place. in hour
242 ! 12h.25m.36s.21==>12.+25./60.d0+36.21/3600.d0
243 ! st0: input. siderial time of greenwich in degree.
244 ! at 0 hour.
245 ! st: output. siderial time in degree.
246 ! at longitude tlong (common), at time time (hour)
247 !
248  subroutine ksided(time, st0, st)
249  implicit real*8 (a-h, o-z)
250 #include "Zkcele.h"
251 ! elapsed time from 0ut in deg.
252  et= (time-dtgmts)*15.d0
253  std= st0 + tlons + sidcor* et
254 ! mod(360)
255  st= mod(std, 360.d0)
256  end
257 ! -------------------------------------------------------------
258 ! compute siderial time of greenwich at ut 0h of the
259 ! day.
260 ! ed: input. elapsed day since 1900.1.0 noon of ut.
261 ! st0: output.
262  subroutine kside0(ed, st0)
263  implicit real*8 (a-h, o-z)
264 ! consts.. to get siderial time in degree.
265  parameter(
266  1 c1= (45.836d0/3600.d0+38.d0/60.d0 + 6.0d0)*15.d0,
267  2 c2= 8640184.542d0/3600.d0 *15.d0,
268  3 c3= 0.0929d0/3600.d0*15.d0 )
269 !
270 !
271  tu=ed/36525.d0
272  sd=( c3*tu + c2)* tu + c1
273  st0=mod(sd, 360.d0)
274  end
275 ! get elapsed day from 1900/1/0 noon ut at greenwich
276 ! if 15019.5 is added. this is equivalent to the
277 ! modified julian day of the day at 0:0:0.
278 ! year, month, day: input. integer*4. year must be such as
279 ! 87
280 ! ed: output.
281  subroutine ktu(iyear, month, day, ed)
282  implicit real*8 (a-h, o-z)
283  integer*4 year, month, day
284  year=mod(iyear, 1900)
285  if(month .le. 2) then
286  iy=year-1
287  im=month+12
288  else
289  iy=year
290  im=month
291  endif
292  ed= 365*iy + 30*im + day + int(3*(im+1)/5) + int(iy/4)
293  1 - 33.5d0
294  end
295 ! ----------------------------------------------------------
296 ! convert horizontal to equatorial coord.
297 ! /usage/ call khtoe(st, hx, hy, hz, ex, ey, ez)
298 ! st: input. siderial time in deg.
299 ! (hx,hy,hz): input. direction cos of horizontal angle
300 ! (ex,ey,ez): output. // equatorial angle
301 ! ** note **
302 ! to convert these angle into theta and fai
303 ! use call kdtoe(ex, ey, ez, teta, fai)
304 !
305 ! convert to equatorial to horizontal
306 ! /usage/ call ketoh(st, ex, ey, ez, hx, hy, hz)
307 ! (ex, .) is input and (hx,..) is output
308 ! to convert these angle into theta and fai
309 ! use call khtoa(hx, hy, hz, teta, fai)
310 !
311  subroutine khtoe(st, hx, hy, hz, ex, ey, ez)
312  implicit real*8 (a-h, o-z)
313 #include "Zkcele.h"
314  coss=cos(st*torad)
315  sins=sin(st*torad)
316  ex=hx*coss*sinlat - hy * sins + hz*coss*coslat
317  ey=hx*sins*sinlat + hy*coss + hz * sins*coslat
318  ez=-hx*coslat + hz*sinlat
319  end
320  subroutine ketoh(st, ex, ey, ez, hx, hy, hz)
321  implicit real*8 (a-h, o-z)
322 #include "Zkcele.h"
323  coss=cos(st*torad)
324  sins=sin(st*torad)
325  hx=ex*sinlat*coss + ey*sinlat*sins - ez*coslat
326  hy=-ex*sins + ey*coss
327  hz= ex*coslat*coss + ey*coslat*sins + ez * sinlat
328  end
329  subroutine ketod( delta, alfa, ex, ey, ez)
330  implicit real*8 (a-h, o-z)
331 ! convert r.a and declination into direction cos
332 ! this can be used to get other direction cosines
333 ! from latitude and longitude (say ecliptic coordinate)
334 #include "Zkcele.h"
335  cosa=cos(alfa*torad)
336  sina=sin(alfa*torad)
337  cosd=cos(delta*torad)
338  sind=sin(delta*torad)
339 !
340  ex=cosd*cosa
341  ey=cosd*sina
342  ez=sind
343  return
344  entry khtod(h, a, hx, hy, hz)
345  cosh=cos(h*torad)
346  sinh=sin(h*torad)
347  cosa=cos(a*torad)
348  sina=sin(a*torad)
349  hx=cosh*cosa
350  hy=-cosh*sina
351  hz=sinh
352  end
353  subroutine kdtoe(ex, ey, ez, delta, alfa)
354  implicit real*8 (a-h, o-z)
355 ! this can be used to get other latitude and longitude
356 ! from direction cosines. (say ecliptic coordinate)
357  call kdtoa(ex, ey, ez, t, f)
358  delta=90.d0-t
359  alfa=mod(f+360.d0, 360.d0)
360  end
361  subroutine kdtoh(hx, hy, hz, teta, fai)
362  implicit real*8 (a-h, o-z)
363  call kdtoa(hx, hy, hz, t, f)
364  teta=90.d0-t
365  fai=mod(360.d0-f, 360.d0)
366  end
367 ! compute direction cos of arrival direction
368 ! of a shower in horizontal coordinate.
369 ! /usage/ call kadthi(astox) init.
370 ! call kadth(ax, ay, az, hx,hy,hz)
371 ! astox: input. angle (in deg) between south to the x-axis of the
372 ! array
373 ! (ax,ay,ax): input. direction cos of arrival direction in array
374 ! coordinate (x-y plane is assumed to be horizontal)
375 ! (hx, hy, hz):output. direction cos of arrival direction in
376 ! horizontal coord.
377  subroutine kadthi(astox)
378  implicit real*8 (a-h, o-z)
379 #include "Zkcele.h"
380  cossx=cos(astox*torad)
381  sinsx=sin(astox*torad)
382  end
383  subroutine kadth(ax, ay, az, hx, hy, hz)
384  implicit real*8 (a-h, o-z)
385 #include "Zkcele.h"
386  hx=ax*cossx - ay*sinsx
387  hy=ax*sinsx + ay*cossx
388  hz=az
389  end
390 ! inverse of kadth
391  subroutine khtad(hx, hy, hz, ax, ay, az)
392  implicit real*8 (a-h, o-z)
393 #include "Zkcele.h"
394  ax=hx*cossx + hy*sinsx
395  ay=-hx*sinsx + hy*cossx
396  az=hz
397  end
398 ! *************************************************************
399 ! * kdhtoh: for given declination and time from culmination,
400 ! * get d.c in horizontal system at observation
401 ! * given by kcelei
402 ! *************************************************************
403 ! del: input. declination in degree of source
404 ! h: input. time (in hour) from the meridian (+ -)
405 ! w1,2,3: output. direction cos in horizontal system
406 !
407  subroutine kdhtoh(del, h, w1, w2, w3)
408 !
409  implicit real*8 (a-h, o-z)
410 #include "Zkcele.h"
411  data delsv/-100.d0/
412  save delsv, cosd, sind
413 !
414  if(del .ne. delsv) then
415  cosd=cos(del*torad)
416  sind=sin(del*torad)
417  delsv=del
418  endif
419  fai=h*tofai *torad
420  sinfai=sin(fai)
421  cosfai=cos(fai)
422  w1=sinlat*cosd*cosfai - coslat*sind
423  w2=cosd*sinfai
424  w3=coslat*cosd*cosfai + sinlat*sind
425  end
426 ! ************
427 ! from declination and zenith angle give time from
428 ! culmination
429 ! del:input. declination in degree
430 ! w3:input. 3rd component of the direction cos of zenith
431 ! h: output. time in hour from the culmination
432 ! icon: output =0 ---> h obtained
433 ! 1 ---> such zenith angle cannot happen
434  subroutine kdztoh(del, w3, h, icon)
435 ! ************
436 !
437  implicit real*8 (a-h, o-z)
438 #include "Zkcele.h"
439  data delsv/-100.d0/
440  save delsv, cosd, sind
441 
442  if(del .ne. delsv) then
443  cosd=cos(del*torad)
444  sind=sin(del*torad)
445  delsv=del
446  endif
447  if(cosd .eq. 0. .or. coslat .eq. 0.) then
448  if(abs(w3-sinlat*sind) .le. 1.d-5) then
449  h=12.d0
450  icon=0
451  else
452  icon=1
453  endif
454  else
455  cosx=( w3 - sind*sinlat )/cosd/coslat
456  if(abs(cosx) .le. 1.d0) then
457  icon=0
458  fai=acos(cosx)*todeg
459  h=fai*toh
460  elseif(abs(w3- sinlat*sind) .le. 1.d-5) then
461  icon=0
462  h=12.d0
463  else
464  icon=1
465  endif
466  endif
467  end
468 ! from declination and zenith angle give time from
469 ! culmination
470 ! del:input. declination in degree
471 ! w3:input. 3rd component of the direction cos of zenith
472 ! h: output. time in hour from the culmination
473 ! icon: output =0 ---> h obtained
474 ! 1 ---> max zenith angle should be smaller
475 ! than the w3 and w3 is changed to
476 ! the max value. h corresponds to
477 ! such value .
478 ! 2-----> min zenith angle realized is larger
479 ! than w3 so that no h is obtained
480 ! w3: output. see above (icon=1)
481 ! 1------------------------0 cos (zenith)
482 ! ! !
483 ! ! !
484 ! !min & max zenith observable
485 ! ! ! ! <---w3 position
486 ! 2 0 1 <---icon
487  subroutine kdzth2(del, w3, h, icon)
488 ! ************
489 !
490  implicit real*8 (a-h, o-z)
491 #include "Zkcele.h"
492  data delsv/-100.d0/
493  save delsv, cosd, sind
494 
495  if(del .ne. delsv) then
496  cosd=cos(del*torad)
497  sind=sin(del*torad)
498  delsv=del
499  endif
500  if(cosd .eq. 0.d0 .or. coslat .eq. 0.d0) then
501  if(abs(w3-sinlat*sind) .le. 1.d-5) then
502  h=12.d0
503  icon=0
504  elseif(w3 .lt. sinlat*sind) then
505  w3=sinlat*sind
506  h=12.d0
507  icon=1
508  else
509  icon=2
510  endif
511  else
512  cosx=( w3 - sind*sinlat )/cosd/coslat
513  if(abs(cosx) .le. 1.d0) then
514  icon=0
515  fai=acos(cosx)*todeg
516  h=fai*toh
517  elseif(abs(w3- sinlat*sind) .le. 1.d-5) then
518  icon=0
519  h=12.d0
520  elseif(w3 .lt. sinlat*sind) then
521  h=12.d0
522  w3=sinlat*sind
523  icon=1
524  else
525  icon=2
526  endif
527  endif
528  end
529 ! ---------- equatorial angle to galactic angle -----------
530 ! /usage/ call keqtog(dec, ra, glat, glon)
531 !
532 ! dec: input. declination in degree
533 ! ra: input. right ascension in degree
534 ! glat: output. galactic latitude in degree
535 ! glon: output. galactic longitude in degree
536 !
537  subroutine keqtog(dec, ra, glat, glon)
538  implicit real*8 (a-h, o-z)
539 !
540  call ketod(dec, ra, ex, ey, ez)
541  call kedtgd(ex, ey, ez, gx, gy, gz)
542  call kdtoa(gx, gy, gz, glat, glon)
543  glat=90.d0-glat
544  glon=mod(glon+360.d0, 360.d0)
545  end
546 ! -------------- inverse of above -------------
547  subroutine kgtoeq(glat, glon, dec, ra)
548  implicit real*8 (a-h, o-z)
549  call ketod(glat, glon, gx, gy, gz)
550  call kgdted(gx, gy, gz, ex, ey, ez)
551  call kdtoe(ex, ey, ez, dec, ra)
552  end
553 ! ------- galactic direction cos to equatorial direction cos
554 ! /usage/ call kgdted(gx, gy, gz, ex, ey, ez)
555 !
556 ! gx, gy, gz: input. galactic direction cos
557 ! ex, ey, ez: output. equatorial //
558 !
559  subroutine kgdted(gx, gy, gz, ex, ey, ez)
560 !
561  implicit real*8 (a-h, o-z)
562 #include "Zkcele.h"
563  logical first/.true./
564  parameter(
565  + t=(12.d0+49d0/60.d0)*15.d0*torad, f=62.6d0*torad)
566 !
567  if(first) then
568  first=.false.
569  cos33=cos(33.d0*torad)
570  sin33=sin(33.d0*torad)
571  sint=sin(t)
572  cost=cos(t)
573  sinf=sin(f)
574  cosf=cos(f)
575  a11=-sint
576  a12=-cost*cosf
577  a13=cost*sinf
578  a21=cost
579  a22=-sint*cosf
580  a23=sint*sinf
581  a32=sinf
582  a33=cosf
583  b11=-sint
584  b12=cost
585  b21=-cosf*cost
586  b22=-cosf*sint
587  b23=sinf
588  b31=sinf*cost
589  b32=sinf*sint
590  b33=cosf
591  endif
592  gxp=cos33*gx + sin33*gy
593  gyp=-sin33*gx + cos33*gy
594  gzp=gz
595  ex=a11*gxp +a12*gyp + a13*gzp
596  ey=a21*gxp +a22*gyp + a23*gzp
597  ez= a32*gyp + a33*gzp
598  return
599 ! --------------------- e to g ----------------------
600  entry kedtgd(ex, ey, ez, gx, gy, gz)
601  if(first) then
602  first=.false.
603  cos33=cos(33.d0*torad)
604  sin33=sin(33.d0*torad)
605  sint=sin(t)
606  cost=cos(t)
607  sinf=sin(f)
608  cosf=cos(f)
609  a11=-sint
610  a12=-cost*cosf
611  a13=cost*sinf
612  a21=cost
613  a22=-sint*cosf
614  a23=sint*sinf
615  a32=sinf
616  a33=cosf
617  b11=-sint
618  b12=cost
619  b21=-cosf*cost
620  b22=-cosf*sint
621  b23=sinf
622  b31=sinf*cost
623  b32=sinf*sint
624  b33=cosf
625  endif
626  gxp=b11*ex + b12*ey
627  gyp=b21*ex + b22*ey + b23*ez
628  gzp=b31*ex + b32*ey + b33*ez
629  gx= cos33*gxp -sin33*gyp
630  gy= sin33*gxp + cos33*gyp
631  gz=gzp
632  return
633  end
634 ! real*8 mjd, time
635 ! integer*4 y, m, d
636 ! mjd=47096.3114004629d0
637 ! call kmjdym(mjd, y, m, d, time)
638 ! write(*,*) ' y,m,d=',y, m, d, ' time=',time
639 ! end
640  subroutine kmjdym(mjd, y, m, d, time)
641 ! not used in janzos. see kdcmjd
642  implicit real*8 (a-h, o-z)
643  real*8 mjd, jd
644  integer*4 y, m, d, a, b, c, e, f, g, h
645  time=(mjd- int(mjd))*24.d0
646  jd=mjd+ 2400000.5d0
647  a=int(jd)+68569
648  b=int( a/36524.25)
649  c=a - int(36524.25d0*b+0.75d0)
650  e=int( (c+1)/365.2425d0)
651  f= c - int(365.25d0*e)+31
652  g=int(f/30.59d0)
653  d=f -int(30.59d0*g)+ 0.5d0 + (jd -int(jd))
654  h=int(g/11.d0)
655  m=g-12*h+2
656  y=100*(b-49)+ e + h
657  if(d .eq. 32) then
658  d=1
659  y=y+1
660  m=1
661  endif
662  end
663 ! this include kdcmjd
664 ! and kmjdst
665 !
666 ! real*8 mjd, time, st
667 ! integer*4 y, m, d
668 ! mjd=47161.0000004629d0
669 ! call kdcmjd(mjd, y, m, d, time)
670 ! write(*,*) ' y,m,d=',y, m, d, ' time=',time
671 ! call kcelei(36., 135., 9.)
672 ! call kmjdst(mjd, st)
673 ! write(*,*) ' st=',st
674 ! end
675 ! ****************************************************************
676 ! *
677 ! * kdcmjd: decompose mjd into year, month, day, and hour (ut)
678 ! *
679 ! ****** tested 89.03.13******************************************
680 ! this one is based on honda.
681 ! same result is obtained as kmjdym made by k.k
682 !
683 ! /usage/ call kdcmjd(mjd, iy, im, id, ihr, imn, sec
684 !
685 ! mjd: input. real*8. modified julian day
686 ! iy: output. integer*4. year. say, 1989
687 ! im: // month. say, 11
688 ! id: // day. say, 23
689 ! ihr: // // hour say, 12
690 ! imn: // // min. say 15
691 ! sec: // sec. say 12.4567
692 !
693 !
694  subroutine kdcmjd(mjd,iy,im,id,ihr,imn,sec)
695  implicit real*8 (a-h, o-z)
696 ! input mjd : modified julian day (fractional) real*8
697 ! output iy : year im month id day of month
698  real*8 mjd
699 !
700  time =(mjd- int(mjd))*24.0d0
701  ihr = int(time)
702  time =(time - ihr)*60.d0
703  imn = int(time)
704  sec =(time - imn)*60.d0
705 !
706  jd= int(mjd + 2400001.0d0)
707  l = jd + 68569
708  n = 4*l/146097
709  l = l - (146097*n+3)/4
710  iy = 4000*(l+1)/1461001
711  l = l - 1461*iy/4+31
712  im = 80*l/2447
713  id = l - 2447*im/80
714  l = im/11
715  im = im + 2 - 12*l
716  iy = 100*(n-49) + iy + l
717  end
718 ! ****************************************************************
719 ! *
720 ! * kmjdst: mjd to siderial time conversion. (local)
721 ! * this is based old equinox. for j2000 ephemeris
722 ! * use the new one with the same name
723 ! ****** tested 89.03.13******************************************
724 !
725 ! /usage/ call kmjdst(mjd, st)
726 !
727 ! kcelei must have been called beforehand.
728 !
729 ! mjd: input. real*8. modified julian day
730 ! st: output. siderial time at specified longitude
731 ! (normalized to 1.)
732 ! subroutine kmjdst(mjd, st)
733 ! implicit real*8 (a-h, o-z)
734 ! real*8 mjd
735 ! data siddy0 /0.671262d0/
736 !
737 ! du = (mjd - 40000.0d0)
738 ! tu = du/36525.0d0
739 !
740 ! sidsol= sidcor +( sidcr2 + sidcr3*tu )*tu
741 ! sidday= siddy0 + sidsol*du + tlons/360.0d0
742 !
743 ! sidt = sidday-int(sidday)
744 ! if(sidday.lt.0.0d0) then
745 ! sidt =1.0d0 + sidt
746 ! endif
747 ! st= sidt
748 ! end
749  subroutine kmjdst(mjd, st)
750  implicit real*8 (a-h, o-z)
751 #include "Zkcele.h"
752  real*8 mjd
753  parameter(c1=(50.54841d0/3600.d0 + 41.d0/60.+18.d0),
754  * c2=8640184.812866d0/3600.d0,
755  * c3=0.0931047d0/3600.d0, c4=-0.0000062d0/3600.d0)
756 ! get j2000 time
757  call kmtoj2(mjd, t)
758  am= ((c4*t+ c3)*t + c2)*t + c1
759 ! approximate ut1 (dut1 is < 1 sec) if mjd is correct
760  ut1=( mjd - int(mjd) )*24.d0
761  st=( ut1+ 12.d0 + am )*15.d0 + tlons
762  st=mod(st, 360.d0)
763  if(st .lt. 0.d0) then
764  st=st+360.d0
765  endif
766  end
767  subroutine kmjdtj(mjd, jd)
768  real*8 mjd, jd
769  jd=mjd+2400000.5d0
770  end
771  subroutine kjtmjd(jd, mjd)
772  real*8 jd, mjd
773  mjd=jd-2400000.5d0
774  end
775 ! test of j2000 conversion
776 ! declination is changed about 0.05 deg
777 ! right ascension is changed about 0.12 deg
778 !
779 ! real*8 pij(3,3), mjd, ex, ey, ez, ex2, ey2, ez2,
780 ! * d, r, do, ao
781 !c mjd of about 90.04.20.
782 ! mjd=48000.d0
783 ! call kpmtrx(mjd, pij)
784 ! write(*,*) (pij(i,1), i=1, 3 )
785 ! write(*,*) (pij(i,2), i=1, 3 )
786 ! write(*,*) (pij(i,3), i=1, 3 )
787 ! call ketod(35.d0, 100.d0, ex, ey, ez)
788 ! write(*,*) ' ex , ey , ez =', ex , ey , ez
789 ! call kxtoj2(pij, ex, ey, ez, ex2, ey2, ez2)
790 ! write(*,*) ' ex2, ey2, ez2=', ex2, ey2, ez2
791 ! call kj2tox(pij, ex2, ey2, ez2, ex, ey, ez)
792 ! write(*,*) ' ex , ey , ez =', ex , ey , ez
793 ! call kdtoe(ex2, ey2, ez2, d, r)
794 ! write(*,*) ' d, r=',d, r
795 ! do=0.
796 ! ao=0.
797 ! call ketod(do, ao, ex, ey, ez)
798 ! call kxtoj2(pij, ex, ey, ez, ex2, ey2, ez2)
799 ! call kdtoe(ex2, ey2, ez2, d, r)
800 ! write(*,*) ' do, ao=',do, ao
801 ! write(*,*) ' d, r=',d, r
802 ! do=50.
803 ! ao=0.
804 ! call ketod(do, ao, ex, ey, ez)
805 ! call kxtoj2(pij, ex, ey, ez, ex2, ey2, ez2)
806 ! call kdtoe(ex2, ey2, ez2, d, r)
807 ! write(*,*) ' do, ao=',do, ao
808 ! write(*,*) ' d, r=',d, r
809 ! do=25.
810 ! ao=0.
811 ! call ketod(do, ao, ex, ey, ez)
812 ! call kxtoj2(pij, ex, ey, ez, ex2, ey2, ez2)
813 ! call kdtoe(ex2, ey2, ez2, d, r)
814 ! write(*,*) ' do, ao=',do, ao
815 ! write(*,*) ' d, r=',d, r
816 ! end
817 ! ***********************************************************
818 ! *
819 ! * kpmtrx: compute precession matrix defined in p.423-425
820 ! * of 'japanese ephemeris 1990'
821 ! *
822 ! ***********************************************************
823 ! /usage/ call kpmtrx(mjd, pij)
824 ! mjd: input. modified julian day (real*8)
825 ! pij: output. pij(3,3) precession matrix
826 ! pij(i,j)=nij
827 ! suppose directional cosines are
828 ! given in the rectangular equatorial
829 ! coordinate based on the equinox at the instance of
830 ! the observation. (the observed directional cosines are
831 ! such ones provided that the siderial time contains the
832 ! effect of the precession).
833 ! the matrix computed here can be used to obtain the
834 ! directional cosines at j2000 by
835 !
836 ! d2 = pji dobsv
837 ! **** this is computed only at first event of each run *****
838 ! because change is very small.
839 !
840  subroutine kpmtrx(mjd, pij)
841  implicit real*8 (a-h,o-z)
842  real*8 mjd
843  dimension pij(3,3)
844  parameter(pi=3.14159265358979324d0,
845  * torad=pi/3600.d0/180.d0)
846 ! days from 2000y01m1.5d (julian day,2451545.0)
847 ! in unit of 100 julian years
848  call kmtoj2(mjd, t)
849  t2 = t*t
850  t3 = t*t2
851 !
852  zeta = 2306.2181d0*t + 0.30188d0*t2 + 0.017998d0*t3
853  za = 2306.2181d0*t + 1.09468d0*t2 + 0.018203d0*t3
854  teta = 2004.3109d0*t - 0.42665d0*t2 - 0.041833d0*t3
855 !
856  zeta = zeta* torad
857  za = za* torad
858  teta = teta*torad
859 !
860  pij(1,1) = cos(zeta)*cos(teta)*cos(za) -sin(zeta)*sin(za)
861  pij(1,2) =-sin(zeta)*cos(teta)*cos(za) -cos(zeta)*sin(za)
862  pij(1,3) = -sin(teta)*cos(za)
863  pij(2,1) = cos(zeta)*cos(teta)*sin(za) +sin(zeta)*cos(za)
864  pij(2,2) =-sin(zeta)*cos(teta)*sin(za) +cos(zeta)*cos(za)
865  pij(2,3) = -sin(teta)*sin(za)
866  pij(3,1) = cos(zeta)*sin(teta)
867  pij(3,2) =-sin(zeta)*sin(teta)
868  pij(3,3) = cos(teta)
869  end
870  subroutine kmtoj2(mjd, t)
871 ! days from 2000y01m1.5d (julian day,2451545.0)
872 ! in unit of 100 julian years
873  real*8 t, mjd
874  t = (mjd - 51544.5d0)/36525d0
875  end
876 ! *****************************************************************
877 ! *
878 ! * kj2tox: convert equatorial vector in j2000 into those at
879 ! * time x which has been specified by pij matrix
880 ! * obtained in kpmtrx
881 ! *
882 ! *****************************************************************
883 !
884  subroutine kj2tox(pij, ex2, ey2, ez2, ex, ey, ez)
885 !
886 ! pij(3,3): input. precession matrix obtained in kpmtrx
887 ! ex2,...ez2: input. directional cosines in j2000 ephemeris
888 ! ex,...ez: output. directional cosines at x
889 !
890  implicit real*8 (a-h,o-z)
891  dimension pij(3,3)
892 !
893  ex= pij(1,1)*ex2 + pij(1,2)*ey2 + pij(1,3)*ez2
894  ey= pij(2,1)*ex2 + pij(2,2)*ey2 + pij(2,3)*ez2
895  ez= pij(3,1)*ex2 + pij(3,2)*ey2 + pij(3,3)*ez2
896  end
897 ! *****************************************************************
898 ! *
899 ! * kxtoj2: convert equatorial vector at x which has been specifie
900 ! * by pij matrix computed in kpmtrx into the one
901 ! * in j2000 ephemeris
902 ! *
903 ! *****************************************************************
904 !
905  subroutine kxtoj2(pij, ex, ey, ez, ex2, ey2, ez2)
906 !
907 ! pij(3,3): input. precession matrix obtained in kpmtrx
908 ! ex,...ez: input. directional cosines at x
909 ! ex2,...ez2: output.directional cosines in j2000 ephemeris
910 !
911  implicit real*8 (a-h,o-z)
912  dimension pij(3,3)
913 !
914  ex2= pij(1,1)*ex + pij(2,1)*ey + pij(3,1)*ez
915  ey2= pij(1,2)*ex + pij(2,2)*ey + pij(3,2)*ez
916  ez2= pij(1,3)*ex + pij(2,3)*ey + pij(3,3)*ez
917  end
918 ! test kmoon
919 ! implicit real*8 (a-h, o-z)
920 ! real*8 mjd/48234.00068287d0/
921 ! call kmoon(mjd, elat, elon, rm)
922 ! write(*,*) ' elat=',elat, ' elon=',elon, ' rm=',rm
923 ! mjd=33250.0d0
924 ! call kctoq(mjd, 0.2535301d0, 1.5274972d0,
925 ! * 0.0260904d0, ex, ey, ez)
926 ! write(*,*) ex, ey,ez
927 ! end
928 ! ************************************************************
929 ! *
930 ! * kmoon: compute the moon position in the ecliptic coord.
931 ! * (apparent geocentric ecliptic coordinate)
932 ! * (accuracy is better than 1/100 degree)
933 ! ************************************************************
934 ! /usage/ call kmoon(mjd, elat, elon, rmoon)
935 !
936 ! mjd: input. real*8. modified julian day of the place, time
937 ! elat: output. apparent ecliptic latitude of the moon
938 ! (degree)
939 ! elon: output. apparent ecliptic longitude of them moon
940 ! (degree)
941 ! rmoon: output. distance from the center of the earth
942 ! to that of the moon. (gravitation center)
943 ! (in m).
944 ! the constant of the sin parallax is
945 ! sinpi=ae/r where ae= the equatorial
946 ! radius of the earth, r the distance
947 ! to the moon. (between the gravitational
948 ! center). ae=6378.140 km
949 !
950 ! **note** this coordinate may be converted into that in the
951 ! apparent geocentric equatorial coord, and then
952 ! converted to the apparent topocentric equatorial coord.
953 !
954  subroutine kmoon(mjd, elat, elon, rmoon)
955  implicit real*8 (a-h, o-z)
956 #include "Zkcele.h"
957  real*8 mjd, ksind, kcosd
958 !
959  real*8 c(62), d(62), e(62)
960  real*8 f(46), g(46), h(46)
961 !
962  data c/
963  1 1.2740d0, 0.6583d0, 0.2136d0, 0.1856d0,
964  2 0.1143d0, 0.0588d0, 0.0572d0, 0.0533d0, 0.0459d0,
965  3 0.0410d0, 0.0348d0, 0.0305d0, 0.0153d0, 0.0125d0,
966  4 0.0110d0, 0.0107d0, 0.0100d0, 0.0085d0, 0.0079d0,
967  5 0.0068d0, 0.0052d0, 0.0050d0, 0.0048d0, 0.0040d0,
968  6 0.0040d0, 0.0040d0, 0.0039d0, 0.0037d0, 0.0027d0,
969  7 0.0026d0, 0.0024d0, 0.0024d0, 0.0022d0, 0.0021d0,
970  8 0.0021d0, 0.0021d0, 0.0020d0, 0.0018d0, 0.0016d0,
971  9 0.0012d0, 0.0011d0, 0.0009d0, 0.0008d0, 0.0008d0,
972  a 0.0007d0, 0.0007d0, 0.0007d0, 0.0006d0, 0.0005d0,
973  b 0.0005d0, 0.0005d0, 0.0005d0, 0.0004d0, 0.0004d0,
974  c 0.0004d0, 0.0004d0, 0.0003d0, 0.0003d0, 0.0003d0,
975  d 0.0003d0, 0.0003d0, 0.0003d0/
976 !
977  data d/
978  1 107.248d0, 51.668d0, 317.831d0, 176.531d0,
979  2 292.463d0, 86.16 d0, 103.78 d0, 30.58 d0, 124.86 d0,
980  3 342.38 d0, 25.83 d0, 155.45 d0, 240.79 d0, 271.38 d0,
981  4 226.45 d0, 55.58 d0, 296.75 d0, 34.5 d0, 290.7 d0,
982  5 228.2 d0, 133.1 d0, 202.4 d0, 68.6 d0, 34.1 d0,
983  6 9.5 d0, 93.8 d0, 103.3 d0, 65.1 d0, 321.3 d0,
984  7 174.8 d0, 82.7 d0, 4.7 d0, 121.4 d0, 134.4 d0,
985  8 173.1 d0, 100.3 d0, 248.6 d0, 98.1 d0, 344.1 d0,
986  9 52.1 d0, 250.3 d0, 81.0 d0, 207.0 d0, 31.0 d0,
987  a 346.0 d0, 294.0 d0, 90.0 d0, 237.0 d0, 82.0 d0,
988  b 276.0 d0, 73.0 d0, 112.0 d0, 116.0 d0, 25.0 d0,
989  c 181.0 d0, 18.0 d0, 60.0 d0, 13.0 d0, 13.0 d0,
990  d 152.0 d0, 317.0 d0, 348.0 d0/
991 !
992  data e/
993  1 -4133.3536d0, 8905.3422d0, 9543.9773d0, 359.9905d0,
994  2 9664.0404d0, 638.635d0, -3773.363d0,13677.331d0, -8545.352d0,
995  3 4411.998d0, 4452.671d0, 5131.979d0, 758.698d0, 14436.029d0,
996  4 -4892.052d0,-13038.696d0,14315.966d0,-8266.71d0, -4493.34d0,
997  5 9265.33d0, 319.32d0, 4812.66d0, -19.34 d0,13317.34d0,
998  6 18449.32d0, -1.33 d0, 17810.68d0, 5410.62d0, 9183.99d0,
999  7 -13797.39d0, 998.63d0, 9224.66d0, -8185.36d0, 9903.97d0,
1000  8 719.98 d0, -3413.37d0, -19.34d0, 4013.29d0, 18569.38d0,
1001  9 -12678.71d0, 19208.02d0, - 8586.0d0, 14037.3d0,-7906.7d0,
1002  a 4052.0 d0, -4853.3d0, 278.6 d0, 1118.7d0, 22582.7d0,
1003  b 19088.0d0, -17450.7d0, 5091.3d0, -398.7d0, -120.1d0,
1004  c 9584.7 d0, 720.d0, -3814.0d0, -3494.7d0,18089.3d0,
1005  d 5492.0d0, -40.7d0, 23221.3d0/
1006 !
1007  data f/
1008  1 0.2806d0, 0.2777d0, 0.1732d0, 0.0554d0,
1009  2 0.0463d0, 0.0326d0, 0.0172d0, 0.0093d0, 0.0088d0,
1010  3 0.0082d0, 0.0043d0, 0.0042d0, 0.0034d0, 0.0025d0,
1011  4 0.0022d0, 0.0021d0, 0.0019d0, 0.0018d0, 0.0018d0,
1012  5 0.0017d0, 0.0016d0, 0.0015d0, 0.0015d0, 0.0014d0,
1013  6 0.0013d0, 0.0013d0, 0.0012d0, 0.0012d0, 0.0011d0,
1014  7 0.0010d0, 0.0008d0, 0.0008d0, 0.0007d0, 0.0006d0,
1015  8 0.0006d0, 0.0005d0, 0.0005d0, 0.0004d0, 0.0004d0,
1016  9 0.0004d0, 0.0004d0, 0.0004d0, 0.0003d0, 0.0003d0,
1017  a 0.0003d0, 0.0003d0/
1018 !
1019  data g/
1020  1 215.147d0, 77.316d0, 4.563d0, 308.98 d0,
1021  2 343.48d0, 287.90d0, 194.06 d0, 25.6 d0, 98.4 d0,
1022  3 1.1 d0, 322.4 d0, 266.8 d0, 188.0 d0, 312.5 d0,
1023  4 291.4 d0, 340.0 d0, 218.6 d0, 291.8 d0, 52.8 d0,
1024  5 168.7 d0, 73.8 d0, 262.1 d0, 31.7 d0, 260.8 d0,
1025  6 239.7 d0, 30.4 d0, 304.9 d0, 12.4 d0, 173.0 d0,
1026  7 312.9 d0, 1.0 d0, 190.0 d0, 22.0 d0, 117.0 d0,
1027  8 47.0 d0, 22.0 d0, 150.0 d0, 119.0 d0, 246.0 d0,
1028  9 301.0 d0, 126.0 d0, 104.0 d0, 340.0 d0, 270.0 d0,
1029  a 358.0 d0, 148.0 d0/
1030 !
1031  data h/
1032  1 9604.0088d0, 60.0316d0, -4073.3220d0, 8965.374d0,
1033  2 698.667d0, 13737.362d0,14375.997d0, -8845.31d0,-4711.96d0,
1034  3 -3713.33d0, 5470.66d0, 18509.35d0, -4433.31d0, 8605.38d0,
1035  4 13377.37d0, 1058.66d0, 9244.02d0, -8206.68d0, 5192.01d0,
1036  5 14496.06d0, 420.02d0, 9284.69d0, 9964.00d0, - 299.96d0,
1037  6 4472.03d0, 379.35d0, 4812.68d0, -4851.36d0,19147.99d0,
1038  7 -12978.66d0, 17870.7d0, 9724.1d0, 13098.7d0, 5590.7d0,
1039  8 -13617.3d0, -8485.3d0, 4193.4d0, -9483.9d0, 23282.3d0,
1040  9 10242.6d0, 9325.4d0, 14097.4d0, 22642.7d0,18149.4d0,
1041  a -3353.3d0, 19268.0d0/
1042 !
1043  t=(mjd-42412.d0)/365.25d0
1044  t=t + (0.0317d0*t+1.43d0)*1.d-6
1045 !
1046  a = 0.0040d0*ksind(93.8d0 - 1.33d0*t)
1047  * +0.0020d0*ksind(248.6d0 - 19.34d0*t)
1048  * +0.0006d0*ksind(66.d0 + 0.2d0*t)
1049  * +0.0006d0*ksind(249.d0 -19.3d0*t)
1050 !
1051  b= 0.0267d0*ksind(68.64d0 - 19.341d0*t)
1052  * +0.0043d0*ksind(342.d0 - 19.36d0*t)
1053  * +0.0040d0*ksind( 93.8d0 - 1.33 d0*t)
1054  * +0.0020d0*ksind(248.6d0 - 19.34d0*t)
1055  * +0.0005d0*ksind(358.d0 - 19.4d0*t)
1056 ! longitude
1057  tmp=124.8754d0+4812.67881d0*t +
1058  * 6.2887d0*ksind(338.915d0+ 4771.9886d0*t+a)
1059 !
1060  do i=1, 62
1061  tmp=tmp+ c(i)*ksind( d(i) + e(i)*t )
1062  enddo
1063  elon=mod(tmp,360.d0)
1064 ! latitude
1065  tmp=5.1282d0*ksind(236.231d0 + 4832.0202d0*t+b)
1066 !
1067  do i=1, 46
1068  tmp=tmp+ f(i)*ksind( g(i) + h(i)*t )
1069  enddo
1070  elat=tmp
1071 !
1072  sinpi= 0.9507d0
1073  * + 0.0518d0*kcosd(338.92d0 + 4771.989d0*t)
1074  * + 0.0095d0*kcosd(287.2 d0 - 4133.35 d0*t)
1075  * + 0.0078d0*kcosd( 51.7 d0 + 8905.34 d0*t)
1076  * + 0.0028d0*kcosd(317.8 d0 + 9543.98 d0*t)
1077  * + 0.0009d0*kcosd( 31.0 d0 +13677.3 d0*t)
1078  * + 0.0005d0*kcosd(305.0 d0 - 8545.4 d0*t)
1079  * + 0.0004d0*kcosd(284.0 d0 - 3773.4 d0*t)
1080  * + 0.0003d0*kcosd(342.0 d0 + 4412.0 d0*t)
1081 !
1082  rmoon=ae/(sinpi*torad)
1083  end
1084  real*8 function ksind(x)
1085 ! sin x with x in degree
1086  implicit real*8 (a-h, o-z)
1087 #include "Zkcele.h"
1088  ksind=sin(x*torad)
1089  end
1090  real*8 function kcosd(x)
1091 ! cos x with x in degree
1092  implicit real*8 (a-h, o-z)
1093 #include "Zkcele.h"
1094  kcosd=cos(x*torad)
1095  end
1096 ! ************************************************************
1097 ! *
1098 ! * kctoq: ecliptic to equatorial coordinate transformation
1099 ! * kqtoc: eqatorial to ecliptic coordinate transformation
1100 ! *
1101 ! ************************************************************
1102 ! /usage/ call kctoq(mjd, cx, cy, cz, ex, ey, ez)
1103 !
1104 ! mjd: input. real*8. modified julian day of the place, time
1105 ! cx,cy,cz: input. directional cosines in ecliptic coordinate.
1106 ! ex,ey,ez: output. // equatorial coordinate.
1107  subroutine kctoq(mjd, cx, cy, cz, ex, ey, ez)
1109  implicit real*8 (a-h, o-z)
1110  real*8 mjd
1111 ! get mean obliquity of the ecliptic
1112  call kmobec(mjd, cose, sine)
1113  ex=cx
1114  ey=cy*cose - cz*sine
1115  ez=cy*sine + cz*cose
1116  end
1117 ! eqatorial to ecliptic coordinate transformation
1118 ! call kqtoc(mjd, ex, ey, ez, cx, cy, cz)
1119  subroutine kqtoc(mjd, ex, ey, ez, cx, cy, cz)
1120  implicit real*8 (a-h, o-z)
1121  real*8 mjd
1122 ! get mean obliquity of the ecliptic
1123  call kmobec(mjd, cose, sine)
1124  cx=ex
1125  cy=ey*cose + ez*sine
1126  cz=-ey*sine + ez*cose
1127  end
1128 ! ********************************************************
1129 ! *
1130 ! * kmobec: get mean obliquity of teh ecliptic plane
1131 ! *
1132 ! * (inclination angle of ecliptic plane)
1133 ! ********************************************************
1134 ! /usage/ call kmobec(mjd, cose, sine)
1135 ! mjd: input. real*8 modified jd.
1136 ! cose: output. cosine of obliquity
1137 ! sine: output. sine of obliquity
1138 !
1139  subroutine kmobec(mjd, cose, sine)
1140  implicit real*8 (a-h, o-z)
1141 #include "Zkcele.h"
1142  real*8 mjd
1143 ! get cos and sin of inclination angle of the
1144 ! mean ecliptic plane.
1145 ! get time from j2000.
1146  call kmtoj2(mjd, t)
1147 ! eps=(((0.0000005036d0*t -0.000000164d0)*t - 0.01300417d0)*t
1148  eps=(((0.0000005036d0*t -0.00000164d0)*t - 0.01300417d0)*t
1149  * +23.439291d0)*torad
1150  cose=cos(eps)
1151  sine=sin(eps)
1152  end
1153 ! test ksun
1154 ! real*8 mjd
1155 ! mjd=48234.00068287d0
1156 ! call ksun(mjd, slon, rsun)
1157 ! write(*,*) ' slon=',slon, ' rsun=',rsun
1158 ! end
1159 ! ************************************************************
1160 ! *
1161 ! * ksuneq: compute sun's position in the geocentric
1162 ! * equatorial coordinate
1163 ! *
1164 ! * accuracy is about 1/100. degree
1165 ! * no need to convert this one into topocentric one in
1166 ! * this accuracy.
1167 ! ************************************************************
1168 ! /usage/ call ksuneq(mjd, ex, ey, ez)
1169 !
1170 ! mjd: input. real*8. modified jd.
1171 ! ex,ey,ez: output. directional cosines in the geocentric
1172 ! equatorial coordinate
1173 !
1174  subroutine ksuneq(mjd, ex, ey, ez)
1175  implicit real*8 (a-h, o-z)
1176  real*8 mjd
1177 ! get ecliptic longitude in deg
1178  call ksun(mjd, slon, rsun)
1179 ! convert to directional cos. in ecliptic
1180  call ketod(0.d0,slon, cx, cy, cz)
1181 ! convert to equatorial coordinate
1182  call kctoq(mjd, cx, cy, cz, ex, ey, ez)
1183  end
1184 ! ************************************************************
1185 ! *
1186 ! * ksun: compute sun's position in the geocentric
1187 ! * ecliptic coordinate
1188 ! *
1189 ! * accuracy is about 1/100. degree
1190 ! * no need to convert this one into topocentric one in
1191 ! * this accuracy.
1192 ! ************************************************************
1193 ! /usage/ call ksun(mjd, slon, rsun)
1194 !
1195 ! mjd: input. real*8. modified julian day when the position is
1196 ! wanted.
1197 ! slon: output. ecliptic longitude in degree.
1198 ! rsun: output. distance between the centers of earth and
1199 ! sun in m.
1200 ! *** note ***
1201 ! if the earth position in the heriocentric ecliptic coordinate
1202 ! is wanted, it is given by slon+180.
1203 !
1204 ! the ecliptic latitude is always very small (< 1''), and is to
1205 ! be set to zero in our approximation.
1206 ! to convert the ecliptic coordinate into the equatorial
1207 ! coordinate, use, ketod(0.d0, slon, cx, cy, cz),
1208 ! kctoq(mjd,cx, cy, xz, ex, ey, ez), kdtoe(ex, ey,ez, dec, ra)
1209 !
1210 !
1211  subroutine ksun(mjd, slon, rsun)
1212  implicit real*8 (a-h, o-z)
1213 #include "Zkcele.h"
1214  real*8 mjd, ksind, kcosd
1215 !
1216  t=(mjd-42412.d0)/365.25d0
1217  t=t + (0.0317d0*t+1.43d0)*1.d-6
1218  tmp = 279.0358d0 +360.00769d0*t
1219  1 +(1.9159d0-0.00005d0*t)*ksind(356.531d0+359.991d0*t)
1220  2 + 0.02d0 *ksind(353.06d0 + 719.981d0*t)
1221  3 - 0.0048d0 *ksind(248.64d0 - 19.341d0*t)
1222  4 + 0.0020d0 *ksind(285.0d0 + 329.64d0*t)
1223  5 + 0.0018d0 *ksind(334.2d0 -4452.67d0*t)
1224  6 + 0.0018d0 *ksind(293.7d0 - 0.20d0*t)
1225  7 + 0.0015d0 *ksind(242.4d0 + 450.37d0*t)
1226  8 + 0.0013d0 *ksind(211.1d0 + 225.18d0*t)
1227  9 + 0.0008d0 *ksind(208.0d0 + 659.29d0*t)
1228  a + 0.0007d0 *ksind( 53.5d0 + 90.38d0*t)
1229  b + 0.0007d0 *ksind( 12.1d0 - 30.35d0*t)
1230  c + 0.0006d0 *ksind(239.1d0 + 337.18d0*t)
1231  d + 0.0005d0 *ksind( 10.1d0 - 1.50d0*t)
1232  e + 0.0005d0 *ksind( 99.1d0 - 22.81d0*t)
1233  f + 0.0004d0 *ksind(264.8d0 + 315.56d0*t)
1234  g + 0.0004d0 *ksind(233.8d0 + 299.30d0*t)
1235  h + 0.0004d0 *ksind(198.1d0 + 720.02d0*t)
1236  i + 0.0003d0 *ksind(349.6d0 + 1079.97d0*t)
1237  k + 0.0003d0 *ksind(241.2d0 -44.43d0*t)
1238 !
1239  slon=mod(tmp, 360.d0)
1240 !
1241  q=(-0.007261d0+0.0000002d0*t)*kcosd(356.53d0 + 359.991d0*t)
1242  * + 0.000030d0
1243  1 - 0.000091d0 * kcosd(353.1d0 + 719.98d0*t)
1244  2 + 0.000013d0 * kcosd(205.8d0 + 4452.67d0*t)
1245  3 + 0.000007d0 * kcosd( 62.d0 + 450.4d0*t)
1246  4 + 0.000007d0 * kcosd(105.d0 + 329.6d0*t)
1247 !
1248  rsun=10.**q * aunit
1249  end
1250  subroutine kadbp(nftch,dx,dy,dz,dt,wt,u,v,w,tz,icon)
1251  implicit real*8 (a-h, o-z)
1252  dimension dt(nftch),dx(nftch),dy(nftch),dz(nftch),wt(nftch)
1253 !----------------------------------------------------------------------
1254  sww=0.d0
1255  swx=0.d0
1256  swy=0.d0
1257  swz=0.d0
1258  swt=0.d0
1259  sxy=0.d0
1260  syz=0.d0
1261  szx=0.d0
1262  sxt=0.d0
1263  syt=0.d0
1264  sx2=0.d0
1265  sy2=0.d0
1266  do i=1,nftch
1267  sww=sww+wt(i)
1268  swx=swx+dx(i)*wt(i)
1269  swy=swy+dy(i)*wt(i)
1270  swz=swz+dz(i)*wt(i)
1271  swt=swt+dt(i)*wt(i)
1272  sxy=sxy+dx(i)*dy(i)*wt(i)
1273  syz=syz+dy(i)*dz(i)*wt(i)
1274  szx=szx+dz(i)*dx(i)*wt(i)
1275  sxt=sxt+dx(i)*dt(i)*wt(i)
1276  syt=syt+dy(i)*dt(i)*wt(i)
1277  sx2=sx2+dx(i)*dx(i)*wt(i)
1278  sy2=sy2+dy(i)*dy(i)*wt(i)
1279  enddo
1280 !
1281  a1=sww*sx2-swx*swx
1282  a2=sww*sxy-swx*swy
1283  a3=sww*szx-swx*swz
1284  a4=sww*sxt-swx*swt
1285  b1=a2
1286  b2=sww*sy2-swy*swy
1287  b3=sww*syz-swy*swz
1288  b4=sww*syt-swy*swt
1289  ab=a1*b2-a2*b1
1290  if(abs(ab).gt.1.d-6) then
1291  p=(a2*b3-a3*b2)/ab
1292  q=(a2*b4-a4*b2)/ab
1293  r=(a3*b1-a1*b3)/ab
1294  s=(a4*b1-a1*b4)/ab
1295  aa=p*p+r*r+1.0d0
1296  bb=0.6*(p*q+r*s)
1297  cc=0.09*(q*q+s*s)-1.0d0
1298  t1=-0.5d0*bb/aa
1299  t2=bb*bb-4.d0*aa*cc
1300  if(t2.lt.0.d0) then
1301 ! % solution is imaginary %
1302  icon=2
1303  else
1304 ! % solvable ] %
1305  t2=0.5d0*sqrt(t2)/aa
1306  w=t1+t2
1307  if(w.lt.0.d0) w=t1-t2
1308  u=p*w+0.3d0*q
1309  v=r*w+0.3d0*s
1310  tz=(u*swx+v*swy+w*swz+0.3d0*swt)/(0.3d0*sww)
1311  if(abs(u).le.1.0d0 .and. abs(v).le.1.0d0) then
1312  icon=0
1313  else
1314 ! % solution is not normalized %
1315  icon=1
1316  endif
1317  endif
1318 ! direction cosines cannot be determined
1319  else
1320  icon=3
1321  endif
1322  return
1323  end
1324 ! -------------------------------------------
1325 ! normalize 3-d vector.
1326  subroutine knormv(a1, b1, c1, fn1)
1327  real*8 a1, b1, c1, fn1
1328  fn1=sqrt( a1**2+b1**2+c1**2)
1329  a1=a1/fn1
1330  b1=b1/fn1
1331  c1=c1/fn1
1332  end
1333 ! get theta and fai of unnormalized 3-d vector
1334  subroutine kvtoa(vx, vy, vz, teta, fai)
1335  implicit real*8 (a-h, o-z)
1336 !
1337  d=sqrt( vx**2 + vy**2 + vz**2)
1338  call kdtoa(vx/d, vy/d, vz/d, teta, fai)
1339  end
1340 ! get theta and fai of direction cos.
1341  subroutine kdtoa(vx, vy, vz, teta, fai)
1342  implicit real*8 (a-h, o-z)
1343 #include "Zkcele.h"
1344  if(vz .gt. 1.d0) then
1345  teta=0.
1346  else
1347  teta=acos(vz)
1348  endif
1349  if(abs(teta) .lt. 1.d-4) then
1350  fai=0.
1351  else
1352  fai=atan2(vy, vx)
1353  endif
1354 ! to degree
1355  teta=todeg*teta
1356  fai=todeg*fai
1357  end
1358 ! ------------------------------------------------------------------
1359 ! get difference of 2 vector angles.
1360 ! (a1, b1, c1) 1 vector (direction cos).
1361 ! (a2, b2, c2) another // these are input
1362 ! difax, difay: projected angle difference. in deg. output
1363 ! difa: absolute difference. in deg. output
1364 ! if direction cos's are invalid, -1. is put
1365  subroutine kdifva(a1, a2, b1, b2, c1, c2, difax,
1366  * difay, difa)
1367  implicit real*8 (a-h, o-z)
1368 #include "Zkcele.h"
1369 !
1370  tetap(ww1, ww2)= asin( ww1/ sqrt(abs(1.d0-ww2**2)))* todeg
1371 ! component of angle difference
1372  tmp= a1*a2+b1*b2+c1*c2
1373  if(tmp .ge. 1.00d0) then
1374  difa=-1.d0
1375  else
1376  difax= tetap(a1,b1) - tetap(a2, b2)
1377  difay= tetap(b1,a1) - tetap(b2, a2)
1378  difa=acos( tmp )*todeg
1379  endif
1380  end
1381 ! **************************************************************
1382 ! *
1383 ! * komeg0: init for komega and/or komeg1
1384 ! * komega: get solid angle around a source given by komeg0
1385 ! * for a given point in celestial coord.
1386 ! * komeg1: get theta between a source given by komeg0
1387 ! * and a given point in celestial coord.
1388 ! *
1389 ! **************************************************************
1390 ! odec: input. declination in deg
1391 ! ora: input. r.a in deg
1392 ! dec: input. declination id deg
1393 ! ra: input. r.a in deg
1394 ! omega: output. solid angle spaned by (dec, ra) around
1395 ! (odec, ora)
1396 ! teta: output. opening angle between (dec, ra) and
1397 ! (odec, ora). in deg
1398  subroutine komeg0(odec, ora)
1399  implicit real*8 (a-h, o-z)
1400 #include "Zkcele.h"
1401  parameter(coeff=pi*2.)
1402  save ex, ey, ez
1403  call ketod(odec, ora, ex, ey, ez)
1404  return
1405  entry komega(dec, ra, omega)
1406  call ketod(dec, ra, rx, ry, rz)
1407  cost=ex*rx + ey*ry + ez*rz
1408  omega= coeff * (1.d0- cost)
1409  return
1410  entry komeg1(dec, ra, teta)
1411  call ketod(dec, ra, rx, ry, rz)
1412  cost=ex*rx + ey*ry + ez*rz
1413  teta=acos(cost)* todeg
1414  end
1415 ! ********************** get opening angle between two
1416 ! ********************** celestial coordinates
1417 ! odec: input. declination in degree
1418 ! ora: input. corresponding r.a in deg
1419 ! dec: input. another declination in deg
1420 ! ra: input. corresponding r.a in deg
1421 ! teta: output. opening angle between two. in deg.
1422  subroutine koangl(odec, ora, dec, ra, teta)
1423  implicit real*8 (a-h, o-z)
1424 #include "Zkcele.h"
1425  call ketod(odec, ora, ex, ey, ez)
1426  call ketod(dec, ra, rx, ry, rz)
1427  cost=ex*rx + ey*ry + ez*rz
1428  teta=acos(cost)* todeg
1429  end
1430 ! implicit real*8 (a-h, o-z)
1431 ! real*8 mjd
1432 ! call kcelei(36.005845953d0, 139.190535564d0, 9.d0,
1433 ! * 875.8d0)
1434 !
1435 ! write(*,*) ' ug,vg,wg=', ug, vg, wg
1436 ! time=21.d0 + 15.d0/60.d0
1437 ! call kmjd(79, 9, 8, time, mjd)
1438 ! call kmjdst(mjd, st)
1439 ! write(*,*) ' mjd=',mjd
1440 ! write(*,*) ' st=',st-tlons
1441 ! ex=3942.937d3
1442 ! ey=-4398.962d3
1443 ! ez=4754.583d3
1444 ! call knormv(ex,ey, ez, rs)
1445 ! write(*,*) ' ex*rs=',ex*rs, ' ey*rs=',ey*rs,' ez*rs=',ez*rs
1446 ! write(*,*) ' rs=',rs
1447 ! call kdtoe(ex, ey, ez, de, ra)
1448 ! write(*,*) ' ra=',ra, ' de=',de
1449 ! call kgcttc(mjd, ex, ey, ez, rs, ex2, ey2, ez2)
1450 ! call kdtoe(ex2, ey2, ez2, de, ra)
1451 ! write(*,*) ' ra=',ra, ' de=',de
1452 ! end
1453 ! *************************************************************
1454 ! *
1455 ! *
1456 ! * kgcttc: conversion from the geocentric to topocentric
1457 ! * coordinate (topocenter --> origin is at the
1458 ! * observation place)
1459 ! *
1460 ! * for our purpose, this may be needed only for the moon.
1461 ! *************************************************************
1462 !
1463 ! /usage/ call kgcttc(mjd, ex, ey, ez, rs, tex, tey, tez)
1464 !
1465 ! mjd : input. real*8 modified jd.
1466 ! ex, ey, ez: input. direction cosines in the geocentric
1467 ! coordinate
1468 ! rs. input. distance between the center of the earth and
1469 ! the object (say, moon) (in m)
1470 ! tex, tey, tez. output. directions cosines in the topocentric
1471 ! coordinate
1472 !
1473 ! ***note*** the observation place should have been specified by
1474 ! call kcelei.
1475 ! small correction due to the difference of the
1476 ! geocenter and the center of the earth for the
1477 ! local place is adjusted by using very approximate
1478 ! values.
1479 !
1480  subroutine kgcttc(mjd, ex, ey, ez, rs, tex, tey, tez)
1481  implicit real*8 (a-h, o-z)
1482 #include "Zkcele.h"
1483  real*8 mjd, ksind, kcosd
1484 ! get mean greenwich siderial time in degree
1485  call kmjdst(mjd, st)
1486  st=st-tlons
1487  csg=kcosd(st)
1488  sng=ksind(st)
1489 ! get geocentric equatorial coord. of the observation
1490 ! place
1491  a=ug*csg - vg*sng
1492  b=ug*sng + vg*csg
1493  c=wg
1494 ! convert the object position into topocentric coord.
1495  da=ex*rs - a
1496  db=ey*rs - b
1497  dc=ez*rs - c
1498 ! normalize the vector, da,db,dc
1499  call knormv(da, db, dc, dummy)
1500  tex=da
1501  tey=db
1502  tez=dc
1503  end
1504 ! test kmoont
1505 ! implicit real*8 (a-h, o-z)
1506 ! real*8 mjd/48234.00068287d0/
1507 ! common /$$$/ ex1, ey1, ez1
1508 ! dmax=-1.
1509 ! dmin=100.
1510 ! do 100 i=1, 24
1511 ! call kcelei(30.d0, 90.d0, 8.d0, 4300.d0)
1512 ! call kmoont(mjd, ex, ey, ez)
1513 ! call kdtoe(ex, ey, ez, dec, ra)
1514 ! write(*,*) ' dec=', dec, ' ra=',ra
1515 ! mjd=mjd+ 1./24.
1516 ! call kdifva(ex, ex1,ey,ey1, ez, ez1, difax,
1517 ! * difay, difa)
1518 ! dmax=max(dmax, difa)
1519 ! dmin=min(dmin, difa)
1520 ! 100 continue
1521 ! write(*,*) ' dmax=', dmax, ' dmin=', dmin
1522 ! end
1523 ! ************************************************************
1524 ! *
1525 ! * kmoont: compute the moon position in the topocentric
1526 ! * equatorial coordinate
1527 ! * (accuracy is better than 1/100 degree)
1528 ! * kcelei must have been called.
1529 ! ************************************************************
1530 ! /usage/ call kmoont(mjd, ex, ey, ez)
1531 !
1532 ! mjd: input. real*8. modified julian day
1533 ! ex, ey, ez. apparent topocentric directional cosines in the
1534 ! topocentric equatorial coordinate.
1535 !
1536 ! ** geocentric and topocentric diff. is order of .5 deg
1537 !
1538 !
1539  subroutine kmoont(mjd, ex, ey, ez)
1540  implicit real*8 (a-h, o-z)
1541 ! common /$$$/ ex1, ey1, ez1
1542  real*8 mjd
1543 ! get ecliptic latitude and longitude of the moon
1544  call kmoon(mjd, elat, elon, rmoon)
1545 ! convert to direction cosine in geocentric ecliptic
1546  call ketod( elat, elon, cx, cy, cz)
1547 ! convert to geocentric equatorial coordinate
1548  call kctoq(mjd, cx, cy, cz, ex, ey, ez)
1549 !$$$$$$$$$$$$$$$
1550 ! call kdtoe(ex, ey, ez, dec, ra)
1551 ! write(*,*) ' dec=', dec, ' ra=', ra
1552 ! ex1=ex
1553 ! ey1=ey
1554 ! ez1=ez
1555 !$$$$$$$$$$$$$$
1556 ! convert to topocentric coord.
1557  call kgcttc(mjd, ex, ey, ez, rmoon, ex, ey, ez)
1558  end
1559 ! ***********************************************************
1560 ! *
1561 ! * kb50j2: convert dec, ra in b1950.0 into j2000
1562 ! * proper motion and e-term neglected
1563 ! * 5/100 degree error may be included
1564 ! *
1565 ! * kj2b50: inverse of the above
1566 ! *
1567 ! *
1568 ! ***********************************************************
1569 ! dec, ra: input. (dec, ra)(b1950.0)
1570 ! dec2, ra2: output (dec, ra) (j2000)
1571  subroutine kb50j2(dec, ra, dec2, ra2)
1572  implicit real*8 (a-h, o-z)
1573  call ketod(dec, ra, ex, ey, ez)
1574 ! write(*,*) ' ex, ,, ', ex, ey, ez
1575  ex2=.9999256782d0*ex-0.011182061d0*ey-0.0048579477d0*ez
1576  ey2=0.0111820609d0*ex+.9999374784d0*ey-0.0000271765d0*ez
1577  ez2=0.0048579479d0*ex-0.0000271474d0*ey+.9999881997d0*ez
1578 ! write(*,*) ' ex2 ,, ', ex2, ey2, ez2
1579  call kdtoe(ex2, ey2, ez2, dec2, ra2)
1580  end
1581 ! dec2, ra2: input (dec, ra) (j2000)
1582 ! dec, ra: output (dec, ra)(b1950.0)
1583  subroutine kj2b50(dec2, ra2, dec, ra)
1584  implicit real*8 (a-h, o-z)
1585  call ketod(dec2, ra2, ex2, ey2, ez2)
1586 ! write(*,*) ' ex2, ,, ', ex2, ey2, ez2
1587  ex=.9999257080d0*ex2+0.0111789382d0*ey2+0.0048590039d0*ez2
1588  ey=-0.0111789382d0*ex2+.9999375133d0*ey2-0.0000271579d0*ez2
1589  ez=-0.0048590038d0*ex2-0.0000271626d0*ey2+.9999881946d0*ez2
1590 ! write(*,*) ' ex ,, ', ex, ey, ez
1591  call kdtoe(ex, ey, ez, dec, ra)
1592  end
1593 ! ***********************************************************
1594 ! *
1595 ! * kj90j2: convert dec, ra in 1990 japanese ephemeris into j2000
1596 ! *
1597 ! * kj2j90: inverse of the above
1598 ! *
1599 ! *
1600 ! ***********************************************************
1601 ! dec, ra: input. (dec, ra)(j1990.5)
1602 ! dec2, ra2: output (dec, ra) (j2000)
1603  subroutine kj90j2(dec, ra, dec2, ra2)
1604  implicit real*8 (a-h, o-z)
1605  call ketod(dec, ra, ex, ey, ez)
1606 ! write(*,*) ' ex, ,, ', ex, ey, ez
1607  ex2=.99999732d0*ex-0.00212430d0*ey-0.00092315d0*ez
1608  ey2=0.00212430d0*ex+.99999774d0*ey-0.00000098d0*ez
1609  ez2=0.00092315d0*ex-0.00000098d0*ey+.99999957d0*ez
1610 ! write(*,*) ' ex2 ,, ', ex2, ey2, ez2
1611  call kdtoe(ex2, ey2, ez2, dec2, ra2)
1612  end
1613 ! dec2, ra2: input (dec, ra) (j2000)
1614 ! dec, ra: output (dec, ra)(b1950.0)
1615  subroutine kj2j90(dec2, ra2, dec, ra)
1616  implicit real*8 (a-h, o-z)
1617  call ketod(dec2, ra2, ex2, ey2, ez2)
1618 ! write(*,*) ' ex2, ,, ', ex2, ey2, ez2
1619  ex=.99999732d0*ex2+0.00212430d0*ey2+0.00092315d0*ez2
1620  ey=-0.00212430d0*ex2+.99999774d0*ey2-0.00000098d0*ez2
1621  ez=-0.00092315d0*ex2-0.00000098d0*ey2+.99999957d0*ez2
1622 ! write(*,*) ' ex ,, ', ex, ey, ez
1623  call kdtoe(ex, ey, ez, dec, ra)
1624  end
1625 ! ***********************************************************
1626 ! *
1627 ! * kjxjy: convert steller positions for date jx into jy
1628 ! *
1629 ! *
1630 ! ***********************************************************
1631 !
1632 ! /usage/ call kjxjy(mjd1, mjd2, dec1, ra1, dec2, ra2)
1633 !
1634 ! mjd1: input. real*8 modified jd of j'x'
1635 ! mjd2: input. real*8 modified jd of j'y'
1636 ! dec1: input. declination of a source in deg. at j'x'
1637 ! ra1 : input. raight ascensiion of the source in deg.
1638 ! dec2: ouput. declination in deg at j'y'
1639 ! ra2 : ouput. right ascension in deg at j'y'
1640 !
1641  subroutine kjxjy(mjd1, mjd2, dec1, ra1, dec2, ra2)
1642  implicit real*8 (a-h, o-z)
1643  real*8 mjd1, mjd2
1644  dimension pij1(3,3), pij2(3,3)
1645 !
1646 ! compute precession matrix
1647  call kpmtrx(mjd1, pij1)
1648 !
1649 ! do 100 j=1, 3
1650 ! write(*,*) (pij1(i, j), i=1, 3)
1651 ! 100 continue
1652  call kpmtrx(mjd2, pij2)
1653 ! do 200 i=1, 3
1654 ! write(*,*) (pij2(i, j), j=1, 3)
1655 ! 200 continue
1656 ! get vectors
1657  call ketod(dec1, ra1, ex1, ey1, ez1)
1658 ! convert x-->j2000
1659  call kxtoj2(pij1, ex1, ey1, ez1, ex2, ey2, ez2)
1660 ! convert j2000--->y
1661  call kj2tox(pij2, ex2, ey2, ez2, ex, ey, ez)
1662 ! convert to dec, ra
1663  call kdtoe(ex, ey, ez, dec2, ra2)
1664  end
1665 
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
subroutine kdifva(a1, a2, b1, b2, c1, c2, difax,
Definition: kceles.f:1366
subroutine kgdted(gx, gy, gz, ex, ey, ez)
Definition: kceles.f:560
nodes z
subroutine ktu(iyear, month, day, ed)
Definition: kceles.f:282
real *8 function kcosd(x)
Definition: kceles.f:1091
subroutine knormv(a1, b1, c1, fn1)
Definition: kceles.f:1327
subroutine kcelei(tlat, tlon, dtgmt, height)
Definition: kceles.f:125
subroutine ketoh(st, ex, ey, ez, hx, hy, hz)
Definition: kceles.f:321
subroutine kmoon(mjd, elat, elon, rmoon)
Definition: kceles.f:955
dE dx *! Nuc Int sampling table e
Definition: cblkMuInt.h:130
subroutine kdhtoh(del, h, w1, w2, w3)
Definition: kceles.f:408
! Zkcele h ! unit here is aunit parameter pi real sinlat
Definition: Zkcele.h:6
! Zkcele h ! unit here is aunit parameter pi real dtgmts
Definition: Zkcele.h:6
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz r
Definition: ZavoidUnionMap.h:1
nodes i
! for length to thickness conversion or v v ! integer maxnodes real Hinf ! This is used when making table for dim simulation ! The slant length for vertical height to km is ! divided by LenStep m steps ! It can cover the slant length of about km for cos
Definition: Zatmos.h:8
integer npitbl real *nx dx real dx
Definition: Zcinippxc.h:10
subroutine kjtmjd(jd, mjd)
Definition: kceles.f:772
subroutine time(xxx)
Definition: chook.f:5
subroutine komeg0(odec, ora)
Definition: kceles.f:1399
! Zkcele h ! unit here is aunit parameter pi real sinsx
Definition: Zkcele.h:6
subroutine kdcmjd(mjd, iy, im, id, ihr, imn, sec)
Definition: kceles.f:695
subroutine khtoe(st, hx, hy, hz, ex, ey, ez)
Definition: kceles.f:312
subroutine keqtog(dec, ra, glat, glon)
Definition: kceles.f:538
! Zkcele h ! unit here is tofai
Definition: Zkcele.h:3
! Zkcele h ! unit here is aunit parameter pi real * heighs
Definition: Zkcele.h:6
subroutine kdtoa(vx, vy, vz, teta, fai)
Definition: kceles.f:1342
subroutine kqtoc(mjd, ex, ey, ez, cx, cy, cz)
Definition: kceles.f:1120
subroutine kgtoeq(glat, glon, dec, ra)
Definition: kceles.f:548
subroutine ksuneq(mjd, ex, ey, ez)
Definition: kceles.f:1175
subroutine kb50j2(dec, ra, dec2, ra2)
Definition: kceles.f:1572
subroutine kdzth2(del, w3, h, icon)
Definition: kceles.f:488
max ptcl codes in the komega
Definition: Zcode.h:2
subroutine kmobec(mjd, cose, sine)
Definition: kceles.f:1140
! Zkcele h ! unit here is ae
Definition: Zkcele.h:3
subroutine kjxjy(mjd1, mjd2, dec1, ra1, dec2, ra2)
Definition: kceles.f:1642
subroutine kgcrc(fai, al, h, u, v, w)
Definition: kceles.f:162
********************block data cblkHeavy ********************integer j data *HeavyG2symbol p
Definition: cblkHeavy.h:7
subroutine ketod(delta, alfa, ex, ey, ez)
Definition: kceles.f:330
! Zkcele h ! unit here is aunit parameter pi real tlats
Definition: Zkcele.h:6
! Zkcele h ! unit here is aunit parameter pi real ug
Definition: Zkcele.h:6
subroutine kadthi(astox)
Definition: kceles.f:378
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
subroutine kmjdym(mjd, y, m, d, time)
Definition: kceles.f:641
struct ob o[NpMax]
Definition: Zprivate.h:34
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos height
Definition: ZavoidUnionMap.h:1
subroutine kvtoa(vx, vy, vz, teta, fai)
Definition: kceles.f:1335
subroutine kpmtrx(mjd, pij)
Definition: kceles.f:841
subroutine kctoq(mjd, cx, cy, cz, ex, ey, ez)
Definition: kceles.f:1108
! constants thru Cosmos real * pi
Definition: Zglobalc.h:2
subroutine kj2tox(pij, ex2, ey2, ez2, ex, ey, ez)
Definition: kceles.f:885
subroutine kj2b50(dec2, ra2, dec, ra)
Definition: kceles.f:1584
subroutine kmjdst(mjd, st)
Definition: kceles.f:750
subroutine ksun(mjd, slon, rsun)
Definition: kceles.f:1212
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
subroutine kdtoe(ex, ey, ez, delta, alfa)
Definition: kceles.f:354
subroutine khtad(hx, hy, hz, ax, ay, az)
Definition: kceles.f:392
nodes a
subroutine kdztoh(del, w3, h, icon)
Definition: kceles.f:435
subroutine kdtoh(hx, hy, hz, teta, fai)
Definition: kceles.f:362
dE dx *! Nuc Int sampling table b
Definition: cblkMuInt.h:130
! Zkcele h ! unit here is aunit parameter pi real * tlons
Definition: Zkcele.h:6
subroutine kadth(ax, ay, az, hx, hy, hz)
Definition: kceles.f:384
subroutine kgcttc(mjd, ex, ey, ez, rs, tex, tey, tez)
Definition: kceles.f:1481
! Zkcele h ! unit here is aunit parameter pi real coslat
Definition: Zkcele.h:6
! Zkcele h ! unit here is aunit parameter pi real vg
Definition: Zkcele.h:6
subroutine kj90j2(dec, ra, dec2, ra2)
Definition: kceles.f:1604
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon ! knockon is considered Obsolete *PhotoProd false
Definition: cblkElemag.h:7
dE dx *! Nuc Int sampling table h
Definition: cblkMuInt.h:130
subroutine ksided(time, st0, st)
Definition: kceles.f:249
dE dx *! Nuc Int sampling table g
Definition: cblkMuInt.h:130
subroutine kadbp(nftch, dx, dy, dz, dt, wt, u, v, w, tz, icon)
Definition: kceles.f:1251
nodes t
subroutine ksidet(year, month, day, time, st)
Definition: kceles.f:201
subroutine kj2j90(dec2, ra2, dec, ra)
Definition: kceles.f:1616
subroutine kside0(ed, st0)
Definition: kceles.f:263
! Zkcele h ! unit here is toh
Definition: Zkcele.h:3
integer n
Definition: Zcinippxc.h:1
! Zkcele h ! unit here is aunit parameter pi real cossx
Definition: Zkcele.h:6
real *8 function ksind(x)
Definition: kceles.f:1085
subroutine koangl(odec, ora, dec, ra, teta)
Definition: kceles.f:1423
subroutine kxtoj2(pij, ex, ey, ez, ex2, ey2, ez2)
Definition: kceles.f:906
subroutine kmjdtj(mjd, jd)
Definition: kceles.f:768
subroutine kmjd(year, month, day, time, mjd)
Definition: kceles.f:223
! structure defining a particle at production ! Basic idea of what is to be contained in ! the particle structue is that dynamical ones should be included those derivable from the particle code ! is not included ******************************************************type fmom momentum sequence union map real e endmap map real * x
Definition: Zptcl.h:21
dE dx *! Nuc Int sampling table f
Definition: cblkMuInt.h:130
subroutine kmtoj2(mjd, t)
Definition: kceles.f:871
subroutine kmoont(mjd, ex, ey, ez)
Definition: kceles.f:1540
dE dx *! Nuc Int sampling table c
Definition: cblkMuInt.h:130