NCEPLIBS-w3emc  2.11.0
w3fb07.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Grid coords to lat/lon for grib.
3 C> @author John Stackpole @date 1988-01-01
4 
5 C> Converts the coordinates of a location on earth given in a
6 C> grid coordinate system overlaid on a polar stereographic map pro-
7 C> jection true at 60 degrees n or s latitude to the
8 C> natural coordinate system of latitude/longitude
9 C> w3fb07() is the reverse of w3fb06().
10 C> uses grib specification of the location of the grid
11 C>
12 C> Program history log:
13 C> - John Stackpole 1988-01-01
14 C> - Ralph Jones 1990-04-12 Convert to cray cft77 fortran.
15 C>
16 C> @param[in] XI I coordinate of the point real*4.
17 C> @param[in] XJ J coordinate of the point real*4.
18 C> @param[in] ALAT1 Latitude of lower left point of grid (point 1,1)
19 C> latitude <0 for southern hemisphere; real*4.
20 C> @param[in] ALON1 Longitude of lower left point of grid (point 1,1)
21 C> east longitude used throughout; real*4.
22 C> @param[in] DX Mesh length of grid in meters at 60 deg lat
23 C> must be set negative if using
24 C> southern hemisphere projection; real*4
25 C> 190500.0 lfm grid,
26 C> 381000.0 nh pe grid, -381000.0 sh pe grid, etc.
27 C> @param[in] ALONV The orientation of the grid. i.e.,
28 C> the east longitude value of the vertical meridian
29 C> which is parallel to the y-axis (or columns of
30 C> the grid) along which latitude increases as
31 C> the y-coordinate increases. real*4
32 C> for example:
33 C> 255.0 for lfm grid,
34 C> 280.0 nh pe grid, 100.0 sh pe grid, etc.
35 C> @param[out] ALAT Latitude in degrees (negative in southern hemi.).
36 C> @param[out] ALON East longitude in degrees, real*4.
37 C>
38 C> @note Formulae and notation loosely based on hoke, hayes,
39 C> and renninger's "map projections and grid systems...", march 1981
40 C> afgwc/tn-79/003
41 C>
42 C> @author John Stackpole @date 1988-01-01
43  SUBROUTINE w3fb07(XI,XJ,ALAT1,ALON1,DX,ALONV,ALAT,ALON)
44 C
45  DATA rerth /6.3712e+6/,pi/3.1416/
46  DATA ss60 /1.86603/
47 C
48 C PRELIMINARY VARIABLES AND REDIFINITIONS
49 C
50 C H = 1 FOR NORTHERN HEMISPHERE; = -1 FOR SOUTHERN
51 C
52 C REFLON IS LONGITUDE UPON WHICH THE POSITIVE X-COORDINATE
53 C DRAWN THROUGH THE POLE AND TO THE RIGHT LIES
54 C ROTATED AROUND FROM ORIENTATION (Y-COORDINATE) LONGITUDE
55 C DIFFERENTLY IN EACH HEMISPHERE
56 C
57  IF (dx.LT.0) THEN
58  h = -1.0
59  dxl = -dx
60  reflon = alonv - 90.0
61  ELSE
62  h = 1.0
63  dxl = dx
64  reflon = alonv - 270.0
65  ENDIF
66 C
67  radpd = pi / 180.0
68  degprd = 180.0 / pi
69  rebydx = rerth / dxl
70 C
71 C RADIUS TO LOWER LEFT HAND (LL) CORNER
72 C
73  ala1 = alat1 * radpd
74  rmll = rebydx * cos(ala1) * ss60/(1. + h * sin(ala1))
75 C
76 C USE LL POINT INFO TO LOCATE POLE POINT
77 C
78  alo1 = (alon1 - reflon) * radpd
79  polei = 1. - rmll * cos(alo1)
80  polej = 1. - h * rmll * sin(alo1)
81 C
82 C RADIUS TO THE I,J POINT (IN GRID UNITS)
83 C
84  xx = xi - polei
85  yy = (xj - polej) * h
86  r2 = xx**2 + yy**2
87 C
88 C NOW THE MAGIC FORMULAE
89 C
90  IF (r2.EQ.0) THEN
91  alat = h * 90.
92  alon = reflon
93  ELSE
94  gi2 = (rebydx * ss60)**2
95  alat = degprd * h * asin((gi2 - r2)/(gi2 + r2))
96  arccos = acos(xx/sqrt(r2))
97  IF (yy.GT.0) THEN
98  alon = reflon + degprd * arccos
99  ELSE
100  alon = reflon - degprd * arccos
101  ENDIF
102  ENDIF
103  IF (alon.LT.0) alon = alon + 360.
104 C
105  RETURN
106  END
subroutine w3fb07(XI, XJ, ALAT1, ALON1, DX, ALONV, ALAT, ALON)
Converts the coordinates of a location on earth given in a grid coordinate system overlaid on a polar...
Definition: w3fb07.f:44