da_llxy.inc
References to this file elsewhere.
1 subroutine da_llxy (info, loc, 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(info_type), intent(in) :: info
12 type(model_loc_type), intent(inout) :: loc
13 logical , intent(out) :: outside !wrt local domain
14 logical, optional, intent(out) :: outside_all !wrt all domains
15
16 ! too many return statments to trace
17 ! if (trace_use_frequent) call da_trace_entry("da_llxy")
18
19 outside = .false.
20 loc % x = -1.0
21 loc % y = -1.0
22
23 ! get the (x, y) coordinates
24
25 if (fg_format == fg_format_wrf) then
26 call da_llxy_wrf(map_info, info%lat, info%lon, loc%x, loc%y)
27 else if (fg_format == fg_format_kma_global) then
28 call da_llxy_kma_global (info%lat, info%lon, loc%x, loc%y)
29 else
30 call da_llxy_default (info%lat, info%lon, loc%x, loc%y)
31 end if
32
33 call da_togrid (loc%x, its-2, ite+2, loc%i, loc%dx, loc%dxm)!
34
35 call da_togrid (loc%y, jts-2, jte+2, loc%j, loc%dy, loc%dym)
36
37 ! refactor to remove this ugly duplication later
38 if (present(outside_all)) then
39 outside_all = .false.
40 ! Do not check for global options
41 if (.not. global) then
42 if ((int(loc%x) < ids) .or. (int(loc%x) >= ide) .or. &
43 (int(loc%y) < jds) .or. (int(loc%y) >= jde)) then
44 outside_all = .true.
45 outside = .true.
46 return
47 end if
48 if (def_sub_domain) then
49 if (x_start_sub_domain > loc%x .or. y_start_sub_domain > loc%y .or. &
50 x_end_sub_domain < loc%x .or. y_end_sub_domain < loc%y) then
51 outside_all = .true.
52 outside = .true.
53 return
54 end if
55 end if
56 end if
57 end if
58
59 if (fg_format == fg_format_kma_global) then
60 if ((loc%j < jts-1) .or. (loc%j > jte)) then
61 outside = .true.
62 return
63 end if
64
65 if (loc%j == jde) then
66 loc%j = loc%j - 1
67 loc%dy = 1.0
68 loc%dym = 0.0
69 end if
70
71 return
72 end if
73
74 ! Check for edge of domain:
75
76 if ((loc%i < ids) .or. (loc%i >= ide) .or. &
77 (loc%j < jds) .or. (loc%j >= jde)) then
78 outside = .true.
79 return
80 end if
81
82 ! FIX? hack
83 if ((loc%i < its-1) .or. (loc%i > ite) .or. &
84 (loc%j < jts-1) .or. (loc%j > jte)) then
85 ! if ((loc%i < its-1) .or. (loc%i >= ite) .or. &
86 ! (loc%j < jts-1) .or. (loc%j >= jte)) then
87 outside = .true.
88 return
89
90 if (def_sub_domain) then
91 if (x_start_sub_domain > loc%x .or. y_start_sub_domain > loc%y .or. &
92 x_end_sub_domain < loc%x .or. y_end_sub_domain < loc%y) then
93 outside = .true.
94 end if
95 end if
96 end if
97
98 ! if (trace_use_frequent) call da_trace_exit("da_llxy")
99
100 end subroutine da_llxy
101
102