2 !WRF:MEDIATION_LAYER:NESTING
4 SUBROUTINE med_force_domain ( parent_grid , nested_grid )
8 USE module_dm, ONLY : intercomm_active, &
9 mpi_comm_to_kid, mpi_comm_to_mom, which_kid
11 USE module_dm, ONLY : intercomm_active
15 TYPE(domain), POINTER :: parent_grid , nested_grid
16 TYPE(domain), POINTER :: grid
18 #if !defined(MAC_KLUDGE)
19 TYPE (grid_config_rec_type) :: config_flags
22 ! ----------------------------------------------------------
23 ! ------------------------------------------------------
25 ! ------------------------------------------------------
27 ! ------------------------------------------------------
28 ! Interface definitions for EM CORE
29 ! ------------------------------------------------------
31 #if !defined(MAC_KLUDGE)
32 ! ------------------------------------------------------
33 ! These routines are supplied by module_dm.F from the
34 ! external communication package (e.g. external/RSL)
35 ! ------------------------------------------------------
36 SUBROUTINE interp_domain_em_part1 ( grid, intermediate_grid, ngrid, config_flags &
38 # include "dummy_new_args.inc"
43 TYPE(domain), POINTER :: grid ! name of the grid being dereferenced (must be "grid")
44 TYPE(domain), POINTER :: intermediate_grid
45 TYPE(domain), POINTER :: ngrid
46 TYPE (grid_config_rec_type) :: config_flags
47 # include "dummy_new_decl.inc"
48 END SUBROUTINE interp_domain_em_part1
50 SUBROUTINE force_domain_em_part2 ( grid, nested_grid, parent_grid, config_flags &
52 # include "dummy_new_args.inc"
57 TYPE(domain), POINTER :: grid ! name of the grid being dereferenced (must be "grid")
58 TYPE(domain), POINTER :: nested_grid
59 TYPE(domain), POINTER :: parent_grid ! KAL added for vertical nesting
60 TYPE (grid_config_rec_type) :: config_flags
61 # include "dummy_new_decl.inc"
62 END SUBROUTINE force_domain_em_part2
64 ! ----------------------------------------------------------
65 ! This routine is supplied by dyn_em/couple_or_uncouple_em.F
66 ! ----------------------------------------------------------
67 SUBROUTINE couple_or_uncouple_em ( grid, config_flags , couple &
69 # include "dummy_new_args.inc"
74 TYPE(domain), INTENT(INOUT) :: grid
75 TYPE (grid_config_rec_type) :: config_flags
76 LOGICAL, INTENT( IN) :: couple
77 # include "dummy_new_decl.inc"
78 END SUBROUTINE couple_or_uncouple_em
82 ! ----------------------------------------------------------
83 ! End of Interface blocks
84 ! ----------------------------------------------------------
85 ! ----------------------------------------------------------
86 ! ----------------------------------------------------------
88 ! ----------------------------------------------------------
89 ! ----------------------------------------------------------
90 ! Forcing calls for EM CORE.
91 ! ----------------------------------------------------------
92 #if (EM_CORE == 1 && defined( DM_PARALLEL ))
93 # if !defined(MAC_KLUDGE)
94 CALL model_to_grid_config_rec ( nested_grid%id , model_config_rec , config_flags )
96 grid => nested_grid%intermediate_grid
97 # if (defined(MOVE_NESTS) || ((!defined(KEEP_INT_AROUND)) && (!defined(SGIALTIX)) && (!defined(FUJITSU_FX10))))
98 ! IF ( intercomm_active(grid%id) ) THEN
99 CALL alloc_space_field ( grid, grid%id , 1 , 2 , .TRUE. , intercomm_active(grid%id), &
100 grid%sd31, grid%ed31, grid%sd32, grid%ed32, grid%sd33, grid%ed33, &
101 grid%sm31, grid%em31, grid%sm32, grid%em32, grid%sm33, grid%em33, &
102 grid%sp31, grid%ep31, grid%sp32, grid%ep32, grid%sp33, grid%ep33, &
103 grid%sp31x, grid%ep31x, grid%sp32x, grid%ep32x, grid%sp33x, grid%ep33x,&
104 grid%sp31y, grid%ep31y, grid%sp32y, grid%ep32y, grid%sp33y, grid%ep33y,&
105 grid%sm31x, grid%em31x, grid%sm32x, grid%em32x, grid%sm33x, grid%em33x, & ! x-xpose
106 grid%sm31y, grid%em31y, grid%sm32y, grid%em32y, grid%sm33y, grid%em33y & ! y-xpose
111 ! couple parent domain
113 IF ( grid%active_this_task ) THEN
114 CALL push_communicators_for_domain(grid%id)
115 ! swich config_flags to point to parent rconfig info
116 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
117 CALL couple_or_uncouple_em ( grid , config_flags , .true. &
119 # include "actual_new_args.inc"
122 CALL pop_communicators_for_domain
124 ! couple nested domain
126 IF ( grid%active_this_task ) THEN
127 CALL push_communicators_for_domain(grid%id)
128 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
129 CALL couple_or_uncouple_em ( grid , config_flags , .true. &
131 # include "actual_new_args.inc"
134 CALL pop_communicators_for_domain
136 ! perform first part: transfer data from parent to intermediate domain
137 ! at the same resolution but on the same decomposition as the nest
138 ! note that this will involve communication on multiple DM procs
140 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
142 ! Added following line to handle adaptive time step. This should probably
143 ! go somewhere else, but I'm not sure where.
145 ! T. Hutchinson, WSI 1/23/07
148 IF ( parent_grid%active_this_task .AND. nested_grid%active_this_task ) THEN
149 nested_grid%intermediate_grid%dt = grid%dt
151 IF ( parent_grid%active_this_task ) THEN
152 CALL BYTE_BCAST( parent_grid%dt,RWORDSIZE,mpi_comm_to_kid( which_kid( nested_grid%id ) , parent_grid%id ))
153 ELSE IF ( nested_grid%active_this_task ) THEN
154 CALL BYTE_BCAST( nested_grid%dt,RWORDSIZE,mpi_comm_to_mom( nested_grid%id ) )
157 IF ( parent_grid%active_this_task .OR. nested_grid%active_this_task ) THEN
158 CALL wrf_dm_nestexchange_init
160 CALL interp_domain_em_part1 ( grid , nested_grid%intermediate_grid, nested_grid, config_flags &
162 # include "actual_new_args.inc"
167 IF ( nested_grid%active_this_task ) THEN
168 grid => nested_grid%intermediate_grid
169 ! perform 2nd part: run interpolation on the intermediate domain
170 ! and compute the values for the nest boundaries
171 ! note that this is all local (no communication)
172 CALL model_to_grid_config_rec ( nested_grid%id , model_config_rec , config_flags )
173 CALL force_domain_em_part2 ( grid, nested_grid, parent_grid, config_flags &
175 # include "actual_new_args.inc"
181 IF ( grid%active_this_task ) THEN
182 CALL push_communicators_for_domain(grid%id)
183 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
184 CALL couple_or_uncouple_em ( grid , config_flags , .false. &
186 # include "actual_new_args.inc"
189 CALL pop_communicators_for_domain
191 ! uncouple the parent
193 IF ( grid%active_this_task ) THEN
194 CALL push_communicators_for_domain(grid%id)
195 CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
196 CALL couple_or_uncouple_em ( grid , config_flags , .false. &
198 # include "actual_new_args.inc"
201 CALL pop_communicators_for_domain
203 IF ( nested_grid%first_force ) THEN
204 nested_grid%first_force = .FALSE.
206 nested_grid%dtbc = 0.
208 grid => nested_grid%intermediate_grid
209 # if (defined(MOVE_NESTS) || ((!defined(KEEP_INT_AROUND)) && (!defined(SGIALTIX)) && (!defined(FUJITSU_FX10))))
210 IF ( intercomm_active(grid%id) ) THEN
211 CALL dealloc_space_field ( grid )
216 ! ------------------------------------------------------
217 ! End of Forcing calls for EM CORE.
218 ! ------------------------------------------------------
220 END SUBROUTINE med_force_domain