Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-Fire-merge.git] / phys / module_physics_addtendc.F
blobb8756cb2c5c529691137c5e3efc8c43dc3e662b7
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 (MYNNPBLSCHEME2,MYNNPBLSCHEME3)
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 (BOULACSCHEME)
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
832        CASE (CAMUWPBLSCHEME)
833            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
834                 ids,ide, jds, jde, kds, kde,                     &
835                 ims, ime, jms, jme, kms, kme,                    &
836                 its, ite, jts, jte, kts, kte                     )
838            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
839                 ids,ide, jds, jde, kds, kde,                     &
840                 ims, ime, jms, jme, kms, kme,                    &
841                 its, ite, jts, jte, kts, kte                     )
843            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
844                 ids,ide, jds, jde, kds, kde,                     &
845                 ims, ime, jms, jme, kms, kme,                    &
846                 its, ite, jts, jte, kts, kte                     )
848         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
849            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
850                 config_flags,                                    &
851                 ids,ide, jds, jde, kds, kde,                     &
852                 ims, ime, jms, jme, kms, kme,                    &
853                 its, ite, jts, jte, kts, kte                     )
855        IF(.not. adv_moist_cond)THEN
857         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
858            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCBLTEN,  &
859                 config_flags,                                    &
860                 ids,ide, jds, jde, kds, kde,                     &
861                 ims, ime, jms, jme, kms, kme,                    &
862                 its, ite, jts, jte, kts, kte                     )
864         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
865              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice mass mixing ratio
866            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQIBLTEN,  &
867                 config_flags,                                    &
868                 ids,ide, jds, jde, kds, kde,                     &
869                 ims, ime, jms, jme, kms, kme,                    &
870                 its, ite, jts, jte, kts, kte                     )
871         if (P_QT .ge. PARAM_FIRST_SCALAR)                                         &
872              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice  number mixing ratio
873            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQNIBLTEN,&
874                config_flags,                                    &
875                ids,ide, jds, jde, kds, kde,                     &
876                ims, ime, jms, jme, kms, kme,                    &
877                its, ite, jts, jte, kts, kte                     )
878        ELSE
880         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
881            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
882                 config_flags,                                    &
883                 ids,ide, jds, jde, kds, kde,                     &
884                 ims, ime, jms, jme, kms, kme,                    &
885                 its, ite, jts, jte, kts, kte                     )
886         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
887              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice mass mixing ratio
888            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
889                 config_flags,                                    &
890                 ids,ide, jds, jde, kds, kde,                     &
891                 ims, ime, jms, jme, kms, kme,                    &
892                 its, ite, jts, jte, kts, kte                     )
893         if (P_QNI .ge. PARAM_FIRST_SCALAR)                                         &
894              !Balwinder.Singh@pnnl.gov : Diffuse or mix cloud ice  number mixing ratio
895            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNI),RQNIBLTEN,&
896                 config_flags,                                    &
897                 ids,ide, jds, jde, kds, kde,                     &
898                 ims, ime, jms, jme, kms, kme,                    &
899                 its, ite, jts, jte, kts, kte                     )
900        ENDIF
903       CASE (TEMFPBLSCHEME)
904            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
905                 ids,ide, jds, jde, kds, kde,                     &
906                 ims, ime, jms, jme, kms, kme,                    &
907                 its, ite, jts, jte, kts, kte                     )
909            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
910                 ids,ide, jds, jde, kds, kde,                     &
911                 ims, ime, jms, jme, kms, kme,                    &
912                 its, ite, jts, jte, kts, kte                     )
914            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
915                 ids,ide, jds, jde, kds, kde,                     &
916                 ims, ime, jms, jme, kms, kme,                    &
917                 its, ite, jts, jte, kts, kte                     )
919         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
920            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
921                 config_flags,                                    &
922                 ids,ide, jds, jde, kds, kde,                     &
923                 ims, ime, jms, jme, kms, kme,                    &
924                 its, ite, jts, jte, kts, kte                     )
926         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
927            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
928                 config_flags,                                    &
929                 ids,ide, jds, jde, kds, kde,                     &
930                 ims, ime, jms, jme, kms, kme,                    &
931                 its, ite, jts, jte, kts, kte                     )
932      
933         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
934            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
935                 config_flags,                                    &
936                 ids,ide, jds, jde, kds, kde,                     &
937                 ims, ime, jms, jme, kms, kme,                    &
938                 its, ite, jts, jte, kts, kte                     )
940       CASE (GBMPBLSCHEME)
941            CALL add_a2a(rt_tendf,RTHBLTEN,config_flags,          &
942                 ids,ide, jds, jde, kds, kde,                     &
943                 ims, ime, jms, jme, kms, kme,                    &
944                 its, ite, jts, jte, kts, kte                     )
946            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
947                 ids,ide, jds, jde, kds, kde,                     &
948                 ims, ime, jms, jme, kms, kme,                    &
949                 its, ite, jts, jte, kts, kte                     )
951            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
952                 ids,ide, jds, jde, kds, kde,                     &
953                 ims, ime, jms, jme, kms, kme,                    &
954                 its, ite, jts, jte, kts, kte                     )
956         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
957            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVBLTEN,  &
958                 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_QC .ge. PARAM_FIRST_SCALAR)                                         &
964            CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCBLTEN,  &
965                 config_flags,                                    &
966                 ids,ide, jds, jde, kds, kde,                     &
967                 ims, ime, jms, jme, kms, kme,                    &
968                 its, ite, jts, jte, kts, kte                     )
969      
970         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
971            CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQIBLTEN,  &
972                 config_flags,                                    &
973                 ids,ide, jds, jde, kds, kde,                     &
974                 ims, ime, jms, jme, kms, kme,                    &
975                 its, ite, jts, jte, kts, kte                     )
977 #if ( WRFPLUS == 1 )
978 ! this is for WRFPlus only
979 !---------------------------
980       CASE (SURFDRAGSCHEME)
982            CALL add_a2c_u(ru_tendf,RUBLTEN,config_flags,         &
983                 ids,ide, jds, jde, kds, kde,                     &
984                 ims, ime, jms, jme, kms, kme,                    &
985                 its, ite, jts, jte, kts, kte                     )
987            CALL add_a2c_v(rv_tendf,RVBLTEN,config_flags,         &
988                 ids,ide, jds, jde, kds, kde,                     &
989                 ims, ime, jms, jme, kms, kme,                    &
990                 its, ite, jts, jte, kts, kte                     )
991 #endif
993       CASE DEFAULT
995        print*,'phy_bl_ten: The pbl scheme does not exist'
997    END SELECT
999 END SUBROUTINE phy_bl_ten
1001 !=================================================================
1002 SUBROUTINE phy_cu_ten(config_flags,rk_step,n_moist,n_scalar,     &
1003                       rt_tendf,ru_tendf,rv_tendf,                &
1004                       RUCUTEN,RVCUTEN,RTHCUTEN,                  &
1005                       RQVCUTEN,RQCCUTEN,RQRCUTEN,                &
1006                       RQICUTEN,RQSCUTEN,RQCNCUTEN,RQINCUTEN,     &
1007                       moist_tendf,                               &
1008                       scalar_tendf,adv_moist_cond,               &
1009                       ids, ide, jds, jde, kds, kde,              &
1010                       ims, ime, jms, jme, kms, kme,              &
1011                       its, ite, jts, jte, kts, kte               )
1012 !-----------------------------------------------------------------
1013    IMPLICIT NONE
1014 !-----------------------------------------------------------------
1015    TYPE(grid_config_rec_type  ) , INTENT(IN   ) :: config_flags
1017    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1018                                    ims, ime, jms, jme, kms, kme, &
1019                                    its, ite, jts, jte, kts, kte, &
1020                                    n_moist, n_scalar, rk_step
1022    LOGICAL , INTENT(IN)     :: adv_moist_cond
1024    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1025           INTENT(INOUT)     ::                      moist_tendf
1027    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_scalar),         &
1028           INTENT(INOUT)     ::                      scalar_tendf
1030    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1031                                                         RUCUTEN, &
1032                                                         RVCUTEN, &
1033                                                        RTHCUTEN, &
1034                                                        RQVCUTEN, &
1035                                                        RQCCUTEN, &
1036                                                        RQRCUTEN, &
1037                                                        RQICUTEN, &
1038                                                        RQSCUTEN, &
1039                                                       RQCNCUTEN, &
1040                                                       RQINCUTEN
1042    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) ::  &
1043                                                        rt_tendf, &
1044                                                        ru_tendf, &
1045                                                        rv_tendf
1048 ! LOCAL VARS
1050    INTEGER :: i,j,k
1052    SELECT CASE (config_flags%cu_physics)   
1054    CASE (KFSCHEME)
1055         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1056                 ids,ide, jds, jde, kds, kde,                     &
1057                 ims, ime, jms, jme, kms, kme,                    &
1058                 its, ite, jts, jte, kts, kte                     )
1060         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1061         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1062                 config_flags,                                    &
1063                 ids,ide, jds, jde, kds, kde,                     &
1064                 ims, ime, jms, jme, kms, kme,                    &
1065                 its, ite, jts, jte, kts, kte                     )
1067         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1068         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1069                 config_flags,                                    &
1070                 ids,ide, jds, jde, kds, kde,                     &
1071                 ims, ime, jms, jme, kms, kme,                    &
1072                 its, ite, jts, jte, kts, kte                     )
1074         if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
1075         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRCUTEN,     &
1076                 config_flags,                                    &
1077                 ids,ide, jds, jde, kds, kde,                     &
1078                 ims, ime, jms, jme, kms, kme,                    &
1079                 its, ite, jts, jte, kts, kte                     )
1081         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1082         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1083                 config_flags,                                    &
1084                 ids,ide, jds, jde, kds, kde,                     &
1085                 ims, ime, jms, jme, kms, kme,                    &
1086                 its, ite, jts, jte, kts, kte                     )
1088         if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
1089         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN,     &
1090                 config_flags,                                    &
1091                 ids,ide, jds, jde, kds, kde,                     &
1092                 ims, ime, jms, jme, kms, kme,                    &
1093                 its, ite, jts, jte, kts, kte                     )
1095        IF(.not. adv_moist_cond)THEN
1097         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1098            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1099                 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_QT .ge. PARAM_FIRST_SCALAR)                        &
1105            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRCUTEN, &
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_QT .ge. PARAM_FIRST_SCALAR)                        &
1112            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
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_QT .ge. PARAM_FIRST_SCALAR)                        &
1119            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSCUTEN, &
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        ENDIF
1127    CASE (BMJSCHEME)
1128         CALL add_a2a(rt_tendf,RTHCUTEN,                          &
1129                 config_flags,                                    &
1130                 ids,ide, jds, jde, kds, kde,                     &
1131                 ims, ime, jms, jme, kms, kme,                    &
1132                 its, ite, jts, jte, kts, kte                     )
1134         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1135         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1136                 config_flags,                                    &
1137                 ids,ide, jds, jde, kds, kde,                     &
1138                 ims, ime, jms, jme, kms, kme,                    &
1139                 its, ite, jts, jte, kts, kte                     )
1141    CASE (KFETASCHEME, KFCUPSCHEME)!BSINGH -  Added KFCUPSCHEME for CuP
1142         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1143                 ids,ide, jds, jde, kds, kde,                     &
1144                 ims, ime, jms, jme, kms, kme,                    &
1145                 its, ite, jts, jte, kts, kte                     )
1147         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1148         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1149                 config_flags,                                    &
1150                 ids,ide, jds, jde, kds, kde,                     &
1151                 ims, ime, jms, jme, kms, kme,                    &
1152                 its, ite, jts, jte, kts, kte                     )
1154         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1155         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1156                 config_flags,                                    &
1157                 ids,ide, jds, jde, kds, kde,                     &
1158                 ims, ime, jms, jme, kms, kme,                    &
1159                 its, ite, jts, jte, kts, kte                     )
1161         if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
1162         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRCUTEN,     &
1163                 config_flags,                                    &
1164                 ids,ide, jds, jde, kds, kde,                     &
1165                 ims, ime, jms, jme, kms, kme,                    &
1166                 its, ite, jts, jte, kts, kte                     )
1168         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1169         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1170                 config_flags,                                    &
1171                 ids,ide, jds, jde, kds, kde,                     &
1172                 ims, ime, jms, jme, kms, kme,                    &
1173                 its, ite, jts, jte, kts, kte                     )
1175         if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
1176         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN,     &
1177                 config_flags,                                    &
1178                 ids,ide, jds, jde, kds, kde,                     &
1179                 ims, ime, jms, jme, kms, kme,                    &
1180                 its, ite, jts, jte, kts, kte                     )
1182        IF(.not. adv_moist_cond)THEN
1184         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1185            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1186                 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_QT .ge. PARAM_FIRST_SCALAR)                        &
1192            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRCUTEN, &
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_QT .ge. PARAM_FIRST_SCALAR)                        &
1199            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
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_QT .ge. PARAM_FIRST_SCALAR)                        &
1206            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSCUTEN, &
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        ENDIF
1214    CASE (MSKFSCHEME)!JTR: Separate MSKF for cmt
1215         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1216                 ids,ide, jds, jde, kds, kde,                     &
1217                 ims, ime, jms, jme, kms, kme,                    &
1218                 its, ite, jts, jte, kts, kte                     )
1220         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1221                 ids,ide, jds, jde, kds, kde,                     &
1222                 ims, ime, jms, jme, kms, kme,                    &
1223                 its, ite, jts, jte, kts, kte                     )
1225         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1226                 ids,ide, jds, jde, kds, kde,                     &
1227                 ims, ime, jms, jme, kms, kme,                    &
1228                 its, ite, jts, jte, kts, kte                     )
1230         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1231         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1232                 config_flags,                                    &
1233                 ids,ide, jds, jde, kds, kde,                     &
1234                 ims, ime, jms, jme, kms, kme,                    &
1235                 its, ite, jts, jte, kts, kte                     )
1237         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1238         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1239                 config_flags,                                    &
1240                 ids,ide, jds, jde, kds, kde,                     &
1241                 ims, ime, jms, jme, kms, kme,                    &
1242                 its, ite, jts, jte, kts, kte                     )
1244         if (P_QR .ge. PARAM_FIRST_SCALAR)                                         &
1245         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRCUTEN,     &
1246                 config_flags,                                    &
1247                 ids,ide, jds, jde, kds, kde,                     &
1248                 ims, ime, jms, jme, kms, kme,                    &
1249                 its, ite, jts, jte, kts, kte                     )
1251         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1252         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1253                 config_flags,                                    &
1254                 ids,ide, jds, jde, kds, kde,                     &
1255                 ims, ime, jms, jme, kms, kme,                    &
1256                 its, ite, jts, jte, kts, kte                     )
1258         if (P_QS .ge. PARAM_FIRST_SCALAR)                                         &
1259         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSCUTEN,     &
1260                 config_flags,                                    &
1261                 ids,ide, jds, jde, kds, kde,                     &
1262                 ims, ime, jms, jme, kms, kme,                    &
1263                 its, ite, jts, jte, kts, kte                     )
1265        IF(.not. adv_moist_cond)THEN
1267         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1268            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1269                 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_QT .ge. PARAM_FIRST_SCALAR)                        &
1275            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQRCUTEN, &
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_QT .ge. PARAM_FIRST_SCALAR)                        &
1282            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
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_QT .ge. PARAM_FIRST_SCALAR)                        &
1289            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQSCUTEN, &
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        ENDIF
1298    CASE (GDSCHEME, G3SCHEME, GFSCHEME)
1299         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1300                 ids,ide, jds, jde, kds, kde,                     &
1301                 ims, ime, jms, jme, kms, kme,                    &
1302                 its, ite, jts, jte, kts, kte                     )
1304         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1305         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1306                 config_flags,                                    &
1307                 ids,ide, jds, jde, kds, kde,                     &
1308                 ims, ime, jms, jme, kms, kme,                    &
1309                 its, ite, jts, jte, kts, kte                     )
1311         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1312         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),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_QI .ge. PARAM_FIRST_SCALAR)                                         &
1319         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
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(.not. adv_moist_cond)THEN
1327         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1328            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1329                 config_flags,                                    &
1330                 ids,ide, jds, jde, kds, kde,                     &
1331                 ims, ime, jms, jme, kms, kme,                    &
1332                 its, ite, jts, jte, kts, kte                     )
1334         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1335            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1336                 config_flags,                                    &
1337                 ids,ide, jds, jde, kds, kde,                     &
1338                 ims, ime, jms, jme, kms, kme,                    &
1339                 its, ite, jts, jte, kts, kte                     )
1341        ENDIF
1343    CASE (KSASSCHEME,NSASSCHEME)
1344         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1345                 ids,ide, jds, jde, kds, kde,                     &
1346                 ims, ime, jms, jme, kms, kme,                    &
1347                 its, ite, jts, jte, kts, kte                     )
1349         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1350                 ids,ide, jds, jde, kds, kde,                     &
1351                 ims, ime, jms, jme, kms, kme,                    &
1352                 its, ite, jts, jte, kts, kte                     )
1354         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1355                 ids,ide, jds, jde, kds, kde,                     &
1356                 ims, ime, jms, jme, kms, kme,                    &
1357                 its, ite, jts, jte, kts, kte                     )
1359         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1360         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1361                 config_flags,                                    &
1362                 ids,ide, jds, jde, kds, kde,                     &
1363                 ims, ime, jms, jme, kms, kme,                    &
1364                 its, ite, jts, jte, kts, kte                     )
1366         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1367         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1368                 config_flags,                                    &
1369                 ids,ide, jds, jde, kds, kde,                     &
1370                 ims, ime, jms, jme, kms, kme,                    &
1371                 its, ite, jts, jte, kts, kte                     )
1373         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1374         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1375                 config_flags,                                    &
1376                 ids,ide, jds, jde, kds, kde,                     &
1377                 ims, ime, jms, jme, kms, kme,                    &
1378                 its, ite, jts, jte, kts, kte                     )
1380        IF(.not. adv_moist_cond)THEN
1382         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1383            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1384                 config_flags,                                    &
1385                 ids,ide, jds, jde, kds, kde,                     &
1386                 ims, ime, jms, jme, kms, kme,                    &
1387                 its, ite, jts, jte, kts, kte                     )
1389         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1390            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1391                 config_flags,                                    &
1392                 ids,ide, jds, jde, kds, kde,                     &
1393                 ims, ime, jms, jme, kms, kme,                    &
1394                 its, ite, jts, jte, kts, kte                     )
1396        ENDIF
1398    CASE (SASSCHEME,OSASSCHEME,SCALESASSCHEME)
1399         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1400                 ids,ide, jds, jde, kds, kde,                     &
1401                 ims, ime, jms, jme, kms, kme,                    &
1402                 its, ite, jts, jte, kts, kte                     )
1404         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1405         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1406                 config_flags,                                    &
1407                 ids,ide, jds, jde, kds, kde,                     &
1408                 ims, ime, jms, jme, kms, kme,                    &
1409                 its, ite, jts, jte, kts, kte                     )
1410           
1411         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1412         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1413                 config_flags,                                    &
1414                 ids,ide, jds, jde, kds, kde,                     &
1415                 ims, ime, jms, jme, kms, kme,                    &
1416                 its, ite, jts, jte, kts, kte                     )
1417           
1418         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1419         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1420                 config_flags,                                    &
1421                 ids,ide, jds, jde, kds, kde,                     &
1422                 ims, ime, jms, jme, kms, kme,                    &
1423                 its, ite, jts, jte, kts, kte                     )
1425        IF(.not. adv_moist_cond)THEN
1427         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1428            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1429                 config_flags,                                    &
1430                 ids,ide, jds, jde, kds, kde,                     &
1431                 ims, ime, jms, jme, kms, kme,                    &
1432                 its, ite, jts, jte, kts, kte                     )
1434         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1435            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1436                 config_flags,                                    &
1437                 ids,ide, jds, jde, kds, kde,                     &
1438                 ims, ime, jms, jme, kms, kme,                    &
1439                 its, ite, jts, jte, kts, kte                     )
1441        ENDIF
1443    CASE (CAMZMSCHEME)
1444         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1445                 ids,ide, jds, jde, kds, kde,                     &
1446                 ims, ime, jms, jme, kms, kme,                    &
1447                 its, ite, jts, jte, kts, kte                     )
1449         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1450                 ids,ide, jds, jde, kds, kde,                     &
1451                 ims, ime, jms, jme, kms, kme,                    &
1452                 its, ite, jts, jte, kts, kte                     )
1454         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1455                 ids,ide, jds, jde, kds, kde,                     &
1456                 ims, ime, jms, jme, kms, kme,                    &
1457                 its, ite, jts, jte, kts, kte                     )
1458                                                                                                                                         
1459         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1460         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1461                 config_flags,                                    &
1462                 ids,ide, jds, jde, kds, kde,                     &
1463                 ims, ime, jms, jme, kms, kme,                    &
1464                 its, ite, jts, jte, kts, kte                     )
1465           
1466         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1467         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1468                 config_flags,                                    &
1469                 ids,ide, jds, jde, kds, kde,                     &
1470                 ims, ime, jms, jme, kms, kme,                    &
1471                 its, ite, jts, jte, kts, kte                     )
1472           
1473         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1474         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1475                 config_flags,                                    &
1476                 ids,ide, jds, jde, kds, kde,                     &
1477                 ims, ime, jms, jme, kms, kme,                    &
1478                 its, ite, jts, jte, kts, kte                     )
1480         if (P_QNC .ge. PARAM_FIRST_SCALAR)                       &!BSINGH - QNC scalar
1481         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNC),RQCNCUTEN,  &
1482                 config_flags,                                    &
1483                 ids,ide, jds, jde, kds, kde,                     &
1484                 ims, ime, jms, jme, kms, kme,                    &
1485                 its, ite, jts, jte, kts, kte                     )
1486         if (P_QNI .ge. PARAM_FIRST_SCALAR)                       &!BSINGH - QNI scalar
1487         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNI),RQINCUTEN,  &
1488                 config_flags,                                    &
1489                 ids,ide, jds, jde, kds, kde,                     &
1490                 ims, ime, jms, jme, kms, kme,                    &
1491                 its, ite, jts, jte, kts, kte                     )
1492         
1493         
1494        IF(.not. adv_moist_cond)THEN
1496         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1497            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1498                 config_flags,                                    &
1499                 ids,ide, jds, jde, kds, kde,                     &
1500                 ims, ime, jms, jme, kms, kme,                    &
1501                 its, ite, jts, jte, kts, kte                     )
1503         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1504            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1505                 config_flags,                                    &
1506                 ids,ide, jds, jde, kds, kde,                     &
1507                 ims, ime, jms, jme, kms, kme,                    &
1508                 its, ite, jts, jte, kts, kte                     )
1510        ENDIF
1512    CASE (TIEDTKESCHEME, NTIEDTKESCHEME)
1513         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1514                 ids,ide, jds, jde, kds, kde,                     &
1515                 ims, ime, jms, jme, kms, kme,                    &
1516                 its, ite, jts, jte, kts, kte                     )
1518         CALL add_a2c_u(ru_tendf,RUCUTEN,config_flags,            &
1519                 ids,ide, jds, jde, kds, kde,                     &
1520                 ims, ime, jms, jme, kms, kme,                    &
1521                 its, ite, jts, jte, kts, kte                     )
1523         CALL add_a2c_v(rv_tendf,RVCUTEN,config_flags,            &
1524                 ids,ide, jds, jde, kds, kde,                     &
1525                 ims, ime, jms, jme, kms, kme,                    &
1526                 its, ite, jts, jte, kts, kte                     )
1528         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1529         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1530                 config_flags,                                    &
1531                 ids,ide, jds, jde, kds, kde,                     &
1532                 ims, ime, jms, jme, kms, kme,                    &
1533                 its, ite, jts, jte, kts, kte                     )
1535         if (P_QC .ge. PARAM_FIRST_SCALAR)                                         &
1536         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCCUTEN,     &
1537                 config_flags,                                    &
1538                 ids,ide, jds, jde, kds, kde,                     &
1539                 ims, ime, jms, jme, kms, kme,                    &
1540                 its, ite, jts, jte, kts, kte                     )
1542         if (P_QI .ge. PARAM_FIRST_SCALAR)                                         &
1543         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQICUTEN,     &
1544                 config_flags,                                    &
1545                 ids,ide, jds, jde, kds, kde,                     &
1546                 ims, ime, jms, jme, kms, kme,                    &
1547                 its, ite, jts, jte, kts, kte                     )
1549        IF(.not. adv_moist_cond)THEN
1551         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1552            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1553                 config_flags,                                    &
1554                 ids,ide, jds, jde, kds, kde,                     &
1555                 ims, ime, jms, jme, kms, kme,                    &
1556                 its, ite, jts, jte, kts, kte                     )
1558         if (P_QT .ge. PARAM_FIRST_SCALAR)                        &
1559            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1560                 config_flags,                                    &
1561                 ids,ide, jds, jde, kds, kde,                     &
1562                 ims, ime, jms, jme, kms, kme,                    &
1563                 its, ite, jts, jte, kts, kte                     )
1565        ENDIF
1567 #if ( WRFPLUS == 1 )
1568 ! this is for WRFPlus only
1569 !-------------------------------
1570    CASE (DUCUSCHEME)
1571         CALL add_a2a(rt_tendf,RTHCUTEN,config_flags,             &
1572                 ids,ide, jds, jde, kds, kde,                     &
1573                 ims, ime, jms, jme, kms, kme,                    &
1574                 its, ite, jts, jte, kts, kte                     )
1576         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1577         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVCUTEN,     &
1578                 config_flags,                                    &
1579                 ids,ide, jds, jde, kds, kde,                     &
1580                 ims, ime, jms, jme, kms, kme,                    &
1581                 its, ite, jts, jte, kts, kte                     )
1583        IF(.not. adv_moist_cond)THEN
1585         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1586            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQCCUTEN, &
1587                 config_flags,                                    &
1588                 ids,ide, jds, jde, kds, kde,                     &
1589                 ims, ime, jms, jme, kms, kme,                    &
1590                 its, ite, jts, jte, kts, kte                     )
1592         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1593            CALL add_a2a(scalar_tendf(ims,kms,jms,P_QT),RQICUTEN, &
1594                 config_flags,                                    &
1595                 ids,ide, jds, jde, kds, kde,                     &
1596                 ims, ime, jms, jme, kms, kme,                    &
1597                 its, ite, jts, jte, kts, kte                     )
1599        ENDIF
1600 #endif
1602    CASE DEFAULT
1604    END SELECT
1606 END SUBROUTINE phy_cu_ten
1608 !=================================================================
1609 SUBROUTINE phy_shcu_ten(config_flags,rk_step,n_moist,n_scalar,   &
1610                       rt_tendf,ru_tendf,rv_tendf,                &
1611                       RUSHTEN,RVSHTEN,RTHSHTEN,                  &
1612                       RQVSHTEN,RQCSHTEN,RQRSHTEN,                &
1613                       RQISHTEN,RQSSHTEN,RQGSHTEN,RQCNSHTEN,      &
1614                       RQINSHTEN,moist_tendf,scalar_tendf,        &
1615                       ids, ide, jds, jde, kds, kde,              &
1616                       ims, ime, jms, jme, kms, kme,              &
1617                       its, ite, jts, jte, kts, kte               )
1618 !-----------------------------------------------------------------
1619    IMPLICIT NONE
1620 !-----------------------------------------------------------------
1621    TYPE(grid_config_rec_type  ) , INTENT(IN   ) :: config_flags
1623    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1624                                    ims, ime, jms, jme, kms, kme, &
1625                                    its, ite, jts, jte, kts, kte, &
1626                                    n_moist, n_scalar, rk_step
1628    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1629           INTENT(INOUT)     ::                      moist_tendf 
1631    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_scalar),         &
1632           INTENT(INOUT)     ::                      scalar_tendf
1634    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1635                                                         RUSHTEN, &
1636                                                         RVSHTEN, &
1637                                                        RTHSHTEN, &
1638                                                        RQVSHTEN, &
1639                                                        RQCSHTEN, &
1640                                                        RQRSHTEN, &
1641                                                        RQISHTEN, &
1642                                                        RQSSHTEN, &
1643                                                        RQGSHTEN, &
1644                                                       RQCNSHTEN, &
1645                                                       RQINSHTEN
1647    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) ::  &
1648                                                        rt_tendf, &
1649                                                        ru_tendf, &
1650                                                        rv_tendf
1652 ! LOCAL VARS
1654    INTEGER :: i,j,k
1656    SELECT CASE (config_flags%shcu_physics)
1658    CASE (CAMUWSHCUSCHEME)
1659         CALL add_a2c_u(ru_tendf,RUSHTEN,config_flags,            &
1660                 ids,ide, jds, jde, kds, kde,                     &
1661                 ims, ime, jms, jme, kms, kme,                    &
1662                 its, ite, jts, jte, kts, kte                     )
1664         CALL add_a2c_v(rv_tendf,RVSHTEN,config_flags,            &
1665                 ids,ide, jds, jde, kds, kde,                     &
1666                 ims, ime, jms, jme, kms, kme,                    &
1667                 its, ite, jts, jte, kts, kte                     )
1669         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1670                 ids,ide, jds, jde, kds, kde,                     &
1671                 ims, ime, jms, jme, kms, kme,                    &
1672                 its, ite, jts, jte, kts, kte                     )
1674         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1675         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1676                 config_flags,                                    &
1677                 ids,ide, jds, jde, kds, kde,                     &
1678                 ims, ime, jms, jme, kms, kme,                    &
1679                 its, ite, jts, jte, kts, kte                     )
1681         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1682         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
1683                 config_flags,                                    &
1684                 ids,ide, jds, jde, kds, kde,                     &
1685                 ims, ime, jms, jme, kms, kme,                    &
1686                 its, ite, jts, jte, kts, kte                     )
1688         if (P_QR .ge. PARAM_FIRST_SCALAR)                        &
1689         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRSHTEN,     &
1690                 config_flags,                                    &
1691                 ids,ide, jds, jde, kds, kde,                     &
1692                 ims, ime, jms, jme, kms, kme,                    &
1693                 its, ite, jts, jte, kts, kte                     )
1695         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1696         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQISHTEN,     &
1697                 config_flags,                                    &
1698                 ids,ide, jds, jde, kds, kde,                     &
1699                 ims, ime, jms, jme, kms, kme,                    &
1700                 its, ite, jts, jte, kts, kte                     )
1702         if (P_QS .ge. PARAM_FIRST_SCALAR)                        &
1703         CALL add_a2a(moist_tendf(ims,kms,jms,P_QS),RQSSHTEN,     &
1704                 config_flags,                                    &
1705                 ids,ide, jds, jde, kds, kde,                     &
1706                 ims, ime, jms, jme, kms, kme,                    &
1707                 its, ite, jts, jte, kts, kte                     )
1709         if (P_QG .ge. PARAM_FIRST_SCALAR)                        &
1710         CALL add_a2a(moist_tendf(ims,kms,jms,P_QG),RQGSHTEN,     &
1711                 config_flags,                                    &
1712                 ids,ide, jds, jde, kds, kde,                     &
1713                 ims, ime, jms, jme, kms, kme,                    &
1714                 its, ite, jts, jte, kts, kte                     )
1715         if (P_QNC .ge. PARAM_FIRST_SCALAR)                       &
1716         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNC),RQCNSHTEN,  &
1717                 config_flags,                                    &
1718                 ids,ide, jds, jde, kds, kde,                     &
1719                 ims, ime, jms, jme, kms, kme,                    &
1720                 its, ite, jts, jte, kts, kte                     )
1721         if (P_QNI .ge. PARAM_FIRST_SCALAR)                       &
1722         CALL add_a2a(scalar_tendf(ims,kms,jms,P_QNI),RQINSHTEN,  &
1723                 config_flags,                                    &
1724                 ids,ide, jds, jde, kds, kde,                     &
1725                 ims, ime, jms, jme, kms, kme,                    &
1726                 its, ite, jts, jte, kts, kte                     )
1727         
1729    CASE (GRIMSSHCUSCHEME)
1730         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1731                 ids,ide, jds, jde, kds, kde,                     &
1732                 ims, ime, jms, jme, kms, kme,                    &
1733                 its, ite, jts, jte, kts, kte                     )
1735         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1736         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1737                 config_flags,                                    &
1738                 ids,ide, jds, jde, kds, kde,                     &
1739                 ims, ime, jms, jme, kms, kme,                    &
1740                 its, ite, jts, jte, kts, kte                     )
1742         if (P_QC .ge. PARAM_FIRST_SCALAR)                        &
1743         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
1744                 config_flags,                                    &
1745                 ids,ide, jds, jde, kds, kde,                     &
1746                 ims, ime, jms, jme, kms, kme,                    &
1747                 its, ite, jts, jte, kts, kte                     )
1749         if (P_QI .ge. PARAM_FIRST_SCALAR)                        &
1750         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQISHTEN,     &
1751                 config_flags,                                    &
1752                 ids,ide, jds, jde, kds, kde,                     &
1753                 ims, ime, jms, jme, kms, kme,                    &
1754                 its, ite, jts, jte, kts, kte                     )
1756    CASE (NSCVSHCUSCHEME)
1757         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1758                 ids,ide, jds, jde, kds, kde,                     &
1759                 ims, ime, jms, jme, kms, kme,                    &
1760                 its, ite, jts, jte, kts, kte                     )
1762         CALL add_a2c_u(ru_tendf,RUSHTEN,config_flags,            &
1763                 ids,ide, jds, jde, kds, kde,                     &
1764                 ims, ime, jms, jme, kms, kme,                    &
1765                 its, ite, jts, jte, kts, kte                     )
1767         CALL add_a2c_v(rv_tendf,RVSHTEN,config_flags,            &
1768                 ids,ide, jds, jde, kds, kde,                     &
1769                 ims, ime, jms, jme, kms, kme,                    &
1770                 its, ite, jts, jte, kts, kte                     )
1772         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1773         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1774                 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_QC .ge. PARAM_FIRST_SCALAR)                                         &
1780         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
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_QI .ge. PARAM_FIRST_SCALAR)                                         &
1787         CALL add_a2a(moist_tendf(ims,kms,jms,P_QI),RQISHTEN,     &
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   CASE (DENGSHCUSCHEME)
1794         CALL add_a2c_u(ru_tendf,RUSHTEN,config_flags,            &
1795                 ids,ide, jds, jde, kds, kde,                     &
1796                 ims, ime, jms, jme, kms, kme,                    &
1797                 its, ite, jts, jte, kts, kte                     )
1799         CALL add_a2c_v(rv_tendf,RVSHTEN,config_flags,            &
1800                 ids,ide, jds, jde, kds, kde,                     &
1801                 ims, ime, jms, jme, kms, kme,                    &
1802                 its, ite, jts, jte, kts, kte                     )
1804         CALL add_a2a(rt_tendf,RTHSHTEN,config_flags,             &
1805                 ids,ide, jds, jde, kds, kde,                     &
1806                 ims, ime, jms, jme, kms, kme,                    &
1807                 its, ite, jts, jte, kts, kte                     )
1809         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1810         CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVSHTEN,     &
1811                 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_QC .ge. PARAM_FIRST_SCALAR)                        &
1817         CALL add_a2a(moist_tendf(ims,kms,jms,P_QC),RQCSHTEN,     &
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_QR .ge. PARAM_FIRST_SCALAR)                        &
1824         CALL add_a2a(moist_tendf(ims,kms,jms,P_QR),RQRSHTEN,     &
1825                 config_flags,                                    &
1826                 ids,ide, jds, jde, kds, kde,                     &
1827                 ims, ime, jms, jme, kms, kme,                    &
1828                 its, ite, jts, jte, kts, kte                     )
1831    CASE DEFAULT
1833    END SELECT
1836 END SUBROUTINE phy_shcu_ten
1838 !=================================================================
1839 SUBROUTINE phy_fg_ten(config_flags,rk_step,n_moist,            &
1840                       rph_tendf,rt_tendf,ru_tendf,rv_tendf,    &
1841                       mu_tendf, moist_tendf,                   &
1842                       RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN,          &
1843                       RPHNDGDTEN,RQVNDGDTEN,RMUNDGDTEN,        &
1844                       ids, ide, jds, jde, kds, kde,              &
1845                       ims, ime, jms, jme, kms, kme,              &
1846                       its, ite, jts, jte, kts, kte               )
1847 !-----------------------------------------------------------------
1848    IMPLICIT NONE
1849 !-----------------------------------------------------------------
1850    TYPE(grid_config_rec_type) ,     INTENT(IN   ) :: config_flags
1852    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1853                                    ims, ime, jms, jme, kms, kme, &
1854                                    its, ite, jts, jte, kts, kte, &
1855                                    n_moist, rk_step
1857    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1858           INTENT(INOUT)     ::                      moist_tendf
1860    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1861                                                        RTHNDGDTEN, &
1862                                                        RPHNDGDTEN, &
1863                                                         RUNDGDTEN, &
1864                                                         RVNDGDTEN, &
1865                                                        RQVNDGDTEN
1867    REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN  ) ::  RMUNDGDTEN
1869    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT)::   &
1870                                                        rph_tendf,&
1871                                                        rt_tendf, &
1872                                                        ru_tendf, &
1873                                                        rv_tendf
1875    REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT)::  mu_tendf
1877 ! LOCAL VARS
1879    INTEGER :: i,j,k,IBGN,IEND,JBGN,JEND
1881 !-----------------------------------------------------------------
1883    SELECT CASE(config_flags%grid_fdda)
1885       CASE (PSUFDDAGD)
1887            CALL add_a2a(rt_tendf,RTHNDGDTEN,config_flags,        &
1888                 ids,ide, jds, jde, kds, kde,                     &
1889                 ims, ime, jms, jme, kms, kme,                    &
1890                 its, ite, jts, jte, kts, kte                     )
1892 ! note fdda u and v tendencies are staggered
1893            CALL add_c2c_u(ru_tendf,RUNDGDTEN,config_flags,       &
1894                 ids,ide, jds, jde, kds, kde,                     &
1895                 ims, ime, jms, jme, kms, kme,                    &
1896                 its, ite, jts, jte, kts, kte                     )
1898            CALL add_c2c_v(rv_tendf,RVNDGDTEN,config_flags,       &
1899                 ids,ide, jds, jde, kds, kde,                     &
1900                 ims, ime, jms, jme, kms, kme,                    &
1901                 its, ite, jts, jte, kts, kte                     )
1903            CALL add_a2a(mu_tendf,RMUNDGDTEN,config_flags,      &
1904                 ids,ide, jds, jde, kds, kds,                     &
1905                 ims, ime, jms, jme, kms, kms,                    &
1906                 its, ite, jts, jte, kts, kts                     )
1908         if (P_QV .ge. PARAM_FIRST_SCALAR)                                         &
1909            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVNDGDTEN,  &
1910                 config_flags,                                    &
1911                 ids,ide, jds, jde, kds, kde,                     &
1912                 ims, ime, jms, jme, kms, kme,                    &
1913                 its, ite, jts, jte, kts, kte                     )
1915       CASE (SPNUDGING)
1917 ! note fdda u and v tendencies are staggered
1918            CALL add_c2c_u(ru_tendf,RUNDGDTEN,config_flags,       &
1919                 ids,ide, jds, jde, kds, kde,                     &
1920                 ims, ime, jms, jme, kms, kme,                    &
1921                 its, ite, jts, jte, kts, kte                     )
1923            CALL add_c2c_v(rv_tendf,RVNDGDTEN,config_flags,       &
1924                 ids,ide, jds, jde, kds, kde,                     &
1925                 ims, ime, jms, jme, kms, kme,                    &
1926                 its, ite, jts, jte, kts, kte                     )
1928            CALL add_a2a(rt_tendf,RTHNDGDTEN,config_flags,        &
1929                 ids,ide, jds, jde, kds, kde,                     &
1930                 ims, ime, jms, jme, kms, kme,                    &
1931                 its, ite, jts, jte, kts, kte                     )
1933            CALL add_a2a_ph(rph_tendf,RPHNDGDTEN,config_flags,        &
1934                 ids,ide, jds, jde, kds, kde,                     &
1935                 ims, ime, jms, jme, kms, kme,                    &
1936                 its, ite, jts, jte, kts, kte                     )
1938         if (P_QV .ge. PARAM_FIRST_SCALAR)                        &
1939            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),RQVNDGDTEN,&
1940                 config_flags,                                    &
1941                 ids,ide, jds, jde, kds, kde,                     &
1942                 ims, ime, jms, jme, kms, kme,                    &
1943                 its, ite, jts, jte, kts, kte                     )
1945       CASE DEFAULT
1947    END SELECT
1949 END SUBROUTINE phy_fg_ten
1951 !=================================================================
1952 SUBROUTINE phy_fr_ten(config_flags,rk_step,n_moist,            &
1953                       rt_tendf,ru_tendf,rv_tendf,              &
1954                       mu_tendf, moist_tendf,                   &
1955                       rthfrten,rqvfrten,                       &
1956                       ids, ide, jds, jde, kds, kde,              &
1957                       ims, ime, jms, jme, kms, kme,              &
1958                       its, ite, jts, jte, kts, kte               )
1959 !-----------------------------------------------------------------
1960    USE module_state_description, ONLY :                         &
1961                    FIRE_SFIRE1, FIRE_SFIRE
1962 !-----------------------------------------------------------------
1963    IMPLICIT NONE
1964 !-----------------------------------------------------------------
1965    TYPE(grid_config_rec_type) ,     INTENT(IN   ) :: config_flags
1967    INTEGER , INTENT(IN)        ::  ids, ide, jds, jde, kds, kde, &
1968                                    ims, ime, jms, jme, kms, kme, &
1969                                    its, ite, jts, jte, kts, kte, &
1970                                    n_moist, rk_step
1972    REAL , DIMENSION(ims:ime, kms:kme, jms:jme, n_moist),         &
1973           INTENT(INOUT)     ::                      moist_tendf
1975    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN  ) ::   &
1976                                                        rthfrten, &
1977                                                        rqvfrten 
1979    REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT)::   &
1980                                                        rt_tendf, &
1981                                                        ru_tendf, &
1982                                                        rv_tendf
1984    REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT)::  mu_tendf
1986 ! LOCAL VARS
1988    INTEGER :: i,j,k,IBGN,IEND,JBGN,JEND
1990 !-----------------------------------------------------------------
1992    SELECT CASE(config_flags%ifire)
1994       CASE (FIRE_SFIRE1, FIRE_SFIRE)
1996            CALL add_a2a(rt_tendf,rthfrten,                       &
1997                 config_flags,                                    &
1998                 ids,ide, jds, jde, kds, kde,                     &
1999                 ims, ime, jms, jme, kms, kme,                    &
2000                 its, ite, jts, jte, kts, kte                     )
2002            CALL add_a2a(moist_tendf(ims,kms,jms,P_QV),rqvfrten,  &
2003                 config_flags,                                    &
2004                 ids,ide, jds, jde, kds, kde,                     &
2005                 ims, ime, jms, jme, kms, kme,                    &
2006                 its, ite, jts, jte, kts, kte                     )
2008       CASE DEFAULT
2010    END SELECT
2012 END SUBROUTINE phy_fr_ten
2014 !----------------------------------------------------------------------
2015 SUBROUTINE advance_ppt(RTHCUTEN,RQVCUTEN,RQCCUTEN,RQRCUTEN,           &
2016                      CLDFRA_CUP,                                      &     ! add LD 01/11/2012 !BSINGH -  Added for CuP
2017                      RQICUTEN,RQSCUTEN,                               &
2018                      RAINC,RAINCV,RAINSH,PRATEC,PRATESH,  &
2019                      NCA, HTOP,HBOT,CUTOP,CUBOT,                      &
2020                      CUPPT, DT, config_flags,                         &
2021                      ids,ide, jds,jde, kds,kde,                       &
2022                      ims,ime, jms,jme, kms,kme,                       &
2023                      its,ite, jts,jte, kts,kte                        )     
2024 !----------------------------------------------------------------------
2025    USE module_state_description
2026    USE module_cu_kf
2027    USE module_cu_kfeta
2028 #if ( WRFPLUS == 1 )
2029    USE module_cu_du              !  Added by Zhuxiao
2030 #endif
2031 !----------------------------------------------------------------------
2032    IMPLICIT NONE
2033 !----------------------------------------------------------------------
2034    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2036    INTEGER,      INTENT(IN   )    ::                             &
2037                                       ids,ide, jds,jde, kds,kde, &
2038                                       ims,ime, jms,jme, kms,kme, &
2039                                       its,ite, jts,jte, kts,kte
2042    REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),                 &
2043          INTENT(INOUT)  ::                             RTHCUTEN, &
2044                                                        RQVCUTEN, &
2045                                                        RQCCUTEN, &
2046                                                        RQRCUTEN, &
2047                                                        RQICUTEN, &
2048                                                        RQSCUTEN, &
2049                                                        CLDFRA_CUP        ! add LD 01/11/2012 !BSINGH - For CuP
2051    REAL, DIMENSION( ims:ime , jms:jme ),                         &
2052           INTENT(INOUT) ::                                RAINC, &
2053                                                          RAINSH, &
2054                                                          RAINCV, &
2055                                                          PRATEC, &
2056                                                         PRATESH, &
2057                                                             NCA, &
2058                                                            HTOP, &
2059                                                            HBOT, &
2060                                                           CUTOP, &
2061                                                           CUBOT, &
2062                                                           CUPPT
2063    REAL, INTENT(IN) ::                                       DT
2065 ! LOCAL  VAR
2067    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,k_start,k_end
2068    INTEGER :: NCUTOP, NCUBOT
2070 !-----------------------------------------------------------------
2072    IF (config_flags%cu_physics .eq. 0) return
2074 ! SET START AND END POINTS FOR TILES
2076    i_start = its
2077    i_end   = min( ite,ide-1 )
2078    j_start = jts
2079    j_end   = min( jte,jde-1 )
2081 !  IF( config_flags%nested .or. config_flags%specified ) THEN
2082 !    i_start = max( its,ids+1 )
2083 !    i_end   = min( ite,ide-2 )
2084 !    j_start = max( jts,jds+1 )
2085 !    j_end   = min( jte,jde-2 )
2086 !  ENDIF
2088    k_start = kts
2089    k_end = min( kte, kde-1 )
2091 ! Update total cumulus scheme precipitation
2093 ! in mm  
2095    DO J = j_start,j_end
2096    DO i = i_start,i_end
2097       RAINC(I,J)  = RAINC(I,J) + PRATEC(I,J)*DT
2098       RAINSH(I,J) = RAINSH(I,J) + PRATESH(I,J)*DT
2099       CUPPT(I,J)  = CUPPT(I,J) + (PRATEC(I,J)+PRATESH(I,J))*DT/1000.
2100    ENDDO
2101    ENDDO
2103    SELECT CASE (config_flags%cu_physics)
2105    CASE (KFSCHEME)
2107         DO J = j_start,j_end
2108         DO i = i_start,i_end
2110            IF ( NCA(I,J) .GT. 0 ) THEN
2112               IF ( NINT(NCA(I,J) / DT) .le. 0 ) THEN
2114               ! set tendency to zero
2115 !                PRATEC(I,J)=0.
2116 !                RAINCV(I,J)=0.
2117                  DO k = k_start,k_end
2118                     RTHCUTEN(i,k,j)=0.
2119                     RQVCUTEN(i,k,j)=0.
2120                     RQCCUTEN(i,k,j)=0.
2121                     RQRCUTEN(i,k,j)=0.
2122                     if (P_QI .ge. PARAM_FIRST_SCALAR) RQICUTEN(i,k,j)=0.
2123                     if (P_QS .ge. PARAM_FIRST_SCALAR) RQSCUTEN(i,k,j)=0.
2124                  ENDDO
2125               ENDIF
2127               NCA(I,J)=NCA(I,J)-DT ! Decrease NCA
2129            ENDIF
2131         ENDDO
2132         ENDDO
2134    CASE (BMJSCHEME, CAMZMSCHEME)
2136         DO J = j_start,j_end
2137         DO i = i_start,i_end
2139 ! HTOP, HBOT FOR GFDL RADIATION
2140            NCUTOP=NINT(CUTOP(I,J))
2141            NCUBOT=NINT(CUBOT(I,J))
2142            IF(NCUTOP>1.AND.NCUTOP<KDE)THEN
2143              HTOP(I,J)=MAX(CUTOP(I,J),HTOP(I,J))
2144            ENDIF
2145            IF(NCUBOT>0.AND.NCUBOT<KDE)THEN
2146              HBOT(I,J)=MIN(CUBOT(I,J),HBOT(I,J))
2147            ENDIF
2149         ENDDO
2150         ENDDO
2152    CASE (KFETASCHEME, MSKFSCHEME, KFCUPSCHEME)!BSINGH - added KFCUPSCHEME for CuP
2154         DO J = j_start,j_end
2155         DO i = i_start,i_end
2157 ! HTOP, HBOT FOR GFDL RADIATION
2158            NCUTOP=NINT(CUTOP(I,J))
2159            NCUBOT=NINT(CUBOT(I,J))
2160            IF(NCUTOP>1.AND.NCUTOP<KDE)THEN
2161              HTOP(I,J)=MAX(CUTOP(I,J),HTOP(I,J))
2162            ENDIF
2163            IF(NCUBOT>0.AND.NCUBOT<KDE)THEN
2164              HBOT(I,J)=MIN(CUBOT(I,J),HBOT(I,J))
2165            ENDIF
2167            IF ( NCA(I,J) .GT. 0 ) THEN
2169               IF ( NINT(NCA(I,J) / DT) .LE. 1 ) THEN
2171               ! set tendency to zero
2172 !                PRATEC(I,J)=0.
2173 !                RAINCV(I,J)=0.
2174                  DO k = k_start,k_end
2175                     RTHCUTEN(i,k,j)=0.
2176                     RQVCUTEN(i,k,j)=0.
2177                     RQCCUTEN(i,k,j)=0.
2178                     RQRCUTEN(i,k,j)=0.
2179                     if (P_QI .ge. PARAM_FIRST_SCALAR) RQICUTEN(i,k,j)=0.
2180                     if (P_QS .ge. PARAM_FIRST_SCALAR) RQSCUTEN(i,k,j)=0.
2181                  ENDDO
2182               ENDIF
2184               NCA(I,J)=NCA(I,J)-DT ! Decrease NCA
2185 !              NCA(I,J)=NCA(I,J)-1. ! Decrease NCA
2187            ENDIF
2189         ENDDO
2190         ENDDO
2192         IF ( config_flags%cu_physics == kfcupscheme ) THEN
2193            DO J = j_start,j_end
2194            DO i = i_start,i_end
2195              IF ( NCA(I,J) .GT. 0 ) THEN
2196               IF ( NINT(NCA(I,J) / DT) .LE. 1 ) THEN
2197                  DO k = k_start,k_end
2198                     CLDFRA_CUP(i,k,j)=0. ! By LKB 12/22/11 01/11/2012 !BSINGH - For CuP
2199                  ENDDO
2200               ENDIF
2201              ENDIF
2202            ENDDO
2203            ENDDO
2204         ENDIF
2206 #if ( WRFPLUS == 1 )
2207 ! this is for WRFPlus only
2208 !---------------------------
2209    CASE (DUCUSCHEME)
2211         DO J = j_start,j_end
2212         DO i = i_start,i_end
2214            IF ( NCA(I,J) .GT. 0 ) THEN
2216               IF ( NINT(NCA(I,J) / DT) .le. 0 ) THEN
2218               ! set tendency to zero
2219 !!                PRATEC(I,J)=0.
2220 !!                RAINCV(I,J)=0.
2221                  DO k = k_start,k_end
2222                     RTHCUTEN(i,k,j)=0.
2223                     RQVCUTEN(i,k,j)=0.
2224                  ENDDO
2225                ENDIF
2227               NCA(I,J)=NCA(I,J)-DT ! Decrease NCA
2229            ENDIF
2231         ENDDO
2232         ENDDO
2233 #endif
2235    CASE DEFAULT
2237    END SELECT
2239 END SUBROUTINE advance_ppt
2241 SUBROUTINE add_a2a(lvar,rvar,config_flags,                  &
2242                    ids,ide, jds, jde, kds, kde,             &
2243                    ims, ime, jms, jme, kms, kme,            &
2244                    its, ite, jts, jte, kts, kte             )
2245 !------------------------------------------------------------
2246    IMPLICIT NONE
2247 !------------------------------------------------------------
2248    TYPE(grid_config_rec_type),  INTENT(IN) :: config_flags
2250    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2251                               ims, ime, jms, jme, kms, kme, &
2252                               its, ite, jts, jte, kts, kte
2254    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2255                                                       rvar
2256    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2257                                                       lvar
2259 ! LOCAL VARS
2260    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2262    i_start = its
2263    i_end   = MIN(ite,ide-1)
2264    j_start = jts
2265    j_end   = MIN(jte,jde-1)
2266    ktf = min(kte,kde-1)
2268    IF ( config_flags%specified .or. &
2269         config_flags%nested) i_start = MAX(ids+1,its)
2270    IF ( config_flags%specified .or. &
2271         config_flags%nested) i_end   = MIN(ide-2,ite)
2272    IF ( config_flags%specified .or. &
2273         config_flags%nested) j_start = MAX(jds+1,jts)
2274    IF ( config_flags%specified .or. &
2275         config_flags%nested) j_end   = MIN(jde-2,jte)
2276       IF ( config_flags%periodic_x ) i_start = its
2277       IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
2279    DO j = j_start,j_end
2280    DO k = kts,ktf
2281    DO i = i_start,i_end
2282       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2283    ENDDO
2284    ENDDO
2285    ENDDO
2287 END SUBROUTINE add_a2a
2289 SUBROUTINE add_a2a_ph(lvar,rvar,config_flags,                  &
2290                    ids,ide, jds, jde, kds, kde,             &
2291                    ims, ime, jms, jme, kms, kme,            &
2292                    its, ite, jts, jte, kts, kte             )
2293 !------------------------------------------------------------
2294    IMPLICIT NONE
2295 !------------------------------------------------------------
2296    TYPE(grid_config_rec_type),  INTENT(IN) :: config_flags
2298    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2299                               ims, ime, jms, jme, kms, kme, &
2300                               its, ite, jts, jte, kts, kte
2302    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2303                                                       rvar
2304    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2305                                                       lvar
2307 ! LOCAL VARS
2308    INTEGER :: i,j,k,i_start,i_end,j_start,j_end
2310    i_start = its
2311    i_end   = MIN(ite,ide-1)
2312    j_start = jts
2313    j_end   = MIN(jte,jde-1)
2315    IF ( config_flags%specified .or. &
2316         config_flags%nested) i_start = MAX(ids+1,its)
2317    IF ( config_flags%specified .or. &
2318         config_flags%nested) i_end   = MIN(ide-2,ite)
2319    IF ( config_flags%specified .or. &
2320         config_flags%nested) j_start = MAX(jds+1,jts)
2321    IF ( config_flags%specified .or. &
2322         config_flags%nested) j_end   = MIN(jde-2,jte)
2323       IF ( config_flags%periodic_x ) i_start = its
2324       IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
2326    DO j = j_start,j_end
2327    DO k = kts,kte
2328    DO i = i_start,i_end
2329       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2330    ENDDO
2331    ENDDO
2332    ENDDO
2334 END SUBROUTINE add_a2a_ph
2336 !------------------------------------------------------------
2337 SUBROUTINE add_a2c_u(lvar,rvar,config_flags,                &
2338                    ids,ide, jds, jde, kds, kde,             &
2339                    ims, ime, jms, jme, kms, kme,            &
2340                    its, ite, jts, jte, kts, kte             )
2341 !------------------------------------------------------------
2342 !------------------------------------------------------------
2343    IMPLICIT NONE
2344 !------------------------------------------------------------
2346    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2348    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2349                               ims, ime, jms, jme, kms, kme, &
2350                               its, ite, jts, jte, kts, kte
2352    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2353                                                       rvar
2354    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2355                                                       lvar
2357 ! LOCAL VARS
2359    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2361    ktf=min(kte,kde-1)
2363    i_start = its
2364    i_end   = ite
2365    j_start = jts
2366    j_end   = MIN(jte,jde-1)
2368    IF ( config_flags%specified .or. &
2369         config_flags%nested) i_start = MAX(ids+1,its)
2370    IF ( config_flags%specified .or. &
2371         config_flags%nested) i_end   = MIN(ide-1,ite)
2372    IF ( config_flags%specified .or. &
2373         config_flags%nested) j_start = MAX(jds+1,jts)
2374    IF ( config_flags%specified .or. &
2375         config_flags%nested) j_end   = MIN(jde-2,jte)
2376       IF ( config_flags%periodic_x ) i_start = its
2377       IF ( config_flags%periodic_x ) i_end = ite
2379    DO j = j_start,j_end
2380    DO k = kts,ktf
2381    DO i = i_start,i_end
2382       lvar(i,k,j) = lvar(i,k,j) + &
2383                        0.5*(rvar(i,k,j)+rvar(i-1,k,j))
2384    ENDDO
2385    ENDDO
2386    ENDDO
2388 END SUBROUTINE add_a2c_u
2390 !------------------------------------------------------------
2391 SUBROUTINE add_a2c_v(lvar,rvar,config_flags,                &
2392                    ids,ide, jds, jde, kds, kde,             &
2393                    ims, ime, jms, jme, kms, kme,            &
2394                    its, ite, jts, jte, kts, kte             )
2395 !------------------------------------------------------------
2396 !------------------------------------------------------------
2397    IMPLICIT NONE
2398 !------------------------------------------------------------
2400    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2402    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2403                               ims, ime, jms, jme, kms, kme, &
2404                               its, ite, jts, jte, kts, kte
2406    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2407                                                       rvar
2408    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2409                                                       lvar
2411 ! LOCAL VARS
2413    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2415    ktf=min(kte,kde-1)
2417    i_start = its
2418    i_end   = MIN(ite,ide-1)
2419    j_start = jts
2420    j_end   = jte
2422    IF ( config_flags%specified .or. &
2423         config_flags%nested) i_start = MAX(ids+1,its)
2424    IF ( config_flags%specified .or. &
2425         config_flags%nested) i_end   = MIN(ide-2,ite)
2426    IF ( config_flags%specified .or. &
2427         config_flags%nested) j_start = MAX(jds+1,jts)
2428    IF ( config_flags%specified .or. &
2429         config_flags%nested) j_end   = MIN(jde-1,jte)
2430       IF ( config_flags%periodic_x ) i_start = its
2431       IF ( config_flags%periodic_x ) i_end = MIN( ite, ide-1 )
2433    DO j = j_start,j_end
2434    DO k = kts,kte
2435    DO i = i_start,i_end
2436       lvar(i,k,j) = lvar(i,k,j) + &
2437                      0.5*(rvar(i,k,j)+rvar(i,k,j-1))
2438    ENDDO
2439    ENDDO
2440    ENDDO
2442 END SUBROUTINE add_a2c_v
2444 !------------------------------------------------------------
2445 SUBROUTINE add_c2c_u(lvar,rvar,config_flags,                &
2446                    ids,ide, jds, jde, kds, kde,             &
2447                    ims, ime, jms, jme, kms, kme,            &
2448                    its, ite, jts, jte, kts, kte             )
2449 !------------------------------------------------------------
2450 !------------------------------------------------------------
2451    IMPLICIT NONE
2452 !------------------------------------------------------------
2454    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2456    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2457                               ims, ime, jms, jme, kms, kme, &
2458                               its, ite, jts, jte, kts, kte
2460    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2461                                                       rvar
2462    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2463                                                       lvar
2465 ! LOCAL VARS
2467    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2469    ktf=min(kte,kde-1)
2471    i_start = its
2472    i_end   = ite
2473    j_start = jts
2474    j_end   = MIN(jte,jde-1)
2477    IF ( config_flags%specified .or. &
2478         config_flags%nested) i_start = MAX(ids+1,its)
2479    IF ( config_flags%specified .or. &
2480         config_flags%nested) i_end   = MIN(ide-1,ite)
2481    IF ( config_flags%specified .or. &
2482         config_flags%nested) j_start = MAX(jds+1,jts)
2483    IF ( config_flags%specified .or. &
2484         config_flags%nested) j_end   = MIN(jde-2,jte)
2486 !  write(*,'(a,6i4)') 'call c2cu, i_start, i_end, j_start, j_end=', i_start, i_end, j_start, j_end
2488    DO j = j_start,j_end
2489    DO k = kts,ktf
2490    DO i = i_start,i_end
2491       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2492    ENDDO
2493    ENDDO
2494    ENDDO
2496 END SUBROUTINE add_c2c_u
2498 SUBROUTINE add_c2c_v(lvar,rvar,config_flags,                &
2499                    ids,ide, jds, jde, kds, kde,             &
2500                    ims, ime, jms, jme, kms, kme,            &
2501                    its, ite, jts, jte, kts, kte             )
2502 !------------------------------------------------------------
2503 !------------------------------------------------------------
2504    IMPLICIT NONE
2505 !------------------------------------------------------------
2507    TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
2509    INTEGER , INTENT(IN   ) :: ids, ide, jds, jde, kds, kde, &
2510                               ims, ime, jms, jme, kms, kme, &
2511                               its, ite, jts, jte, kts, kte
2513    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(IN   ) ::&
2514                                                       rvar
2515    REAL, DIMENSION(ims:ime,kms:kme,jms:jme),INTENT(INOUT) ::&
2516                                                       lvar
2518 ! LOCAL VARS
2520    INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
2522    ktf=min(kte,kde-1)
2524    i_start = its
2525    i_end   = MIN(ite,ide-1)
2526    j_start = jts
2527    j_end   = jte
2529    IF ( config_flags%specified .or. &
2530         config_flags%nested) i_start = MAX(ids+1,its)
2531    IF ( config_flags%specified .or. &
2532         config_flags%nested) i_end   = MIN(ide-2,ite)
2533    IF ( config_flags%specified .or. &
2534         config_flags%nested) j_start = MAX(jds+1,jts)
2535    IF ( config_flags%specified .or. &
2536         config_flags%nested) j_end   = MIN(jde-1,jte)
2538 !  write(*,'(a,6i4)') 'call c2cv, i_start, i_end, j_start, j_end=', i_start, i_end, j_start, j_end
2540    DO j = j_start,j_end
2541    DO k = kts,kte
2542    DO i = i_start,i_end
2543       lvar(i,k,j) = lvar(i,k,j) + rvar(i,k,j)
2544    ENDDO
2545    ENDDO
2546    ENDDO
2548 END SUBROUTINE add_c2c_v
2550 #endif
2552 END MODULE module_physics_addtendc