1 !WRF+/AD:MEDIATION_LAYER:PHYSICS
2 !Created by Ning Pan, 2010-08
4 MODULE a_module_sfs_driver
8 SUBROUTINE a_sfs_driver( grid, config_flags, &
9 nba_mij,a_nba_mij, n_nba_mij, &
10 nba_rij,a_nba_rij, n_nba_rij )
16 USE module_state_description
19 USE module_sfs_nba, ONLY : calc_mij_constants, calc_smnsmn
23 USE module_comm_dm, ONLY : &
25 ,PERIOD_EM_NBA_RIJ_sub &
26 ,HALO_EM_NBA_MIJ_sub &
27 ,PERIOD_EM_NBA_MIJ_sub
34 TYPE(domain) , TARGET :: grid
36 TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
38 INTEGER, INTENT( IN ) :: n_nba_mij, n_nba_rij
40 REAL ,DIMENSION(grid%sm31:grid%em31,grid%sm32:grid%em32,grid%sm33:grid%em33,n_nba_mij) &
43 REAL ,DIMENSION(grid%sm31:grid%em31,grid%sm32:grid%em32,grid%sm33:grid%em33,n_nba_rij) &
48 INTEGER :: k_start , k_end, its, ite, jts, jte
49 INTEGER :: ids , ide , jds , jde , kds , kde , &
50 ims , ime , jms , jme , kms , kme , &
51 ips , ipe , jps , jpe , kps , kpe
53 INTEGER :: imsx, imex, jmsx, jmex, kmsx, kmex, &
54 ipsx, ipex, jpsx, jpex, kpsx, kpex, &
55 imsy, imey, jmsy, jmey, kmsy, kmey, &
56 ipsy, ipey, jpsy, jpey, kpsy, kpey
58 INTEGER :: ij, i, j, k
61 CALL get_ijk_from_grid ( grid , &
62 ids, ide, jds, jde, kds, kde, &
63 ims, ime, jms, jme, kms, kme, &
64 ips, ipe, jps, jpe, kps, kpe, &
65 imsx, imex, jmsx, jmex, kmsx, kmex, &
66 ipsx, ipex, jpsx, jpex, kpsx, kpex, &
67 imsy, imey, jmsy, jmey, kmsy, kmey, &
68 ipsy, ipey, jpsy, jpey, kpsy, kpey )
73 CALL set_tiles ( grid , ids , ide , jds , jde , ips , ipe , jps , jpe )
75 IF ( (config_flags%sfs_opt .EQ. 1) .OR. (config_flags%sfs_opt .EQ. 2) ) THEN
79 DO ij = 1 , grid%num_tiles !----------------------------------------
81 CALL calc_mij_constants( )
83 ENDDO !-------------------------------------------------------------
88 DO ij = 1 , grid%num_tiles !----------------------------------------
90 CALL calc_smnsmn( nba_rij(ims,kms,jms,P_smnsmn), &
91 grid%defor11, grid%defor22, &
92 grid%defor33, grid%defor12, &
93 grid%defor13, grid%defor23, &
95 ids, ide, jds, jde, kds, kde, &
96 ims, ime, jms, jme, kms, kme, &
97 ips, ipe, jps, jpe, kps, kpe, &
98 grid%i_start(ij), grid%i_end(ij), &
99 grid%j_start(ij), grid%j_end(ij), &
102 ENDDO !-------------------------------------------------------------
103 !$OMP END PARALLEL DO
106 # include "HALO_EM_NBA_RIJ.inc"
107 # include "PERIOD_EM_NBA_RIJ.inc"
112 DO ij = 1 , grid%num_tiles !----------------------------------------
114 CALL set_physical_bc3d( nba_rij(ims,kms,jms,P_r12), 'd', &
116 ids, ide, jds, jde, kds, kde, &
117 ims, ime, jms, jme, kms, kme, &
118 ips, ipe, jps, jpe, kps, kpe, &
119 grid%i_start(ij), grid%i_end(ij), &
120 grid%j_start(ij), grid%j_end(ij), &
123 CALL set_physical_bc3d( nba_rij(ims,kms,jms,P_r13), 'e', &
125 ids, ide, jds, jde, kds, kde, &
126 ims, ime, jms, jme, kms, kme, &
127 ips, ipe, jps, jpe, kps, kpe, &
128 grid%i_start(ij), grid%i_end(ij), &
129 grid%j_start(ij), grid%j_end(ij), &
132 CALL set_physical_bc3d( nba_rij(ims,kms,jms,P_r23), 'f', &
134 ids, ide, jds, jde, kds, kde, &
135 ims, ime, jms, jme, kms, kme, &
136 ips, ipe, jps, jpe, kps, kpe, &
137 grid%i_start(ij), grid%i_end(ij), &
138 grid%j_start(ij), grid%j_end(ij), &
141 CALL set_physical_bc3d( nba_rij(ims,kms,jms,P_smnsmn), 'c', &
143 ids, ide, jds, jde, kds, kde, &
144 ims, ime, jms, jme, kms, kme, &
145 ips, ipe, jps, jpe, kps, kpe, &
146 grid%i_start(ij), grid%i_end(ij), &
147 grid%j_start(ij), grid%j_end(ij), &
150 ENDDO !-------------------------------------------------------------
151 !$OMP END PARALLEL DO
154 # include "HALO_EM_NBA_MIJ.inc"
155 # include "PERIOD_EM_NBA_MIJ.inc"
160 DO ij = grid%num_tiles,1,-1 !----------------------------------------
162 CALL a_set_physical_bc3d( a_nba_mij(ims,kms,jms,P_m23), 'f', &
164 ids, ide, jds, jde, kds, kde, &
165 ims, ime, jms, jme, kms, kme, &
166 ips, ipe, jps, jpe, kps, kpe, &
167 grid%i_start(ij), grid%i_end(ij), &
168 grid%j_start(ij), grid%j_end(ij), &
171 CALL a_set_physical_bc3d( a_nba_mij(ims,kms,jms,P_m13), 'e', &
173 ids, ide, jds, jde, kds, kde, &
174 ims, ime, jms, jme, kms, kme, &
175 ips, ipe, jps, jpe, kps, kpe, &
176 grid%i_start(ij), grid%i_end(ij), &
177 grid%j_start(ij), grid%j_end(ij), &
180 CALL a_set_physical_bc3d( a_nba_mij(ims,kms,jms,P_m12), 'd', &
182 ids, ide, jds, jde, kds, kde, &
183 ims, ime, jms, jme, kms, kme, &
184 ips, ipe, jps, jpe, kps, kpe, &
185 grid%i_start(ij), grid%i_end(ij), &
186 grid%j_start(ij), grid%j_end(ij), &
189 CALL a_set_physical_bc3d( a_nba_mij(ims,kms,jms,P_m33), 'p', &
191 ids, ide, jds, jde, kds, kde, &
192 ims, ime, jms, jme, kms, kme, &
193 ips, ipe, jps, jpe, kps, kpe, &
194 grid%i_start(ij), grid%i_end(ij), &
195 grid%j_start(ij), grid%j_end(ij), &
198 CALL a_set_physical_bc3d( a_nba_mij(ims,kms,jms,P_m22), 'p', &
200 ids, ide, jds, jde, kds, kde, &
201 ims, ime, jms, jme, kms, kme, &
202 ips, ipe, jps, jpe, kps, kpe, &
203 grid%i_start(ij), grid%i_end(ij), &
204 grid%j_start(ij), grid%j_end(ij), &
207 CALL a_set_physical_bc3d( a_nba_mij(ims,kms,jms,P_m11), 'p', &
209 ids, ide, jds, jde, kds, kde, &
210 ims, ime, jms, jme, kms, kme, &
211 ips, ipe, jps, jpe, kps, kpe, &
212 grid%i_start(ij), grid%i_end(ij), &
213 grid%j_start(ij), grid%j_end(ij), &
216 ENDDO !-------------------------------------------------------------
217 !$OMP END PARALLEL DO
221 DO ij = grid%num_tiles,1,-1 !----------------------------------------
223 CALL a_calc_m23( nba_mij(ims,kms,jms,P_m23),a_nba_mij(ims,kms,jms,P_m23), &
224 grid%defor22,grid%a_defor22, &
225 grid%defor33,grid%a_defor33, grid%defor12,grid%a_defor12, &
226 grid%defor13,grid%a_defor13, grid%defor23,grid%a_defor23, &
227 nba_rij(ims,kms,jms,P_r12),a_nba_rij(ims,kms,jms,P_r12), &
228 nba_rij(ims,kms,jms,P_r13),a_nba_rij(ims,kms,jms,P_r13), &
229 nba_rij(ims,kms,jms,P_r23),a_nba_rij(ims,kms,jms,P_r23), &
230 nba_rij(ims,kms,jms,P_smnsmn),a_nba_rij(ims,kms,jms,P_smnsmn), &
231 grid%tke_2,grid%a_tke_2, &
232 grid%rdzw,grid%a_rdzw, grid%dx, grid%dy, &
233 grid%fnm, grid%fnp, &
235 ids, ide, jds, jde, kds, kde, &
236 ims, ime, jms, jme, kms, kme, &
237 ips, ipe, jps, jpe, kps, kpe, &
238 grid%i_start(ij), grid%i_end(ij), &
239 grid%j_start(ij), grid%j_end(ij), &
242 ENDDO !-------------------------------------------------------------
243 !$OMP END PARALLEL DO
247 DO ij = 1 , grid%num_tiles !----------------------------------------
249 CALL a_calc_m13( nba_mij(ims,kms,jms,P_m13),a_nba_mij(ims,kms,jms,P_m13), &
250 grid%defor11,grid%a_defor11, &
251 grid%defor33,grid%a_defor33, grid%defor12,grid%a_defor12, &
252 grid%defor13,grid%a_defor13, grid%defor23,grid%a_defor23, &
253 nba_rij(ims,kms,jms,P_r12),a_nba_rij(ims,kms,jms,P_r12), &
254 nba_rij(ims,kms,jms,P_r13),a_nba_rij(ims,kms,jms,P_r13), &
255 nba_rij(ims,kms,jms,P_r23),a_nba_rij(ims,kms,jms,P_r23), &
256 nba_rij(ims,kms,jms,P_smnsmn),a_nba_rij(ims,kms,jms,P_smnsmn), &
257 grid%tke_2,grid%a_tke_2, &
258 grid%rdzw,grid%a_rdzw, grid%dx, grid%dy, &
259 grid%fnm, grid%fnp, &
261 ids, ide, jds, jde, kds, kde, &
262 ims, ime, jms, jme, kms, kme, &
263 ips, ipe, jps, jpe, kps, kpe, &
264 grid%i_start(ij), grid%i_end(ij), &
265 grid%j_start(ij), grid%j_end(ij), &
268 ENDDO !-------------------------------------------------------------
269 !$OMP END PARALLEL DO
273 DO ij = grid%num_tiles,1,-1 !----------------------------------------
275 CALL a_calc_m12( nba_mij(ims,kms,jms,P_m12),a_nba_mij(ims,kms,jms,P_m12), &
276 grid%defor11,grid%a_defor11, grid%defor22,grid%a_defor22, &
277 grid%defor12,grid%a_defor12, &
278 grid%defor13,grid%a_defor13, grid%defor23,grid%a_defor23, &
279 nba_rij(ims,kms,jms,P_r12),a_nba_rij(ims,kms,jms,P_r12), &
280 nba_rij(ims,kms,jms,P_r13),a_nba_rij(ims,kms,jms,P_r13), &
281 nba_rij(ims,kms,jms,P_r23),a_nba_rij(ims,kms,jms,P_r23), &
282 nba_rij(ims,kms,jms,P_smnsmn),a_nba_rij(ims,kms,jms,P_smnsmn), &
283 grid%tke_2,grid%a_tke_2, &
284 grid%rdzw,grid%a_rdzw, grid%dx, grid%dy, &
286 ids, ide, jds, jde, kds, kde, &
287 ims, ime, jms, jme, kms, kme, &
288 ips, ipe, jps, jpe, kps, kpe, &
289 grid%i_start(ij), grid%i_end(ij), &
290 grid%j_start(ij), grid%j_end(ij), &
293 ENDDO !-------------------------------------------------------------
294 !$OMP END PARALLEL DO
298 DO ij = grid%num_tiles,1,-1 !----------------------------------------
300 CALL a_calc_mii( nba_mij(ims,kms,jms,P_m11),a_nba_mij(ims,kms,jms,P_m11), &
301 nba_mij(ims,kms,jms,P_m22),a_nba_mij(ims,kms,jms,P_m22), &
302 nba_mij(ims,kms,jms,P_m33),a_nba_mij(ims,kms,jms,P_m33), &
303 grid%defor11,grid%a_defor11, grid%defor22,grid%a_defor22, &
304 grid%defor33,grid%a_defor33, grid%defor12,grid%a_defor12, &
305 grid%defor13,grid%a_defor13, grid%defor23,grid%a_defor23, &
306 nba_rij(ims,kms,jms,P_r12),a_nba_rij(ims,kms,jms,P_r12), &
307 nba_rij(ims,kms,jms,P_r13),a_nba_rij(ims,kms,jms,P_r13), &
308 nba_rij(ims,kms,jms,P_r23),a_nba_rij(ims,kms,jms,P_r23), &
309 nba_rij(ims,kms,jms,P_smnsmn),a_nba_rij(ims,kms,jms,P_smnsmn), &
310 grid%tke_2,grid%a_tke_2, &
311 grid%rdzw,grid%a_rdzw, grid%dx, grid%dy, &
313 ids, ide, jds, jde, kds, kde, &
314 ims, ime, jms, jme, kms, kme, &
315 ips, ipe, jps, jpe, kps, kpe, &
316 grid%i_start(ij), grid%i_end(ij), &
317 grid%j_start(ij), grid%j_end(ij), &
320 ENDDO !-------------------------------------------------------------
321 !$OMP END PARALLEL DO
325 DO ij = grid%num_tiles,1,-1 !----------------------------------------
327 CALL a_set_physical_bc3d( a_nba_rij(ims,kms,jms,P_smnsmn), 'c', &
329 ids, ide, jds, jde, kds, kde, &
330 ims, ime, jms, jme, kms, kme, &
331 ips, ipe, jps, jpe, kps, kpe, &
332 grid%i_start(ij), grid%i_end(ij), &
333 grid%j_start(ij), grid%j_end(ij), &
336 CALL a_set_physical_bc3d( a_nba_rij(ims,kms,jms,P_r23), 'f', &
338 ids, ide, jds, jde, kds, kde, &
339 ims, ime, jms, jme, kms, kme, &
340 ips, ipe, jps, jpe, kps, kpe, &
341 grid%i_start(ij), grid%i_end(ij), &
342 grid%j_start(ij), grid%j_end(ij), &
345 CALL a_set_physical_bc3d( a_nba_rij(ims,kms,jms,P_r13), 'e', &
347 ids, ide, jds, jde, kds, kde, &
348 ims, ime, jms, jme, kms, kme, &
349 ips, ipe, jps, jpe, kps, kpe, &
350 grid%i_start(ij), grid%i_end(ij), &
351 grid%j_start(ij), grid%j_end(ij), &
354 CALL a_set_physical_bc3d( a_nba_rij(ims,kms,jms,P_r12), 'd', &
356 ids, ide, jds, jde, kds, kde, &
357 ims, ime, jms, jme, kms, kme, &
358 ips, ipe, jps, jpe, kps, kpe, &
359 grid%i_start(ij), grid%i_end(ij), &
360 grid%j_start(ij), grid%j_end(ij), &
364 ENDDO !-------------------------------------------------------------
365 !$OMP END PARALLEL DO
369 DO ij = grid%num_tiles,1,-1 !----------------------------------------
371 CALL a_calc_smnsmn( nba_rij(ims,kms,jms,P_smnsmn),a_nba_rij(ims,kms,jms,P_smnsmn), &
372 grid%defor11,grid%a_defor11, grid%defor22,grid%a_defor22, &
373 grid%defor33,grid%a_defor33, grid%defor12,grid%a_defor12, &
374 grid%defor13,grid%a_defor13, grid%defor23,grid%a_defor23, &
376 ids, ide, jds, jde, kds, kde, &
377 ims, ime, jms, jme, kms, kme, &
378 ips, ipe, jps, jpe, kps, kpe, &
379 grid%i_start(ij), grid%i_end(ij), &
380 grid%j_start(ij), grid%j_end(ij), &
383 ENDDO !-------------------------------------------------------------
384 !$OMP END PARALLEL DO
386 ENDIF !(config_flags%sfs_opt .EQ. 1) .OR. (config_flags%sfs_opt .EQ. 2)
388 END SUBROUTINE a_sfs_driver
390 END MODULE a_module_sfs_driver