1 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
2 | ! Program: geogrid |
---|
3 | ! |
---|
4 | ! Written by Michael G. Duda |
---|
5 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
6 | program geogrid |
---|
7 | |
---|
8 | use gridinfo_module |
---|
9 | use llxy_module |
---|
10 | use list_module |
---|
11 | use module_debug |
---|
12 | use parallel_module |
---|
13 | use process_tile_module |
---|
14 | use source_data_module |
---|
15 | |
---|
16 | implicit none |
---|
17 | |
---|
18 | ! Local variables |
---|
19 | integer :: i, nest_level, temp |
---|
20 | logical :: ew_extra_col, sn_extra_row |
---|
21 | type(list) :: level_list |
---|
22 | |
---|
23 | ! Prepare anything necessary to do parallel processing of domains |
---|
24 | ! The parallel module should be initialized before any other calls take place |
---|
25 | call parallel_start() |
---|
26 | |
---|
27 | call mprintf(.true.,LOGFILE,' *** Starting program geogrid.exe *** ') |
---|
28 | |
---|
29 | ! Have the gridinfo module retrieve description of the grid setup |
---|
30 | call get_grid_params() |
---|
31 | |
---|
32 | ! Get information about the source data to be processed |
---|
33 | call get_datalist() |
---|
34 | |
---|
35 | if (gridtype == 'C') then |
---|
36 | |
---|
37 | ! Tell the llxy module that it can now compute parameters necessary to do |
---|
38 | ! transformations for any nest |
---|
39 | call compute_nest_locations() |
---|
40 | |
---|
41 | ! Process all requested domains |
---|
42 | do i=1,n_domains |
---|
43 | call mprintf(.true.,STDOUT,'Processing domain %i of %i', i1=i, i2=n_domains) |
---|
44 | call mprintf(.true.,LOGFILE,'Processing domain %i of %i', i1=i, i2=n_domains) |
---|
45 | |
---|
46 | ! Get information about the source data we will use for this nest |
---|
47 | call get_source_params(geog_data_res(i)) |
---|
48 | |
---|
49 | ! Set transformations in llxy module to be with respect to current nest |
---|
50 | call select_domain(i) |
---|
51 | |
---|
52 | ! Determine which range of indices we will work on |
---|
53 | call parallel_get_tile_dims(ixdim(i), jydim(i)) |
---|
54 | |
---|
55 | if (my_x == nproc_x-1) then ! One more column for U points |
---|
56 | ew_extra_col = .true. |
---|
57 | else |
---|
58 | ew_extra_col = .false. |
---|
59 | end if |
---|
60 | |
---|
61 | if (my_y == nproc_y-1) then ! One more row for V points |
---|
62 | sn_extra_row = .true. |
---|
63 | else |
---|
64 | sn_extra_row = .false. |
---|
65 | end if |
---|
66 | |
---|
67 | ! Process fields for a tile of the current nest |
---|
68 | call process_tile(i, gridtype, dyn_opt, & |
---|
69 | 1, ixdim(i), 1, jydim(i), & |
---|
70 | my_minx, my_maxx, my_miny, my_maxy, & ! These come from parallel_module |
---|
71 | ew_extra_col, sn_extra_row) |
---|
72 | end do |
---|
73 | |
---|
74 | else if (gridtype == 'E') then |
---|
75 | |
---|
76 | ! Get number of grid points and grid spacing for nest levels |
---|
77 | call compute_nest_level_info() |
---|
78 | |
---|
79 | ! Create list to track NMM nesting levels |
---|
80 | call list_init(level_list) |
---|
81 | |
---|
82 | ! Process all requested domains |
---|
83 | do i=1,n_domains |
---|
84 | |
---|
85 | nest_level = get_nest_level(i) |
---|
86 | |
---|
87 | if (.not. list_search(level_list, ikey=nest_level, ivalue=temp)) then |
---|
88 | call list_insert(level_list, ikey=nest_level, ivalue=nest_level) |
---|
89 | |
---|
90 | if (nest_level == 1) then |
---|
91 | call mprintf(.true.,STDOUT,'Processing coarse domain', i1=nest_level) |
---|
92 | call mprintf(.true.,LOGFILE,'Processing coarse domain', i1=nest_level) |
---|
93 | else |
---|
94 | call mprintf(.true.,STDOUT,'Processing nesting level %i', i1=nest_level-1) |
---|
95 | call mprintf(.true.,LOGFILE,'Processing nesting level %i', i1=nest_level-1) |
---|
96 | end if |
---|
97 | |
---|
98 | ! Get information about the source data we will use for this nest |
---|
99 | call get_source_params(geog_data_res(i)) |
---|
100 | |
---|
101 | ! Set transformations in llxy module to be with respect to current nest |
---|
102 | call select_domain(nest_level) |
---|
103 | |
---|
104 | ! Determine which range of indices we will work on |
---|
105 | call parallel_get_tile_dims(ixdim(nest_level), jydim(nest_level)) |
---|
106 | |
---|
107 | sn_extra_row = .false. |
---|
108 | ew_extra_col = .false. |
---|
109 | |
---|
110 | ! Process fields for a tile of the current nest |
---|
111 | call process_tile(nest_level, gridtype, dyn_opt, & |
---|
112 | 1, ixdim(nest_level), 1, jydim(nest_level), & |
---|
113 | my_minx, my_maxx, my_miny, my_maxy, & ! These come from parallel_module |
---|
114 | ew_extra_col, sn_extra_row) |
---|
115 | end if |
---|
116 | end do |
---|
117 | |
---|
118 | ! Free up list that was used for tracking NMM nesting levels |
---|
119 | call list_destroy(level_list) |
---|
120 | |
---|
121 | end if |
---|
122 | |
---|
123 | ! Free up memory used by list of source data to be processed |
---|
124 | call datalist_destroy() |
---|
125 | |
---|
126 | ! Clean up parallel stuff |
---|
127 | call parallel_finish() |
---|
128 | |
---|
129 | call mprintf(.true.,STDOUT,'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') |
---|
130 | call mprintf(.true.,STDOUT,'! Successful completion of geogrid. !') |
---|
131 | call mprintf(.true.,STDOUT,'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') |
---|
132 | |
---|
133 | call mprintf(.true.,LOGFILE,' *** Successful completion of program geogrid.exe *** ') |
---|
134 | |
---|
135 | stop |
---|
136 | |
---|
137 | end program geogrid |
---|