2 !WRF:MEDIATION_LAYER:NESTING
4 SUBROUTINE med_force_domain ( parent_grid , nested_grid )
8 TYPE(domain), POINTER :: parent_grid , nested_grid
9 TYPE(domain), POINTER :: grid
11 #if !defined(MAC_KLUDGE)
12 TYPE (grid_config_rec_type) :: config_flags
15 ! ----------------------------------------------------------
16 ! ------------------------------------------------------
18 ! ------------------------------------------------------
20 ! ------------------------------------------------------
21 ! Interface definitions for EM CORE
22 ! ------------------------------------------------------
24 #if !defined(MAC_KLUDGE)
25 ! ------------------------------------------------------
26 ! These routines are supplied by module_dm.F from the
27 ! external communication package (e.g. external/RSL)
28 ! ------------------------------------------------------
29 SUBROUTINE interp_domain_em_part1 ( grid, intermediate_grid, ngrid, config_flags &
31 # include "dummy_new_args.inc"
36 TYPE(domain), POINTER :: grid ! name of the grid being dereferenced (must be "grid")
37 TYPE(domain), POINTER :: intermediate_grid
38 TYPE(domain), POINTER :: ngrid
39 TYPE (grid_config_rec_type) :: config_flags
40 # include <dummy_new_decl.inc>
41 END SUBROUTINE interp_domain_em_part1
43 SUBROUTINE force_domain_em_part2 ( grid, nested_grid, config_flags &
45 # include "dummy_new_args.inc"
50 TYPE(domain), POINTER :: grid ! name of the grid being dereferenced (must be "grid")
51 TYPE(domain), POINTER :: nested_grid
52 TYPE (grid_config_rec_type) :: config_flags
53 # include <dummy_new_decl.inc>
54 END SUBROUTINE force_domain_em_part2
56 ! ----------------------------------------------------------
57 ! This routine is supplied by dyn_em/couple_or_uncouple_em.F
58 ! ----------------------------------------------------------
59 SUBROUTINE couple_or_uncouple_em ( grid, config_flags , couple &
61 # include "dummy_new_args.inc"
66 TYPE(domain), INTENT(INOUT) :: grid
67 TYPE (grid_config_rec_type) :: config_flags
68 LOGICAL, INTENT( IN) :: couple
69 # include <dummy_new_decl.inc>
70 END SUBROUTINE couple_or_uncouple_em
73 ! ----------------------------------------------------------
74 ! Interface definitions for NMM (placeholder)
75 ! ----------------------------------------------------------
76 #if (NMM_CORE == 1 && NMM_NEST ==1)
77 !=======================================================================
78 ! Added for the NMM core. This is gopal's doing.
79 !=======================================================================
81 SUBROUTINE interp_domain_nmm_part1 ( grid, intermediate_grid, ngrid, config_flags &
83 # include "dummy_args.inc"
88 TYPE(domain), POINTER :: grid ! name of the grid being dereferenced (must be "grid")
89 TYPE(domain), POINTER :: intermediate_grid
90 TYPE(domain), POINTER :: ngrid
91 TYPE (grid_config_rec_type) :: config_flags
92 # include <dummy_decl.inc>
93 END SUBROUTINE interp_domain_nmm_part1
95 SUBROUTINE force_domain_nmm_part2 ( grid, nested_grid, config_flags &
97 # include "dummy_args.inc"
102 TYPE(domain), POINTER :: grid ! name of the grid being dereferenced (must be "grid")
103 TYPE(domain), POINTER :: nested_grid
104 TYPE (grid_config_rec_type) :: config_flags
106 # include <dummy_decl.inc>
107 END SUBROUTINE force_domain_nmm_part2
108 !=======================================================================
109 ! End of gopal's doing.
110 !=======================================================================
112 ! ----------------------------------------------------------
113 ! Interface definitions for COAMPS (placeholder)
114 ! ----------------------------------------------------------
115 #if (COAMPS_CORE == 1)
118 ! ----------------------------------------------------------
119 ! End of Interface blocks
120 ! ----------------------------------------------------------
122 ! ----------------------------------------------------------
123 ! ----------------------------------------------------------
125 ! ----------------------------------------------------------
126 ! ----------------------------------------------------------
127 ! Forcing calls for EM CORE.
128 ! ----------------------------------------------------------
129 #if (EM_CORE == 1 && defined( DM_PARALLEL ))
130 # if !defined(MAC_KLUDGE)
131 CALL model_to_grid_config_rec ( nested_grid%id , model_config_rec , config_flags )
133 grid => nested_grid%intermediate_grid
134 # if defined(MOVE_NESTS) || (!defined(SGIALTIX))
135 CALL alloc_space_field ( grid, grid%id , 1 , 2 , .TRUE. , &
136 grid%sd31, grid%ed31, grid%sd32, grid%ed32, grid%sd33, grid%ed33, &
137 grid%sm31, grid%em31, grid%sm32, grid%em32, grid%sm33, grid%em33, &
138 grid%sm31x, grid%em31x, grid%sm32x, grid%em32x, grid%sm33x, grid%em33x, & ! x-xpose
139 grid%sm31y, grid%em31y, grid%sm32y, grid%em32y, grid%sm33y, grid%em33y & ! y-xpose
143 ! couple parent domain
145 ! swich config_flags to point to parent rconfig info
146 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
147 CALL couple_or_uncouple_em ( grid , config_flags , .true. &
149 # include "actual_new_args.inc"
152 ! couple nested domain
154 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
155 CALL couple_or_uncouple_em ( grid , config_flags , .true. &
157 # include "actual_new_args.inc"
160 ! perform first part: transfer data from parent to intermediate domain
161 ! at the same resolution but on the same decomposition as the nest
162 ! note that this will involve communication on multiple DM procs
164 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
166 ! Added following line to handle adaptive time step. This should probably
167 ! go somewhere else, but I'm not sure where.
169 ! T. Hutchinson, WSI 1/23/07
171 nested_grid%intermediate_grid%dt = grid%dt
173 CALL interp_domain_em_part1 ( grid , nested_grid%intermediate_grid, nested_grid, config_flags &
175 # include "actual_new_args.inc"
178 grid => nested_grid%intermediate_grid
179 ! perform 2nd part: run interpolation on the intermediate domain
180 ! and compute the values for the nest boundaries
181 ! note that this is all local (no communication)
182 CALL model_to_grid_config_rec ( nested_grid%id , model_config_rec , config_flags )
183 CALL force_domain_em_part2 ( grid, nested_grid, config_flags &
185 # include "actual_new_args.inc"
190 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
191 CALL couple_or_uncouple_em ( grid , config_flags , .false. &
193 # include "actual_new_args.inc"
196 ! uncouple the parent
198 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
199 CALL couple_or_uncouple_em ( grid , config_flags , .false. &
201 # include "actual_new_args.inc"
204 IF ( nested_grid%first_force ) THEN
205 nested_grid%first_force = .FALSE.
207 nested_grid%dtbc = 0.
209 grid => nested_grid%intermediate_grid
210 # if defined(MOVE_NESTS) || (!defined(SGIALTIX))
211 CALL dealloc_space_field ( grid )
215 ! ------------------------------------------------------
216 ! End of Forcing calls for EM CORE.
217 ! ------------------------------------------------------
218 ! ------------------------------------------------------
219 ! ------------------------------------------------------
220 ! Forcing calls for NMM. (Placeholder)
221 ! ------------------------------------------------------
222 # if (NMM_CORE == 1 && NMM_NEST == 1)
223 !=======================================================================
224 ! Added for the NMM core. This is gopal's doing.
225 !=======================================================================
227 CALL model_to_grid_config_rec ( nested_grid%id , model_config_rec , config_flags )
229 grid => nested_grid%intermediate_grid
230 !dusan orig CALL alloc_space_field ( grid, grid%id , 1 , 2 , .TRUE. , &
231 #if defined(MOVE_NESTS) || (!defined(SGIALTIX))
232 CALL alloc_space_field ( grid, grid%id , 1 , 3 , .FALSE. , &
233 grid%sd31, grid%ed31, grid%sd32, grid%ed32, grid%sd33, grid%ed33, &
234 grid%sm31, grid%em31, grid%sm32, grid%em32, grid%sm33, grid%em33, &
235 grid%sm31x, grid%em31x, grid%sm32x, grid%em32x, grid%sm33x, grid%em33x, & ! x-xpose
236 grid%sm31y, grid%em31y, grid%sm32y, grid%em32y, grid%sm33y, grid%em33y & ! y-xpose
240 ! couple parent domain
242 ! swich config_flags to point to parent rconfig info
243 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
245 ! on restart do not force the nest the first time since it has already been forced
246 ! prior to the writing of the restart file
247 IF ( .NOT. ( config_flags%restart .AND. nested_grid%first_force ) ) THEN
248 ! couple nested domain
250 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
251 ! perform first part: transfer data from parent to intermediate domain
252 ! at the same resolution but on the same decomposition as the nest
253 ! note that this will involve communication on multiple DM procs
255 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
256 CALL interp_domain_nmm_part1 ( grid , nested_grid%intermediate_grid, nested_grid, config_flags &
258 # include "actual_args.inc"
261 ENDIF ! not restart and first force
263 grid => nested_grid%intermediate_grid
264 IF ( .NOT. ( config_flags%restart .AND. nested_grid%first_force ) ) THEN
265 ! perform 2nd part: run interpolation on the intermediate domain
266 ! and compute the values for the nest boundaries
267 ! note that this is all local (no communication)
268 CALL model_to_grid_config_rec ( nested_grid%id , model_config_rec , config_flags )
269 CALL force_domain_nmm_part2 ( grid, nested_grid, config_flags &
271 # include "actual_args.inc"
274 ENDIF ! not restart and first_force
276 IF ( nested_grid%first_force ) THEN
277 nested_grid%first_force = .FALSE.
279 nested_grid%dtbc = 0.
281 grid => nested_grid%intermediate_grid
282 #if defined(MOVE_NESTS) || (!defined(SGIALTIX))
283 CALL dealloc_space_field ( grid )
285 !=======================================================================
286 ! End of gopal's doing.
287 !=======================================================================
289 ! ------------------------------------------------------
290 ! End of Forcing calls for NMM.
291 ! ------------------------------------------------------
292 ! ------------------------------------------------------
293 ! ------------------------------------------------------
294 ! Forcing calls for COAMPS. (Placeholder)
295 ! ------------------------------------------------------
296 # if (COAMPS_CORE == 1)
298 ! ------------------------------------------------------
299 ! End of Forcing calls for COAMPS.
300 ! ------------------------------------------------------
302 END SUBROUTINE med_force_domain