da_llij_latlon.inc

References to this file elsewhere.
1 subroutine da_llij_latlon(lat, lon, proj, i, j)
2 
3    !----------------------------------------------------------------------- 
4    ! Purpose: Compute the i/j 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)            :: i
13    real, intent(out)            :: j
14 
15    real                         :: deltalat
16    real                         :: deltalon
17    real                         :: lon360
18    real                         :: latinc
19    real                         :: loninc
20 
21    ! Extract the latitude and longitude increments for this grid
22    ! (e.g., 2.5 deg for NCEP reanalysis) from the proj structure, where
23    ! loninc is saved in the stdlon tag and latinc is saved in truelat1
24 
25    latinc = proj%truelat1
26    loninc = proj%stdlon
27 
28    ! Compute deltalat and deltalon as the difference between the input 
29    ! lat/lon and the origin lat/lon
30 
31    deltalat = lat - proj%lat1
32 
33    ! To account for issues around the dateline, convert the incoming
34    ! longitudes to be 0->360.
35    if (lon < 0) then 
36       lon360 = lon + 360.0 
37    else 
38       lon360 = lon
39    end if    
40    deltalon = lon360 - proj%lon1      
41     
42    ! Compute i/j
43    i = deltalon/loninc + 1.
44    j = deltalat/latinc + 1.
45 
46 end subroutine da_llij_latlon
47 
48