da_llxy_latlon.inc

References to this file elsewhere.
1 subroutine da_llxy_latlon(lat, lon, proj, x, y)
2 
3    !----------------------------------------------------------------------- 
4    ! Purpose: Compute the x/y location of a lat/lon on a LATLON grid.
5    !-----------------------------------------------------------------------
6 
7    implicit none
8 
9    real, intent(in)             :: lat
10    real, intent(in)             :: lon
11    type(proj_info), intent(in)  :: proj
12    real, intent(out)            :: x
13    real, intent(out)            :: y
14 
15    real                         :: deltalat
16    real                         :: deltalon
17    real                         :: lon360
18    real                         :: latinc
19    real                         :: loninc
20 
21    if (trace_use_frequent) call da_trace_entry("da_llxy_latlon")
22 
23    ! Extract the latitude and longitude increments for this grid
24    ! (e.g., 2.5 deg for NCEP reanalysis) from the proj structure, where
25    ! loninc is saved in the stdlon tag and latinc is saved in truelat1
26 
27    latinc = proj%truelat1
28    loninc = proj%stdlon
29 
30    ! Compute deltalat and deltalon as the difference between the input 
31    ! lat/lon and the origin lat/lon
32 
33    deltalat = lat - proj%lat1
34 
35    ! To account for issues around the dateline, convert the incoming
36    ! longitudes to be 0->360.0
37    if (lon < 0) then 
38       lon360 = lon + 360.0 
39    else 
40       lon360 = lon
41    end if    
42    deltalon = lon360 - proj%lon1      
43     
44    ! Compute x/y
45    x = deltalon/loninc + 1.0
46    y = deltalat/latinc + 1.0
47 
48    if (trace_use_frequent) call da_trace_exit("da_llxy_latlon")
49 
50 end subroutine da_llxy_latlon
51 
52