da_llxy_new.inc

References to this file elsewhere.
1 subroutine da_llxy_new (info, outside, outside_all)
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !-----------------------------------------------------------------------
6 
7    ! This routine converts (lat, lon) into (x,y) coordinates
8 
9    implicit none
10 
11    type(infa_type),   intent(inout) :: info
12    logical,           intent(inout) :: outside(:,:)      ! wrt local domain
13    logical, optional, intent(out)   :: outside_all(:,:)  ! wrt all domains
14 
15    if (trace_use) call da_trace_entry("da_llxy_new")
16 
17    outside(:,:) = .false.
18    info%x(:,:)   = -1.0
19    info%y(:,:)   = -1.0
20    
21    ! get the (x, y) coordinates
22 
23    if (fg_format == fg_format_wrf) then
24       call da_llxy_wrf_new(map_info, info)
25    else if (fg_format == fg_format_kma_global) then
26       call da_llxy_kma_global_new (info)
27    else
28       call da_llxy_default_new (info)
29    end if
30 
31    call da_togrid_new (info%x, its-2, ite+2, info%i, info%dx, info%dxm)
32    call da_togrid_new (info%y, jts-2, jte+2, info%j, info%dy, info%dym)
33 
34    ! refactor to remove this ugly duplication later
35    if (present(outside_all)) then
36       outside_all(:,:) = .false.
37       ! Do not check for global options 
38       if (.not. global) then 
39          where ((int(info%x(:,:)) < ids) .or. (int(info%x(:,:)) >= ide) .or. &
40             (int(info%y(:,:)) < jds) .or. (int(info%y(:,:)) >= jde))
41             outside_all(:,:) = .true. 
42             outside(:,:) = .true. 
43          end where
44          if (def_sub_domain) then
45             where (x_start_sub_domain > info%x(:,:) .or. y_start_sub_domain > info%y(:,:) .or. &
46                 x_end_sub_domain   < info%x(:,:) .or. y_end_sub_domain   < info%y(:,:))
47                outside_all(:,:) = .true.
48                outside(:,:) = .true. 
49             end where
50          end if
51       end if
52    end if
53 
54    if (fg_format == fg_format_kma_global) then
55       where ((info%j(:,:) < jts-1) .or. (info%j(:,:)  > jte))
56          outside(:,:) = .true.
57       end where
58 
59       where (info%j(:,:) == jde)
60          info%j(:,:) = info%j(:,:) - 1
61          info%dy(:,:)  = 1.0
62          info%dym(:,:) = 0.0
63       end where
64 
65       return
66    end if
67 
68    ! Check for edge of domain:
69 
70    where ((info%i(:,:) < ids) .or. (info%i(:,:) >= ide) .or. &
71       (info%j(:,:) < jds) .or. (info%j(:,:) >= jde))
72       outside     = .true. 
73    end where
74 
75    ! FIX? hack
76    where ((info%i(:,:) < its-1) .or. (info%i(:,:) > ite) .or. &
77       (info%j(:,:) < jts-1) .or. (info%j(:,:) > jte))
78       outside(:,:) = .true.
79    end where
80 
81    if (def_sub_domain) then
82       where (x_start_sub_domain > info%x(:,:) .or. y_start_sub_domain > info%y(:,:) .or. &
83              x_end_sub_domain   < info%x(:,:) .or. y_end_sub_domain   < info%y(:,:))
84          outside = .true.
85       end where 
86    end if
87 
88    if (trace_use) call da_trace_exit("da_llxy_new")
89 
90 end subroutine da_llxy_new
91 
92