updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / wrftladj / module_first_rk_step_part1_ad.F
bloba82001ef8d06a94d1fdb2c9c19ce513ee8435817
1 !WRF:MEDIATION_LAYER:SOLVER
3 #define BENCH_START(A)
4 #define BENCH_END(A)
6 MODULE a_module_first_rk_step_part1
8 CONTAINS
10   SUBROUTINE a_first_rk_step_part1 (   grid , config_flags              &
11                              , moist , a_moist , moist_tend , a_moist_tend       &
12                              , chem  , chem_tend                &
13                              , tracer, a_tracer, tracer_tend, a_tracer_tend      &
14                              , scalar , a_scalar , scalar_tend , a_scalar_tend   &
15                              , fdda3d, fdda2d                   &
16                              , aerod                            &
17                              , ru_tendf, a_ru_tendf, rv_tendf, a_rv_tendf        &
18                              , rw_tendf, a_rw_tendf, t_tendf, a_t_tendf          &
19                              , ph_tendf, a_ph_tendf, mu_tendf, a_mu_tendf        &
20                              , tke_tend, a_tke_tend             &
21                              , adapt_step_flag , curr_secs      &
22                              , psim , psih , gz1oz0 , chklowq &
23                              , cu_act_flag , hol , th_phy , a_th_phy      &
24                              , pi_phy , a_pi_phy , p_phy , a_p_phy , t_phy , a_t_phy &
25                              , dz8w , a_dz8w , p8w , a_p8w , t8w , a_t8w   &
26                              , ids, ide, jds, jde, kds, kde     &
27                              , ims, ime, jms, jme, kms, kme     &
28                              , ips, ipe, jps, jpe, kps, kpe     &
29                              , imsx,imex,jmsx,jmex,kmsx,kmex    &
30                              , ipsx,ipex,jpsx,jpex,kpsx,kpex    &
31                              , imsy,imey,jmsy,jmey,kmsy,kmey    &
32                              , ipsy,ipey,jpsy,jpey,kpsy,kpey    &
33                              , k_start , k_end                  &
34                              , f_flux                           &
35                              , feedback_is_ready                &
36                             )
37     USE module_state_description
38     USE module_model_constants
39     USE module_domain, ONLY : domain, domain_clock_get, get_ijk_from_subgrid
40     USE module_configure, ONLY : grid_config_rec_type, model_config_rec
41 !   USE module_radiation_driver, ONLY : pre_radiation_driver, radiation_driver
42 !   USE module_surface_driver, ONLY : surface_driver
43 !   USE module_cumulus_driver, ONLY : cumulus_driver
44 !   USE module_shallowcu_driver, ONLY : shallowcu_driver
45 !   USE module_pbl_driver, ONLY : pbl_driver
46 !   USE module_fr_sfire_driver_wrf, ONLY : sfire_driver_em_step
47 !   USE module_fddagd_driver, ONLY : fddagd_driver
48 !   USE module_em, ONLY : init_zero_tendency
49 !   USE module_force_scm
50 !   USE module_convtrans_prep
51     USE module_big_step_utilities_em, ONLY : phy_prep
52 !use module_scalar_tables
53 #ifdef DM_PARALLEL
54     USE module_dm, ONLY : local_communicator, mytask, ntasks, ntasks_x, ntasks_y, local_communicator_periodic, wrf_dm_maxval
55     USE module_comm_dm, ONLY : halo_em_phys_a_sub,halo_em_fdda_sfc_sub
56 #endif
57     USE module_utility
58     USE a_module_em, ONLY : a_init_zero_tendency
59     USE a_module_big_step_utilities_em, ONLY : a_phy_prep
60     USE a_module_pbl_driver, ONLY : a_pbl_driver
61     USE a_module_cumulus_driver, ONLY : a_cumulus_driver
62     IMPLICIT NONE
64     TYPE ( domain ), INTENT(INOUT) :: grid
65     TYPE ( grid_config_rec_type ), INTENT(IN) :: config_flags
66     TYPE(WRFU_Time)                :: currentTime
68     INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde,     &
69                            ims, ime, jms, jme, kms, kme,     &
70                            ips, ipe, jps, jpe, kps, kpe,     &
71                            imsx,imex,jmsx,jmex,kmsx,kmex,    &
72                            ipsx,ipex,jpsx,jpex,kpsx,kpex,    &
73                            imsy,imey,jmsy,jmey,kmsy,kmey,    &
74                            ipsy,ipey,jpsy,jpey,kpsy,kpey
77     LOGICAL ,INTENT(IN)                        :: adapt_step_flag
78     REAL, INTENT(IN)                           :: curr_secs
80     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: moist
81     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: a_moist
82     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: moist_tend
83     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: a_moist_tend
84     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_chem),INTENT(INOUT)   :: chem
85     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_chem),INTENT(INOUT)   :: chem_tend
86     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_tracer),INTENT(INOUT)   :: tracer
87     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_tracer),INTENT(INOUT)   :: a_tracer
88     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_tracer),INTENT(INOUT)   :: tracer_tend
89     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_tracer),INTENT(INOUT)   :: a_tracer_tend
90     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT)   :: scalar
91     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT)   :: a_scalar
92     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT)   :: scalar_tend
93     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT)   :: a_scalar_tend
94     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_fdda3d),INTENT(INOUT)  :: fdda3d
95     REAL    ,DIMENSION(ims:ime,1:1,jms:jme,num_fdda2d),INTENT(INOUT)      :: fdda2d
96     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_aerod),INTENT(INOUT)   :: aerod
97     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: psim
98     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: psih
99     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: gz1oz0
100     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: chklowq
101     LOGICAL ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: cu_act_flag
102     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: hol
104     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: th_phy
105     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_th_phy
106     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: pi_phy
107     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_pi_phy
108     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: p_phy
109     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_p_phy
110     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t_phy
111     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_t_phy
112     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: dz8w
113     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_dz8w
114     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: p8w
115     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_p8w
116     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t8w
117     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_t8w
119     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: ru_tendf
120     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_ru_tendf
121     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rv_tendf
122     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_rv_tendf
123     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rw_tendf
124     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_rw_tendf
125     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: ph_tendf
126     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_ph_tendf
127     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t_tendf
128     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_t_tendf
129     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: tke_tend
130     REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: a_tke_tend
132     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT) :: mu_tendf
133     REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT) :: a_mu_tendf
135     INTEGER, INTENT(IN)                           ::  k_start, k_end
136     LOGICAL, INTENT(IN), OPTIONAL                 ::  f_flux
137     LOGICAL, INTENT(IN), OPTIONAL :: feedback_is_ready  ! For WRF-CMAQ coupled model, indicates feedback information is available
139 ! Local
140     REAL, DIMENSION( ims:ime, jms:jme ) :: exch_temf  ! 1/7/09 WA
142     REAL, DIMENSION( ims:ime, jms:jme ) :: ht_loc, mixht
143     INTEGER                             :: ij
144     INTEGER  num_roof_layers
145     INTEGER  num_wall_layers
146     INTEGER  num_road_layers
147     INTEGER  iswater
148     LOGICAL  :: l_flux
149     INTEGER  :: isurban
150     INTEGER  rk_step
151     INTEGER                         :: yr, month, day, hr, minute, sec, rc
152     CHARACTER*80                    :: mesg
154    INTEGER                         :: sids , side , sjds , sjde , skds , skde , &
155                                       sims , sime , sjms , sjme , skms , skme , &
156                                       sips , sipe , sjps , sjpe , skps , skpe
158    CHARACTER (LEN=256) :: mminlu
160 #if ( WRF_DFI_RADAR == 1 )
161     INTEGER  do_capsupress   ! =1 do CAP supress, other = don't
162 #endif
164   CALL get_ijk_from_subgrid (  grid ,                   &
165                             sids, side, sjds, sjde, skds, skde,    &
166                             sims, sime, sjms, sjme, skms, skme,    &
167                             sips, sipe, sjps, sjpe, skps, skpe    )
169  ! initialize all tendencies to zero in order to update physics
170  ! tendencies first (separate from dry dynamics).
172    l_flux=.FALSE.
173    if (present(f_flux)) l_flux=f_flux
175     rk_step = 1
177 #ifdef DM_PARALLEL
178 #     include "HALO_EM_PHYS_A.inc"
179 #endif
181       !$OMP PARALLEL DO   &
182       !$OMP PRIVATE ( ij )
183       DO ij = 1 , grid%num_tiles
185         CALL wrf_debug ( 200 , ' call phy_prep' )
186         CALL phy_prep ( config_flags,                                    &
187                         grid%mut, grid%muu, grid%muv,                    &
188                         grid%c1h, grid%c2h, grid%c1f, grid%c2f,          &
189                         grid%u_2, grid%v_2, grid%p, grid%pb, grid%alt,   &
190                         grid%ph_2, grid%phb, grid%t_2, moist, num_moist, &
191                         grid%rho,th_phy, grid%th_phy_m_t0,               &
192                         p_phy, pi_phy, grid%u_phy, grid%v_phy,           &
193                         p8w, t_phy, t8w, grid%z, grid%z_at_w, dz8w,      &
194                         grid%p_hyd, grid%p_hyd_w, grid%dnw,              &
195                         grid%fnm, grid%fnp, grid%znw, grid%p_top,        &
196                         ids, ide, jds, jde, kds, kde,                    &
197                         ims, ime, jms, jme, kms, kme,                    &
198                         grid%i_start(ij), grid%i_end(ij),                &
199                         grid%j_start(ij), grid%j_end(ij),                &
200                         k_start, k_end                                   )
201       ENDDO
202       !$OMP END PARALLEL DO
204 BENCH_END(phy_prep_tim)
207 !  Adjoint part begin
209 ! cumulus para.
211       CALL wrf_debug ( 200 , ' call a_cumulus_driver' )
213 BENCH_START(a_cu_driver_tim)
214       CALL a_cumulus_driver(grid                                             &
215                  ! Prognostic variables
216      &             ,U=grid%u_phy, V=grid%v_phy, TH=th_phy, THB=a_th_phy, T=grid%t_phy, TB=grid%a_t_phy  &
217      &             ,W=grid%w_2, P=grid%p_hyd, PB=grid%a_p_hyd, PI=pi_phy, RHO=grid%rho, RHOB=grid%a_rho &
218                  ! Other arguments
219      &             ,ITIMESTEP=grid%itimestep ,DT=grid%dt      ,DX=grid%dx              &
220      &             ,CUDT=grid%cudt,CURR_SECS=curr_secs,ADAPT_STEP_FLAG=adapt_step_flag &
221      &             ,CUDTACTTIME=grid%cudtacttime                                       &
222      &             ,RAINC=grid%rainc   ,RAINCV=grid%raincv   ,PRATEC=grid%pratec       &
223      &             ,RAINCVB=grid%a_raincv, PRATECB=grid%a_pratec                       &
224      &             ,NCA=grid%nca                                                       &
225      &             ,HTOP=grid%cutop     ,HBOT=grid%cubot       ,KPBL=grid%kpbl         &
226      &             ,Z=grid%z ,Z_AT_W=grid%z_at_w ,MAVAIL=grid%mavail ,PBLH=grid%pblh   &
227      &             ,DZ8W=dz8w     ,P8W=grid%p_hyd_w, PSFC=grid%psfc, TSK=grid%tsk      &
228      &             ,ZB=grid%a_z, DZ8WB=a_dz8w                                        &
229      &             ,TKE_PBL=grid%tke_pbl, UST=grid%ust                                 &
230      &             ,W0AVG=grid%w0avg   ,STEPCU=grid%stepcu                             &
231      &             ,CLDEFI=grid%cldefi ,LOWLYR=grid%lowlyr ,XLAND=grid%xland           &
232      &             ,APR_GR=grid%apr_gr ,APR_W=grid%apr_w   ,APR_MC=grid%apr_mc         &
233      &             ,APR_ST=grid%apr_st ,APR_AS=grid%apr_as ,APR_CAPMA=grid%apr_capma   &
234      &             ,APR_CAPME=grid%apr_capme          ,APR_CAPMI=grid%apr_capmi     &
235      &             ,MASS_FLUX=grid%mass_flux          ,XF_ENS=grid%xf_ens           &
236      &             ,PR_ENS=grid%pr_ens ,HT=grid%ht,EDT_OUT=grid%edt_out             &
237      &             ,imomentum=grid%imomentum,clos_choice=grid%clos_choice           &
238      &             ,ishallow=config_flags%ishallow                                  &
239      &             ,cugd_tten=grid%cugd_tten,cugd_qvten=grid%cugd_qvten,cugd_qcten=grid%cugd_qcten   &
240      &             ,cugd_ttens=grid%cugd_ttens,cugd_qvtens=grid%cugd_qvtens   &
241      &             ,ENSDIM=config_flags%ensdim ,MAXIENS=config_flags%maxiens ,MAXENS=config_flags%maxens         &
242      &             ,MAXENS2=config_flags%maxens2 ,MAXENS3=config_flags%maxens3       &
243      &             ,CU_ACT_FLAG=cu_act_flag   ,WARM_RAIN=grid%warm_rain   &
244      &             ,HFX=grid%hfx, QFX=grid%qfx                            &
245      &             ,CLDFRA=grid%cldfra, TPERT2D=grid%tpert2d              &
246      &             ,GSW=grid%gsw,cugd_avedx=config_flags%cugd_avedx       &
247      &             ,k22_shallow=grid%k22_shallow,kbcon_shallow=grid%kbcon_shallow &
248      &             ,ktop_shallow=grid%ktop_shallow,xmb_shallow=grid%xmb_shallow   &
249      &             ,PERIODIC_X=(config_flags%polar .OR. config_flags%periodic_x)  &
250      &             ,PERIODIC_Y=config_flags%periodic_y                    &
251                  ! Zhang-McFarlane outputs
252      &             ,CAPE=grid%cape ,ZMMU=grid%zmmu ,ZMMD=grid%zmmd        &
253      &             ,ZMDT=grid%zmdt ,ZMDQ=grid%zmdq                        &
254      &             ,DLF=grid%dlf, RLIQ=grid%rliq                          &
255      &             ,PCONVB=grid%pconvb, PCONVT=grid%pconvt                &
256      &             ,EVAPTZM=grid%evaptzm, FZSNTZM=grid%fzsntzm, EVSNTZM=grid%evsntzm     &
257      &             ,EVAPQZM=grid%evapqzm, ZMFLXPRC=grid%zmflxprc          &
258      &             ,ZMFLXSNW=grid%zmflxsnw, ZMNTPRPD=grid%zmntprpd        &
259      &             ,ZMNTSNPD=grid%zmntsnpd, ZMEIHEAT=grid%zmeiheat        &
260      &             ,CMFMC=grid%cmfmc, CMFMCDZM=grid%cmfmcdzm              &
261      &             ,PRECCDZM=grid%preccdzm, PRECZ=grid%precz              &
262      &             ,ZMMTU=grid%zmmtu, ZMMTV=grid%zmmtv  &
263      &             ,ZMUPGU=grid%zmupgu, ZMUPGD=grid%zmupgd                &
264      &             ,ZMVPGU=grid%zmvpgu, ZMVPGD=grid%zmvpgd                &
265      &             ,ZMICUU=grid%zmicuu, ZMICUD=grid%zmicud                &
266      &             ,ZMICVU=grid%zmicvu, ZMICVD=grid%zmicvd                &
267      &             ,ZMDICE=grid%zmdice, ZMDLIQ=grid%zmdliq                &
268                  ! Selection flag
269      &             ,pgcon=config_flags%sas_pgcon                          &
270      &             ,CU_PHYSICS=config_flags%cu_physics                    &
271      &             ,BL_PBL_PHYSICS=config_flags%bl_pbl_physics            &
272      &             ,SF_SFCLAY_PHYSICS=config_flags%sf_sfclay_physics      &
273      &             ,KFETA_TRIGGER=config_flags%kfeta_trigger              &
274                  ! Dimension arguments
275      &             ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde     &
276      &             ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme     &
277      &             ,IPS=ips,IPE=ipe, JPS=jps,JPE=jpe, KPS=kps,KPE=kpe     &
278      &             ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1)     &
279      &             ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1)     &
280      &             ,KTS=k_start, KTE=min(k_end,kde-1)                     &
281      &             ,NUM_TILES=grid%num_tiles                              &
282                  ! Moisture tendency arguments
283      &             ,RQVCUTEN=grid%rqvcuten , RQCCUTEN=grid%rqccuten       &
284      &             ,RQVCUTENB=grid%a_rqvcuten                            &
285      &             ,RQSCUTEN=grid%rqscuten , RQICUTEN=grid%rqicuten       &
286      &             ,RQRCUTEN=grid%rqrcuten                                &
287      &             ,RQVBLTEN=grid%rqvblten , RQVFTEN=grid%rqvften         &
288                  ! Other tendency arguments
289      &             ,RTHRATEN=grid%rthraten , RTHBLTEN=grid%rthblten       &
290      &             ,RUCUTEN=grid%rucuten   , RVCUTEN=grid%rvcuten         &
291      &             ,RTHCUTEN=grid%rthcuten , RTHFTEN=grid%rthften         &
292      &             ,RTHCUTENB=grid%a_rthcuten                            &
293                  ! Moisture tracer arguments
294      &             ,QV_CURR=moist(ims,kms,jms,P_QV), F_QV=F_QV            &
295      &             ,QV_CURRB=a_moist(ims,kms,jms,P_QV)                   &
296      &             ,QC_CURR=moist(ims,kms,jms,P_QC), F_QC=F_QC            &
297      &             ,QR_CURR=moist(ims,kms,jms,P_QR), F_QR=F_QR            &
298      &             ,QI_CURR=moist(ims,kms,jms,P_QI), F_QI=F_QI            &
299      &             ,QS_CURR=moist(ims,kms,jms,P_QS), F_QS=F_QS            &
300      &             ,QG_CURR=moist(ims,kms,jms,P_QG), F_QG=F_QG            &
301 ! Variables for Tiedtke and NSAS schemes
302      &             ,ZNU=grid%znu                                          &
303      &             ,MP_PHYSICS=config_flags%mp_physics                    &
304      &             ,GD_CLOUD=grid%GD_CLOUD,GD_CLOUD2=grid%GD_CLOUD2       &
305      &             ,cfu1=grid%cfu1,cfd1=grid%cfd1,dfu1=grid%dfu1,efu1=grid%efu1,dfd1=grid%dfd1,efd1=grid%efd1,f_flux=l_flux)
306 BENCH_END(a_cu_driver_tim)
309 !*********
310 ! pbl
312       CALL wrf_debug ( 200 , ' call a_pbl_driver' )
313 BENCH_START(a_pbl_driver_tim)
314       CALL a_pbl_driver(                                                              &
315      &         AKHS=grid%akhs          ,AKMS=grid%akms                              &
316      &        ,BL_PBL_PHYSICS=config_flags%bl_pbl_physics                           &
317      &        ,BLDT=grid%bldt, CURR_SECS=curr_secs, ADAPT_STEP_FLAG=adapt_step_flag &
318      &        ,BLDTACTTIME=grid%bldtacttime                                         &
319      &        ,BR=grid%br              ,CHKLOWQ=chklowq    ,CT=grid%ct              &
320      &        ,DT=grid%dt              ,DX=grid%dx              ,DZ8W=dz8w          &
321      &        ,EXCH_H=grid%exch_h     ,EXCH_M=grid%exch_m                           &
322      &        ,FM=grid%fm         ,FHH=grid%fh                                      &
323      &        ,F=grid%f  ,GRDFLX=grid%grdflx      &
324      &        ,GZ1OZ0=gz1oz0      ,HFX=grid%hfx  ,HT=grid%ht                        &
325      &        ,ID=grid%id         ,ITIMESTEP=grid%itimestep     ,KPBL=grid%kpbl          &
326      &        ,LH=grid%lh ,LOWLYR=grid%lowlyr ,P8W=grid%p_hyd_w, P8WB=grid%a_p_hyd_w   &
327      &        ,PBLH=grid%pblh ,PI_PHY=pi_phy,PI_PHYB=a_pi_phy, PSIH=psih          &
328      &        ,PSIM=psim ,P_PHY=grid%p_hyd, QFX=grid%qfx            &
329      &        ,QSFC=grid%qsfc          ,QZ0=grid%qz0  ,MIXHT=mixht                  &
330      &        ,RA_LW_PHYSICS=config_flags%ra_lw_physics                   &
331      &        ,RHO=grid%rho            ,RQCBLTEN=grid%rqcblten  ,RQIBLTEN=grid%rqiblten  &
332      &        ,RQCBLTENB=grid%a_rqcblten  ,RQIBLTENB=grid%a_rqiblten  &
333      &        ,RQVBLTEN=grid%rqvblten  ,RQVBLTENB=grid%a_rqvblten                  &
334      &        ,RTHBLTEN=grid%rthblten  ,RTHBLTENB=grid%a_rthblten                  &
335      &        ,RUBLTEN=grid%rublten, RUBLTENB=grid%a_rublten    &
336      &        ,RVBLTEN=grid%rvblten ,RVBLTENB=grid%a_rvblten   ,SNOW=grid%snow       ,STEPBL=grid%stepbl      &
337      &        ,THZ0=grid%thz0          ,TH_PHY=th_phy                               &
338      &        ,TSK=grid%tsk ,T_PHY=grid%t_phy, T_PHYB=grid%a_t_phy ,UST=grid%ust       &
339      &        ,U10=grid%u10 ,UZ0=grid%uz0 ,U_FRAME=grid%u_frame ,U_PHY=grid%u_phy ,U_PHYB=grid%a_u_phy &
340      &        ,V10=grid%v10 ,VZ0=grid%vz0 ,V_FRAME=grid%v_frame ,V_PHY=grid%v_phy ,V_PHYB=grid%a_v_phy &
341               ,T2=grid%t2 &
342      &        ,WARM_RAIN=grid%warm_rain                    ,WSPD=grid%wspd          &
343      &        ,XICE=grid%xice   ,XLAND=grid%xland  ,Z=grid%z ,ZB=grid%a_z      &
344      &        ,ZNT=grid%znt                                                    &
345 ! paj: topo_wind
346      &        ,CTOPO=grid%ctopo,CTOPO2=grid%ctopo2                                   &
347 ! variables added for BEP
348      &          ,FRC_URB2D=grid%frc_urb2d                                                  &
349      &          ,A_U_BEP=grid%a_u_bep,A_V_BEP=grid%a_v_bep,A_T_BEP=grid%a_t_bep          &
350      &          ,A_Q_BEP=grid%a_q_bep                                                    &
351      &          ,B_U_BEP=grid%b_u_bep,B_V_BEP=grid%b_v_bep,B_T_BEP=grid%b_t_bep          &
352      &          ,B_Q_BEP=grid%b_q_bep                                                    &
353      &          ,SF_BEP=grid%sf_bep,VL_BEP=grid%vl_bep                                   &
354      &          ,A_E_BEP=grid%a_e_bep,B_E_BEP=grid%b_e_bep,DLG_BEP=grid%dlg_bep          &
355      &          ,DL_U_BEP=grid%dl_u_bep                                                  &
356      &          ,SF_SFCLAY_PHYSICS=config_flags%sf_sfclay_physics                        &
357      &          ,SF_URBAN_PHYSICS=config_flags%sf_urban_physics                          &
358 ! Bep changes end
359 ! add tke_pbl, and turbulent fluxes
360      &          ,TKE_PBL=grid%tke_pbl,EL_PBL=grid%el_pbl,WU_TUR=grid%wu_tur,WV_tur=grid%wv_tur,WT_tur=grid%wt_tur,WQ_tur=grid%wq_tur   &
361 ! end add tke_pbl, and turbulent fluxes
362      &        ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde          &
363      &        ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme          &
364      &        ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1)          &
365      &        ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1)          &
366      &        ,KTS=k_start, KTE=min(k_end,kde-1)                          &
367      &        ,NUM_TILES=grid%num_tiles                                   &
368           ! Variables Required by ACM PBL  - jp
369      &        ,ZNU=grid%znu,ZNW=grid%znw,MUT=grid%mut,MUTB=grid%a_mut, P_TOP=grid%p_top    &
370           ! Variables required by TEMF PBL - WA 9/9/08
371               ,te_temf=grid%te_temf                                 &
372               ,kh_temf=grid%kh_temf,km_temf=grid%km_temf            &
373               ,shf_temf=grid%shf_temf,qf_temf=grid%qf_temf          &
374               ,uw_temf=grid%uw_temf,vw_temf=grid%vw_temf            &
375               ,hd_temf=grid%hd_temf,lcl_temf=grid%lcl_temf          &
376               ,wupd_temf=grid%wupd_temf,mf_temf=grid%mf_temf          &
377               ,thup_temf=grid%thup_temf,qtup_temf=grid%qtup_temf          &
378               ,qlup_temf=grid%qlup_temf          &
379               ,cf3d_temf=grid%cf3d_temf,cfm_temf=grid%cfm_temf          &
380               ,hct_temf=grid%hct_temf                               &
381               ,flhc=grid%flhc,flqc=grid%flqc                        &
382               ,exch_temf=exch_temf                      &
383           ! optional
384      &        ,QV_CURR=moist(ims,kms,jms,P_QV), F_QV=F_QV                 &
385      &        ,QV_CURRB=a_moist(ims,kms,jms,P_QV)                        &
386      &        ,QC_CURR=moist(ims,kms,jms,P_QC), F_QC=F_QC                 &
387      &        ,QR_CURR=moist(ims,kms,jms,P_QR), F_QR=F_QR                 &
388      &        ,QI_CURR=moist(ims,kms,jms,P_QI), F_QI=F_QI                 &
389      &        ,QS_CURR=moist(ims,kms,jms,P_QS), F_QS=F_QS                 &
390      &        ,QG_CURR=moist(ims,kms,jms,P_QG), F_QG=F_QG                 &
391      &        ,HOL=HOL, MOL=grid%mol, REGIME=grid%REGIME                  &
392 !mynn mp
393      &        ,QKE=scalar(ims,kms,jms,P_qke_adv), tsq=grid%tsq, qsq=grid%qsq  &
394      &        ,cov=grid%cov                                               &
395      &        ,DQKE=grid%dqke,QWT=grid%qWT                                &
396      &        ,QSHEAR=grid%qSHEAR,QBUOY=grid%qBUOY,QDISS=grid%qDISS       &
397      &        ,tke_budget=config_flags%tke_budget                         &
398      &        ,rmol=grid%rmol, ch=grid%ch                                 &
399      &        ,qcg=grid%qcg, grav_settling=config_flags%grav_settling     &
400 !GWD for ARW
401      &        ,GWD_OPT=config_flags%gwd_opt &
402      &        ,DTAUX3D=grid%dtaux3d,DTAUY3D=grid%dtauy3d &
403      &        ,DTAUX3DB=grid%a_dtaux3d,DTAUY3DB=grid%a_dtauy3d &
404      &        ,DUSFCG=grid%dusfcg,DVSFCG=grid%dvsfcg &
405      &        ,DUSFCGB=grid%a_dusfcg,DVSFCGB=grid%a_dvsfcg &
406      &        ,VAR2D=grid%var2d,OC12D=grid%oc12d     &
407      &        ,OA1=grid%oa1,OA2=grid%oa2,OA3=grid%oa3,OA4=grid%oa4        &
408      &        ,OL1=grid%ol1,OL2=grid%ol2,OL3=grid%ol3,OL4=grid%ol4        &
409      &        ,SINA=grid%sina, COSA=grid%cosa                             &
410      &        ,MFSHCONV=grid%mfshconv                                     & 
411      &        ,MASSFLUX_EDKF=grid%massflux_EDKF                           & 
412      &        ,ENTR_EDKF=grid%entr_EDKF, DETR_EDKF=grid%detr_EDKF         &
413      &        ,THL_UP=grid%thl_up                                         &
414      &        ,THV_UP=grid%thv_up, RT_UP=grid%rt_up ,RV_UP=grid%rv_up     &
415      &        ,RC_UP=grid%rc_up, U_UP=grid% u_up, V_UP=grid%v_up          &
416      &        ,FRAC_UP=grid%frac_up, RC_MF=grid%RC_MF                     &
417 ! For Wind Turbine Drag Parameterizations
418      &        ,phb=grid%phb                                               &
419      &        ,XLAT_U=grid%xlat_u,XLONG_U=grid%xlong_u                    &
420 !Variables required for camuwpbl scheme
421      &        ,Z_AT_W=grid%z_at_w,CLDFRA=grid%cldfra                      &
422      &        ,RTHRATENLW=grid%rthratenlw,TAURESX2D=grid%tauresx2d        &
423      &        ,TAURESY2D=grid%tauresy2d                                   &
424      &        ,TPERT2D=grid%tpert2d,QPERT2D=grid%qpert2d                  &
425      &        ,WPERT2D=grid%wpert2d                                       &
426      &        ,XLAT_V=grid%xlat_v,XLONG_V=grid%xlong_v                    &
427      &        )
430 BENCH_END(a_pbl_driver_tim)
432       !$OMP PARALLEL DO   &
433       !$OMP PRIVATE ( ij )
434       DO ij = 1 , grid%num_tiles
436         CALL wrf_debug ( 200 , ' call a_phy_prep' )
437         CALL a_phy_prep ( config_flags,                           &
438                         grid%mut,grid%a_mut, grid%muu, grid%a_muu, grid%muv, grid%a_muv, &
439                         grid%u_2,grid%a_u_2, grid%v_2,grid%a_v_2,             &
440                         grid%p,grid%a_p, grid%pb, grid%alt,grid%a_alt,        &
441                         grid%ph_2,grid%a_ph_2, grid%phb, grid%t_2,grid%a_t_2, &
442                         moist,a_moist, num_moist,                             &
443                         grid%rho,grid%a_rho, th_phy,a_th_phy, p_phy,a_p_phy, pi_phy,a_pi_phy, &
444                         grid%u_phy,grid%a_u_phy, grid%v_phy,grid%a_v_phy,                         &
445                         p8w,a_p8w, grid%t_phy,grid%a_t_phy, t8w,a_t8w, grid%z,grid%a_z, &
446                         grid%z_at_w,grid%a_z_at_w, dz8w,a_dz8w,               &
447                         grid%p_hyd,grid%a_p_hyd, grid%p_hyd_w,grid%a_p_hyd_w, &
448                         grid%dnw,                                             &
449                         grid%fnm, grid%fnp, grid%znw, grid%p_top,             &
450                         ids, ide, jds, jde, kds, kde,           &
451                         ims, ime, jms, jme, kms, kme,           &
452                         grid%i_start(ij), grid%i_end(ij),       &
453                         grid%j_start(ij), grid%j_end(ij),       &
454                         k_start, k_end                         )
455       ENDDO
456       !$OMP END PARALLEL DO
458 BENCH_END(a_phy_prep_tim)
460 #ifdef DM_PARALLEL
461 #     include "HALO_EM_PHYS_A.inc"
462 #endif
464 BENCH_START(a_init_zero_tend_tim)
465        !$OMP PARALLEL DO   &
466        !$OMP PRIVATE ( ij )
468        DO ij = 1 , grid%num_tiles
470          CALL wrf_debug ( 200 , ' call init_zero_tendency' )
471          CALL a_init_zero_tendency(a_ru_tendf, &
472                                    a_rv_tendf, &
473                                    a_rw_tendf, &
474                                    a_ph_tendf, &
475                                    a_t_tendf,  &
476                                    a_tke_tend, &
477                                    a_mu_tendf,  &
478                                    a_moist_tend,  &
479                                    a_scalar_tend, &
480                                    a_tracer_tend, &
481                                    num_tracer,                   &
482                                    num_moist,num_chem,num_scalar, &
483                                    rk_step,                          &
484                                    ids, ide, jds, jde, kds, kde,     &
485                                    ims, ime, jms, jme, kms, kme,     &
486                                    grid%i_start(ij), grid%i_end(ij), &
487                                    grid%j_start(ij), grid%j_end(ij), &
488                                    k_start, k_end                   )
490        END DO
491        !$OMP END PARALLEL DO
492 BENCH_END(a_init_zero_tend_tim)
494   END SUBROUTINE a_first_rk_step_part1
496 END MODULE a_module_first_rk_step_part1