NCEPLIBS-w3emc  2.11.0
w3fb05.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Grid coordinates to latitude, longitude.
3 C> @author Ralph Jones @date 1986-07-17
4 C>
5 C> Converts the coordinates of a location from the grid(i,j)
6 C> coordinate system overlaid on the polar stereographic map projec-
7 C> tion true at 60 degrees n or s latitude to the natural coordinate
8 C> system of latitude/longitude on the earth. w3fb05() is the reverse
9 C> of w3fb04().
10 C>
11 C> Program history log:
12 C> - Ralph Jones 1986-07-17
13 C> - Ralph Jones 1989-11-01 Change to cray cft77 fortran.
14 C>
15 C> @param[in] XI I of the point relative to the north or s. pole
16 C> @param[in] XJ J of the point relative to the north or s. pole
17 C> @param[in] XMESHL Mesh length of grid in km at 60 degrees(<0 if sh)
18 C> (190.5 lfm grid, 381.0 nh pe grid,-381.0 sh pe grid)
19 C> @param[in] ORIENT Orientation west longitude of the grid
20 C> (105.0 lfm grid, 80.0 nh pe grid, 260.0 sh pe grid)
21 C> @param[out] ALAT Latitude in degrees (<0 if sh)
22 C> @param[out] ALONG West longitude in degrees
23 C>
24 C> @note All parameters in the calling statement must be
25 C> real. the range of allowable latitudes is from a pole to
26 C> 30 degrees into the opposite hemisphere.
27 C> the grid used in this subroutine has its origin (i=0,j=0)
28 C> at the pole, so if the user's grid has its origin at a point
29 C> other than a pole, a translation is required to get i and j for
30 C> input into w3fb05(). the subroutine grid is oriented so that
31 C> gridlines of i=constant are parallel to a west longitude sup-
32 C> plied by the user. the earth's radius is taken to be 6371.2 km.
33 C>
34 C> @note This code will not vectorize, it is normaly used in a
35 C> double do loop with w3ft01(), w3ft00(), etc. to vectorize it,
36 C> put it in line, put w3ft01(), w3ft00(), etc. in line.
37 C>
38 C> @author Ralph Jones @date 1986-07-17
39  SUBROUTINE w3fb05(XI,XJ,XMESHL,ORIENT,ALAT,ALONG)
40 C
41  DATA degprd/57.2957795/
42  DATA earthr/6371.2/
43 C
44  gi2 = ((1.86603 * earthr) / (xmeshl))**2
45  r2 = xi * xi + xj * xj
46 C
47  IF (r2.EQ.0.0) THEN
48  along = 0.0
49  alat = 90.0
50  IF (xmeshl.LT.0.0) alat = -alat
51  RETURN
52  ELSE
53  alat = asin((gi2 - r2) / (gi2 + r2)) * degprd
54  angle = degprd * atan2(xj,xi)
55  IF (angle.LT.0.0) angle = angle + 360.0
56  ENDIF
57 C
58  IF (xmeshl.GE.0.0) THEN
59  along = 270.0 + orient - angle
60 C
61  ELSE
62 C
63  along = angle + orient - 270.0
64  alat = -(alat)
65  ENDIF
66 C
67  IF (along.LT.0.0) along = along + 360.0
68  IF (along.GE.360.0) along = along - 360.0
69 C
70  RETURN
71 C
72  END