start_em.F

References to this file elsewhere.
1 !-------------------------------------------------------------------
2 
3    SUBROUTINE start_domain_em ( grid, allowed_to_read  &
4 ! Actual arguments generated from Registry
5 # include "em_dummy_new_args.inc"
6 !
7 )
8 
9    USE module_domain
10    USE module_dm
11 !  USE module_io_domain
12    USE module_state_description
13    USE module_model_constants
14    USE module_bc
15    USE module_bc_em
16 !  USE module_timing
17    USE module_configure
18    USE module_tiles
19 
20    USE module_physics_init
21 #ifdef WRF_CHEM
22    USE module_aerosols_sorgam, only: sum_pm_sorgam
23    USE module_mosaic_driver, only: sum_pm_mosaic
24 #endif
25 
26 #ifdef DM_PARALLEL
27    USE module_dm
28 #endif
29 
30 !!debug
31 !USE module_compute_geop
32 
33    USE module_model_constants
34    IMPLICIT NONE
35    !  Input data.
36    TYPE (domain)          :: grid
37 
38    LOGICAL , INTENT(IN)   :: allowed_to_read
39 
40    !  Definitions of dummy arguments to this routine (generated from Registry).
41 # include "em_dummy_new_decl.inc"
42 
43    !  Structure that contains run-time configuration (namelist) data for domain
44    TYPE (grid_config_rec_type)              :: config_flags
45 
46    !  Local data
47    INTEGER                             ::                       &
48                                   ids, ide, jds, jde, kds, kde, &
49                                   ims, ime, jms, jme, kms, kme, &
50                                   ips, ipe, jps, jpe, kps, kpe, &
51                                   its, ite, jts, jte, kts, kte, &
52                                   ij,i,j,k,ii,jj,kk,loop,error,l
53 
54    INTEGER ::              imsx, imex, jmsx, jmex, kmsx, kmex,    &
55                            ipsx, ipex, jpsx, jpex, kpsx, kpex,    &
56                            imsy, imey, jmsy, jmey, kmsy, kmey,    &
57                            ipsy, ipey, jpsy, jpey, kpsy, kpey
58 
59    INTEGER     :: i_m
60 
61    REAL        :: p00, t00, a, p_surf, pd_surf
62 #ifdef WRF_CHEM
63    REAL        RGASUNIV ! universal gas constant [ J/mol-K ]
64    PARAMETER ( RGASUNIV = 8.314510 )
65       REAL,DIMENSION(grid%sm31:grid%em31,grid%sm32:grid%em32,grid%sm33:grid%em33) :: &
66                       z_at_w,convfac
67    REAL :: tempfac
68 #endif
69 
70    REAL :: qvf1, qvf2, qvf
71    REAL :: MPDT
72    REAL :: spongeweight
73    LOGICAL :: first_trip_for_this_domain, start_of_simulation
74 #ifndef WRF_CHEM
75       REAL,ALLOCATABLE,DIMENSION(:,:,:) :: cldfra_old
76 #endif
77 
78    REAL :: lat1 , lat2 , lat3 , lat4
79    REAL :: lon1 , lon2 , lon3 , lon4
80    INTEGER :: num_points_lat_lon , iloc , jloc
81    CHARACTER (LEN=132) :: message
82    REAL, DIMENSION(:,:), ALLOCATABLE :: clat_glob
83 
84 ! Needed by some comm layers, e.g. RSL. If needed, nmm_data_calls.inc is
85 ! generated from the registry.  The definition of REGISTER_I1 allows
86 ! I1 data to be communicated in this routine if necessary.
87 #ifdef DM_PARALLEL
88 #    include "em_data_calls.inc"
89 #endif
90   CALL get_ijk_from_grid ( grid ,                               &
91                            ids, ide, jds, jde, kds, kde,        &
92                            ims, ime, jms, jme, kms, kme,        &
93                            ips, ipe, jps, jpe, kps, kpe,        &
94                            imsx, imex, jmsx, jmex, kmsx, kmex,  &
95                            ipsx, ipex, jpsx, jpex, kpsx, kpex,  &
96                            imsy, imey, jmsy, jmey, kmsy, kmey,  &
97                            ipsy, ipey, jpsy, jpey, kpsy, kpey )
98 
99    kts = kps ; kte = kpe     ! note that tile is entire patch
100    its = ips ; ite = ipe     ! note that tile is entire patch
101    jts = jps ; jte = jpe    ! note that tile is entire patch
102 #ifndef WRF_CHEM
103          ALLOCATE(CLDFRA_OLD(IMS:IME,KMS:KME,JMS:JME),STAT=I)  ; CLDFRA_OLD = 0.
104 #endif
105    CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
106 
107    IF ( ( MOD (ide-ids,config_flags%parent_grid_ratio) .NE. 0 ) .OR. &
108         ( MOD (jde-jds,config_flags%parent_grid_ratio) .NE. 0 ) ) THEN
109       WRITE(message, FMT='("Nested dimensions are illegal for domain ",I2,":  Both &
110          &MOD(",I4,"-",I1,",",I2,") and MOD(",I4,"-",I1,",",I2,") must = 0" )') &
111          grid%id,ide,ids,config_flags%parent_grid_ratio,jde,jds,config_flags%parent_grid_ratio
112       CALL wrf_error_fatal ( message ) 
113    END IF
114 
115    IF ( config_flags%polar ) THEN
116 !write(0,*)__FILE__,__LINE__,' clat ',ips,ipe,jps,jpe
117 !do j = jps,jpe
118 !write(0,*)__FILE__,__LINE__,' clat ',ids,j,grid%clat(ips,j) 
119 !enddo
120 
121 #ifdef DM_PARALLEL
122 ! WARNING:  this might present scaling issues on very large numbers of processors
123      ALLOCATE( clat_glob(ids:ide,jds:jde) )
124 
125      CALL wrf_patch_to_global_real ( grid%clat, clat_glob, grid%domdesc, 'xy', 'xy', &
126                                      ids, ide, jds, jde, 1, 1, &
127                                      ims, ime, jms, jme, 1, 1, &
128                                      its, ite, jts, jte, 1, 1 )
129 
130      CALL wrf_dm_bcast_real ( clat_glob , (ide-ids+1)*(jde-jds+1) )
131 
132 !write(0,*)__FILE__,__LINE__,' clat_glb ',ids,ide,jds,jde
133 !do j = jds,jde
134 !write(0,*)__FILE__,__LINE__,' clat_glb ',ids,j,clat_glob(ipsx,j) ,clat_glob(ids,j)
135 !enddo
136 
137      grid%clat_xxx(ipsx:ipex,jpsx:jpex) = clat_glob(ipsx:ipex,jpsx:jpex)
138 
139 !write(0,*)__FILE__,__LINE__,' clat_xxx ',ipsx,ipex,jpsx,jpex
140 !do j = jpsx,jpex
141 !write(0,*)__FILE__,__LINE__,' clat_xxx ',ids,j,grid%clat_xxx(ids,j) 
142 !enddo
143 
144      DEALLOCATE( clat_glob )
145 #endif
146    ENDIF
147 
148 ! here we check to see if the boundary conditions are set properly
149 
150    CALL boundary_condition_check( config_flags, bdyzone, error, grid%id )
151 
152 !kludge - need to stop CG from resetting precip and phys tendencies to zero
153 !         when we are in here due to a nest being spawned, we want to still
154 !         recompute the base state, but that is about it
155    !  This is temporary and will need to be changed when grid%itimestep is removed.
156 
157    IF ( grid%itimestep .EQ. 0 ) THEN
158       first_trip_for_this_domain = .TRUE.
159    ELSE
160       first_trip_for_this_domain = .FALSE.
161    END IF
162 
163    IF ( .not. ( config_flags%restart .or. grid%moved ) ) THEN 
164        grid%itimestep=0
165    ENDIF
166 
167    IF ( config_flags%restart .or. grid%moved ) THEN 
168        first_trip_for_this_domain = .TRUE.
169    ENDIF
170 
171    IF (config_flags%specified) THEN
172 !
173 ! Arrays for specified boundary conditions
174 ! wig: Add a combined exponential+linear weight on the mother boundaries
175 !      following code changes by Ruby Leung. For the nested grid, there
176 !      appears to be some problems when a sponge is used. The points where
177 !      processors meet have problematic values.
178 
179      DO loop = grid%spec_zone + 1, grid%spec_zone + grid%relax_zone
180        grid%fcx(loop) = 0.1 / grid%dt * (grid%spec_zone + grid%relax_zone - loop) / (grid%relax_zone - 1)
181        grid%gcx(loop) = 1.0 / grid%dt / 50. * (grid%spec_zone + grid%relax_zone - loop) / (grid%relax_zone - 1)
182 !      spongeweight=exp(-(loop-2)/3.)
183 !      grid%fcx(loop) = grid%fcx(loop)*spongeweight
184 !      grid%gcx(loop) = grid%gcx(loop)*spongeweight
185      ENDDO
186 
187    ELSE IF (config_flags%nested) THEN
188 !
189 ! Arrays for nested boundary conditions
190 
191      DO loop = grid%spec_zone + 1, grid%spec_zone + grid%relax_zone
192        grid%fcx(loop) = 0.1 / grid%dt * (grid%spec_zone + grid%relax_zone - loop) / (grid%relax_zone - 1)
193        grid%gcx(loop) = 1.0 / grid%dt / 50. * (grid%spec_zone + grid%relax_zone - loop) / (grid%relax_zone - 1)
194 !      spongeweight=exp(-(loop-2)/3.)
195 !      grid%fcx(loop) = grid%fcx(loop)*spongeweight
196 !      grid%gcx(loop) = grid%gcx(loop)*spongeweight
197 !      grid%fcx(loop) = 0.
198 !      grid%gcx(loop) = 0.
199      ENDDO
200 
201      grid%dtbc = 0.
202 
203    ENDIF
204 
205    IF ( ( grid%id .NE. 1 ) .AND. ( .NOT. config_flags%input_from_file ) ) THEN
206    
207       !  Every time a domain starts or every time a domain moves, this routine is called.  We want
208       !  the center (middle) lat/lon of the grid for the metacode.  The lat/lon values are
209       !  defined at mass points.  Depending on the even/odd points in the SN and WE directions,
210       !  we end up with the middle point as either 1 point or an average of either 2 or 4 points.
211       !  Add to this, the need to make sure that we are on the correct patch to retrieve the
212       !  value of the lat/lon, AND that the lat/lons (for an average) may not all be on the same
213       !  patch.  Once we find the correct value for lat lon, we need to keep it around on all patches, 
214       !  which is where the wrf_dm_min_real calls come in.  
215       !  If this is the most coarse domain, we do not go in here.  Also, if there is an input file
216       !  (which has the right values for the middle lat/lon) we do not go in this IF test.
217    
218       IF      ( ( MOD(ide,2) .EQ. 0 ) .AND. ( MOD(jde,2) .EQ. 0 ) ) THEN
219          num_points_lat_lon = 1
220          iloc = ide/2
221          jloc = jde/2
222          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
223               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
224             lat1 = grid%xlat (iloc,jloc)
225             lon1 = grid%xlong(iloc,jloc)
226          ELSE
227             lat1 = 99999.
228             lon1 = 99999.
229          END IF
230          lat1 = wrf_dm_min_real ( lat1 )
231          lon1 = wrf_dm_min_real ( lon1 )
232          CALL nl_set_cen_lat ( grid%id , lat1 )
233          CALL nl_set_cen_lon ( grid%id , lon1 )
234       ELSE IF ( ( MOD(ide,2) .NE. 0 ) .AND. ( MOD(jde,2) .EQ. 0 ) ) THEN
235          num_points_lat_lon = 2
236          iloc = (ide-1)/2
237          jloc =  jde   /2
238          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
239               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
240             lat1 = grid%xlat (iloc,jloc)
241             lon1 = grid%xlong(iloc,jloc)
242          ELSE
243             lat1 = 99999.
244             lon1 = 99999.
245          END IF
246          lat1 = wrf_dm_min_real ( lat1 )
247          lon1 = wrf_dm_min_real ( lon1 )
248    
249          iloc = (ide+1)/2
250          jloc =  jde   /2
251          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
252               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
253             lat2 = grid%xlat (iloc,jloc)
254             lon2 = grid%xlong(iloc,jloc)
255          ELSE
256             lat2 = 99999.
257             lon2 = 99999.
258          END IF
259          lat2 = wrf_dm_min_real ( lat2 )
260          lon2 = wrf_dm_min_real ( lon2 )
261    
262          CALL nl_set_cen_lat ( grid%id , ( lat1 + lat2 ) * 0.50 )
263          CALL nl_set_cen_lon ( grid%id , ( lon1 + lon2 ) * 0.50 )
264       ELSE IF ( ( MOD(ide,2) .EQ. 0 ) .AND. ( MOD(jde,2) .NE. 0 ) ) THEN
265          num_points_lat_lon = 2
266          iloc =  ide   /2
267          jloc = (jde-1)/2
268          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
269               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
270             lat1 = grid%xlat (iloc,jloc)
271             lon1 = grid%xlong(iloc,jloc)
272          ELSE
273             lat1 = 99999.
274             lon1 = 99999.
275          END IF
276          lat1 = wrf_dm_min_real ( lat1 )
277          lon1 = wrf_dm_min_real ( lon1 )
278    
279          iloc =  ide   /2
280          jloc = (jde+1)/2
281          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
282               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
283             lat2 = grid%xlat (iloc,jloc)
284             lon2 = grid%xlong(iloc,jloc)
285          ELSE
286             lat2 = 99999.
287             lon2 = 99999.
288          END IF
289          lat2 = wrf_dm_min_real ( lat2 )
290          lon2 = wrf_dm_min_real ( lon2 )
291    
292          CALL nl_set_cen_lat ( grid%id , ( lat1 + lat2 ) * 0.50 )
293          CALL nl_set_cen_lon ( grid%id , ( lon1 + lon2 ) * 0.50 )
294       ELSE IF ( ( MOD(ide,2) .NE. 0 ) .AND. ( MOD(jde,2) .NE. 0 ) ) THEN
295          num_points_lat_lon = 4
296          iloc = (ide-1)/2
297          jloc = (jde-1)/2
298          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
299               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
300             lat1 = grid%xlat (iloc,jloc)
301             lon1 = grid%xlong(iloc,jloc)
302          ELSE
303             lat1 = 99999.
304             lon1 = 99999.
305          END IF
306          lat1 = wrf_dm_min_real ( lat1 )
307          lon1 = wrf_dm_min_real ( lon1 )
308    
309          iloc = (ide+1)/2
310          jloc = (jde-1)/2
311          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
312               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
313             lat2 = grid%xlat (iloc,jloc)
314             lon2 = grid%xlong(iloc,jloc)
315          ELSE
316             lat2 = 99999.
317             lon2 = 99999.
318          END IF
319          lat2 = wrf_dm_min_real ( lat2 )
320          lon2 = wrf_dm_min_real ( lon2 )
321    
322          iloc = (ide-1)/2
323          jloc = (jde+1)/2
324          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
325               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
326             lat3 = grid%xlat (iloc,jloc)
327             lon3 = grid%xlong(iloc,jloc)
328          ELSE
329             lat3 = 99999.
330             lon3 = 99999.
331          END IF
332          lat3 = wrf_dm_min_real ( lat3 )
333          lon3 = wrf_dm_min_real ( lon3 )
334    
335          iloc = (ide+1)/2
336          jloc = (jde+1)/2
337          IF ( ( ips .LE. iloc ) .AND. ( ipe .GE. iloc ) .AND. &
338               ( jps .LE. jloc ) .AND. ( jpe .GE. jloc ) ) THEN
339             lat4 = grid%xlat (iloc,jloc)
340             lon4 = grid%xlong(iloc,jloc)
341          ELSE
342             lat4 = 99999.
343             lon4 = 99999.
344          END IF
345          lat4 = wrf_dm_min_real ( lat4 )
346          lon4 = wrf_dm_min_real ( lon4 )
347    
348          CALL nl_set_cen_lat ( grid%id , ( lat1 + lat2 + lat3 + lat4 ) * 0.25 )
349          CALL nl_set_cen_lon ( grid%id , ( lon1 + lon2 + lon3 + lon4 ) * 0.25 )
350       END IF
351    END IF
352 
353    IF ( .NOT. config_flags%restart .AND. &
354         (( config_flags%input_from_hires ) .OR. ( config_flags%input_from_file ))) THEN
355 
356       IF ( config_flags%map_proj .EQ. 0 ) THEN
357          CALL wrf_error_fatal ( 'start_domain: Idealized case cannot have a separate nested input file' )
358       END IF 
359 
360       CALL nl_get_base_pres  ( 1 , p00 )
361       CALL nl_get_base_temp  ( 1 , t00 )
362       CALL nl_get_base_lapse ( 1 , a   )
363 
364       !  Base state potential temperature and inverse density (alpha = 1/rho) from
365       !  the half eta levels and the base-profile surface pressure.  Compute 1/rho
366       !  from equation of state.  The potential temperature is a perturbation from t0.
367 
368       DO j = jts, MIN(jte,jde-1)
369          DO i = its, MIN(ite,ide-1)
370 
371             !  Base state pressure is a function of eta level and terrain, only, plus
372             !  the hand full of constants: p00 (sea level pressure, Pa), t00 (sea level
373             !  temperature, K), and A (temperature difference, from 1000 mb to 300 mb, K).
374 
375             p_surf = p00 * EXP ( -t00/a + ( (t00/a)**2 - 2.*g*grid%ht(i,j)/a/r_d ) **0.5 )
376 
377             DO k = 1, kte-1
378                grid%em_pb(i,k,j) = grid%em_znu(k)*(p_surf - grid%p_top) + grid%p_top
379                grid%em_t_init(i,k,j) = (t00 + A*LOG(grid%em_pb(i,k,j)/p00))*(p00/grid%em_pb(i,k,j))**(r_d/cp) - t0
380                grid%em_alb(i,k,j) = (r_d/p1000mb)*(grid%em_t_init(i,k,j)+t0)*(grid%em_pb(i,k,j)/p1000mb)**cvpm
381             END DO
382 
383             !  Base state mu is defined as base state surface pressure minus grid%p_top
384 
385             grid%em_mub(i,j) = p_surf - grid%p_top
386 
387             !  Integrate base geopotential, starting at terrain elevation.  This assures that
388             !  the base state is in exact hydrostatic balance with respect to the model equations.
389             !  This field is on full levels.
390 
391             grid%em_phb(i,1,j) = grid%ht(i,j) * g
392             DO k  = 2,kte
393                grid%em_phb(i,k,j) = grid%em_phb(i,k-1,j) - grid%em_dnw(k-1)*grid%em_mub(i,j)*grid%em_alb(i,k-1,j)
394             END DO
395          END DO
396       END DO
397 
398    ENDIF
399 
400    IF(.not.config_flags%restart)THEN
401 
402 !  if this is for a nested domain, the defined/interpolated fields are the _2
403 
404      IF ( first_trip_for_this_domain ) THEN
405 
406 ! data that is expected to be zero must be explicitly initialized as such
407 !    grid%h_diabatic = 0.
408 
409        DO j = jts,min(jte,jde-1)
410        DO k = kts,kte-1
411        DO i = its, min(ite,ide-1)
412            IF ( grid%imask_nostag(i,j) .EQ. 1 ) THEN
413              grid%em_t_1(i,k,j)=grid%em_t_2(i,k,j)
414            ENDIF
415        ENDDO
416        ENDDO
417        ENDDO
418   
419        DO j = jts,min(jte,jde-1)
420        DO i = its, min(ite,ide-1)
421            IF ( grid%imask_nostag(i,j) .EQ. 1 ) THEN
422              grid%em_mu_1(i,j)=grid%em_mu_2(i,j)
423            ENDIF
424        ENDDO
425        ENDDO
426      END IF
427 
428 !  reconstitute base-state fields
429 
430     IF(config_flags%max_dom .EQ. 1)THEN
431 ! with single domain, grid%em_t_init from wrfinput is OK to use
432      DO j = jts,min(jte,jde-1)
433      DO k = kts,kte-1
434      DO i = its, min(ite,ide-1)
435        IF ( grid%imask_nostag(i,j) .EQ. 1 ) THEN
436          grid%em_pb(i,k,j) = grid%em_znu(k)*grid%em_mub(i,j)+grid%p_top
437          grid%em_alb(i,k,j) = (r_d/p1000mb)*(grid%em_t_init(i,k,j)+t0)*(grid%em_pb(i,k,j)/p1000mb)**cvpm
438        ENDIF
439      ENDDO
440      ENDDO
441      ENDDO
442     ELSE
443 ! with nests, grid%em_t_init generally needs recomputations (since it is not interpolated)
444      DO j = jts,min(jte,jde-1)
445      DO k = kts,kte-1
446      DO i = its, min(ite,ide-1)
447        IF ( grid%imask_nostag(i,j) .EQ. 1 ) THEN
448          grid%em_pb(i,k,j) = grid%em_znu(k)*grid%em_mub(i,j)+grid%p_top
449          grid%em_alb(i,k,j) = -grid%em_rdnw(k)*(grid%em_phb(i,k+1,j)-grid%em_phb(i,k,j))/grid%em_mub(i,j)
450          grid%em_t_init(i,k,j) = grid%em_alb(i,k,j)*(p1000mb/r_d)/((grid%em_pb(i,k,j)/p1000mb)**cvpm) - t0
451        ENDIF
452      ENDDO
453      ENDDO
454      ENDDO
455     ENDIF
456 
457      DO j = jts,min(jte,jde-1)
458 
459        k = kte-1
460        DO i = its, min(ite,ide-1)
461          IF ( grid%imask_nostag(i,j) .EQ. 1 ) THEN
462            qvf1 = 0.5*(moist(i,k,j,P_QV)+moist(i,k,j,P_QV))
463            qvf2 = 1./(1.+qvf1)
464            qvf1 = qvf1*qvf2
465            grid%em_p(i,k,j) = - 0.5*(grid%em_mu_1(i,j)+qvf1*grid%em_mub(i,j))/grid%em_rdnw(k)/qvf2
466            qvf = 1. + rvovrd*moist(i,k,j,P_QV)
467            grid%em_alt(i,k,j) = (r_d/p1000mb)*(grid%em_t_1(i,k,j)+t0)*qvf*(((grid%em_p(i,k,j)+grid%em_pb(i,k,j))/p1000mb)**cvpm)
468            grid%em_al(i,k,j) = grid%em_alt(i,k,j) - grid%em_alb(i,k,j)
469          ENDIF
470        ENDDO
471 
472        DO k = kte-2, 1, -1
473        DO i = its, min(ite,ide-1)
474          IF ( grid%imask_nostag(i,j) .EQ. 1 ) THEN
475            qvf1 = 0.5*(moist(i,k,j,P_QV)+moist(i,k+1,j,P_QV))
476            qvf2 = 1./(1.+qvf1)
477            qvf1 = qvf1*qvf2
478            grid%em_p(i,k,j) = grid%em_p(i,k+1,j) - (grid%em_mu_1(i,j) + qvf1*grid%em_mub(i,j))/qvf2/grid%em_rdn(k+1)
479            qvf = 1. + rvovrd*moist(i,k,j,P_QV)
480            grid%em_alt(i,k,j) = (r_d/p1000mb)*(grid%em_t_1(i,k,j)+t0)*qvf* &
481                         (((grid%em_p(i,k,j)+grid%em_pb(i,k,j))/p1000mb)**cvpm)
482            grid%em_al(i,k,j) = grid%em_alt(i,k,j) - grid%em_alb(i,k,j)
483          ENDIF
484        ENDDO
485        ENDDO
486 
487      ENDDO
488 
489    ENDIF
490 
491    IF ( ( grid%id .NE. 1 ) .AND. .NOT. ( config_flags%restart ) .AND. &
492        ( ( config_flags%input_from_hires ) .OR. ( config_flags%input_from_file ) ) ) THEN
493       DO j = jts, MIN(jte,jde-1)
494          DO i = its, MIN(ite,ide-1)
495             grid%em_mu_2(i,j) = grid%em_mu_2(i,j) + grid%em_al(i,1,j) / ( grid%em_alt(i,1,j) * grid%em_alb(i,1,j) ) * &
496                                     g * ( grid%ht(i,j) - grid%ht_fine(i,j) )
497          END DO
498        END DO
499        DO j = jts,min(jte,jde-1)
500        DO i = its, min(ite,ide-1)
501           grid%em_mu_1(i,j)=grid%em_mu_2(i,j)
502        ENDDO
503        ENDDO
504 
505    END IF
506 
507    IF ( first_trip_for_this_domain ) THEN
508 
509    CALL wrf_debug ( 100 , 'module_start: start_domain_rk: Before call to phy_init' )
510 
511 ! namelist MPDT does not exist yet, so set it here
512 ! MPDT is the call frequency for microphysics in minutes (0 means every step)
513    MPDT = 0.
514 
515 ! set GMT outside of phy_init because phy_init may not be called on this
516 ! process if, for example, it is a moving nest and if this part of the domain is not
517 ! being initialized (not the leading edge).
518    CALL domain_setgmtetc( grid, start_of_simulation )
519 
520    CALL set_tiles ( grid , grid%imask_nostag, ims, ime, jms, jme, ips, ipe, jps, jpe )
521 
522 ! Phy_init is not necessarily thread-safe; do not multi-thread this loop.
523 ! The tiling is to handle the fact that we may be masking off part of the computation.
524    DO ij = 1, grid%num_tiles
525 
526      CALL phy_init (  grid%id , config_flags, grid%DT, grid%RESTART, grid%em_znw, grid%em_znu,   &
527                       grid%p_top, grid%tsk, grid%RADT,grid%BLDT,grid%CUDT, MPDT, &
528                       grid%rthcuten, grid%rqvcuten, grid%rqrcuten,           &
529                       grid%rqccuten, grid%rqscuten, grid%rqicuten,           &
530                       grid%rublten,grid%rvblten,grid%rthblten,               &
531                       grid%rqvblten,grid%rqcblten,grid%rqiblten,             &
532                       grid%rthraten,grid%rthratenlw,grid%rthratensw,         &
533                       grid%stepbl,grid%stepra,grid%stepcu,                   &
534                       grid%w0avg, grid%rainnc, grid%rainc, grid%raincv, grid%rainncv,  &
535                       grid%nca,grid%swrad_scat,                    &
536                       grid%cldefi,grid%lowlyr,                          &
537                       grid%mass_flux,                              &
538                       grid%rthften, grid%rqvften,                       &
539                       grid%cldfra,                                      &
540 #ifdef WRF_CHEM
541                       grid%cldfra_old,                                  &
542 #endif
543 #ifndef WRF_CHEM
544                       cldfra_old,                                  &
545 #endif
546                       grid%glw,grid%gsw,grid%emiss,grid%lu_index, &
547                       grid%landuse_ISICE, grid%landuse_LUCATS,            &
548                       grid%landuse_LUSEAS, grid%landuse_ISN,              &
549                       grid%lu_state,                                      &
550                       grid%xlat,grid%xlong,grid%albedo,grid%albbck,grid%GMT,grid%JULYR,grid%JULDAY,     &
551                       grid%levsiz, num_ozmixm, num_aerosolc, grid%paerlev,  &
552                       grid%tmn,grid%xland,grid%znt,grid%z0,grid%ust,grid%mol,grid%pblh,grid%tke_myj,     &
553                       grid%exch_h,grid%thc,grid%snowc,grid%mavail,grid%hfx,grid%qfx,grid%rainbl, &
554                       grid%tslb,grid%zs,grid%dzs,config_flags%num_soil_layers,grid%warm_rain,  &
555                       grid%adv_moist_cond,                         &
556                       grid%apr_gr,grid%apr_w,grid%apr_mc,grid%apr_st,grid%apr_as,      &
557                       grid%apr_capma,grid%apr_capme,grid%apr_capmi,          &
558                       grid%xice,grid%xicem,grid%vegfra,grid%snow,grid%canwat,grid%smstav,         &
559                       grid%smstot, grid%sfcrunoff,grid%udrunoff,grid%grdflx,grid%acsnow,      &
560                       grid%acsnom,grid%ivgtyp,grid%isltyp, grid%sfcevp,grid%smois,     &
561                       grid%sh2o, grid%snowh, grid%smfr3d,                    &
562                       grid%DX,grid%DY,grid%f_ice_phy,grid%f_rain_phy,grid%f_rimef_phy, &
563                       grid%mp_restart_state,grid%tbpvs_state,grid%tbpvs0_state,&
564                       allowed_to_read, grid%moved, start_of_simulation,               &
565                       ids, ide, jds, jde, kds, kde,           &
566                       ims, ime, jms, jme, kms, kme,           &
567                       grid%i_start(ij), grid%i_end(ij), grid%j_start(ij), grid%j_end(ij), kts, kte, &
568                       ozmixm,grid%pin,                             &     ! Optional
569                       grid%m_ps_1,grid%m_ps_2,grid%m_hybi,aerosolc_1,aerosolc_2,&  ! Optional
570                       grid%rundgdten,grid%rvndgdten,grid%rthndgdten,         &     ! Optional
571                       grid%rqvndgdten,grid%rmundgdten,                  &     ! Optional
572                       grid%FGDT,grid%stepfg,                        &     ! Optional
573                       grid%DZR, grid%DZB, grid%DZG,                          & !Optional urban
574                       grid%TR_URB2D,grid%TB_URB2D,grid%TG_URB2D,grid%TC_URB2D,    & !Optional urban
575                       grid%QC_URB2D, grid%XXXR_URB2D,grid%XXXB_URB2D,        & !Optional urban
576                       grid%XXXG_URB2D, grid%XXXC_URB2D,                 & !Optional urban
577                       grid%TRL_URB3D, grid%TBL_URB3D, grid%TGL_URB3D,        & !Optional urban
578                       grid%SH_URB2D, grid%LH_URB2D, grid%G_URB2D, grid%RN_URB2D,  & !Optional urban
579                       grid%TS_URB2D, grid%FRC_URB2D, grid%UTYPE_URB2D,      & !Optional urban
580                       itimestep=grid%itimestep, fdob=grid%fdob             &
581                       )
582 
583    ENDDO
584 
585 
586  
587    CALL wrf_debug ( 100 , 'module_start: start_domain_rk: After call to phy_init' )
588 
589 #ifdef MCELIO
590    LU_MASK = 0.
591    WHERE ( grid%lu_index .EQ. 16 ) LU_MASK = 1.
592 #endif
593 
594    END IF
595 
596 #if 0
597 #include "CYCLE_TEST.inc"
598 #endif
599 
600 !
601 !
602 
603  !  set physical boundary conditions for all initialized variables
604 
605 !-----------------------------------------------------------------------
606 !  Stencils for patch communications  (WCS, 29 June 2001)
607 !  Note:  the size of this halo exchange reflects the 
608 !         fact that we are carrying the uncoupled variables 
609 !         as state variables in the mass coordinate model, as
610 !         opposed to the coupled variables as in the height
611 !         coordinate model.
612 !
613 !                           * * * * *
614 !         *        * * *    * * * * *
615 !       * + *      * + *    * * + * * 
616 !         *        * * *    * * * * *
617 !                           * * * * *
618 !
619 !j  grid%em_u_1                          x
620 !j  grid%em_u_2                          x
621 !j  grid%em_v_1                          x
622 !j  grid%em_v_2                          x
623 !j  grid%em_w_1                          x
624 !j  grid%em_w_2                          x
625 !j  grid%em_t_1                          x
626 !j  grid%em_t_2                          x
627 !j grid%em_ph_1                          x
628 !j grid%em_ph_2                          x
629 !
630 !j  grid%em_t_init                       x
631 !
632 !j  grid%em_phb   x
633 !j  grid%em_ph0   x
634 !j  grid%em_php   x
635 !j   grid%em_pb   x
636 !j   grid%em_al   x
637 !j  grid%em_alt   x
638 !j  grid%em_alb   x
639 !
640 !  the following are 2D (xy) variables
641 !
642 !j grid%em_mu_1                          x
643 !j grid%em_mu_2                          x
644 !j grid%em_mub   x
645 !j grid%em_mu0   x
646 !j grid%ht    x
647 !j grid%msftx x
648 !j grid%msfty x
649 !j grid%msfux x
650 !j grid%msfuy x
651 !j grid%msfvx x
652 !j grid%msfvy x
653 !j grid%sina  x
654 !j grid%cosa  x
655 !j grid%e     x
656 !j grid%f     x
657 !
658 !  4D variables
659 !
660 ! moist                        x
661 !  chem                        x
662 !scalar                        x
663 
664 !--------------------------------------------------------------
665 
666 #ifdef DM_PARALLEL
667 #  include "HALO_EM_INIT_1.inc"
668 #  include "HALO_EM_INIT_2.inc"
669 #  include "HALO_EM_INIT_3.inc"
670 #  include "HALO_EM_INIT_4.inc"
671 #  include "HALO_EM_INIT_5.inc"
672 #  include "PERIOD_BDY_EM_INIT.inc"
673 #  include "PERIOD_BDY_EM_MOIST.inc"
674 #  include "PERIOD_BDY_EM_CHEM.inc"
675 #endif
676 
677 
678    CALL set_physical_bc3d( grid%em_u_1 , 'U' , config_flags ,                  &
679                          ids , ide , jds , jde , kds , kde ,        &
680                          ims , ime , jms , jme , kms , kme ,        &
681                          its , ite , jts , jte , kts , kte ,        &
682                          its , ite , jts , jte , kts , kte )
683    CALL set_physical_bc3d( grid%em_u_2 , 'U' , config_flags ,                  &
684                          ids , ide , jds , jde , kds , kde ,        &
685                          ims , ime , jms , jme , kms , kme ,        &
686                          its , ite , jts , jte , kts , kte ,        &
687                          its , ite , jts , jte , kts , kte )
688 
689    CALL set_physical_bc3d( grid%em_v_1 , 'V' , config_flags ,                  &
690                          ids , ide , jds , jde , kds , kde ,        &
691                          ims , ime , jms , jme , kms , kme ,        &
692                          its , ite , jts , jte , kts , kte ,        &
693                          its , ite , jts , jte , kts , kte )
694    CALL set_physical_bc3d( grid%em_v_2 , 'V' , config_flags ,                  &
695                          ids , ide , jds , jde , kds , kde ,        &
696                          ims , ime , jms , jme , kms , kme ,        &
697                          its , ite , jts , jte , kts , kte ,        &
698                          its , ite , jts , jte , kts , kte )
699 
700 ! set kinematic condition for w 
701 
702    CALL set_physical_bc2d( grid%ht , 'r' , config_flags ,                &
703                            ids , ide , jds , jde , &
704                            ims , ime , jms , jme , &
705                            its , ite , jts , jte , &
706                            its , ite , jts , jte   )
707 
708    IF ( .not. config_flags%restart ) THEN 
709    CALL set_w_surface(  config_flags, grid%em_znw,                         &
710                         grid%em_w_1, grid%ht, grid%em_u_1, grid%em_v_1, grid%cf1, &
711                         grid%cf2, grid%cf3, grid%rdx, grid%rdy, grid%msftx, grid%msfty, &
712                         ids, ide, jds, jde, kds, kde,                      &
713                         ips, ipe, jps, jpe, kps, kpe,                      &
714                         its, ite, jts, jte, kts, kte,                      &
715                         ims, ime, jms, jme, kms, kme                      )
716    CALL set_w_surface(  config_flags, grid%em_znw,                         &
717                         grid%em_w_2, grid%ht, grid%em_u_2, grid%em_v_2, grid%cf1, &
718                         grid%cf2, grid%cf3, grid%rdx, grid%rdy, grid%msftx, grid%msfty, &
719                         ids, ide, jds, jde, kds, kde,                      &
720                         ips, ipe, jps, jpe, kps, kpe,                      &
721                         its, ite, jts, jte, kts, kte,                      &
722                         ims, ime, jms, jme, kms, kme                      )
723    END IF
724 
725 ! finished setting kinematic condition for w at the surface
726 
727    CALL set_physical_bc3d( grid%em_w_1 , 'W' , config_flags ,                 &
728                          ids , ide , jds , jde , kds , kde ,        &
729                          ims , ime , jms , jme , kms , kme ,        &
730                          its , ite , jts , jte , kts , kte ,        &
731                          its , ite , jts , jte , kts , kte )
732    CALL set_physical_bc3d( grid%em_w_2 , 'W' , config_flags ,                 &
733                          ids , ide , jds , jde , kds , kde ,        &
734                          ims , ime , jms , jme , kms , kme ,        &
735                          its , ite , jts , jte , kts , kte ,        &
736                          its , ite , jts , jte , kts , kte )
737 
738    CALL set_physical_bc3d( grid%em_ph_1 , 'W' , config_flags ,                 &
739                          ids , ide , jds , jde , kds , kde ,        &
740                          ims , ime , jms , jme , kms , kme ,        &
741                          its , ite , jts , jte , kts , kte ,        &
742                          its , ite , jts , jte , kts , kte )
743 
744    CALL set_physical_bc3d( grid%em_ph_2 , 'W' , config_flags ,                 &
745                          ids , ide , jds , jde , kds , kde ,        &
746                          ims , ime , jms , jme , kms , kme ,        &
747                          its , ite , jts , jte , kts , kte ,        &
748                          its , ite , jts , jte , kts , kte )
749 
750    CALL set_physical_bc3d( grid%em_t_1 , 't' , config_flags ,                 &
751                          ids , ide , jds , jde , kds , kde ,        &
752                          ims , ime , jms , jme , kms , kme ,        &
753                          its , ite , jts , jte , kts , kte ,        &
754                          its , ite , jts , jte , kts , kte )
755 
756    CALL set_physical_bc3d( grid%em_t_2 , 't' , config_flags ,                 &
757                          ids , ide , jds , jde , kds , kde ,        &
758                          ims , ime , jms , jme , kms , kme ,        &
759                          its , ite , jts , jte , kts , kte ,        &
760                          its , ite , jts , jte , kts , kte )
761 
762    CALL set_physical_bc2d( grid%em_mu_1, 't' , config_flags ,   &
763                            ids , ide , jds , jde ,  &
764                            ims , ime , jms , jme ,  &
765                            its , ite , jts , jte ,  &
766                            its , ite , jts , jte   )
767    CALL set_physical_bc2d( grid%em_mu_2, 't' , config_flags ,   &
768                            ids , ide , jds , jde ,  &
769                            ims , ime , jms , jme ,  &
770                            its , ite , jts , jte ,  &
771                            its , ite , jts , jte   )
772    CALL set_physical_bc2d( grid%em_mub , 't' , config_flags ,   &
773                            ids , ide , jds , jde ,  &
774                            ims , ime , jms , jme ,  &
775                            its , ite , jts , jte ,  &
776                            its , ite , jts , jte   )
777    CALL set_physical_bc2d( grid%em_mu0 , 't' , config_flags ,   &
778                            ids , ide , jds , jde ,  &
779                            ims , ime , jms , jme ,  &
780                            its , ite , jts , jte ,  &
781                            its , ite , jts , jte   )
782 
783 
784    CALL set_physical_bc3d( grid%em_phb , 'W' , config_flags ,                 &
785                          ids , ide , jds , jde , kds , kde ,        &
786                          ims , ime , jms , jme , kms , kme ,        &
787                          its , ite , jts , jte , kts , kte ,        &
788                          its , ite , jts , jte , kts , kte )
789    CALL set_physical_bc3d( grid%em_ph0 , 'W' , config_flags ,                 &
790                          ids , ide , jds , jde , kds , kde ,        &
791                          ims , ime , jms , jme , kms , kme ,        &
792                          its , ite , jts , jte , kts , kte ,        &
793                          its , ite , jts , jte , kts , kte )
794    CALL set_physical_bc3d( grid%em_php , 'W' , config_flags ,                 &
795                          ids , ide , jds , jde , kds , kde ,        &
796                          ims , ime , jms , jme , kms , kme ,        &
797                          its , ite , jts , jte , kts , kte ,        &
798                          its , ite , jts , jte , kts , kte )
799 
800    CALL set_physical_bc3d( grid%em_pb , 't' , config_flags ,                 &
801                          ids , ide , jds , jde , kds , kde ,        &
802                          ims , ime , jms , jme , kms , kme ,        &
803                          its , ite , jts , jte , kts , kte ,        &
804                          its , ite , jts , jte , kts , kte )
805    CALL set_physical_bc3d( grid%em_al , 't' , config_flags ,                 &
806                          ids , ide , jds , jde , kds , kde ,        &
807                          ims , ime , jms , jme , kms , kme ,        &
808                          its , ite , jts , jte , kts , kte ,        &
809                          its , ite , jts , jte , kts , kte )
810    CALL set_physical_bc3d( grid%em_alt , 't' , config_flags ,                 &
811                          ids , ide , jds , jde , kds , kde ,        &
812                          ims , ime , jms , jme , kms , kme ,        &
813                          its , ite , jts , jte , kts , kte ,        &
814                          its , ite , jts , jte , kts , kte )
815    CALL set_physical_bc3d( grid%em_alb , 't' , config_flags ,                 &
816                          ids , ide , jds , jde , kds , kde ,        &
817                          ims , ime , jms , jme , kms , kme ,        &
818                          its , ite , jts , jte , kts , kte ,        &
819                          its , ite , jts , jte , kts , kte )
820    CALL set_physical_bc3d(grid%em_t_init, 't' , config_flags ,                 &
821                          ids , ide , jds , jde , kds , kde ,        &
822                          ims , ime , jms , jme , kms , kme ,        &
823                          its , ite , jts , jte , kts , kte ,        &
824                          its , ite , jts , jte , kts , kte )
825 
826    IF (num_moist > 0) THEN
827 
828 ! use of (:,:,:,loop) not efficient on DEC, but (ims,kms,jms,loop) not portable to SGI/Cray
829 
830       loop_3d_m   : DO loop = 1 , num_moist
831          CALL set_physical_bc3d( moist(:,:,:,loop) , 'r' , config_flags ,                 &
832                                  ids , ide , jds , jde , kds , kde ,        &
833                                  ims , ime , jms , jme , kms , kme ,        &
834                                  its , ite , jts , jte , kts , kte ,        &
835                                  its , ite , jts , jte , kts , kte )
836       END DO loop_3d_m
837 
838    ENDIF
839 
840 !wig 17-Oct-2006, begin: I think the following should be here...
841    IF (num_scalar > 0) THEN
842 
843 ! use of (:,:,:,loop) not efficient on DEC, but (ims,kms,jms,loop) not portable to SGI/Cray
844 
845       loop_3d_s   : DO loop = 1 , num_scalar
846          CALL set_physical_bc3d( scalar(:,:,:,loop) , 'r' , config_flags ,                 &
847                                  ids , ide , jds , jde , kds , kde ,        &
848                                  ims , ime , jms , jme , kms , kme ,        &
849                                  its , ite , jts , jte , kts , kte ,        &
850                                  its , ite , jts , jte , kts , kte )
851       END DO loop_3d_s
852 
853    ENDIF
854 !wig end.
855 
856 
857 #ifdef WRF_CHEM
858 !
859 !   we do this here, so we only have one chem_init routine for either core....
860 !
861          do j=jts,min(jte,jde-1)
862             do i=its,min(ite,ide-1)
863                do k=kts,kte
864                  z_at_w(i,k,j)=(grid%em_ph_2(i,k,j)+grid%em_phb(i,k,j))/g
865                enddo
866                do k=kts,min(kte,kde-1)
867                  tempfac=(grid%em_t_1(i,k,j) + t0)*((grid%em_p(i,k,j) + grid%em_pb(i,k,j))/p1000mb)**rcp
868                  convfac(i,k,j) = (grid%em_p(i,k,j)+grid%em_pb(i,k,j))/rgasuniv/tempfac
869                enddo
870             enddo
871          enddo
872 
873          CALL chem_init (grid%id,chem,scalar,grid%dt,grid%bioemdt,grid%photdt,     &
874                          grid%chemdt,                                       &
875                          grid%stepbioe,grid%stepphot,grid%stepchem,grid%stepfirepl,      &
876                          grid%plumerisefire_frq,z_at_w,g,grid%aerwrf,config_flags,            &
877                          grid%em_alt,grid%em_t_1,grid%em_p,convfac,                              &
878                          grid%gd_cloud, grid%gd_cloud2,                                  &
879                          grid%gd_cloud_b, grid%gd_cloud2_b,                              &
880                          grid%tauaer1,grid%tauaer2,grid%tauaer3,grid%tauaer4,                   &
881                          grid%gaer1,grid%gaer2,grid%gaer3,grid%gaer4,                           &
882                          grid%waer1,grid%waer2,grid%waer3,grid%waer4,                           &
883                          grid%pm2_5_dry,grid%pm2_5_water,grid%pm2_5_dry_ec,                &
884                          grid%chem_in_opt,                                  &
885                          ids , ide , jds , jde , kds , kde ,                &
886                          ims , ime , jms , jme , kms , kme ,                &
887                          its , ite , jts , jte , kts , kte                  )
888 
889 !
890 ! calculate initial pm
891 !
892 !       print *,'calculating initial pm'
893         select case (config_flags%chem_opt)
894         case (RADM2SORG, RACMSORG)
895            call sum_pm_sorgam (                                             &
896                 grid%em_alt, chem, grid%h2oaj, grid%h2oai,                                    &
897                 grid%pm2_5_dry, grid%pm2_5_water, grid%pm2_5_dry_ec, grid%pm10,                 &
898                 ids,ide, jds,jde, kds,kde,                                  &
899                 ims,ime, jms,jme, kms,kme,                                  &
900                 its,ite, jts,jte, kts,kte-1                                 )
901 
902         case (CBMZ_MOSAIC_4BIN,CBMZ_MOSAIC_8BIN,CBMZ_MOSAIC_4BIN_AQ,CBMZ_MOSAIC_8BIN_AQ)
903            call sum_pm_mosaic (                                             &
904                 grid%em_alt, chem,                                                  &
905                 grid%pm2_5_dry, grid%pm2_5_water, grid%pm2_5_dry_ec, grid%pm10,                 &
906                 ids,ide, jds,jde, kds,kde,                                  &
907                 ims,ime, jms,jme, kms,kme,                                  &
908                 its,ite, jts,jte, kts,kte-1                                 )
909 
910         case default
911            do j=jts,min(jte,jde-1)
912               do k=kts,min(kte,kde-1)
913                  do i=its,min(ite,ide-1)
914                     grid%pm2_5_dry(i,k,j)    = 0.
915                     grid%pm2_5_water(i,k,j)  = 0.
916                     grid%pm2_5_dry_ec(i,k,j) = 0.
917                     grid%pm10(i,k,j)         = 0.
918                  enddo
919               enddo
920            enddo
921         end select
922 #endif
923 
924    IF (num_chem >= PARAM_FIRST_SCALAR ) THEN
925 ! use of (:,:,:,loop) not efficient on DEC, but (ims,kms,jms,loop) not portable to SGI/Cray
926 
927       loop_3d_c   : DO loop = PARAM_FIRST_SCALAR , num_chem
928          CALL set_physical_bc3d( chem(:,:,:,loop) , 'r' , config_flags ,                 &
929                                  ids , ide , jds , jde , kds , kde ,        &
930                                  ims , ime , jms , jme , kms , kme ,        &
931                                  its , ite , jts , jte , kts , kte ,        &
932                                  its , ite , jts , jte , kts , kte )
933       END DO loop_3d_c
934 
935    ENDIF
936 
937    CALL set_physical_bc2d( grid%msftx , 'r' , config_flags ,              &
938                          ids , ide , jds , jde , &
939                          ims , ime , jms , jme , &
940                          its , ite , jts , jte , &
941                          its , ite , jts , jte   )
942    CALL set_physical_bc2d( grid%msfty , 'r' , config_flags ,              &
943                          ids , ide , jds , jde , &
944                          ims , ime , jms , jme , &
945                          its , ite , jts , jte , &
946                          its , ite , jts , jte   )
947    CALL set_physical_bc2d( grid%msfux , 'x' , config_flags ,              &
948                          ids , ide , jds , jde , &
949                          ims , ime , jms , jme , &
950                          its , ite , jts , jte , &
951                          its , ite , jts , jte   ) 
952    CALL set_physical_bc2d( grid%msfuy , 'x' , config_flags ,              &
953                          ids , ide , jds , jde , &
954                          ims , ime , jms , jme , &
955                          its , ite , jts , jte , &
956                          its , ite , jts , jte   ) 
957    CALL set_physical_bc2d( grid%msfvx , 'y' , config_flags ,              &
958                          ids , ide , jds , jde , &
959                          ims , ime , jms , jme , &
960                          its , ite , jts , jte , &
961                          its , ite , jts , jte   ) 
962    CALL set_physical_bc2d( grid%msfvy , 'y' , config_flags ,              &
963                          ids , ide , jds , jde , &
964                          ims , ime , jms , jme , &
965                          its , ite , jts , jte , &
966                          its , ite , jts , jte   ) 
967    CALL set_physical_bc2d( grid%sina , 'r' , config_flags ,              &
968                          ids , ide , jds , jde , &
969                          ims , ime , jms , jme , &
970                          its , ite , jts , jte , &
971                          its , ite , jts , jte   ) 
972    CALL set_physical_bc2d( grid%cosa , 'r' , config_flags ,              &
973                          ids , ide , jds , jde , &
974                          ims , ime , jms , jme , &
975                          its , ite , jts , jte , &
976                          its , ite , jts , jte   ) 
977    CALL set_physical_bc2d( grid%e , 'r' , config_flags ,                 &
978                          ids , ide , jds , jde , &
979                          ims , ime , jms , jme , &
980                          its , ite , jts , jte , &
981                          its , ite , jts , jte   ) 
982    CALL set_physical_bc2d( grid%f , 'r' , config_flags ,                 &
983                          ids , ide , jds , jde , &
984                          ims , ime , jms , jme , &
985                          its , ite , jts , jte , &
986                          its , ite , jts , jte   ) 
987 
988 #ifndef WRF_CHEM
989       DEALLOCATE(CLDFRA_OLD)
990 #endif
991 #ifdef DM_PARALLEL
992 #   include "HALO_EM_INIT_1.inc"
993 #   include "HALO_EM_INIT_2.inc"
994 #   include "HALO_EM_INIT_3.inc"
995 #   include "HALO_EM_INIT_4.inc"
996 #   include "HALO_EM_INIT_5.inc"
997 #  include "PERIOD_BDY_EM_INIT.inc"
998 #  include "PERIOD_BDY_EM_MOIST.inc"
999 #  include "PERIOD_BDY_EM_CHEM.inc"
1000 #endif
1001 
1002      CALL wrf_debug ( 100 , 'module_start: start_domain_rk: Returning' )
1003 
1004      RETURN
1005 
1006    END SUBROUTINE start_domain_em
1007