da_xyll_latlon.inc
References to this file elsewhere.
1 subroutine da_xyll_latlon(x, y, proj, lat, lon)
2
3 !-----------------------------------------------------------------------
4 ! Purpose: Compute the lat/lon location of an x/y on a LATLON grid.
5 !-----------------------------------------------------------------------
6
7 implicit none
8
9 real, intent(in) :: x
10 real, intent(in) :: y
11 type(proj_info), intent(in) :: proj
12 real, intent(out) :: lat
13 real, intent(out) :: lon
14
15 real :: deltalat
16 real :: deltalon
17 real :: latinc
18 real :: loninc
19
20 if (trace_use_frequent) call da_trace_entry("da_xyll_latlon")
21
22 ! Extract the latitude and longitude increments for this grid
23 ! (e.g., 2.5 deg for NCEP reanalysis) from the proj structure, where
24 ! loninc is saved in the stdlon tag and latinc is saved in truelat1
25
26 latinc = proj%truelat1
27 loninc = proj%stdlon
28
29 ! Compute deltalat and deltalon
30
31 deltalat = (x-1.0)*latinc
32 deltalon = (y-1.0)*loninc
33 lat = proj%lat1 + deltalat
34 lon = proj%lon1 + deltalon
35
36 if ((ABS(lat) > 90.0).OR.(ABS(deltalon) > 360.0)) then
37 ! Off the earth for this grid
38 lat = -999.0
39 lon = -999.0
40 else
41 lon = lon + 360.0
42 lon = MOD(lon,360.0)
43 if (lon > 180.0) lon = lon -360.0
44 end if
45
46 if (trace_use_frequent) call da_trace_exit("da_xyll_latlon")
47
48 end subroutine da_xyll_latlon
49
50