File: xyz2ll.F

package info (click to toggle)
emoslib 000380%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 47,712 kB
  • ctags: 11,551
  • sloc: fortran: 89,643; ansic: 24,200; makefile: 370; sh: 355
file content (95 lines) | stat: -rwxr-xr-x 1,849 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
C Copyright 1981-2007 ECMWF
C 
C Licensed under the GNU Lesser General Public License which
C incorporates the terms and conditions of version 3 of the GNU
C General Public License.
C See LICENSE and gpl-3.0.txt for details.
C

      SUBROUTINE XYZ2LL(X,Y,Z,RLAT,RLONG,INROW)
C---->
C**** XYZ2LL
C
C     Purpose
C     -------
C
C     Converts an array of (x,y,z) coordinates to an
C     array of latitude/longitude values.
C
C
C     Interface
C     ---------
C
C     CALL XYZ2LL(X,Y,Z,RLAT,RLONG,INROW)
C
C     Input
C     -----
C
C     (X,Y,Z) - Array of coordinates.
C     INROW   - Count of coordinates.
C
C
C     Output
C     ------
C
C     RLAT  - Array of latitudes.
C     RLONG - Array of corresponding longitudes.
C
C
C     Method
C     ------
C
C     Z axis is the polar axis directed from south to north.
C     X and Y axes are in the equatorial plane and have origin at the
C     centre of the Earth. The X axis passes through (O north, 0 east).
C     Longitude values are in range (0,360).
C
C
C     Externals
C     ---------
C
C     None.
C
C
C     Author
C     ------
C
C     J.D.Chambers     ECMWF
C
C----<
C
      IMPLICIT NONE
C
C     Subroutine arguments
C
      REAL X,Y,Z,RLAT,RLONG
      DIMENSION X(*),Y(*),Z(*),RLAT(*),RLONG(*)
      INTEGER INROW
C
C     Local variables
C
      REAL*8 FACTOR
      DATA FACTOR/57.2957763671875/
      INTEGER LOOP
C
      DO LOOP = 1, INROW
        RLAT(LOOP)  = ASIN(Z(LOOP)) * FACTOR
      ENDDO
C
      DO LOOP = 1, INROW
        IF( ABS(X(LOOP)).GT.0.0001 ) THEN
          RLONG(LOOP) = ATAN2(Y(LOOP),X(LOOP)) * FACTOR
        ELSE IF ( Y(LOOP).GT.0.0 ) THEN
          RLONG(LOOP) = 90.0
        ELSE
          RLONG(LOOP) = -90.0
        ENDIF
      ENDDO
C
      DO LOOP = 1, INROW
        IF(RLONG(LOOP).LT.0.0) RLONG(LOOP) = RLONG(LOOP) + 360.0
      ENDDO
C
      RETURN
      END