COSMOS v7.655  COSMOSv7655
(AirShowerMC)
ce_cent2llh_ellips.f
Go to the documentation of this file.
1 c include 'cllh2eCent.f'
2 ! program test_ceCent2llh
3 !
4 c include '../Zcoord.h'
5 ! record /coord/ a, b
6 ! integer ios
7 ! real*8 x, y, z
8 ! do while (.true.)
9 ! read(*, *,iostat=ios) x, y, z
10 ! if(ios .ne.. 0) goto 10
11 ! call csetCoord('llh', x, y, z, a)
12 ! call cconv_coord_to('ecen', a, b)
13 ! call cconv_coord_to('llh', b, a)
14 ! write(*,*) a.lat, a.long, a.h
15 ! enddo
16 ! 10 continue
17 ! end
18 ! earth center rectangular coordinate to longitude latitude height
19 ! coordinate converstion.
20 !
21  subroutine cecent2llh(xyz, llh)
22 ! xyz: /coord/ structue. Input. The coordinate system is
23 ! such that the origin is at the center of the earth
24 ! x-axis is directed to (0, 0) latitude and longitude.
25 ! y-axis is directed to (0, 90) latitude and longitude.
26 ! z-axsi is directed to the north pole.
27 ! llh: /coord/ structure. Output. to contain data in latitude,
28 ! longitude, height.
29 ! *** note ***
30 ! llh can be the same as xyz. time component is unchanged
31 !
32  implicit none
33 c---- include '../../Zglobalc.h'
34 #include "Zglobalc.h"
35 c---- include '../Zcoord.h'
36 #include "Zcoord.h"
37 c---- include 'Zearth.h'
38 #include "Zearth.h"
39  type(coord)::llh, xyz
40  type(coord):: temp
41 !
42  real*8 n, cosphi, sinphi, cosl, sinl, hold
43  integer i
44 ! start with ecentricity 0 approximation
45  temp%h = 0.
46  n = eradius
47  do i = 1, 6
48  hold = temp%h
49  temp%h = sqrt( xyz%r(1)**2 + xyz%r(2)**2 +(xyz%r(3)/
50  * (1.d0 - n*ecen2/(n+temp%h)))**2 ) - n
51  cosphi = sqrt( (xyz%r(1)/(n+temp%h))**2 +
52  * (xyz%r(2)/(n+temp%h))**2 )
53  sinphi = xyz%r(3)/(n*one_ecen2 + temp%h)
54 !
55  cosl = xyz%r(1)/(n+temp%h)/cosphi
56  sinl = xyz%r(2)/(n+temp%h)/cosphi
57  n = eradius /sqrt(1.d0 - ecen2*sinphi**2)
58  if(abs(temp%h -hold) .lt. 1.d-2) goto 100 ! abs error < 1 mm
59  enddo
60  100 continue
61 ! write(*, *) ' i=', i ! <i> = 4
62 !
63  temp%lat = atan2(sinphi, cosphi)*todeg
64  temp%long = atan2(sinl, cosl)*todeg
65  llh%lat = temp%lat
66  llh%long = temp%long
67  llh%h = temp%h
68  llh%sys = coord_types(2)
69  end
70 
subroutine cecent2llh(xyz, llh)
integer max_coord_types * coord_types(2)/'llh'/
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
Definition: Zcoord.h:43