updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / phys / module_physics_addtendc.F
blob5e15a32b836dfac8211cb513b19fc2576cdeaf9a
1 !WRF:MODEL_LAYER: PHYSICS
3 ! note: this module really belongs in the dyn_em directory since it is 
4 !       specific only to the EM core. Leaving here for now, with an 
5 !       #if ( EM_CORE == 1 ) directive. JM 20031201
8 !  This MODULE holds the routines which are used to perform updates of the
9 !  model C-grid tendencies with physics A-grid tendencies
10 !  The module consolidates code that was (up to v1.2) duplicated in 
11 !  module_em and module_rk and in
12 !  module_big_step_utilities.F and module_big_step_utilities_em.F
14 !  This MODULE CONTAINS the following routines:
15 !  update_phy_ten, phy_ra_ten, phy_bl_ten, phy_cu_ten, advance_ppt,
16 !  add_a2a, add_a2c_u, and add_a2c_v
19 MODULE module_physics_addtendc
21 #if ( EM_CORE == 1 )
23    USE module_state_description
24    USE module_configure
26 CONTAINS
28 SUBROUTINE update_phy_ten(rph_tendf,rt_tendf,ru_tendf,rv_tendf,moist_tendf, &
29                       scalar_tendf,mu_tendf,                                &
30                       RTHRATEN,RTHBLTEN,RTHCUTEN,RTHSHTEN,                  &
31                       RUBLTEN,RUCUTEN,RUSHTEN,                              &
32                       RVBLTEN,RVCUTEN,RVSHTEN,                              &
33                       RQVBLTEN,RQCBLTEN,RQIBLTEN,RQNIBLTEN,&!RQNCBLTEN,       & !JOE
34                       RQVCUTEN,RQCCUTEN,RQRCUTEN,RQICUTEN,RQSCUTEN,         &
35                       RQCNCUTEN,RQINCUTEN,                                  &
36                       RQVSHTEN,RQCSHTEN,RQRSHTEN,RQISHTEN,RQSSHTEN,RQGSHTEN,&
37                       RQCNSHTEN,RQINSHTEN,                                  &
38                       RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN,RPHNDGDTEN,            &
39                       RQVNDGDTEN,RMUNDGDTEN,                                &
40                       rthfrten,rqvfrten,                                    & !fire
41                       n_moist,n_scalar,config_flags,rk_step,adv_moist_cond, &
42                       ids, ide, jds, jde, kds, kde,                         &
43                       ims, ime, jms, jme, kms, kme,                         &
44                       its, ite, jts, jte, kts, kte                          )
45 !-------------------------------------------------------------------
46    IMPLICIT NONE
47 !-------------------------------------------------------------------
49    TYPE(grid_config_rec_type   ) ,   INTENT(IN   ) :: config_flags
51    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde,   &
52                                    ims, ime, jms, jme, kms, kme,   &
53                                    its, ite, jts, jte, kts, kte,   &
54                                    n_moist,n_scalar,rk_step
56    LOGICAL , INTENT(IN)        :: adv_moist_cond
58    REAL , DIMENSION(ims:ime , kms:kme, jms:jme),INTENT(INOUT) ::   &
59                                                          ru_tendf, &
60                                                          rv_tendf, &
61                                                          rt_tendf, &
62                                                          rph_tendf
64    REAL , DIMENSION(ims:ime , jms:jme),INTENT(INOUT) ::  mu_tendf
66    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),           &
67           INTENT(INOUT)     ::                        moist_tendf
69    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_scalar),           &
70           INTENT(INOUT)     ::                        scalar_tendf
72    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
73                                                        RTHRATEN, &
74                                                        RTHBLTEN, &
75                                                        RTHCUTEN, &
76                                                        RTHSHTEN, &
77                                                         RUBLTEN, &
78                                                         RUCUTEN, &
79                                                         RUSHTEN, &
80                                                         RVBLTEN, &
81                                                         RVCUTEN, &
82                                                         RVSHTEN, &
83                                                        RQVBLTEN, &
84                                                        RQCBLTEN, &
85                                                        RQIBLTEN, &
86                                                       RQNIBLTEN, & !For CAMUWPBL
87                                                        RQVCUTEN, &
88                                                        RQCCUTEN, &
89                                                        RQRCUTEN, &
90                                                        RQICUTEN, &
91                                                        RQSCUTEN, &
92                                                       RQCNCUTEN, &
93                                                       RQINCUTEN, &
94                                                        RQVSHTEN, &
95                                                        RQCSHTEN, &
96                                                        RQRSHTEN, &
97                                                        RQISHTEN, &
98                                                        RQSSHTEN, &
99                                                        RQGSHTEN, &
100                                                       RQCNSHTEN, &
101                                                       RQINSHTEN, &
102                                                      RTHNDGDTEN, &
103                                                      RPHNDGDTEN, &
104                                                      RQVNDGDTEN, &
105                                                       RUNDGDTEN, &
106                                                       RVNDGDTEN
108    REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN  ) :: RMUNDGDTEN
110    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   & ! fire
111                                                        rthfrten, &
112                                                        rqvfrten   
113 !------------------------------------------------------------------
114 !  set up loop bounds for this grid's boundary conditions
116    if (config_flags%ra_lw_physics .gt. 0 .or.                  &
117        config_flags%ra_sw_physics .gt. 0)                      &
118       CALL phy_ra_ten(config_flags,rt_tendf,RTHRATEN,          &
119                       ids, ide, jds, jde, kds, kde,            &
120                       ims, ime, jms, jme, kms, kme,            &
121                       its, ite, jts, jte, kts, kte             )
123    if (config_flags%bl_pbl_physics .gt. 0)                     &
124       CALL phy_bl_ten(config_flags,rk_step,n_moist,n_scalar,   &
125                       rt_tendf,ru_tendf,rv_tendf,moist_tendf,  &
126                       scalar_tendf,adv_moist_cond,             &
127                       RTHBLTEN,RUBLTEN,RVBLTEN,                &
128                       RQVBLTEN,RQCBLTEN,RQIBLTEN,              &
129                       RQNIBLTEN,                               &! For CAMUWPBL
130                       ids, ide, jds, jde, kds, kde,            &
131                       ims, ime, jms, jme, kms, kme,            &
132                       its, ite, jts, jte, kts, kte             )
134    if (config_flags%cu_physics .gt. 0)                         &
135       CALL phy_cu_ten(config_flags,rk_step,n_moist,n_scalar,   &
136                       rt_tendf,ru_tendf,rv_tendf,              &
137                       RUCUTEN,RVCUTEN,RTHCUTEN,                &
138                       RQVCUTEN,RQCCUTEN,RQRCUTEN,              &
139                       RQICUTEN,RQSCUTEN,RQCNCUTEN,RQINCUTEN,   &
140                       moist_tendf,                             &
141                       scalar_tendf,adv_moist_cond,             &
142                       ids, ide, jds, jde, kds, kde,            &
143                       ims, ime, jms, jme, kms, kme,            &
144                       its, ite, jts, jte, kts, kte             )
146    if (config_flags%shcu_physics .gt. 0)                       &
147       CALL phy_shcu_ten(config_flags,rk_step,n_moist,n_scalar, &
148                       rt_tendf,ru_tendf,rv_tendf,              &
149                       RUSHTEN,RVSHTEN,RTHSHTEN,                &
150                       RQVSHTEN,RQCSHTEN,RQRSHTEN,              &
151                       RQISHTEN,RQSSHTEN,RQGSHTEN,RQCNSHTEN,    &
152                       RQINSHTEN,moist_tendf,scalar_tendf,      &
153                       ids, ide, jds, jde, kds, kde,            &
154                       ims, ime, jms, jme, kms, kme,            &
155                       its, ite, jts, jte, kts, kte             )
157    if (config_flags%grid_fdda .gt. 0)                          &
158       CALL phy_fg_ten(config_flags,rk_step,n_moist,            &
159                       rph_tendf,rt_tendf,ru_tendf,rv_tendf,    &
160                       mu_tendf, moist_tendf,                   &
161                       RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN,          &
162                       RPHNDGDTEN,RQVNDGDTEN,RMUNDGDTEN,        &
163                       ids, ide, jds, jde, kds, kde,            &
164                       ims, ime, jms, jme, kms, kme,            &
165                       its, ite, jts, jte, kts, kte             )
167    if (config_flags%ifire .gt. 0)                              & ! fire
168       CALL phy_fr_ten(config_flags,rk_step,n_moist,            &
169                       rt_tendf,ru_tendf,rv_tendf,              &
170                       mu_tendf, moist_tendf,                   &
171                       rthfrten,rqvfrten,                       &
172                       ids, ide, jds, jde, kds, kde,            &
173                       ims, ime, jms, jme, kms, kme,            &
174                       its, ite, jts, jte, kts, kte             )
176 END SUBROUTINE update_phy_ten
178 !=================================================================
179 SUBROUTINE phy_ra_ten(config_flags,rt_tendf,RTHRATEN,            &
180                       ids, ide, jds, jde, kds, kde,              &
181                       ims, ime, jms, jme, kms, kme,              &
182                       its, ite, jts, jte, kts, kte               )
183 !-----------------------------------------------------------------
184    IMPLICIT NONE
185 !-----------------------------------------------------------------
186    TYPE(grid_config_rec_type  ) , INTENT(IN   ) :: config_flags
188    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
189                                    ims, ime, jms, jme, kms, kme, &
190                                    its, ite, jts, jte, kts, kte
192    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
193                                                        RTHRATEN
195    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) ::  &
196                                                        rt_tendf
198 ! LOCAL VARS
200    INTEGER :: i,j,k
202    CALL add_a2a(rt_tendf,RTHRATEN,config_flags,                  &
203                 ids,ide, jds, jde, kds, kde,                     &
204                 ims, ime, jms, jme, kms, kme,                    &
205                 its, ite, jts, jte, kts, kte                     )
207 END SUBROUTINE phy_ra_ten
209 !=================================================================
210 SUBROUTINE phy_bl_ten(config_flags,rk_step,n_moist,n_scalar,     &
211                       rt_tendf,ru_tendf,rv_tendf,moist_tendf,    &
212                       scalar_tendf,adv_moist_cond,               &
213                       RTHBLTEN,RUBLTEN,RVBLTEN,                  & 
214                       RQVBLTEN,RQCBLTEN,RQIBLTEN,RQNIBLTEN,      &
215                       ids, ide, jds, jde, kds, kde,              &
216                       ims, ime, jms, jme, kms, kme,              &
217                       its, ite, jts, jte, kts, kte               )
218 !-----------------------------------------------------------------
219    IMPLICIT NONE
220 !-----------------------------------------------------------------
221    TYPE(grid_config_rec_type) ,     INTENT(IN   ) :: config_flags
223    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
224                                    ims, ime, jms, jme, kms, kme, &
225                                    its, ite, jts, jte, kts, kte, &
226                                    n_moist, n_scalar, rk_step
228    LOGICAL , INTENT(IN)     :: adv_moist_cond
230    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
231           INTENT(INOUT)     ::                      moist_tendf
233    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_scalar),         &
234           INTENT(INOUT)     ::                      scalar_tendf
236    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   & 
237                                                        RTHBLTEN, &
238                                                         RUBLTEN, &
239                                                         RVBLTEN, &
240                                                        RQVBLTEN, &
241                                                        RQCBLTEN, &
242                                                        RQIBLTEN, &
243                                                       RQNIBLTEN
245    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT)::   &
246                                                        rt_tendf, &
247                                                        ru_tendf, &
248                                                        rv_tendf
249 ! LOCAL VARS
251    INTEGER :: i,j,k,IBGN,IEND,JBGN,JEND
253 !-----------------------------------------------------------------
255    SELECT CASE(config_flags%bl_pbl_physics)
257       CASE (YSUSCHEME)
259            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
260                 ids,ide, jds, jde, kds, kde,                     &
261                 ims, ime, jms, jme, kms, kme,                    &
262                 its, ite, jts, jte, kts, kte                     )
264            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
265                 ids,ide, jds, jde, kds, kde,                     &
266                 ims, ime, jms, jme, kms, kme,                    &
267                 its, ite, jts, jte, kts, kte                     )
269            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
270                 ids,ide, jds, jde, kds, kde,                     &
271                 ims, ime, jms, jme, kms, kme,                    &
272                 its, ite, jts, jte, kts, kte                     )
274         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
275            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
276                 config_flags,                                    &
277                 ids,ide, jds, jde, kds, kde,                     &
278                 ims, ime, jms, jme, kms, kme,                    &
279                 its, ite, jts, jte, kts, kte                     )
281         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
282            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
283                 config_flags,                                    &
284                 ids,ide, jds, jde, kds, kde,                     &
285                 ims, ime, jms, jme, kms, kme,                    &
286                 its, ite, jts, jte, kts, kte                     )
287      
288         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
289            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
290                 config_flags,                                    &
291                 ids,ide, jds, jde, kds, kde,                     &
292                 ims, ime, jms, jme, kms, kme,                    &
293                 its, ite, jts, jte, kts, kte                     )
295        IF(.not. adv_moist_cond)THEN
297         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
298            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
299                 config_flags,                                    &
300                 ids,ide, jds, jde, kds, kde,                     &
301                 ims, ime, jms, jme, kms, kme,                    &
302                 its, ite, jts, jte, kts, kte                     )
303      
304         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
305            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
306                 config_flags,                                    &
307                 ids,ide, jds, jde, kds, kde,                     &
308                 ims, ime, jms, jme, kms, kme,                    &
309                 its, ite, jts, jte, kts, kte                     )
310        ENDIF
312       CASE (SHINHONGSCHEME)
314            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
315                 ids,ide, jds, jde, kds, kde,                     &
316                 ims, ime, jms, jme, kms, kme,                    &
317                 its, ite, jts, jte, kts, kte                     )
319            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
320                 ids,ide, jds, jde, kds, kde,                     &
321                 ims, ime, jms, jme, kms, kme,                    &
322                 its, ite, jts, jte, kts, kte                     )
324            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
325                 ids,ide, jds, jde, kds, kde,                     &
326                 ims, ime, jms, jme, kms, kme,                    &
327                 its, ite, jts, jte, kts, kte                     )
329         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
330            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
331                 config_flags,                                    &
332                 ids,ide, jds, jde, kds, kde,                     &
333                 ims, ime, jms, jme, kms, kme,                    &
334                 its, ite, jts, jte, kts, kte                     )
336         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
337            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
338                 config_flags,                                    &
339                 ids,ide, jds, jde, kds, kde,                     &
340                 ims, ime, jms, jme, kms, kme,                    &
341                 its, ite, jts, jte, kts, kte                     )
343         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
344            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
345                 config_flags,                                    &
346                 ids,ide, jds, jde, kds, kde,                     &
347                 ims, ime, jms, jme, kms, kme,                    &
348                 its, ite, jts, jte, kts, kte                     )
350        IF(.not. adv_moist_cond)THEN
352         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
353            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN, &
354                 config_flags,                                    &
355                 ids,ide, jds, jde, kds, kde,                     &
356                 ims, ime, jms, jme, kms, kme,                    &
357                 its, ite, jts, jte, kts, kte                     )
359         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
360            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN, &
361                 config_flags,                                    &
362                 ids,ide, jds, jde, kds, kde,                     &
363                 ims, ime, jms, jme, kms, kme,                    &
364                 its, ite, jts, jte, kts, kte                     )
365        ENDIF
367       CASE (MRFSCHEME)
369            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
370                 ids,ide, jds, jde, kds, kde,                     &
371                 ims, ime, jms, jme, kms, kme,                    &
372                 its, ite, jts, jte, kts, kte                     )
374            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
375                 ids,ide, jds, jde, kds, kde,                     &
376                 ims, ime, jms, jme, kms, kme,                    &
377                 its, ite, jts, jte, kts, kte                     )
379            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
380                 ids,ide, jds, jde, kds, kde,                     &
381                 ims, ime, jms, jme, kms, kme,                    &
382                 its, ite, jts, jte, kts, kte                     )
384         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
385            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
386                 config_flags,                                    &
387                 ids,ide, jds, jde, kds, kde,                     &
388                 ims, ime, jms, jme, kms, kme,                    &
389                 its, ite, jts, jte, kts, kte                     )
391         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
392            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
393                 config_flags,                                    &
394                 ids,ide, jds, jde, kds, kde,                     &
395                 ims, ime, jms, jme, kms, kme,                    &
396                 its, ite, jts, jte, kts, kte                     )
397      
398         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
399            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
400                 config_flags,                                    &
401                 ids,ide, jds, jde, kds, kde,                     &
402                 ims, ime, jms, jme, kms, kme,                    &
403                 its, ite, jts, jte, kts, kte                     )
405        IF(.not. adv_moist_cond)THEN
407         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
408            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
409                 config_flags,                                    &
410                 ids,ide, jds, jde, kds, kde,                     &
411                 ims, ime, jms, jme, kms, kme,                    &
412                 its, ite, jts, jte, kts, kte                     )
413      
414         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
415            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
416                 config_flags,                                    &
417                 ids,ide, jds, jde, kds, kde,                     &
418                 ims, ime, jms, jme, kms, kme,                    &
419                 its, ite, jts, jte, kts, kte                     )
420        ENDIF
422       CASE (ACMPBLSCHEME)
424            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
425                 ids,ide, jds, jde, kds, kde,                     &
426                 ims, ime, jms, jme, kms, kme,                    &
427                 its, ite, jts, jte, kts, kte                     )
429            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
430                 ids,ide, jds, jde, kds, kde,                     &
431                 ims, ime, jms, jme, kms, kme,                    &
432                 its, ite, jts, jte, kts, kte                     )
434            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
435                 ids,ide, jds, jde, kds, kde,                     &
436                 ims, ime, jms, jme, kms, kme,                    &
437                 its, ite, jts, jte, kts, kte                     )
439         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
440            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
441                 config_flags,                                    &
442                 ids,ide, jds, jde, kds, kde,                     &
443                 ims, ime, jms, jme, kms, kme,                    &
444                 its, ite, jts, jte, kts, kte                     )
446         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
447            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
448                 config_flags,                                    &
449                 ids,ide, jds, jde, kds, kde,                     &
450                 ims, ime, jms, jme, kms, kme,                    &
451                 its, ite, jts, jte, kts, kte                     )
452      
453         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
454            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
455                 config_flags,                                    &
456                 ids,ide, jds, jde, kds, kde,                     &
457                 ims, ime, jms, jme, kms, kme,                    &
458                 its, ite, jts, jte, kts, kte                     )
460        IF(.not. adv_moist_cond)THEN
462         if (P_QT .ge. PARAM_FIRST_SCALAR)THEN
463            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
464                 config_flags,                                    &
465                 ids,ide, jds, jde, kds, kde,                     &
466                 ims, ime, jms, jme, kms, kme,                    &
467                 its, ite, jts, jte, kts, kte                     )
469            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
470                 config_flags,                                    &
471                 ids,ide, jds, jde, kds, kde,                     &
472                 ims, ime, jms, jme, kms, kme,                    &
473                 its, ite, jts, jte, kts, kte                     )
474         ENDIF
475      
476        ENDIF
478       CASE (MYJPBLSCHEME)
480            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
481                 ids,ide, jds, jde, kds, kde,                     &
482                 ims, ime, jms, jme, kms, kme,                    &
483                 its, ite, jts, jte, kts, kte                     )
485            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
486                 ids,ide, jds, jde, kds, kde,                     &
487                 ims, ime, jms, jme, kms, kme,                    &
488                 its, ite, jts, jte, kts, kte                     )
490            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
491                 ids,ide, jds, jde, kds, kde,                     &
492                 ims, ime, jms, jme, kms, kme,                    &
493                 its, ite, jts, jte, kts, kte                     )
495         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
496            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
497                 config_flags,                                    &
498                 ids,ide, jds, jde, kds, kde,                     &
499                 ims, ime, jms, jme, kms, kme,                    &
500                 its, ite, jts, jte, kts, kte                     )
502        IF(.not. adv_moist_cond)THEN
504         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
505            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
506                 config_flags,                                    &
507                 ids,ide, jds, jde, kds, kde,                     &
508                 ims, ime, jms, jme, kms, kme,                    &
509                 its, ite, jts, jte, kts, kte                     )
510      
511         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
512            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
513                 config_flags,                                    &
514                 ids,ide, jds, jde, kds, kde,                     &
515                 ims, ime, jms, jme, kms, kme,                    &
516                 its, ite, jts, jte, kts, kte                     )
517      
518 !       if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
519 !          CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSBLTEN,  &
520 !               config_flags,                                    &
521 !               ids,ide, jds, jde, kds, kde,                     &
522 !               ims, ime, jms, jme, kms, kme,                    &
523 !               its, ite, jts, jte, kts, kte                     )
524 !    
525 !       if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
526 !          CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRBLTEN,  &
527 !               config_flags,                                    &
528 !               ids,ide, jds, jde, kds, kde,                     &
529 !               ims, ime, jms, jme, kms, kme,                    &
530 !               its, ite, jts, jte, kts, kte                     )
531 !    
532 !       if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
533 !          CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQGBLTEN,  &
534 !               config_flags,                                    &
535 !               ids,ide, jds, jde, kds, kde,                     &
536 !               ims, ime, jms, jme, kms, kme,                    &
537 !               its, ite, jts, jte, kts, kte                     )
538      
539        ELSE
541         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
542            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
543                 config_flags,                                    &
544                 ids,ide, jds, jde, kds, kde,                     &
545                 ims, ime, jms, jme, kms, kme,                    &
546                 its, ite, jts, jte, kts, kte                     )
548         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
549            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
550                 config_flags,                                    &
551                 ids,ide, jds, jde, kds, kde,                     &
552                 ims, ime, jms, jme, kms, kme,                    &
553                 its, ite, jts, jte, kts, kte                     )
554      
555 !       if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
556 !          CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSBLTEN,  &
557 !               config_flags,                                    &
558 !               ids,ide, jds, jde, kds, kde,                     &
559 !               ims, ime, jms, jme, kms, kme,                    &
560 !               its, ite, jts, jte, kts, kte                     )
561 !    
562 !       if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
563 !          CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRBLTEN,  &
564 !               config_flags,                                    &
565 !               ids,ide, jds, jde, kds, kde,                     &
566 !               ims, ime, jms, jme, kms, kme,                    &
567 !               its, ite, jts, jte, kts, kte                     )
568 !    
569 !       if (P_QG .ge. PARAM_FIRST_SCALAR)                                         &
570 !          CALL add_a2a(moist_tendf(ims,kms,jms,P_QG),RQGBLTEN,  &
571 !               config_flags,                                    &
572 !               ids,ide, jds, jde, kds, kde,                     &
573 !               ims, ime, jms, jme, kms, kme,                    &
574 !               its, ite, jts, jte, kts, kte                     )
575      
576        ENDIF
578       CASE (QNSEPBLSCHEME)
580            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
581                 ids,ide, jds, jde, kds, kde,                     &
582                 ims, ime, jms, jme, kms, kme,                    &
583                 its, ite, jts, jte, kts, kte                     )
585            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
586                 ids,ide, jds, jde, kds, kde,                     &
587                 ims, ime, jms, jme, kms, kme,                    &
588                 its, ite, jts, jte, kts, kte                     )
590            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
591                 ids,ide, jds, jde, kds, kde,                     &
592                 ims, ime, jms, jme, kms, kme,                    &
593                 its, ite, jts, jte, kts, kte                     )
595         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
596            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
597                 config_flags,                                    &
598                 ids,ide, jds, jde, kds, kde,                     &
599                 ims, ime, jms, jme, kms, kme,                    &
600                 its, ite, jts, jte, kts, kte                     )
602        IF(.not. adv_moist_cond)THEN
604         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
605            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
606                 config_flags,                                    &
607                 ids,ide, jds, jde, kds, kde,                     &
608                 ims, ime, jms, jme, kms, kme,                    &
609                 its, ite, jts, jte, kts, kte                     )
610      
611        ELSE
613         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
614            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
615                 config_flags,                                    &
616                 ids,ide, jds, jde, kds, kde,                     &
617                 ims, ime, jms, jme, kms, kme,                    &
618                 its, ite, jts, jte, kts, kte                     )
620        ENDIF
622       CASE (GFSSCHEME)
623                                                                                                                                         
624            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
625                 ids,ide, jds, jde, kds, kde,                     &
626                 ims, ime, jms, jme, kms, kme,                    &
627                 its, ite, jts, jte, kts, kte                     )
628                                                                                                                                         
629            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
630                 ids,ide, jds, jde, kds, kde,                     &
631                 ims, ime, jms, jme, kms, kme,                    &
632                 its, ite, jts, jte, kts, kte                     )
633                                                                                                                                         
634            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
635                 ids,ide, jds, jde, kds, kde,                     &
636                 ims, ime, jms, jme, kms, kme,                    &
637                 its, ite, jts, jte, kts, kte                     )
638                                                                                                                                         
639         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
640            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
641                 config_flags,                                    &
642                 ids,ide, jds, jde, kds, kde,                     &
643                 ims, ime, jms, jme, kms, kme,                    &
644                 its, ite, jts, jte, kts, kte                     )
645                                                                                                                                         
646         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
647            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
648                 config_flags,                                    &
649                 ids,ide, jds, jde, kds, kde,                     &
650                 ims, ime, jms, jme, kms, kme,                    &
651                 its, ite, jts, jte, kts, kte                     )
652                                                                                                                                         
653         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
654            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
655                 config_flags,                                    &
656                 ids,ide, jds, jde, kds, kde,                     &
657                 ims, ime, jms, jme, kms, kme,                    &
658                 its, ite, jts, jte, kts, kte                     )
660        IF(.not. adv_moist_cond)THEN
662         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
663            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
664                 config_flags,                                    &
665                 ids,ide, jds, jde, kds, kde,                     &
666                 ims, ime, jms, jme, kms, kme,                    &
667                 its, ite, jts, jte, kts, kte                     )
668      
669         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
670            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
671                 config_flags,                                    &
672                 ids,ide, jds, jde, kds, kde,                     &
673                 ims, ime, jms, jme, kms, kme,                    &
674                 its, ite, jts, jte, kts, kte                     )
675        ENDIF
677       CASE (MYNNPBLSCHEME)
679            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
680                 ids,ide, jds, jde, kds, kde,                     &
681                 ims, ime, jms, jme, kms, kme,                    &
682                 its, ite, jts, jte, kts, kte                     )
684            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
685                 ids,ide, jds, jde, kds, kde,                     &
686                 ims, ime, jms, jme, kms, kme,                    &
687                 its, ite, jts, jte, kts, kte                     )
689            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
690                 ids,ide, jds, jde, kds, kde,                     &
691                 ims, ime, jms, jme, kms, kme,                    &
692                 its, ite, jts, jte, kts, kte                     )
694         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
695            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
696                 config_flags,                                    &
697                 ids,ide, jds, jde, kds, kde,                     &
698                 ims, ime, jms, jme, kms, kme,                    &
699                 its, ite, jts, jte, kts, kte                     )
701        IF(.not. adv_moist_cond)THEN
703         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
704            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
705                 config_flags,                                    &
706                 ids,ide, jds, jde, kds, kde,                     &
707                 ims, ime, jms, jme, kms, kme,                    &
708                 its, ite, jts, jte, kts, kte                     )
710         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
711            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
712                 config_flags,                                    &
713                 ids,ide, jds, jde, kds, kde,                     &
714                 ims, ime, jms, jme, kms, kme,                    &
715                 its, ite, jts, jte, kts, kte                     )
717        ELSE
719         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
720            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
721                 config_flags,                                    &
722                 ids,ide, jds, jde, kds, kde,                     &
723                 ims, ime, jms, jme, kms, kme,                    &
724                 its, ite, jts, jte, kts, kte                     )
726         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
727            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
728                 config_flags,                                    &
729                 ids,ide, jds, jde, kds, kde,                     &
730                 ims, ime, jms, jme, kms, kme,                    &
731                 its, ite, jts, jte, kts, kte                     )
733        ENDIF
735        CASE (EEPSSCHEME)
737            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
738                 ids,ide, jds, jde, kds, kde,                     &
739                 ims, ime, jms, jme, kms, kme,                    &
740                 its, ite, jts, jte, kts, kte                     )
742            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
743                 ids,ide, jds, jde, kds, kde,                     &
744                 ims, ime, jms, jme, kms, kme,                    &
745                 its, ite, jts, jte, kts, kte                     )
747            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
748                 ids,ide, jds, jde, kds, kde,                     &
749                 ims, ime, jms, jme, kms, kme,                    &
750                 its, ite, jts, jte, kts, kte                     )
752         if (P_QV .ge. PARAM_FIRST_SCALAR)&
753            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
754                 config_flags,                                    &
755                 ids,ide, jds, jde, kds, kde,                     &
756                 ims, ime, jms, jme, kms, kme,                    &
757                 its, ite, jts, jte, kts, kte                     )
759         if (P_QC .ge. PARAM_FIRST_SCALAR)&
760            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
761                 config_flags,                                    &
762                 ids,ide, jds, jde, kds, kde,                     &
763                 ims, ime, jms, jme, kms, kme,                    &
764                 its, ite, jts, jte, kts, kte                     )
766         if (P_QI .ge. PARAM_FIRST_SCALAR)&
767            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
768                 config_flags,                                    &
769                 ids,ide, jds, jde, kds, kde,                     &
770                 ims, ime, jms, jme, kms, kme,                    &
771                 its, ite, jts, jte, kts, kte                     )
772        IF(.not. adv_moist_cond)THEN
774         if (P_QT .ge. PARAM_FIRST_SCALAR)&
775            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
776                 config_flags,                                    &
777                 ids,ide, jds, jde, kds, kde,                     &
778                 ims, ime, jms, jme, kms, kme,                    &
779                 its, ite, jts, jte, kts, kte                     )
781         if (P_QT .ge. PARAM_FIRST_SCALAR)&
782            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
783                 config_flags,                                    &
784                 ids,ide, jds, jde, kds, kde,                     &
785                 ims, ime, jms, jme, kms, kme,                    &
786                 its, ite, jts, jte, kts, kte                     )
787        ENDIF
789        CASE (KEPSSCHEME)
791            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
792                 ids,ide, jds, jde, kds, kde,                     &
793                 ims, ime, jms, jme, kms, kme,                    &
794                 its, ite, jts, jte, kts, kte                     )
796            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
797                 ids,ide, jds, jde, kds, kde,                     &
798                 ims, ime, jms, jme, kms, kme,                    &
799                 its, ite, jts, jte, kts, kte                     )
801            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
802                 ids,ide, jds, jde, kds, kde,                     &
803                 ims, ime, jms, jme, kms, kme,                    &
804                 its, ite, jts, jte, kts, kte                     )
806         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
807            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
808                 config_flags,                                    &
809                 ids,ide, jds, jde, kds, kde,                     &
810                 ims, ime, jms, jme, kms, kme,                    &
811                 its, ite, jts, jte, kts, kte                     )
813        IF(.not. adv_moist_cond)THEN
815         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
816            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN, &
817                 config_flags,                                    &
818                 ids,ide, jds, jde, kds, kde,                     &
819                 ims, ime, jms, jme, kms, kme,                    &
820                 its, ite, jts, jte, kts, kte                     )
822        ELSE
824         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
825            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
826                 config_flags,                                    &
827                 ids,ide, jds, jde, kds, kde,                     &
828                 ims, ime, jms, jme, kms, kme,                    &
829                 its, ite, jts, jte, kts, kte                     )
830        ENDIF
833        CASE (BOULACSCHEME)
835            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
836                 ids,ide, jds, jde, kds, kde,                     &
837                 ims, ime, jms, jme, kms, kme,                    &
838                 its, ite, jts, jte, kts, kte                     )
840            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
841                 ids,ide, jds, jde, kds, kde,                     &
842                 ims, ime, jms, jme, kms, kme,                    &
843                 its, ite, jts, jte, kts, kte                     )
845            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
846                 ids,ide, jds, jde, kds, kde,                     &
847                 ims, ime, jms, jme, kms, kme,                    &
848                 its, ite, jts, jte, kts, kte                     )
850         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
851            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
852                 config_flags,                                    &
853                 ids,ide, jds, jde, kds, kde,                     &
854                 ims, ime, jms, jme, kms, kme,                    &
855                 its, ite, jts, jte, kts, kte                     )
857        IF(.not. adv_moist_cond)THEN
859         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
860            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
861                 config_flags,                                    &
862                 ids,ide, jds, jde, kds, kde,                     &
863                 ims, ime, jms, jme, kms, kme,                    &
864                 its, ite, jts, jte, kts, kte                     )
866        ELSE
868         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
869            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
870                 config_flags,                                    &
871                 ids,ide, jds, jde, kds, kde,                     &
872                 ims, ime, jms, jme, kms, kme,                    &
873                 its, ite, jts, jte, kts, kte                     )
874        ENDIF
876        CASE (CAMUWPBLSCHEME)
877            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
878                 ids,ide, jds, jde, kds, kde,                     &
879                 ims, ime, jms, jme, kms, kme,                    &
880                 its, ite, jts, jte, kts, kte                     )
882            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
883                 ids,ide, jds, jde, kds, kde,                     &
884                 ims, ime, jms, jme, kms, kme,                    &
885                 its, ite, jts, jte, kts, kte                     )
887            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
888                 ids,ide, jds, jde, kds, kde,                     &
889                 ims, ime, jms, jme, kms, kme,                    &
890                 its, ite, jts, jte, kts, kte                     )
892         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
893            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
894                 config_flags,                                    &
895                 ids,ide, jds, jde, kds, kde,                     &
896                 ims, ime, jms, jme, kms, kme,                    &
897                 its, ite, jts, jte, kts, kte                     )
899        IF(.not. adv_moist_cond)THEN
901         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
902            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
903                 config_flags,                                    &
904                 ids,ide, jds, jde, kds, kde,                     &
905                 ims, ime, jms, jme, kms, kme,                    &
906                 its, ite, jts, jte, kts, kte                     )
908         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
909              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice mass mixing ratio
910            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
911                 config_flags,                                    &
912                 ids,ide, jds, jde, kds, kde,                     &
913                 ims, ime, jms, jme, kms, kme,                    &
914                 its, ite, jts, jte, kts, kte                     )
915         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
916              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice  number mixing ratio
917            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQNIBLTEN,&
918                config_flags,                                    &
919                ids,ide, jds, jde, kds, kde,                     &
920                ims, ime, jms, jme, kms, kme,                    &
921                its, ite, jts, jte, kts, kte                     )
922        ELSE
924         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
925            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
926                 config_flags,                                    &
927                 ids,ide, jds, jde, kds, kde,                     &
928                 ims, ime, jms, jme, kms, kme,                    &
929                 its, ite, jts, jte, kts, kte                     )
930         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
931              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice mass mixing ratio
932            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
933                 config_flags,                                    &
934                 ids,ide, jds, jde, kds, kde,                     &
935                 ims, ime, jms, jme, kms, kme,                    &
936                 its, ite, jts, jte, kts, kte                     )
937         if (P_QNI .ge. PARAM_FIRST_SCALAR)                                         &
938              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice  number mixing ratio
939            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNI),RQNIBLTEN,&
940                 config_flags,                                    &
941                 ids,ide, jds, jde, kds, kde,                     &
942                 ims, ime, jms, jme, kms, kme,                    &
943                 its, ite, jts, jte, kts, kte                     )
944        ENDIF
947       CASE (TEMFPBLSCHEME)
948            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
949                 ids,ide, jds, jde, kds, kde,                     &
950                 ims, ime, jms, jme, kms, kme,                    &
951                 its, ite, jts, jte, kts, kte                     )
953            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
954                 ids,ide, jds, jde, kds, kde,                     &
955                 ims, ime, jms, jme, kms, kme,                    &
956                 its, ite, jts, jte, kts, kte                     )
958            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
959                 ids,ide, jds, jde, kds, kde,                     &
960                 ims, ime, jms, jme, kms, kme,                    &
961                 its, ite, jts, jte, kts, kte                     )
963         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
964            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
965                 config_flags,                                    &
966                 ids,ide, jds, jde, kds, kde,                     &
967                 ims, ime, jms, jme, kms, kme,                    &
968                 its, ite, jts, jte, kts, kte                     )
970         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
971            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
972                 config_flags,                                    &
973                 ids,ide, jds, jde, kds, kde,                     &
974                 ims, ime, jms, jme, kms, kme,                    &
975                 its, ite, jts, jte, kts, kte                     )
976      
977         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
978            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
979                 config_flags,                                    &
980                 ids,ide, jds, jde, kds, kde,                     &
981                 ims, ime, jms, jme, kms, kme,                    &
982                 its, ite, jts, jte, kts, kte                     )
984       CASE (GBMPBLSCHEME)
985            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
986                 ids,ide, jds, jde, kds, kde,                     &
987                 ims, ime, jms, jme, kms, kme,                    &
988                 its, ite, jts, jte, kts, kte                     )
990            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
991                 ids,ide, jds, jde, kds, kde,                     &
992                 ims, ime, jms, jme, kms, kme,                    &
993                 its, ite, jts, jte, kts, kte                     )
995            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
996                 ids,ide, jds, jde, kds, kde,                     &
997                 ims, ime, jms, jme, kms, kme,                    &
998                 its, ite, jts, jte, kts, kte                     )
1000         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1001            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
1002                 config_flags,                                    &
1003                 ids,ide, jds, jde, kds, kde,                     &
1004                 ims, ime, jms, jme, kms, kme,                    &
1005                 its, ite, jts, jte, kts, kte                     )
1007         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1008            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
1009                 config_flags,                                    &
1010                 ids,ide, jds, jde, kds, kde,                     &
1011                 ims, ime, jms, jme, kms, kme,                    &
1012                 its, ite, jts, jte, kts, kte                     )
1013      
1014         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1015            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
1016                 config_flags,                                    &
1017                 ids,ide, jds, jde, kds, kde,                     &
1018                 ims, ime, jms, jme, kms, kme,                    &
1019                 its, ite, jts, jte, kts, kte                     )
1021 #if ( WRFPLUS == 1 )
1022 ! this is for WRFPlus only
1023 !---------------------------
1024       CASE (SURFDRAGSCHEME)
1026            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
1027                 ids,ide, jds, jde, kds, kde,                     &
1028                 ims, ime, jms, jme, kms, kme,                    &
1029                 its, ite, jts, jte, kts, kte                     )
1031            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
1032                 ids,ide, jds, jde, kds, kde,                     &
1033                 ims, ime, jms, jme, kms, kme,                    &
1034                 its, ite, jts, jte, kts, kte                     )
1035 #endif
1037       CASE DEFAULT
1039        print*,'phy_bl_ten: The pbl scheme does not exist'
1041    END SELECT
1043 END SUBROUTINE phy_bl_ten
1045 !=================================================================
1046 SUBROUTINE phy_cu_ten(config_flags,rk_step,n_moist,n_scalar,     &
1047                       rt_tendf,ru_tendf,rv_tendf,                &
1048                       RUCUTEN,RVCUTEN,RTHCUTEN,                  &
1049                       RQVCUTEN,RQCCUTEN,RQRCUTEN,                &
1050                       RQICUTEN,RQSCUTEN,RQCNCUTEN,RQINCUTEN,     &
1051                       moist_tendf,                               &
1052                       scalar_tendf,adv_moist_cond,               &
1053                       ids, ide, jds, jde, kds, kde,              &
1054                       ims, ime, jms, jme, kms, kme,              &
1055                       its, ite, jts, jte, kts, kte               )
1056 !-----------------------------------------------------------------
1057    IMPLICIT NONE
1058 !-----------------------------------------------------------------
1059    TYPE(grid_config_rec_type  ) , INTENT(IN   ) :: config_flags
1061    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1062                                    ims, ime, jms, jme, kms, kme, &
1063                                    its, ite, jts, jte, kts, kte, &
1064                                    n_moist, n_scalar, rk_step
1066    LOGICAL , INTENT(IN)     :: adv_moist_cond
1068    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1069           INTENT(INOUT)     ::                      moist_tendf
1071    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_scalar),         &
1072           INTENT(INOUT)     ::                      scalar_tendf
1074    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1075                                                         RUCUTEN, &
1076                                                         RVCUTEN, &
1077                                                        RTHCUTEN, &
1078                                                        RQVCUTEN, &
1079                                                        RQCCUTEN, &
1080                                                        RQRCUTEN, &
1081                                                        RQICUTEN, &
1082                                                        RQSCUTEN, &
1083                                                       RQCNCUTEN, &
1084                                                       RQINCUTEN
1086    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) ::  &
1087                                                        rt_tendf, &
1088                                                        ru_tendf, &
1089                                                        rv_tendf
1092 ! LOCAL VARS
1094    INTEGER :: i,j,k
1096    SELECT CASE (config_flags%cu_physics)   
1098    CASE (KFSCHEME)
1099         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1100                 ids,ide, jds, jde, kds, kde,                     &
1101                 ims, ime, jms, jme, kms, kme,                    &
1102                 its, ite, jts, jte, kts, kte                     )
1104         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1105         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1106                 config_flags,                                    &
1107                 ids,ide, jds, jde, kds, kde,                     &
1108                 ims, ime, jms, jme, kms, kme,                    &
1109                 its, ite, jts, jte, kts, kte                     )
1111         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1112         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1113                 config_flags,                                    &
1114                 ids,ide, jds, jde, kds, kde,                     &
1115                 ims, ime, jms, jme, kms, kme,                    &
1116                 its, ite, jts, jte, kts, kte                     )
1118         if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
1119         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRCUTEN,     &
1120                 config_flags,                                    &
1121                 ids,ide, jds, jde, kds, kde,                     &
1122                 ims, ime, jms, jme, kms, kme,                    &
1123                 its, ite, jts, jte, kts, kte                     )
1125         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1126         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1127                 config_flags,                                    &
1128                 ids,ide, jds, jde, kds, kde,                     &
1129                 ims, ime, jms, jme, kms, kme,                    &
1130                 its, ite, jts, jte, kts, kte                     )
1132         if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
1133         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN,     &
1134                 config_flags,                                    &
1135                 ids,ide, jds, jde, kds, kde,                     &
1136                 ims, ime, jms, jme, kms, kme,                    &
1137                 its, ite, jts, jte, kts, kte                     )
1139        IF(.not. adv_moist_cond)THEN
1141         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1142            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1143                 config_flags,                                    &
1144                 ids,ide, jds, jde, kds, kde,                     &
1145                 ims, ime, jms, jme, kms, kme,                    &
1146                 its, ite, jts, jte, kts, kte                     )
1148         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1149            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRCUTEN, &
1150                 config_flags,                                    &
1151                 ids,ide, jds, jde, kds, kde,                     &
1152                 ims, ime, jms, jme, kms, kme,                    &
1153                 its, ite, jts, jte, kts, kte                     )
1155         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1156            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1157                 config_flags,                                    &
1158                 ids,ide, jds, jde, kds, kde,                     &
1159                 ims, ime, jms, jme, kms, kme,                    &
1160                 its, ite, jts, jte, kts, kte                     )
1162         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1163            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSCUTEN, &
1164                 config_flags,                                    &
1165                 ids,ide, jds, jde, kds, kde,                     &
1166                 ims, ime, jms, jme, kms, kme,                    &
1167                 its, ite, jts, jte, kts, kte                     )
1169        ENDIF
1171    CASE (BMJSCHEME)
1172         CALL add_a2a(rt_tendf,RTHCUTEN,                          &
1173                 config_flags,                                    &
1174                 ids,ide, jds, jde, kds, kde,                     &
1175                 ims, ime, jms, jme, kms, kme,                    &
1176                 its, ite, jts, jte, kts, kte                     )
1178         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1179         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1180                 config_flags,                                    &
1181                 ids,ide, jds, jde, kds, kde,                     &
1182                 ims, ime, jms, jme, kms, kme,                    &
1183                 its, ite, jts, jte, kts, kte                     )
1185    CASE (KFETASCHEME, KFCUPSCHEME)!BSINGH -  Added KFCUPSCHEME for CuP
1186         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1187                 ids,ide, jds, jde, kds, kde,                     &
1188                 ims, ime, jms, jme, kms, kme,                    &
1189                 its, ite, jts, jte, kts, kte                     )
1191         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1192         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1193                 config_flags,                                    &
1194                 ids,ide, jds, jde, kds, kde,                     &
1195                 ims, ime, jms, jme, kms, kme,                    &
1196                 its, ite, jts, jte, kts, kte                     )
1198         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1199         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1200                 config_flags,                                    &
1201                 ids,ide, jds, jde, kds, kde,                     &
1202                 ims, ime, jms, jme, kms, kme,                    &
1203                 its, ite, jts, jte, kts, kte                     )
1205         if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
1206         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRCUTEN,     &
1207                 config_flags,                                    &
1208                 ids,ide, jds, jde, kds, kde,                     &
1209                 ims, ime, jms, jme, kms, kme,                    &
1210                 its, ite, jts, jte, kts, kte                     )
1212         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1213         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1214                 config_flags,                                    &
1215                 ids,ide, jds, jde, kds, kde,                     &
1216                 ims, ime, jms, jme, kms, kme,                    &
1217                 its, ite, jts, jte, kts, kte                     )
1219         if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
1220         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN,     &
1221                 config_flags,                                    &
1222                 ids,ide, jds, jde, kds, kde,                     &
1223                 ims, ime, jms, jme, kms, kme,                    &
1224                 its, ite, jts, jte, kts, kte                     )
1226        IF(.not. adv_moist_cond)THEN
1228         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1229            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1230                 config_flags,                                    &
1231                 ids,ide, jds, jde, kds, kde,                     &
1232                 ims, ime, jms, jme, kms, kme,                    &
1233                 its, ite, jts, jte, kts, kte                     )
1235         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1236            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRCUTEN, &
1237                 config_flags,                                    &
1238                 ids,ide, jds, jde, kds, kde,                     &
1239                 ims, ime, jms, jme, kms, kme,                    &
1240                 its, ite, jts, jte, kts, kte                     )
1242         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1243            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1244                 config_flags,                                    &
1245                 ids,ide, jds, jde, kds, kde,                     &
1246                 ims, ime, jms, jme, kms, kme,                    &
1247                 its, ite, jts, jte, kts, kte                     )
1249         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1250            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSCUTEN, &
1251                 config_flags,                                    &
1252                 ids,ide, jds, jde, kds, kde,                     &
1253                 ims, ime, jms, jme, kms, kme,                    &
1254                 its, ite, jts, jte, kts, kte                     )
1256        ENDIF
1258    CASE (MSKFSCHEME)!JTR: Separate MSKF for cmt
1259         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1260                 ids,ide, jds, jde, kds, kde,                     &
1261                 ims, ime, jms, jme, kms, kme,                    &
1262                 its, ite, jts, jte, kts, kte                     )
1264         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1265                 ids,ide, jds, jde, kds, kde,                     &
1266                 ims, ime, jms, jme, kms, kme,                    &
1267                 its, ite, jts, jte, kts, kte                     )
1269         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1270                 ids,ide, jds, jde, kds, kde,                     &
1271                 ims, ime, jms, jme, kms, kme,                    &
1272                 its, ite, jts, jte, kts, kte                     )
1274         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1275         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1276                 config_flags,                                    &
1277                 ids,ide, jds, jde, kds, kde,                     &
1278                 ims, ime, jms, jme, kms, kme,                    &
1279                 its, ite, jts, jte, kts, kte                     )
1281         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1282         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1283                 config_flags,                                    &
1284                 ids,ide, jds, jde, kds, kde,                     &
1285                 ims, ime, jms, jme, kms, kme,                    &
1286                 its, ite, jts, jte, kts, kte                     )
1288         if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
1289         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRCUTEN,     &
1290                 config_flags,                                    &
1291                 ids,ide, jds, jde, kds, kde,                     &
1292                 ims, ime, jms, jme, kms, kme,                    &
1293                 its, ite, jts, jte, kts, kte                     )
1295         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1296         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1297                 config_flags,                                    &
1298                 ids,ide, jds, jde, kds, kde,                     &
1299                 ims, ime, jms, jme, kms, kme,                    &
1300                 its, ite, jts, jte, kts, kte                     )
1302         if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
1303         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN,     &
1304                 config_flags,                                    &
1305                 ids,ide, jds, jde, kds, kde,                     &
1306                 ims, ime, jms, jme, kms, kme,                    &
1307                 its, ite, jts, jte, kts, kte                     )
1309        IF(.not. adv_moist_cond)THEN
1311         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1312            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1313                 config_flags,                                    &
1314                 ids,ide, jds, jde, kds, kde,                     &
1315                 ims, ime, jms, jme, kms, kme,                    &
1316                 its, ite, jts, jte, kts, kte                     )
1318         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1319            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRCUTEN, &
1320                 config_flags,                                    &
1321                 ids,ide, jds, jde, kds, kde,                     &
1322                 ims, ime, jms, jme, kms, kme,                    &
1323                 its, ite, jts, jte, kts, kte                     )
1325         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1326            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1327                 config_flags,                                    &
1328                 ids,ide, jds, jde, kds, kde,                     &
1329                 ims, ime, jms, jme, kms, kme,                    &
1330                 its, ite, jts, jte, kts, kte                     )
1332         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1333            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSCUTEN, &
1334                 config_flags,                                    &
1335                 ids,ide, jds, jde, kds, kde,                     &
1336                 ims, ime, jms, jme, kms, kme,                    &
1337                 its, ite, jts, jte, kts, kte                     )
1339        ENDIF
1342    CASE (GDSCHEME, G3SCHEME, GFSCHEME)
1343         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1344                 ids,ide, jds, jde, kds, kde,                     &
1345                 ims, ime, jms, jme, kms, kme,                    &
1346                 its, ite, jts, jte, kts, kte                     )
1348         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1349         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1350                 config_flags,                                    &
1351                 ids,ide, jds, jde, kds, kde,                     &
1352                 ims, ime, jms, jme, kms, kme,                    &
1353                 its, ite, jts, jte, kts, kte                     )
1355         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1356         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1357                 config_flags,                                    &
1358                 ids,ide, jds, jde, kds, kde,                     &
1359                 ims, ime, jms, jme, kms, kme,                    &
1360                 its, ite, jts, jte, kts, kte                     )
1362         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1363         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1364                 config_flags,                                    &
1365                 ids,ide, jds, jde, kds, kde,                     &
1366                 ims, ime, jms, jme, kms, kme,                    &
1367                 its, ite, jts, jte, kts, kte                     )
1369        IF(.not. adv_moist_cond)THEN
1371         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1372            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1373                 config_flags,                                    &
1374                 ids,ide, jds, jde, kds, kde,                     &
1375                 ims, ime, jms, jme, kms, kme,                    &
1376                 its, ite, jts, jte, kts, kte                     )
1378         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1379            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1380                 config_flags,                                    &
1381                 ids,ide, jds, jde, kds, kde,                     &
1382                 ims, ime, jms, jme, kms, kme,                    &
1383                 its, ite, jts, jte, kts, kte                     )
1385        ENDIF
1387    CASE (KSASSCHEME,NSASSCHEME)
1388         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1389                 ids,ide, jds, jde, kds, kde,                     &
1390                 ims, ime, jms, jme, kms, kme,                    &
1391                 its, ite, jts, jte, kts, kte                     )
1393         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1394                 ids,ide, jds, jde, kds, kde,                     &
1395                 ims, ime, jms, jme, kms, kme,                    &
1396                 its, ite, jts, jte, kts, kte                     )
1398         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1399                 ids,ide, jds, jde, kds, kde,                     &
1400                 ims, ime, jms, jme, kms, kme,                    &
1401                 its, ite, jts, jte, kts, kte                     )
1403         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1404         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1405                 config_flags,                                    &
1406                 ids,ide, jds, jde, kds, kde,                     &
1407                 ims, ime, jms, jme, kms, kme,                    &
1408                 its, ite, jts, jte, kts, kte                     )
1410         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1411         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1412                 config_flags,                                    &
1413                 ids,ide, jds, jde, kds, kde,                     &
1414                 ims, ime, jms, jme, kms, kme,                    &
1415                 its, ite, jts, jte, kts, kte                     )
1417         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1418         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1419                 config_flags,                                    &
1420                 ids,ide, jds, jde, kds, kde,                     &
1421                 ims, ime, jms, jme, kms, kme,                    &
1422                 its, ite, jts, jte, kts, kte                     )
1424        IF(.not. adv_moist_cond)THEN
1426         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1427            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1428                 config_flags,                                    &
1429                 ids,ide, jds, jde, kds, kde,                     &
1430                 ims, ime, jms, jme, kms, kme,                    &
1431                 its, ite, jts, jte, kts, kte                     )
1433         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1434            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1435                 config_flags,                                    &
1436                 ids,ide, jds, jde, kds, kde,                     &
1437                 ims, ime, jms, jme, kms, kme,                    &
1438                 its, ite, jts, jte, kts, kte                     )
1440        ENDIF
1442    CASE (SASSCHEME,OSASSCHEME,SCALESASSCHEME)
1443         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1444                 ids,ide, jds, jde, kds, kde,                     &
1445                 ims, ime, jms, jme, kms, kme,                    &
1446                 its, ite, jts, jte, kts, kte                     )
1448         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1449         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1450                 config_flags,                                    &
1451                 ids,ide, jds, jde, kds, kde,                     &
1452                 ims, ime, jms, jme, kms, kme,                    &
1453                 its, ite, jts, jte, kts, kte                     )
1454           
1455         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1456         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1457                 config_flags,                                    &
1458                 ids,ide, jds, jde, kds, kde,                     &
1459                 ims, ime, jms, jme, kms, kme,                    &
1460                 its, ite, jts, jte, kts, kte                     )
1461           
1462         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1463         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1464                 config_flags,                                    &
1465                 ids,ide, jds, jde, kds, kde,                     &
1466                 ims, ime, jms, jme, kms, kme,                    &
1467                 its, ite, jts, jte, kts, kte                     )
1469        IF(.not. adv_moist_cond)THEN
1471         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1472            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1473                 config_flags,                                    &
1474                 ids,ide, jds, jde, kds, kde,                     &
1475                 ims, ime, jms, jme, kms, kme,                    &
1476                 its, ite, jts, jte, kts, kte                     )
1478         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1479            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1480                 config_flags,                                    &
1481                 ids,ide, jds, jde, kds, kde,                     &
1482                 ims, ime, jms, jme, kms, kme,                    &
1483                 its, ite, jts, jte, kts, kte                     )
1485        ENDIF
1487    CASE (CAMZMSCHEME)
1488         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1489                 ids,ide, jds, jde, kds, kde,                     &
1490                 ims, ime, jms, jme, kms, kme,                    &
1491                 its, ite, jts, jte, kts, kte                     )
1493         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1494                 ids,ide, jds, jde, kds, kde,                     &
1495                 ims, ime, jms, jme, kms, kme,                    &
1496                 its, ite, jts, jte, kts, kte                     )
1498         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1499                 ids,ide, jds, jde, kds, kde,                     &
1500                 ims, ime, jms, jme, kms, kme,                    &
1501                 its, ite, jts, jte, kts, kte                     )
1502                                                                                                                                         
1503         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1504         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1505                 config_flags,                                    &
1506                 ids,ide, jds, jde, kds, kde,                     &
1507                 ims, ime, jms, jme, kms, kme,                    &
1508                 its, ite, jts, jte, kts, kte                     )
1509           
1510         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1511         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1512                 config_flags,                                    &
1513                 ids,ide, jds, jde, kds, kde,                     &
1514                 ims, ime, jms, jme, kms, kme,                    &
1515                 its, ite, jts, jte, kts, kte                     )
1516           
1517         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1518         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1519                 config_flags,                                    &
1520                 ids,ide, jds, jde, kds, kde,                     &
1521                 ims, ime, jms, jme, kms, kme,                    &
1522                 its, ite, jts, jte, kts, kte                     )
1524         if (P_QNC .ge. PARAM_FIRST_SCALAR)                       &!BSINGH - QNC scalar
1525         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNC),RQCNCUTEN,  &
1526                 config_flags,                                    &
1527                 ids,ide, jds, jde, kds, kde,                     &
1528                 ims, ime, jms, jme, kms, kme,                    &
1529                 its, ite, jts, jte, kts, kte                     )
1530         if (P_QNI .ge. PARAM_FIRST_SCALAR)                       &!BSINGH - QNI scalar
1531         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNI),RQINCUTEN,  &
1532                 config_flags,                                    &
1533                 ids,ide, jds, jde, kds, kde,                     &
1534                 ims, ime, jms, jme, kms, kme,                    &
1535                 its, ite, jts, jte, kts, kte                     )
1536         
1537         
1538        IF(.not. adv_moist_cond)THEN
1540         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1541            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1542                 config_flags,                                    &
1543                 ids,ide, jds, jde, kds, kde,                     &
1544                 ims, ime, jms, jme, kms, kme,                    &
1545                 its, ite, jts, jte, kts, kte                     )
1547         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1548            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1549                 config_flags,                                    &
1550                 ids,ide, jds, jde, kds, kde,                     &
1551                 ims, ime, jms, jme, kms, kme,                    &
1552                 its, ite, jts, jte, kts, kte                     )
1554        ENDIF
1556    CASE (TIEDTKESCHEME, NTIEDTKESCHEME)
1557         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1558                 ids,ide, jds, jde, kds, kde,                     &
1559                 ims, ime, jms, jme, kms, kme,                    &
1560                 its, ite, jts, jte, kts, kte                     )
1562         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1563                 ids,ide, jds, jde, kds, kde,                     &
1564                 ims, ime, jms, jme, kms, kme,                    &
1565                 its, ite, jts, jte, kts, kte                     )
1567         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1568                 ids,ide, jds, jde, kds, kde,                     &
1569                 ims, ime, jms, jme, kms, kme,                    &
1570                 its, ite, jts, jte, kts, kte                     )
1572         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1573         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1574                 config_flags,                                    &
1575                 ids,ide, jds, jde, kds, kde,                     &
1576                 ims, ime, jms, jme, kms, kme,                    &
1577                 its, ite, jts, jte, kts, kte                     )
1579         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1580         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1581                 config_flags,                                    &
1582                 ids,ide, jds, jde, kds, kde,                     &
1583                 ims, ime, jms, jme, kms, kme,                    &
1584                 its, ite, jts, jte, kts, kte                     )
1586         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1587         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1588                 config_flags,                                    &
1589                 ids,ide, jds, jde, kds, kde,                     &
1590                 ims, ime, jms, jme, kms, kme,                    &
1591                 its, ite, jts, jte, kts, kte                     )
1593        IF(.not. adv_moist_cond)THEN
1595         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1596            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1597                 config_flags,                                    &
1598                 ids,ide, jds, jde, kds, kde,                     &
1599                 ims, ime, jms, jme, kms, kme,                    &
1600                 its, ite, jts, jte, kts, kte                     )
1602         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1603            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1604                 config_flags,                                    &
1605                 ids,ide, jds, jde, kds, kde,                     &
1606                 ims, ime, jms, jme, kms, kme,                    &
1607                 its, ite, jts, jte, kts, kte                     )
1609        ENDIF
1611 #if ( WRFPLUS == 1 )
1612 ! this is for WRFPlus only
1613 !-------------------------------
1614    CASE (DUCUSCHEME)
1615         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1616                 ids,ide, jds, jde, kds, kde,                     &
1617                 ims, ime, jms, jme, kms, kme,                    &
1618                 its, ite, jts, jte, kts, kte                     )
1620         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1621         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1622                 config_flags,                                    &
1623                 ids,ide, jds, jde, kds, kde,                     &
1624                 ims, ime, jms, jme, kms, kme,                    &
1625                 its, ite, jts, jte, kts, kte                     )
1627        IF(.not. adv_moist_cond)THEN
1629         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1630            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1631                 config_flags,                                    &
1632                 ids,ide, jds, jde, kds, kde,                     &
1633                 ims, ime, jms, jme, kms, kme,                    &
1634                 its, ite, jts, jte, kts, kte                     )
1636         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1637            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1638                 config_flags,                                    &
1639                 ids,ide, jds, jde, kds, kde,                     &
1640                 ims, ime, jms, jme, kms, kme,                    &
1641                 its, ite, jts, jte, kts, kte                     )
1643        ENDIF
1644 #endif
1646    CASE DEFAULT
1648    END SELECT
1650 END SUBROUTINE phy_cu_ten
1652 !=================================================================
1653 SUBROUTINE phy_shcu_ten(config_flags,rk_step,n_moist,n_scalar,   &
1654                       rt_tendf,ru_tendf,rv_tendf,                &
1655                       RUSHTEN,RVSHTEN,RTHSHTEN,                  &
1656                       RQVSHTEN,RQCSHTEN,RQRSHTEN,                &
1657                       RQISHTEN,RQSSHTEN,RQGSHTEN,RQCNSHTEN,      &
1658                       RQINSHTEN,moist_tendf,scalar_tendf,        &
1659                       ids, ide, jds, jde, kds, kde,              &
1660                       ims, ime, jms, jme, kms, kme,              &
1661                       its, ite, jts, jte, kts, kte               )
1662 !-----------------------------------------------------------------
1663    IMPLICIT NONE
1664 !-----------------------------------------------------------------
1665    TYPE(grid_config_rec_type  ) , INTENT(IN   ) :: config_flags
1667    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1668                                    ims, ime, jms, jme, kms, kme, &
1669                                    its, ite, jts, jte, kts, kte, &
1670                                    n_moist, n_scalar, rk_step
1672    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1673           INTENT(INOUT)     ::                      moist_tendf 
1675    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_scalar),         &
1676           INTENT(INOUT)     ::                      scalar_tendf
1678    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1679                                                         RUSHTEN, &
1680                                                         RVSHTEN, &
1681                                                        RTHSHTEN, &
1682                                                        RQVSHTEN, &
1683                                                        RQCSHTEN, &
1684                                                        RQRSHTEN, &
1685                                                        RQISHTEN, &
1686                                                        RQSSHTEN, &
1687                                                        RQGSHTEN, &
1688                                                       RQCNSHTEN, &
1689                                                       RQINSHTEN
1691    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) ::  &
1692                                                        rt_tendf, &
1693                                                        ru_tendf, &
1694                                                        rv_tendf
1696 ! LOCAL VARS
1698    INTEGER :: i,j,k
1700    SELECT CASE (config_flags%shcu_physics)
1702    CASE (CAMUWSHCUSCHEME)
1703         CALL add_a2c_u(ru_tendf,RUSHTEN,config_flags,            &
1704                 ids,ide, jds, jde, kds, kde,                     &
1705                 ims, ime, jms, jme, kms, kme,                    &
1706                 its, ite, jts, jte, kts, kte                     )
1708         CALL add_a2c_v(rv_tendf,RVSHTEN,config_flags,            &
1709                 ids,ide, jds, jde, kds, kde,                     &
1710                 ims, ime, jms, jme, kms, kme,                    &
1711                 its, ite, jts, jte, kts, kte                     )
1713         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1714                 ids,ide, jds, jde, kds, kde,                     &
1715                 ims, ime, jms, jme, kms, kme,                    &
1716                 its, ite, jts, jte, kts, kte                     )
1718         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1719         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1720                 config_flags,                                    &
1721                 ids,ide, jds, jde, kds, kde,                     &
1722                 ims, ime, jms, jme, kms, kme,                    &
1723                 its, ite, jts, jte, kts, kte                     )
1725         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1726         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
1727                 config_flags,                                    &
1728                 ids,ide, jds, jde, kds, kde,                     &
1729                 ims, ime, jms, jme, kms, kme,                    &
1730                 its, ite, jts, jte, kts, kte                     )
1732         if (P_QR .ge. PARAM_FIRST_SCALAR)                        &
1733         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRSHTEN,     &
1734                 config_flags,                                    &
1735                 ids,ide, jds, jde, kds, kde,                     &
1736                 ims, ime, jms, jme, kms, kme,                    &
1737                 its, ite, jts, jte, kts, kte                     )
1739         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1740         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQISHTEN,     &
1741                 config_flags,                                    &
1742                 ids,ide, jds, jde, kds, kde,                     &
1743                 ims, ime, jms, jme, kms, kme,                    &
1744                 its, ite, jts, jte, kts, kte                     )
1746         if (P_QS .ge. PARAM_FIRST_SCALAR)                        &
1747         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSSHTEN,     &
1748                 config_flags,                                    &
1749                 ids,ide, jds, jde, kds, kde,                     &
1750                 ims, ime, jms, jme, kms, kme,                    &
1751                 its, ite, jts, jte, kts, kte                     )
1753         if (P_QG .ge. PARAM_FIRST_SCALAR)                        &
1754         CALL add_a2a(moist_tendf(ims,kms,jms,P_QG),RQGSHTEN,     &
1755                 config_flags,                                    &
1756                 ids,ide, jds, jde, kds, kde,                     &
1757                 ims, ime, jms, jme, kms, kme,                    &
1758                 its, ite, jts, jte, kts, kte                     )
1759         if (P_QNC .ge. PARAM_FIRST_SCALAR)                       &
1760         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNC),RQCNSHTEN,  &
1761                 config_flags,                                    &
1762                 ids,ide, jds, jde, kds, kde,                     &
1763                 ims, ime, jms, jme, kms, kme,                    &
1764                 its, ite, jts, jte, kts, kte                     )
1765         if (P_QNI .ge. PARAM_FIRST_SCALAR)                       &
1766         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNI),RQINSHTEN,  &
1767                 config_flags,                                    &
1768                 ids,ide, jds, jde, kds, kde,                     &
1769                 ims, ime, jms, jme, kms, kme,                    &
1770                 its, ite, jts, jte, kts, kte                     )
1771         
1773    CASE (GRIMSSHCUSCHEME)
1774         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1775                 ids,ide, jds, jde, kds, kde,                     &
1776                 ims, ime, jms, jme, kms, kme,                    &
1777                 its, ite, jts, jte, kts, kte                     )
1779         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1780         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1781                 config_flags,                                    &
1782                 ids,ide, jds, jde, kds, kde,                     &
1783                 ims, ime, jms, jme, kms, kme,                    &
1784                 its, ite, jts, jte, kts, kte                     )
1786         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1787         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
1788                 config_flags,                                    &
1789                 ids,ide, jds, jde, kds, kde,                     &
1790                 ims, ime, jms, jme, kms, kme,                    &
1791                 its, ite, jts, jte, kts, kte                     )
1793         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1794         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQISHTEN,     &
1795                 config_flags,                                    &
1796                 ids,ide, jds, jde, kds, kde,                     &
1797                 ims, ime, jms, jme, kms, kme,                    &
1798                 its, ite, jts, jte, kts, kte                     )
1800    CASE (NSCVSHCUSCHEME)
1801         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1802                 ids,ide, jds, jde, kds, kde,                     &
1803                 ims, ime, jms, jme, kms, kme,                    &
1804                 its, ite, jts, jte, kts, kte                     )
1806         CALL add_a2c_u(ru_tendf,RUSHTEN,config_flags,            &
1807                 ids,ide, jds, jde, kds, kde,                     &
1808                 ims, ime, jms, jme, kms, kme,                    &
1809                 its, ite, jts, jte, kts, kte                     )
1811         CALL add_a2c_v(rv_tendf,RVSHTEN,config_flags,            &
1812                 ids,ide, jds, jde, kds, kde,                     &
1813                 ims, ime, jms, jme, kms, kme,                    &
1814                 its, ite, jts, jte, kts, kte                     )
1816         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1817         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1818                 config_flags,                                    &
1819                 ids,ide, jds, jde, kds, kde,                     &
1820                 ims, ime, jms, jme, kms, kme,                    &
1821                 its, ite, jts, jte, kts, kte                     )
1823         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1824         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
1825                 config_flags,                                    &
1826                 ids,ide, jds, jde, kds, kde,                     &
1827                 ims, ime, jms, jme, kms, kme,                    &
1828                 its, ite, jts, jte, kts, kte                     )
1830         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1831         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQISHTEN,     &
1832                 config_flags,                                    &
1833                 ids,ide, jds, jde, kds, kde,                     &
1834                 ims, ime, jms, jme, kms, kme,                    &
1835                 its, ite, jts, jte, kts, kte                     )
1837   CASE (DENGSHCUSCHEME)
1838         CALL add_a2c_u(ru_tendf,RUSHTEN,config_flags,            &
1839                 ids,ide, jds, jde, kds, kde,                     &
1840                 ims, ime, jms, jme, kms, kme,                    &
1841                 its, ite, jts, jte, kts, kte                     )
1843         CALL add_a2c_v(rv_tendf,RVSHTEN,config_flags,            &
1844                 ids,ide, jds, jde, kds, kde,                     &
1845                 ims, ime, jms, jme, kms, kme,                    &
1846                 its, ite, jts, jte, kts, kte                     )
1848         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1849                 ids,ide, jds, jde, kds, kde,                     &
1850                 ims, ime, jms, jme, kms, kme,                    &
1851                 its, ite, jts, jte, kts, kte                     )
1853         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1854         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1855                 config_flags,                                    &
1856                 ids,ide, jds, jde, kds, kde,                     &
1857                 ims, ime, jms, jme, kms, kme,                    &
1858                 its, ite, jts, jte, kts, kte                     )
1860         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1861         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
1862                 config_flags,                                    &
1863                 ids,ide, jds, jde, kds, kde,                     &
1864                 ims, ime, jms, jme, kms, kme,                    &
1865                 its, ite, jts, jte, kts, kte                     )
1867         if (P_QR .ge. PARAM_FIRST_SCALAR)                        &
1868         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRSHTEN,     &
1869                 config_flags,                                    &
1870                 ids,ide, jds, jde, kds, kde,                     &
1871                 ims, ime, jms, jme, kms, kme,                    &
1872                 its, ite, jts, jte, kts, kte                     )
1875    CASE DEFAULT
1877    END SELECT
1880 END SUBROUTINE phy_shcu_ten
1882 !=================================================================
1883 SUBROUTINE phy_fg_ten(config_flags,rk_step,n_moist,            &
1884                       rph_tendf,rt_tendf,ru_tendf,rv_tendf,    &
1885                       mu_tendf, moist_tendf,                   &
1886                       RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN,          &
1887                       RPHNDGDTEN,RQVNDGDTEN,RMUNDGDTEN,        &
1888                       ids, ide, jds, jde, kds, kde,              &
1889                       ims, ime, jms, jme, kms, kme,              &
1890                       its, ite, jts, jte, kts, kte               )
1891 !-----------------------------------------------------------------
1892    IMPLICIT NONE
1893 !-----------------------------------------------------------------
1894    TYPE(grid_config_rec_type) ,     INTENT(IN   ) :: config_flags
1896    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1897                                    ims, ime, jms, jme, kms, kme, &
1898                                    its, ite, jts, jte, kts, kte, &
1899                                    n_moist, rk_step
1901    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1902           INTENT(INOUT)     ::                      moist_tendf
1904    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1905                                                        RTHNDGDTEN, &
1906                                                        RPHNDGDTEN, &
1907                                                         RUNDGDTEN, &
1908                                                         RVNDGDTEN, &
1909                                                        RQVNDGDTEN
1911    REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN  ) ::  RMUNDGDTEN
1913    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT)::   &
1914                                                        rph_tendf,&
1915                                                        rt_tendf, &
1916                                                        ru_tendf, &
1917                                                        rv_tendf
1919    REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT)::  mu_tendf
1921 ! LOCAL VARS
1923    INTEGER :: i,j,k,IBGN,IEND,JBGN,JEND
1925 !-----------------------------------------------------------------
1927    SELECT CASE(config_flags%grid_fdda)
1929       CASE (PSUFDDAGD)
1931            CALL add_a2a(rt_tendf,RTHNDGDTEN,config_flags,        &
1932                 ids,ide, jds, jde, kds, kde,                     &
1933                 ims, ime, jms, jme, kms, kme,                    &
1934                 its, ite, jts, jte, kts, kte                     )
1936 ! note fdda u and v tendencies are staggered
1937            CALL add_c2c_u(ru_tendf,RUNDGDTEN,config_flags,       &
1938                 ids,ide, jds, jde, kds, kde,                     &
1939                 ims, ime, jms, jme, kms, kme,                    &
1940                 its, ite, jts, jte, kts, kte                     )
1942            CALL add_c2c_v(rv_tendf,RVNDGDTEN,config_flags,       &
1943                 ids,ide, jds, jde, kds, kde,                     &
1944                 ims, ime, jms, jme, kms, kme,                    &
1945                 its, ite, jts, jte, kts, kte                     )
1947            CALL add_a2a(mu_tendf,RMUNDGDTEN,config_flags,      &
1948                 ids,ide, jds, jde, kds, kds,                     &
1949                 ims, ime, jms, jme, kms, kms,                    &
1950                 its, ite, jts, jte, kts, kts                     )
1952         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1953            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVNDGDTEN,  &
1954                 config_flags,                                    &
1955                 ids,ide, jds, jde, kds, kde,                     &
1956                 ims, ime, jms, jme, kms, kme,                    &
1957                 its, ite, jts, jte, kts, kte                     )
1959       CASE (SPNUDGING)
1961 ! note fdda u and v tendencies are staggered
1962            CALL add_c2c_u(ru_tendf,RUNDGDTEN,config_flags,       &
1963                 ids,ide, jds, jde, kds, kde,                     &
1964                 ims, ime, jms, jme, kms, kme,                    &
1965                 its, ite, jts, jte, kts, kte                     )
1967            CALL add_c2c_v(rv_tendf,RVNDGDTEN,config_flags,       &
1968                 ids,ide, jds, jde, kds, kde,                     &
1969                 ims, ime, jms, jme, kms, kme,                    &
1970                 its, ite, jts, jte, kts, kte                     )
1972            CALL add_a2a(rt_tendf,RTHNDGDTEN,config_flags,        &
1973                 ids,ide, jds, jde, kds, kde,                     &
1974                 ims, ime, jms, jme, kms, kme,                    &
1975                 its, ite, jts, jte, kts, kte                     )
1977            CALL add_a2a_ph(rph_tendf,RPHNDGDTEN,config_flags,        &
1978                 ids,ide, jds, jde, kds, kde,                     &
1979                 ims, ime, jms, jme, kms, kme,                    &
1980                 its, ite, jts, jte, kts, kte                     )
1982         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1983            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVNDGDTEN,&
1984                 config_flags,                                    &
1985                 ids,ide, jds, jde, kds, kde,                     &
1986                 ims, ime, jms, jme, kms, kme,                    &
1987                 its, ite, jts, jte, kts, kte                     )
1989       CASE DEFAULT
1991    END SELECT
1993 END SUBROUTINE phy_fg_ten
1995 !=================================================================
1996 SUBROUTINE phy_fr_ten(config_flags,rk_step,n_moist,            &
1997                       rt_tendf,ru_tendf,rv_tendf,              &
1998                       mu_tendf, moist_tendf,                   &
1999                       rthfrten,rqvfrten,                       &
2000                       ids, ide, jds, jde, kds, kde,              &
2001                       ims, ime, jms, jme, kms, kme,              &
2002                       its, ite, jts, jte, kts, kte               )
2003 !-----------------------------------------------------------------
2004    USE module_state_description, ONLY :                         &
2005                    FIRE_SFIRE
2006 !-----------------------------------------------------------------
2007    IMPLICIT NONE
2008 !-----------------------------------------------------------------
2009    TYPE(grid_config_rec_type) ,     INTENT(IN   ) :: config_flags
2011    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
2012                                    ims, ime, jms, jme, kms, kme, &
2013                                    its, ite, jts, jte, kts, kte, &
2014                                    n_moist, rk_step
2016    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
2017           INTENT(INOUT)     ::                      moist_tendf
2019    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
2020                                                        rthfrten, &
2021                                                        rqvfrten 
2023    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT)::   &
2024                                                        rt_tendf, &
2025                                                        ru_tendf, &
2026                                                        rv_tendf
2028    REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT)::  mu_tendf
2030 ! LOCAL VARS
2032    INTEGER :: i,j,k,IBGN,IEND,JBGN,JEND
2034 !-----------------------------------------------------------------
2036    SELECT CASE(config_flags%ifire)
2038       CASE (FIRE_SFIRE)
2040            CALL add_a2a(rt_tendf,rthfrten,                       &
2041                 config_flags,                                    &
2042                 ids,ide, jds, jde, kds, kde,                     &
2043                 ims, ime, jms, jme, kms, kme,                    &
2044                 its, ite, jts, jte, kts, kte                     )
2046            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),rqvfrten,  &
2047                 config_flags,                                    &
2048                 ids,ide, jds, jde, kds, kde,                     &
2049                 ims, ime, jms, jme, kms, kme,                    &
2050                 its, ite, jts, jte, kts, kte                     )
2052       CASE DEFAULT
2054    END SELECT
2056 END SUBROUTINE phy_fr_ten
2058 !----------------------------------------------------------------------
2059 SUBROUTINE advance_ppt(RTHCUTEN,RQVCUTEN,RQCCUTEN,RQRCUTEN,           &
2060                      CLDFRA_CUP,                                      &     ! add LD 01/11/2012 !BSINGH -  Added for CuP
2061                      RQICUTEN,RQSCUTEN,                               &
2062                      RAINC,RAINCV,RAINSH,PRATEC,PRATESH,  &
2063                      NCA, HTOP,HBOT,CUTOP,CUBOT,                      &
2064                      CUPPT, DT, config_flags,                         &
2065                      ids,ide, jds,jde, kds,kde,                       &
2066                      ims,ime, jms,jme, kms,kme,                       &
2067                      its,ite, jts,jte, kts,kte                        )     
2068 !----------------------------------------------------------------------
2069    USE module_state_description
2070    USE module_cu_kf
2071    USE module_cu_kfeta
2072 #if ( WRFPLUS == 1 )
2073    USE module_cu_du              !  Added by Zhuxiao
2074 #endif
2075 !----------------------------------------------------------------------
2076    IMPLICIT NONE
2077 !----------------------------------------------------------------------
2078    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2080    INTEGER,      INTENT(IN   )    ::                             &
2081                                       ids,ide, jds,jde, kds,kde, &
2082                                       ims,ime, jms,jme, kms,kme, &
2083                                       its,ite, jts,jte, kts,kte
2086    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                 &
2087          INTENT(INOUT)  ::                             RTHCUTEN, &
2088                                                        RQVCUTEN, &
2089                                                        RQCCUTEN, &
2090                                                        RQRCUTEN, &
2091                                                        RQICUTEN, &
2092                                                        RQSCUTEN, &
2093                                                        CLDFRA_CUP        ! add LD 01/11/2012 !BSINGH - For CuP
2095    REAL, DIMENSION( ims:ime , jms:jme ),                         &
2096           INTENT(INOUT) ::                                RAINC, &
2097                                                          RAINSH, &
2098                                                          RAINCV, &
2099                                                          PRATEC, &
2100                                                         PRATESH, &
2101                                                             NCA, &
2102                                                            HTOP, &
2103                                                            HBOT, &
2104                                                           CUTOP, &
2105                                                           CUBOT, &
2106                                                           CUPPT
2107    REAL, INTENT(IN) ::                                       DT
2109 ! LOCAL  VAR
2111    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,k_start,k_end
2112    INTEGER :: NCUTOP, NCUBOT
2114 !-----------------------------------------------------------------
2116    IF (config_flags%cu_physics .eq. 0) return
2118 ! SET START AND END POINTS FOR TILES
2120    i_start = its
2121    i_end   = min( ite,ide-1 )
2122    j_start = jts
2123    j_end   = min( jte,jde-1 )
2125 !  IF( config_flags%nested .or. config_flags%specified ) THEN
2126 !    i_start = max( its,ids+1 )
2127 !    i_end   = min( ite,ide-2 )
2128 !    j_start = max( jts,jds+1 )
2129 !    j_end   = min( jte,jde-2 )
2130 !  ENDIF
2132    k_start = kts
2133    k_end = min( kte, kde-1 )
2135 ! Update total cumulus scheme precipitation
2137 ! in mm  
2139    DO J = j_start,j_end
2140    DO i = i_start,i_end
2141       RAINC(I,J)  = RAINC(I,J) + PRATEC(I,J)*DT
2142       RAINSH(I,J) = RAINSH(I,J) + PRATESH(I,J)*DT
2143       CUPPT(I,J)  = CUPPT(I,J) + (PRATEC(I,J)+PRATESH(I,J))*DT/1000.
2144    ENDDO
2145    ENDDO
2147    SELECT CASE (config_flags%cu_physics)
2149    CASE (KFSCHEME)
2151         DO J = j_start,j_end
2152         DO i = i_start,i_end
2154            IF ( NCA(I,J) .GT. 0 ) THEN
2156               IF ( NINT(NCA(I,J) / DT) .le. 0 ) THEN
2158               ! set tendency to zero
2159 !                PRATEC(I,J)=0.
2160 !                RAINCV(I,J)=0.
2161                  DO k = k_start,k_end
2162                     RTHCUTEN(i,k,j)=0.
2163                     RQVCUTEN(i,k,j)=0.
2164                     RQCCUTEN(i,k,j)=0.
2165                     RQRCUTEN(i,k,j)=0.
2166                     if (P_QI .ge. PARAM_FIRST_SCALAR) RQICUTEN(i,k,j)=0.
2167                     if (P_QS .ge. PARAM_FIRST_SCALAR) RQSCUTEN(i,k,j)=0.
2168                  ENDDO
2169               ENDIF
2171               NCA(I,J)=NCA(I,J)-DT ! Decrease NCA
2173            ENDIF
2175         ENDDO
2176         ENDDO
2178    CASE (BMJSCHEME, CAMZMSCHEME)
2180         DO J = j_start,j_end
2181         DO i = i_start,i_end
2183 ! HTOP, HBOT FOR GFDL RADIATION
2184            NCUTOP=NINT(CUTOP(I,J))
2185            NCUBOT=NINT(CUBOT(I,J))
2186            IF(NCUTOP>1.AND.NCUTOP<KDE)THEN
2187              HTOP(I,J)=MAX(CUTOP(I,J),HTOP(I,J))
2188            ENDIF
2189            IF(NCUBOT>0.AND.NCUBOT<KDE)THEN
2190              HBOT(I,J)=MIN(CUBOT(I,J),HBOT(I,J))
2191            ENDIF
2193         ENDDO
2194         ENDDO
2196    CASE (KFETASCHEME, MSKFSCHEME, KFCUPSCHEME)!BSINGH - added KFCUPSCHEME for CuP
2198         DO J = j_start,j_end
2199         DO i = i_start,i_end
2201 ! HTOP, HBOT FOR GFDL RADIATION
2202            NCUTOP=NINT(CUTOP(I,J))
2203            NCUBOT=NINT(CUBOT(I,J))
2204            IF(NCUTOP>1.AND.NCUTOP<KDE)THEN
2205              HTOP(I,J)=MAX(CUTOP(I,J),HTOP(I,J))
2206            ENDIF
2207            IF(NCUBOT>0.AND.NCUBOT<KDE)THEN
2208              HBOT(I,J)=MIN(CUBOT(I,J),HBOT(I,J))
2209            ENDIF
2211            IF ( NCA(I,J) .GT. 0 ) THEN
2213               IF ( NINT(NCA(I,J) / DT) .LE. 1 ) THEN
2215               ! set tendency to zero
2216 !                PRATEC(I,J)=0.
2217 !                RAINCV(I,J)=0.
2218                  DO k = k_start,k_end
2219                     RTHCUTEN(i,k,j)=0.
2220                     RQVCUTEN(i,k,j)=0.
2221                     RQCCUTEN(i,k,j)=0.
2222                     RQRCUTEN(i,k,j)=0.
2223                     if (P_QI .ge. PARAM_FIRST_SCALAR) RQICUTEN(i,k,j)=0.
2224                     if (P_QS .ge. PARAM_FIRST_SCALAR) RQSCUTEN(i,k,j)=0.
2225                  ENDDO
2226               ENDIF
2228               NCA(I,J)=NCA(I,J)-DT ! Decrease NCA
2229 !              NCA(I,J)=NCA(I,J)-1. ! Decrease NCA
2231            ENDIF
2233         ENDDO
2234         ENDDO
2236         IF ( config_flags%cu_physics == kfcupscheme ) THEN
2237            DO J = j_start,j_end
2238            DO i = i_start,i_end
2239              IF ( NCA(I,J) .GT. 0 ) THEN
2240               IF ( NINT(NCA(I,J) / DT) .LE. 1 ) THEN
2241                  DO k = k_start,k_end
2242                     CLDFRA_CUP(i,k,j)=0. ! By LKB 12/22/11 01/11/2012 !BSINGH - For CuP
2243                  ENDDO
2244               ENDIF
2245              ENDIF
2246            ENDDO
2247            ENDDO
2248         ENDIF
2250 #if ( WRFPLUS == 1 )
2251 ! this is for WRFPlus only
2252 !---------------------------
2253    CASE (DUCUSCHEME)
2255         DO J = j_start,j_end
2256         DO i = i_start,i_end
2258            IF ( NCA(I,J) .GT. 0 ) THEN
2260               IF ( NINT(NCA(I,J) / DT) .le. 0 ) THEN
2262               ! set tendency to zero
2263 !!                PRATEC(I,J)=0.
2264 !!                RAINCV(I,J)=0.
2265                  DO k = k_start,k_end
2266                     RTHCUTEN(i,k,j)=0.
2267                     RQVCUTEN(i,k,j)=0.
2268                  ENDDO
2269                ENDIF
2271               NCA(I,J)=NCA(I,J)-DT ! Decrease NCA
2273            ENDIF
2275         ENDDO
2276         ENDDO
2277 #endif
2279    CASE DEFAULT
2281    END SELECT
2283 END SUBROUTINE advance_ppt
2285 SUBROUTINE add_a2a(lvar,rvar,config_flags,                  &
2286                    ids,ide, jds, jde, kds, kde,             &
2287                    ims, ime, jms, jme, kms, kme,            &
2288                    its, ite, jts, jte, kts, kte             )
2289 !------------------------------------------------------------
2290    IMPLICIT NONE
2291 !------------------------------------------------------------
2292    TYPE(grid_config_rec_type),  INTENT(IN) :: config_flags
2294    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2295                               ims, ime, jms, jme, kms, kme, &
2296                               its, ite, jts, jte, kts, kte
2298    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2299                                                       rvar
2300    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2301                                                       lvar
2303 ! LOCAL VARS
2304    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2306    i_start = its
2307    i_end   = MIN(ite,ide-1)
2308    j_start = jts
2309    j_end   = MIN(jte,jde-1)
2310    ktf = min(kte,kde-1)
2312    IF ( config_flags%specified .or. &
2313         config_flags%nested) i_start = MAX(ids+1,its)
2314    IF ( config_flags%specified .or. &
2315         config_flags%nested) i_end   = MIN(ide-2,ite)
2316    IF ( config_flags%specified .or. &
2317         config_flags%nested) j_start = MAX(jds+1,jts)
2318    IF ( config_flags%specified .or. &
2319         config_flags%nested) j_end   = MIN(jde-2,jte)
2320       IF ( config_flags%periodic_x ) i_start = its
2321       IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
2323    DO j = j_start,j_end
2324    DO k = kts,ktf
2325    DO i = i_start,i_end
2326       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2327    ENDDO
2328    ENDDO
2329    ENDDO
2331 END SUBROUTINE add_a2a
2333 SUBROUTINE add_a2a_ph(lvar,rvar,config_flags,                  &
2334                    ids,ide, jds, jde, kds, kde,             &
2335                    ims, ime, jms, jme, kms, kme,            &
2336                    its, ite, jts, jte, kts, kte             )
2337 !------------------------------------------------------------
2338    IMPLICIT NONE
2339 !------------------------------------------------------------
2340    TYPE(grid_config_rec_type),  INTENT(IN) :: config_flags
2342    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2343                               ims, ime, jms, jme, kms, kme, &
2344                               its, ite, jts, jte, kts, kte
2346    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2347                                                       rvar
2348    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2349                                                       lvar
2351 ! LOCAL VARS
2352    INTEGER :: i,j,k,i_start,i_end,j_start,j_end
2354    i_start = its
2355    i_end   = MIN(ite,ide-1)
2356    j_start = jts
2357    j_end   = MIN(jte,jde-1)
2359    IF ( config_flags%specified .or. &
2360         config_flags%nested) i_start = MAX(ids+1,its)
2361    IF ( config_flags%specified .or. &
2362         config_flags%nested) i_end   = MIN(ide-2,ite)
2363    IF ( config_flags%specified .or. &
2364         config_flags%nested) j_start = MAX(jds+1,jts)
2365    IF ( config_flags%specified .or. &
2366         config_flags%nested) j_end   = MIN(jde-2,jte)
2367       IF ( config_flags%periodic_x ) i_start = its
2368       IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
2370    DO j = j_start,j_end
2371    DO k = kts,kte
2372    DO i = i_start,i_end
2373       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2374    ENDDO
2375    ENDDO
2376    ENDDO
2378 END SUBROUTINE add_a2a_ph
2380 !------------------------------------------------------------
2381 SUBROUTINE add_a2c_u(lvar,rvar,config_flags,                &
2382                    ids,ide, jds, jde, kds, kde,             &
2383                    ims, ime, jms, jme, kms, kme,            &
2384                    its, ite, jts, jte, kts, kte             )
2385 !------------------------------------------------------------
2386 !------------------------------------------------------------
2387    IMPLICIT NONE
2388 !------------------------------------------------------------
2390    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2392    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2393                               ims, ime, jms, jme, kms, kme, &
2394                               its, ite, jts, jte, kts, kte
2396    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2397                                                       rvar
2398    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2399                                                       lvar
2401 ! LOCAL VARS
2403    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2405    ktf=min(kte,kde-1)
2407    i_start = its
2408    i_end   = ite
2409    j_start = jts
2410    j_end   = MIN(jte,jde-1)
2412    IF ( config_flags%specified .or. &
2413         config_flags%nested) i_start = MAX(ids+1,its)
2414    IF ( config_flags%specified .or. &
2415         config_flags%nested) i_end   = MIN(ide-1,ite)
2416    IF ( config_flags%specified .or. &
2417         config_flags%nested) j_start = MAX(jds+1,jts)
2418    IF ( config_flags%specified .or. &
2419         config_flags%nested) j_end   = MIN(jde-2,jte)
2420       IF ( config_flags%periodic_x ) i_start = its
2421       IF ( config_flags%periodic_x ) i_end = ite
2423    DO j = j_start,j_end
2424    DO k = kts,ktf
2425    DO i = i_start,i_end
2426       lvar(i,k,j) = lvar(i,k,j) + &
2427                        0.5*(rvar(i,k,j)+rvar(i-1,k,j))
2428    ENDDO
2429    ENDDO
2430    ENDDO
2432 END SUBROUTINE add_a2c_u
2434 !------------------------------------------------------------
2435 SUBROUTINE add_a2c_v(lvar,rvar,config_flags,                &
2436                    ids,ide, jds, jde, kds, kde,             &
2437                    ims, ime, jms, jme, kms, kme,            &
2438                    its, ite, jts, jte, kts, kte             )
2439 !------------------------------------------------------------
2440 !------------------------------------------------------------
2441    IMPLICIT NONE
2442 !------------------------------------------------------------
2444    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2446    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2447                               ims, ime, jms, jme, kms, kme, &
2448                               its, ite, jts, jte, kts, kte
2450    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2451                                                       rvar
2452    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2453                                                       lvar
2455 ! LOCAL VARS
2457    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2459    ktf=min(kte,kde-1)
2461    i_start = its
2462    i_end   = MIN(ite,ide-1)
2463    j_start = jts
2464    j_end   = jte
2466    IF ( config_flags%specified .or. &
2467         config_flags%nested) i_start = MAX(ids+1,its)
2468    IF ( config_flags%specified .or. &
2469         config_flags%nested) i_end   = MIN(ide-2,ite)
2470    IF ( config_flags%specified .or. &
2471         config_flags%nested) j_start = MAX(jds+1,jts)
2472    IF ( config_flags%specified .or. &
2473         config_flags%nested) j_end   = MIN(jde-1,jte)
2474       IF ( config_flags%periodic_x ) i_start = its
2475       IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
2477    DO j = j_start,j_end
2478    DO k = kts,kte
2479    DO i = i_start,i_end
2480       lvar(i,k,j) = lvar(i,k,j) + &
2481                      0.5*(rvar(i,k,j)+rvar(i,k,j-1))
2482    ENDDO
2483    ENDDO
2484    ENDDO
2486 END SUBROUTINE add_a2c_v
2488 !------------------------------------------------------------
2489 SUBROUTINE add_c2c_u(lvar,rvar,config_flags,                &
2490                    ids,ide, jds, jde, kds, kde,             &
2491                    ims, ime, jms, jme, kms, kme,            &
2492                    its, ite, jts, jte, kts, kte             )
2493 !------------------------------------------------------------
2494 !------------------------------------------------------------
2495    IMPLICIT NONE
2496 !------------------------------------------------------------
2498    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2500    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2501                               ims, ime, jms, jme, kms, kme, &
2502                               its, ite, jts, jte, kts, kte
2504    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2505                                                       rvar
2506    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2507                                                       lvar
2509 ! LOCAL VARS
2511    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2513    ktf=min(kte,kde-1)
2515    i_start = its
2516    i_end   = ite
2517    j_start = jts
2518    j_end   = MIN(jte,jde-1)
2521    IF ( config_flags%specified .or. &
2522         config_flags%nested) i_start = MAX(ids+1,its)
2523    IF ( config_flags%specified .or. &
2524         config_flags%nested) i_end   = MIN(ide-1,ite)
2525    IF ( config_flags%specified .or. &
2526         config_flags%nested) j_start = MAX(jds+1,jts)
2527    IF ( config_flags%specified .or. &
2528         config_flags%nested) j_end   = MIN(jde-2,jte)
2530 !  write(*,'(a,6i4)') 'call c2cu, i_start, i_end, j_start, j_end=', i_start, i_end, j_start, j_end
2532    DO j = j_start,j_end
2533    DO k = kts,ktf
2534    DO i = i_start,i_end
2535       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2536    ENDDO
2537    ENDDO
2538    ENDDO
2540 END SUBROUTINE add_c2c_u
2542 SUBROUTINE add_c2c_v(lvar,rvar,config_flags,                &
2543                    ids,ide, jds, jde, kds, kde,             &
2544                    ims, ime, jms, jme, kms, kme,            &
2545                    its, ite, jts, jte, kts, kte             )
2546 !------------------------------------------------------------
2547 !------------------------------------------------------------
2548    IMPLICIT NONE
2549 !------------------------------------------------------------
2551    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2553    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2554                               ims, ime, jms, jme, kms, kme, &
2555                               its, ite, jts, jte, kts, kte
2557    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2558                                                       rvar
2559    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2560                                                       lvar
2562 ! LOCAL VARS
2564    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2566    ktf=min(kte,kde-1)
2568    i_start = its
2569    i_end   = MIN(ite,ide-1)
2570    j_start = jts
2571    j_end   = jte
2573    IF ( config_flags%specified .or. &
2574         config_flags%nested) i_start = MAX(ids+1,its)
2575    IF ( config_flags%specified .or. &
2576         config_flags%nested) i_end   = MIN(ide-2,ite)
2577    IF ( config_flags%specified .or. &
2578         config_flags%nested) j_start = MAX(jds+1,jts)
2579    IF ( config_flags%specified .or. &
2580         config_flags%nested) j_end   = MIN(jde-1,jte)
2582 !  write(*,'(a,6i4)') 'call c2cv, i_start, i_end, j_start, j_end=', i_start, i_end, j_start, j_end
2584    DO j = j_start,j_end
2585    DO k = kts,kte
2586    DO i = i_start,i_end
2587       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2588    ENDDO
2589    ENDDO
2590    ENDDO
2592 END SUBROUTINE add_c2c_v
2594 #endif
2596 END MODULE module_physics_addtendc