Merge remote-tracking branch 'origin/release-v4.5.2'
[WRF.git] / wrftladj / module_first_rk_step_part2_tl.F
blob8093a8a9b3bda38514ca15035962678fe6a53ed7
1 !WRF+/TL:MEDIATION_LAYER:SOLVER FOR TL
2 !Created by Ning Pan, 2010-08 
4 #define BENCH_START(A)
5 #define BENCH_END(A)
7 MODULE g_module_first_rk_step_part2
9 CONTAINS
11   SUBROUTINE g_first_rk_step_part2 (   grid , config_flags              &
12                , moist ,g_moist , moist_tend ,g_moist_tend               &
13                , chem  ,g_chem  , chem_tend  ,g_chem_tend                &
14                , tracer,g_tracer, tracer_tend,g_tracer_tend              &
15                , scalar,g_scalar, scalar_tend,g_scalar_tend              &
16                , fdda3d,g_fdda3d, fdda2d,     g_fdda2d                   &
17                , ru_tendf,g_ru_tendf, rv_tendf,g_rv_tendf               &
18                , rw_tendf,g_rw_tendf, t_tendf ,g_t_tendf                &
19                , ph_tendf,g_ph_tendf, mu_tendf,g_mu_tendf               &
20                , tke_tend,g_tke_tend           &
21                , adapt_step_flag , curr_secs      &
22                , psim ,g_psim , psih ,g_psih ,  &
23                  gz1oz0 ,g_gz1oz0 , chklowq,g_chklowq         &
24                , cu_act_flag , hol ,g_hol, th_phy,g_th_phy        &
25                , pi_phy ,g_pi_phy, p_phy ,g_p_phy , t_phy ,g_t_phy  &
26                , dz8w ,g_dz8w , p8w ,g_p8w , t8w ,g_t8w  &
27                , nba_mij,g_nba_mij, n_nba_mij         &
28                , nba_rij,g_nba_rij, n_nba_rij         &
29                , ids, ide, jds, jde, kds, kde     &
30                , ims, ime, jms, jme, kms, kme     &
31                , ips, ipe, jps, jpe, kps, kpe     &
32                , imsx,imex,jmsx,jmex,kmsx,kmex    &
33                , ipsx,ipex,jpsx,jpex,kpsx,kpex    &
34                , imsy,imey,jmsy,jmey,kmsy,kmey    &
35                , ipsy,ipey,jpsy,jpey,kpsy,kpey    &
36                , k_start , k_end                  &
37               )
39     USE module_state_description
40     USE module_model_constants
41     USE module_domain, ONLY : domain
42     USE module_configure, ONLY : grid_config_rec_type, model_config_rec
43 #ifdef DM_PARALLEL
44     USE module_dm, ONLY : local_communicator, mytask, ntasks, ntasks_x, ntasks_y, local_communicator_periodic, wrf_dm_maxval, wrf_err_message, local_communicator_x, local_communicator_y
45     USE module_comm_dm, ONLY : halo_em_tke_c_sub,halo_em_tke_d_sub,halo_em_tke_e_sub            &
46             ,halo_em_phys_pbl_sub,halo_em_phys_shcu_sub &
47             ,halo_em_fdda_sub,halo_em_phys_diffusion_sub,halo_em_tke_3_sub &
48             ,halo_em_tke_5_sub,halo_obs_nudge_sub,period_bdy_em_a1_sub,period_bdy_em_phy_bc_sub &
49             ,period_bdy_em_fdda_bc_sub,period_bdy_em_chem_sub,halo_em_phys_cu_sub               &
50             ,halo_em_tke_c_tl_sub,halo_em_phys_pbl_tl_sub                                       &
51             ,halo_em_tke_d_tl_sub,halo_em_tke_e_tl_sub                                          &
52             ,halo_em_phys_diffusion_tl_sub,halo_em_tke_3_tl_sub,halo_em_tke_5_tl_sub
53 #endif
55     USE module_driver_constants
56     USE g_module_diffusion_em, ONLY : g_phy_bc, g_cal_deform_and_div, &
57             g_compute_diff_metrics, g_vertical_diffusion_2,              &
58             g_horizontal_diffusion_2, g_calculate_km_kh, g_tke_rhs
59     USE g_module_em, ONLY : g_calculate_phy_tend
60     USE module_fddaobs_driver, ONLY : fddaobs_driver
61     USE g_module_bc, ONLY : g_set_physical_bc3d, g_set_physical_bc2d
62     USE g_module_physics_addtendc, ONLY : g_update_phy_ten
64     USE g_module_sfs_driver
65     USE module_stoch, ONLY : update_stoch_ten, perturb_physics_tend,RAND_PERT_UPDATE
67     IMPLICIT NONE
69     TYPE ( domain ), INTENT(INOUT) :: grid
70     TYPE ( grid_config_rec_type ), INTENT(IN) :: config_flags
72     INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde,     &
73                            ims, ime, jms, jme, kms, kme,     &
74                            ips, ipe, jps, jpe, kps, kpe,     &
75                            imsx,imex,jmsx,jmex,kmsx,kmex,    &
76                            ipsx,ipex,jpsx,jpex,kpsx,kpex,    &
77                            imsy,imey,jmsy,jmey,kmsy,kmey,    &
78                            ipsy,ipey,jpsy,jpey,kpsy,kpey
80     LOGICAL ,INTENT(IN)                        :: adapt_step_flag
81     REAL, INTENT(IN)                           :: curr_secs
83     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: moist,g_moist
84     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: moist_tend,g_moist_tend
85     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_chem),INTENT(INOUT)   :: chem,g_chem
86     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_chem),INTENT(INOUT)   :: chem_tend,g_chem_tend
87     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_tracer),INTENT(INOUT)   :: tracer,g_tracer
88     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_tracer),INTENT(INOUT)   :: tracer_tend,g_tracer_tend
89     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT)   :: scalar,g_scalar
90     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_scalar),INTENT(INOUT)   :: scalar_tend,g_scalar_tend
91     REAL,DIMENSION(ims:ime,kms:kme,jms:jme,num_fdda3d),INTENT(INOUT)  :: fdda3d,g_fdda3d
92     REAL,DIMENSION(ims:ime,1:1,jms:jme,num_fdda2d),INTENT(INOUT)      :: fdda2d,g_fdda2d
93     REAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: psim,g_psim
94     REAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: psih,g_psih
95     REAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: gz1oz0,g_gz1oz0
96     REAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: chklowq,g_chklowq
97     REAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: hol,g_hol
98     LOGICAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)      :: cu_act_flag
100     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: th_phy,g_th_phy
101     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: pi_phy,g_pi_phy
102     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: p_phy,g_p_phy
103     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t_phy,g_t_phy
104     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: dz8w,g_dz8w
105     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: p8w,g_p8w
106     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t8w,g_t8w
108     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: ru_tendf,g_ru_tendf
109     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rv_tendf,g_rv_tendf
110     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rw_tendf,g_rw_tendf
111     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: ph_tendf,g_ph_tendf
112     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t_tendf,g_t_tendf
113     REAL,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: tke_tend,g_tke_tend
115     REAL,DIMENSION(ims:ime,jms:jme), INTENT(INOUT) :: mu_tendf,g_mu_tendf
117     INTEGER , INTENT(IN)                          ::  k_start, k_end
119   INTEGER, INTENT(  IN ) :: n_nba_mij, n_nba_rij
121   REAL ,DIMENSION(grid%sm31:grid%em31,grid%sm32:grid%em32,grid%sm33:grid%em33,n_nba_mij) &
122   :: nba_mij,g_nba_mij
124   REAL ,DIMENSION(grid%sm31:grid%em31,grid%sm32:grid%em32,grid%sm33:grid%em33,n_nba_rij) &
125   :: nba_rij,g_nba_rij
127 ! Local
129     REAL, DIMENSION( ims:ime, jms:jme ) :: ht_loc,g_ht_loc
130     REAL :: scale_factor
131     INTEGER, DIMENSION( ims:ime, jms:jme ) :: shadowmask 
132     INTEGER                             :: ij
133     INTEGER  num_roof_layers
134     INTEGER  num_wall_layers
135     INTEGER  num_road_layers
136     INTEGER  iswater
137     INTEGER  rk_step 
138 #if ( WRF_DFI_RADAR == 1 )
139     INTEGER  i_start,i_end,j_start,j_end,i,j,k
140 #endif
142    rk_step = 1
144       IF ((grid%skebs_on==1).and.(grid%id .EQ. 1 )) then
145           ! update and backtransform T
146           CALL RAND_PERT_UPDATE(grid,'T',                                     &
147                           grid%SPTFORCS,grid%SPTFORCC,                        &
148                           grid%SPT_AMP,grid%ALPH_T,                           &
149                           ips, ipe, jps, jpe, kps, kpe,                       &
150                           ids, ide, jds, jde, kds, kde,                       &
151                           ims, ime, jms, jme, kms, kme,                       &
152                           k_start, k_end,                                     &
153                           imsx,imex,jmsx,jmex,kmsx,kmex,                      &
154                           ipsx,ipex,jpsx,jpex,kpsx,kpex,                      &
155                           imsy,imey,jmsy,jmey,kmsy,kmey,                      &
156                           ipsy,ipey,jpsy,jpey,kpsy,kpey,                      &
157                           grid%num_stoch_levels,grid%num_stoch_levels,        &
158                           grid%num_stoch_levels,grid%num_stoch_levels,        &
159                           config_flags%restart, grid%iseedarr_skebs,          &
160                           config_flags%seed_dim,                              &
161                           grid%DX,grid%DY,grid%skebs_vertstruc,               &
162                           grid%rt_tendf_stoch,                                &
163                           grid%stddev_cutoff_sppt,grid%gridpt_stddev_sppt,    &
164                           grid%VERTSTRUCC,grid%VERTSTRUCS,grid%VERTAMPUV      )
165           ! Update streamfunction, backtransform U
166            CALL RAND_PERT_UPDATE(grid,'U',                                    &
167                            grid%SPSTREAMFORCS,grid%SPSTREAMFORCC,             &
168                            grid%SPSTREAM_AMP,grid%ALPH_PSI,                   &
169                            ips, ipe, jps, jpe, kps, kpe,                      &
170                            ids, ide, jds, jde, kds, kde,                      &
171                            ims, ime, jms, jme, kms, kme,                      &
172                            k_start, k_end,                                    &
173                            imsx,imex,jmsx,jmex,kmsx,kmex,                     &
174                            ipsx,ipex,jpsx,jpex,kpsx,kpex,                     &
175                            imsy,imey,jmsy,jmey,kmsy,kmey,                     &
176                            ipsy,ipey,jpsy,jpey,kpsy,kpey,                     &
177                            grid% num_stoch_levels,grid% num_stoch_levels,     &
178                            grid% num_stoch_levels,grid% num_stoch_levels,     &
179                            config_flags%restart, grid%iseedarr_skebs,         &
180                            config_flags%seed_dim,                             &
181                            grid%DX,grid%DY,grid%skebs_vertstruc,              &
182                            grid%ru_tendf_stoch,                               &
183                            grid%stddev_cutoff_sppt,grid%gridpt_stddev_sppt,   &
184                            grid%VERTSTRUCC,grid%VERTSTRUCS,grid%VERTAMPUV     )
185           ! Don't update streamfunction, backtransform V
186            CALL RAND_PERT_UPDATE(grid,'V',                                    &
187                            grid%SPSTREAMFORCS,grid%SPSTREAMFORCC,             &
188                            grid%SPSTREAM_AMP,grid%ALPH_PSI,                   &
189                            ips, ipe, jps, jpe, kps, kpe,                      &
190                            ids, ide, jds, jde, kds, kde,                      &
191                            ims, ime, jms, jme, kms, kme,                      &
192                            k_start, k_end,                                    &
193                            imsx,imex,jmsx,jmex,kmsx,kmex,                     &
194                            ipsx,ipex,jpsx,jpex,kpsx,kpex,                     &
195                            imsy,imey,jmsy,jmey,kmsy,kmey,                     &
196                            ipsy,ipey,jpsy,jpey,kpsy,kpey,                     &
197                            grid% num_stoch_levels,grid% num_stoch_levels,     &
198                            grid% num_stoch_levels,grid% num_stoch_levels,     &
199                            config_flags%restart, grid%iseedarr_skebs,         &
200                            config_flags%seed_dim,                             &
201                            grid%DX,grid%DY,grid%skebs_vertstruc,              &
202                            grid%rv_tendf_stoch,                               &
203                            grid%stddev_cutoff_sppt,grid%gridpt_stddev_sppt,   &
204                            grid%VERTSTRUCC,grid%VERTSTRUCS,grid%VERTAMPT      )
205        ENDIF !skebs_on 
207      if ((grid%sppt_on==1).and.(grid%id .EQ. 1 )) then
208           CALL RAND_PERT_UPDATE(grid,'T',                                     &
209                           grid%SPPTFORCS,grid%SPPTFORCC,                      &
210                           grid%SPPT_AMP,grid%ALPH_SPPT,                       &
211                           ips, ipe, jps, jpe, kps, kpe,                       &
212                           ids, ide, jds, jde, kds, kde,                       &
213                           ims, ime, jms, jme, kms, kme,                       &
214                           k_start, k_end,                                     &
215                           imsx,imex,jmsx,jmex,kmsx,kmex,                      &
216                           ipsx,ipex,jpsx,jpex,kpsx,kpex,                      &
217                           imsy,imey,jmsy,jmey,kmsy,kmey,                      &
218                           ipsy,ipey,jpsy,jpey,kpsy,kpey,                      &
219                           grid%num_stoch_levels,grid%num_stoch_levels,        &
220                           grid%num_stoch_levels,grid%num_stoch_levels,        &
221                           config_flags%restart, grid%iseedarr_sppt,           &
222                           config_flags%seed_dim,                              &
223                           grid%DX,grid%DY,grid%sppt_vertstruc,                &
224                           grid%rstoch,                                        &
225                           grid%stddev_cutoff_sppt,grid%gridpt_stddev_sppt,    &
226                           grid%VERTSTRUCC,grid%VERTSTRUCS,grid%VERTAMPT       )
227        ENDIF !sppt_on
229       if ((grid%rand_perturb_on==1).and.(grid%id .EQ. 1 )) then
230            CALL RAND_PERT_UPDATE(grid,'T',                                     &
231                            grid%SPFORCS,grid%SPFORCC,                          &
232                            grid%SP_AMP,grid%ALPH_RAND,                         &
233                            ips, ipe, jps, jpe, kps, kpe,                       &
234                            ids, ide, jds, jde, kds, kde,                       &
235                            ims, ime, jms, jme, kms, kme,                       &
236                            k_start, k_end,                                     &
237                            imsx,imex,jmsx,jmex,kmsx,kmex,                      &
238                            ipsx,ipex,jpsx,jpex,kpsx,kpex,                      &
239                            imsy,imey,jmsy,jmey,kmsy,kmey,                      &
240                            ipsy,ipey,jpsy,jpey,kpsy,kpey,                      &
241                            grid%num_stoch_levels,grid%num_stoch_levels,        &
242                            grid%num_stoch_levels,grid%num_stoch_levels,        &
243                            config_flags%restart, grid%iseedarr_rand_pert,      &
244                            config_flags%seed_dim,                              &
245                            grid%DX,grid%DY,grid%rand_pert_vertstruc,           &
246                            grid%RAND_PERT,                                     &
247                            grid%stddev_cutoff_sppt,grid%gridpt_stddev_sppt,    &
248                            grid%VERTSTRUCC,grid%VERTSTRUCS,grid%VERTAMPT       )
249        ENDIF !rand_perturb_on
251 !!!!! REPLACE WITH g_??? WHEN CONSTRUCTING TL OF PHYSICS. Xing Zhang
253 BENCH_START(tl_cal_phy_tend)
254       !$OMP PARALLEL DO   &
255       !$OMP PRIVATE ( ij )
257       DO ij = 1 , grid%num_tiles
259         CALL wrf_debug ( 200 , ' call g_calculate_phy_tend' )
260         CALL g_calculate_phy_tend (config_flags,grid%mut,grid%g_mut,grid%muu,grid%g_muu, &
261                      grid%muv,grid%g_muv,pi_phy,                       &
262                      grid%rthraten, grid%g_rthraten,                   &
263                      grid%rublten, grid%g_rublten,                     &
264                      grid%rvblten, grid%g_rvblten,                     &
265                      grid%rthblten, grid%g_rthblten,                   &
266                      grid%rqvblten, grid%g_rqvblten,                   &
267                      grid%rqcblten, grid%g_rqcblten,                   &
268                      grid%rqiblten, grid%g_rqiblten,                   &
269                      grid%rucuten, grid%g_rucuten,                     &
270                      grid%rvcuten, grid%g_rvcuten,                     &
271                      grid%rthcuten, grid%g_rthcuten,                   &
272                      grid%rqvcuten, grid%g_rqvcuten,                   &
273                      grid%rqccuten, grid%g_rqccuten,                   &
274                      grid%rqrcuten, grid%g_rqrcuten,                   &
275                      grid%rqicuten, grid%g_rqicuten,                   &
276                      grid%rqscuten, grid%g_rqscuten,                   &
277                      grid%rushten, grid%g_rushten,                     &
278                      grid%rvshten, grid%g_rvshten,                     &
279                      grid%rthshten, grid%g_rthshten,                   &
280                      grid%rqvshten, grid%g_rqvshten,                   &
281                      grid%rqcshten, grid%g_rqcshten,                   &
282                      grid%rqrshten, grid%g_rqrshten,                   &
283                      grid%rqishten, grid%g_rqishten,                   &
284                      grid%rqsshten, grid%g_rqsshten,                   &
285                      grid%rqgshten, grid%g_rqgshten,                   &
286                      grid%RUNDGDTEN, grid%g_RUNDGDTEN,                 &
287                      grid%RVNDGDTEN, grid%g_RVNDGDTEN,                 &
288                      grid%RTHNDGDTEN, grid%g_RTHNDGDTEN,               &
289                      grid%RQVNDGDTEN, grid%g_RQVNDGDTEN,               &
290                      grid%RMUNDGDTEN,                                  &
291                      ids,ide, jds,jde, kds,kde,                        &
292                      ims,ime, jms,jme, kms,kme,                        &
293                      grid%i_start(ij), min(grid%i_end(ij),ide-1),      &
294                      grid%j_start(ij), min(grid%j_end(ij),jde-1),      &
295                      k_start    , min(k_end,kde-1)                     )
297       ENDDO
298       !$OMP END PARALLEL DO
299 BENCH_END(tl_cal_phy_tend)
301        IF(config_flags%diff_opt .eq. 2 .OR. config_flags%diff_opt .eq. 1) THEN
303 BENCH_START(tl_comp_diff_metrics_tim)
304          !$OMP PARALLEL DO   &
305          !$OMP PRIVATE ( ij )
306          DO ij = 1 , grid%num_tiles
307            CALL wrf_debug ( 200 , ' call g_compute_diff_metrics ' )
308            CALL g_compute_diff_metrics ( config_flags, grid%ph_2,grid%g_ph_2, &
309                 grid%phb, grid%z,grid%g_z, grid%rdz,grid%g_rdz, grid%rdzw,grid%g_rdzw, &
310                 grid%zx,grid%g_zx, grid%zy,grid%g_zy, grid%rdx, grid%rdy, &
311                 ids, ide, jds, jde, kds, kde,          &
312                 ims, ime, jms, jme, kms, kme,          &
313                 grid%i_start(ij), grid%i_end(ij),      &
314                 grid%j_start(ij), grid%j_end(ij),      &
315                 k_start    , k_end                    )
316          ENDDO
317          !$OMP END PARALLEL DO
318 BENCH_END(tl_comp_diff_metrics_tim)
320 #ifdef DM_PARALLEL
321 #  include "HALO_EM_TKE_C_TL.inc"
322 #  include "PERIOD_BDY_EM_A1.inc"
323 #endif
325 BENCH_START(tl_tke_diff_bc_tim)
326          !$OMP PARALLEL DO   &
327          !$OMP PRIVATE ( ij )
329          DO ij = 1 , grid%num_tiles
331            CALL wrf_debug ( 200 , ' call tl of bc for diffusion_metrics ' )
332            CALL g_set_physical_bc3d( grid%rdzw ,grid%g_rdzw, 'w', config_flags, &
333                                    ids, ide, jds, jde, kds, kde,       &
334                                    ims, ime, jms, jme, kms, kme,       &
335                                    ips, ipe, jps, jpe, kps, kpe,       &
336                                    grid%i_start(ij), grid%i_end(ij),   &
337                                    grid%j_start(ij), grid%j_end(ij),   &
338                                    k_start    , k_end                 )
339            CALL g_set_physical_bc3d( grid%rdz ,grid%g_rdz, 'w', config_flags, &
340                                    ids, ide, jds, jde, kds, kde,       &
341                                    ims, ime, jms, jme, kms, kme,       &
342                                    ips, ipe, jps, jpe, kps, kpe,       &
343                                    grid%i_start(ij), grid%i_end(ij),   &
344                                    grid%j_start(ij), grid%j_end(ij),   &
345                                    k_start    , k_end                 )
346            CALL g_set_physical_bc3d( grid%z ,grid%g_z, 'w', config_flags, &
347                                    ids, ide, jds, jde, kds, kde,       &
348                                    ims, ime, jms, jme, kms, kme,       &
349                                    ips, ipe, jps, jpe, kps, kpe,       &
350                                    grid%i_start(ij), grid%i_end(ij),   &
351                                    grid%j_start(ij), grid%j_end(ij),   &
352                                    k_start    , k_end                 )
353            CALL g_set_physical_bc3d( grid%zx ,grid%g_zx, 'w', config_flags, &
354                                    ids, ide, jds, jde, kds, kde,       &
355                                    ims, ime, jms, jme, kms, kme,       &
356                                    ips, ipe, jps, jpe, kps, kpe,       &
357                                    grid%i_start(ij), grid%i_end(ij),   &
358                                    grid%j_start(ij), grid%j_end(ij),   &
359                                    k_start    , k_end                 )
360            CALL g_set_physical_bc3d( grid%zy ,grid%g_zy, 'w', config_flags, &
361                                    ids, ide, jds, jde, kds, kde,       &
362                                    ims, ime, jms, jme, kms, kme,       &
363                                    ips, ipe, jps, jpe, kps, kpe,       &
364                                    grid%i_start(ij), grid%i_end(ij),   &
365                                    grid%j_start(ij), grid%j_end(ij),   &
366                                    k_start    , k_end                 )
367            CALL g_set_physical_bc2d( grid%ustm,grid%g_ustm, 't', config_flags, &
368                                    ids, ide, jds, jde,                 &
369                                    ims, ime, jms, jme,                 &
370                                    ips, ipe, jps, jpe,                 &
371                                    grid%i_start(ij), grid%i_end(ij),   &
372                                    grid%j_start(ij), grid%j_end(ij)   )
374          ENDDO
375          !$OMP END PARALLEL DO
376 BENCH_END(tl_tke_diff_bc_tim)
378 BENCH_START(tl_deform_div_tim)
380          !$OMP PARALLEL DO   &
381          !$OMP PRIVATE ( ij )
383          DO ij = 1 , grid%num_tiles
385            CALL wrf_debug ( 200 , ' call g_cal_deform_and_div' )
386            CALL g_cal_deform_and_div ( config_flags,grid%u_2,grid%g_u_2, &
387                 grid%v_2,grid%g_v_2,grid%w_2,grid%g_w_2,grid%div,grid%g_div,  &
388                 grid%defor11,grid%g_defor11,grid%defor22,grid%g_defor22, &
389                 grid%defor33,grid%g_defor33,grid%defor12,grid%g_defor12, &
390                 grid%defor13,grid%g_defor13,grid%defor23,grid%g_defor23, &
391                 nba_rij,g_nba_rij, n_nba_rij,                   &
392                 grid%u_base, grid%v_base,grid%msfux,grid%msfuy,    &
393                 grid%msfvx,grid%msfvy,grid%msftx,grid%msfty,       &
394                 grid%rdx, grid%rdy, grid%dn, grid%dnw, grid%rdz,grid%g_rdz,   &
395                 grid%rdzw,grid%g_rdzw,grid%fnm,grid%fnp,grid%cf1,grid%cf2,    &
396                 grid%cf3,grid%zx,grid%g_zx,grid%zy,grid%g_zy,                 &
397                 ids, ide, jds, jde, kds, kde,        &
398                 ims, ime, jms, jme, kms, kme,        &
399                 grid%i_start(ij), grid%i_end(ij),    &
400                 grid%j_start(ij), grid%j_end(ij),    &
401                 k_start    , k_end                  )
402          ENDDO
403          !$OMP END PARALLEL DO
404 BENCH_END(tl_deform_div_tim)
406 #ifdef DM_PARALLEL
407 #     include "HALO_EM_TKE_D_TL.inc"
408 #endif
410 BENCH_START(tl_calc_tke_tim)
411          !$OMP PARALLEL DO   &
412          !$OMP PRIVATE ( ij )
413          DO ij = 1 , grid%num_tiles
415            CALL wrf_debug ( 200 , ' call g_calculate_km_kh' )
416            CALL g_calculate_km_kh( config_flags,grid%dt,grid%dampcoef,grid%zdamp, &
417                 config_flags%damp_opt,                                 &
418                 grid%xkmh,grid%g_xkmh,grid%xkmv,grid%g_xkmv,grid%xkhh,grid%g_xkhh, &
419                 grid%xkhv,grid%g_xkhv,grid%bn2,grid%g_bn2,             &
420                 grid%khdif,grid%kvdif,grid%div,grid%g_div,             &
421                 grid%defor11,grid%g_defor11,grid%defor22,grid%g_defor22, &
422                 grid%defor33,grid%g_defor33,grid%defor12,grid%g_defor12, &
423                 grid%defor13,grid%g_defor13,grid%defor23,grid%g_defor23, &
424                 grid%tke_2,grid%g_tke_2,p8w,g_p8w,t8w,g_t8w,th_phy,g_th_phy, &
425                 t_phy,g_t_phy,p_phy,g_p_phy,moist,g_moist,grid%dn,grid%dnw,  &
426                 grid%dx,grid%dy,grid%rdz,grid%g_rdz,grid%rdzw,grid%g_rdzw,            &
427                 config_flags%mix_isotropic,num_moist,                  &
428                 grid%cf1, grid%cf2, grid%cf3, grid%warm_rain,          &
429                 grid%mix_upper_bound,                                  &
430                 grid%msftx, grid%msfty,                                &
431                 grid%zx, grid%g_zx, grid%zy, grid%g_zy,                &
432                 ids,ide, jds,jde, kds,kde,                             &
433                 ims,ime, jms,jme, kms,kme,                             &
434                 grid%i_start(ij), grid%i_end(ij),                      &
435                 grid%j_start(ij), grid%j_end(ij),                      &
436                 k_start    , k_end                          )
437          ENDDO
438        !$OMP END PARALLEL DO
439 BENCH_END(tl_calc_tke_tim)
441 #ifdef DM_PARALLEL
442 #     include "HALO_EM_TKE_E_TL.inc"
443 #endif
445        ENDIF
447 #ifdef DM_PARALLEL
448 #      include "PERIOD_BDY_EM_PHY_BC.inc"
449        IF ( config_flags%grid_fdda .eq. 1) THEN
450 #      include "PERIOD_BDY_EM_FDDA_BC.inc"
451        ENDIF
452 #      include "PERIOD_BDY_EM_CHEM.inc"
453 #endif
455 BENCH_START(tl_phy_bc_tim)
456        !$OMP PARALLEL DO   &
457        !$OMP PRIVATE ( ij )
459        DO ij = 1 , grid%num_tiles
461          CALL wrf_debug ( 200 , ' call g_phy_bc' )
462          CALL g_phy_bc (config_flags,grid%div,grid%g_div,grid%defor11,grid%g_defor11, &
463                       grid%defor22,grid%g_defor22,grid%defor33,grid%g_defor33, &
464                       grid%defor12,grid%g_defor12,grid%defor13,grid%g_defor13, &
465                       grid%defor23,grid%g_defor23,                 &
466                       grid%xkmh,grid%g_xkmh,grid%xkmv,grid%g_xkmv, &
467                       grid%xkhh,grid%g_xkhh,grid%xkhv,grid%g_xkhv, &
468                       grid%tke_2,grid%g_tke_2,                     &
469                       grid%rublten,grid%g_rublten, grid%rvblten,grid%g_rvblten, &
470                       grid%rucuten,grid%g_rucuten, grid%rvcuten,grid%g_rvcuten, & 
471                       grid%rushten,grid%g_rushten, grid%rvshten,grid%g_rvshten, &
472                       ids, ide, jds, jde, kds, kde,                &
473                       ims, ime, jms, jme, kms, kme,                &
474                       ips, ipe, jps, jpe, kps, kpe,                &
475                       grid%i_start(ij), grid%i_end(ij),            &
476                       grid%j_start(ij), grid%j_end(ij),            &
477                       k_start    , k_end                           )
478        ENDDO
479        !$OMP END PARALLEL DO
480 BENCH_END(tl_phy_bc_tim)
482 IF ( ( config_flags%sfs_opt .GT. 0 ) .AND. ( config_flags%diff_opt .eq. 2 ) ) THEN
483  CALL g_sfs_driver( grid, config_flags,     &
484                   nba_mij,g_nba_mij, n_nba_mij,     & 
485                   nba_rij,g_nba_rij, n_nba_rij      ) 
487 ENDIF
489 #ifdef DM_PARALLEL
490 !-----------------------------------------------------------------------
492 ! MPP for some physics tendency, km, kh, deformation, and divergence
494 !                                                         * * * * * * *
495 !                                            * * * * *    * * * * * * *
496 !               *                     *      * * * * *    * * * * * * *
497 !             * + *      * + *        +      * * + * *    * * * + * * *
498 !               *                     *      * * * * *    * * * * * * *
499 !                                            * * * * *    * * * * * * *
500 !                                                         * * * * * * *
502 ! (for PBL)
503 ! rublten                  x
504 ! rvblten                             x
506 ! (for Cumulus)
507 ! rucuten                  x
508 ! rvcuten                             x
510 ! (for Shallow Cumulus)
511 ! rushten                  x
512 ! rvshten                             x
514 ! (for FDDA)
515 ! rundgdten     x
516 ! rvndgdten     x
518 ! (for TKE3)
519 ! tke_2                                          x               
520 ! (for TKE5)
521 ! tke_2                                                         x
523 ! (for diff_opt >= 1)
524 ! defor11                  x
525 ! defor22                             x
526 ! defor12       x
527 ! defor13                  x
528 ! defor23                             x
529 ! div           x
530 ! xkmv          x
531 ! xkmh          x
532 ! xkhv          x
533 ! xkhh          x
534 ! tke           x
536 !-----------------------------------------------------------------------
537        IF ( config_flags%bl_pbl_physics .ge. 1 ) THEN
538 #      include "HALO_EM_PHYS_PBL_TL.inc"
539        ENDIF
540        IF ( config_flags%shcu_physics .gt. 1 ) THEN
541 #      include "HALO_EM_PHYS_SHCU.inc"
542        ENDIF
543        IF ( config_flags%cu_physics == SASSCHEME      .or.   &
544             config_flags%cu_physics == TIEDTKESCHEME  .or.   &
545             config_flags%cu_physics == NTIEDTKESCHEME .or.   &
546             config_flags%cu_physics == CAMZMSCHEME    .or.   &
547             config_flags%cu_physics == NSASSCHEME ) THEN
548 #      include "HALO_EM_PHYS_CU.inc"
549        ENDIF
550        IF ( config_flags%grid_fdda .ge. 1) THEN
551 #      include "HALO_EM_FDDA.inc"
552        ENDIF
553        IF ( config_flags%diff_opt .ge. 1 ) THEN
554 #      include "HALO_EM_PHYS_DIFFUSION_TL.inc"
555        ENDIF
557        IF      ( config_flags%h_mom_adv_order <= 4 ) THEN
558 #       include "HALO_EM_TKE_3_TL.inc"
559        ELSE IF ( config_flags%h_mom_adv_order <= 6 ) THEN
560 #       include "HALO_EM_TKE_5_TL.inc"
561        ELSE
562          WRITE(wrf_err_message,*)'solve_em: invalid h_mom_adv_order = ',config_flags%h_mom_adv_order
563          CALL wrf_error_fatal(TRIM(wrf_err_message))
564        ENDIF
565 #endif
567 BENCH_START(tl_update_phy_ten_tim)
568        !$OMP PARALLEL DO   &
569        !$OMP PRIVATE ( ij )
571        DO ij = 1 , grid%num_tiles
573          CALL wrf_debug ( 200 , ' call g_update_phy_ten' )
574 #if ( WRF_DFI_RADAR == 1 )
575          if (config_flags%cu_physics .gt. 0) then
576            i_start = grid%i_start(ij)
577            i_end   = min( grid%i_end(ij),ide-1 )
578            j_start = grid%j_start(ij)
579            j_end   = min( grid%j_end(ij),jde-1 )
580            if (grid%dfi_stage == DFI_FWD ) &
581                  CALL wrf_debug ( 200 , ' Zero out cu_physics' )
582            DO j = j_start, j_end
583            DO k = k_start, min( k_end,kde-1 ) - 1
584            DO i = i_start, i_end
585              if (grid%dfi_stage ==DFI_FWD  &
586              .and. grid%dfi_tten_rad(i,k,j) >= 1.0e-7 .and.  &
587                    grid%dfi_tten_rad(i,k,j) <= 10.) then
589                 grid%g_rthcuten(i,k,j) = 0.0
590                 grid%rthcuten(i,k,j) = 0.0
592              endif
593            ENDDO
594            ENDDO
595            ENDDO
596          ENDIF
597 #endif
598          CALL g_update_phy_ten(ph_tendf,t_tendf, g_t_tendf, ru_tendf, g_ru_tendf,      &
599                            rv_tendf,g_rv_tendf,moist_tend,g_moist_tend,    &
600                            scalar_tend, mu_tendf,                           &
601                            grid%rthraten,grid%rthblten,grid%g_rthblten,       &
602                            grid%rthcuten,grid%g_rthcuten,grid%rthshten, &
603                            grid%rublten,grid%g_rublten,grid%rucuten,grid%rushten,          &
604                            grid%rvblten,grid%g_rvblten,grid%rvcuten,grid%rvshten,          &
605                            grid%rqvblten,grid%g_rqvblten,grid%rqcblten,grid%rqiblten,       &
606                            grid%rqvcuten,grid%g_rqvcuten,grid%rqccuten,grid%rqrcuten,       &
607                            grid%rqicuten,grid%rqscuten,                     &
608                            grid%rqvshten,grid%rqcshten,grid%rqrshten,       &
609                            grid%rqishten,grid%rqsshten,grid%rqgshten,       &
610                            grid%RUNDGDTEN,                                  &
611                            grid%RVNDGDTEN,grid%RTHNDGDTEN,grid%RPHNDGDTEN,  &
612                            grid%RQVNDGDTEN,grid%RMUNDGDTEN,                 &
613                            grid%rthfrten,grid%rqvfrten,                     &  ! fire
614                            num_moist,num_scalar,config_flags,rk_step,       &
615                            grid%adv_moist_cond,                             &
616                            ids, ide, jds, jde, kds, kde,                    &
617                            ims, ime, jms, jme, kms, kme,                    &
618                            grid%i_start(ij), grid%i_end(ij),                &
619                            grid%j_start(ij), grid%j_end(ij),                &
620                            k_start, k_end                               )
622        END DO
623        !$OMP END PARALLEL DO
624 BENCH_END(tl_update_phy_ten_tim)
626 #ifdef PLANET
627        IF ( (config_flags%damp_opt == 101) .OR. &
628             (config_flags%damp_opt == 103)      ) THEN
629          !$OMP PARALLEL DO   &
630          !$OMP PRIVATE ( ij )
631          DO ij = 1 , grid%num_tiles
632 !!!!! Need tl of damptop, but cannot find declaration of damptop. Ning Pan, 2010-08-11
633            CALL damptop( grid%u_2, grid%v_2, grid%t_2, &
634                          grid%mut, grid%muu, grid%muv, &
635                          pi_phy,                                &
636                          t_tendf, ru_tendf, rv_tendf, P2SI,     &
637                          ids, ide, jds, jde, kds, kde,          &
638                          ims, ime, jms, jme, kms, kme,          &
639                          grid%i_start(ij), grid%i_end(ij),      &
640                          grid%j_start(ij), grid%j_end(ij),      &
641                          k_start, k_end                         )
642          END DO
643          !$OMP END PARALLEL DO
644        END IF
645 #endif
647        IF( config_flags%diff_opt .eq. 2 .and. config_flags%km_opt .eq. 2 ) THEN
649 BENCH_START(tl_tke_rhs_tim)
650          !$OMP PARALLEL DO   &
651          !$OMP PRIVATE ( ij )
652          DO ij = 1 , grid%num_tiles
654            CALL g_tke_rhs  ( tke_tend,g_tke_tend,grid%bn2,grid%g_bn2, &
655                 config_flags,grid%defor11,grid%g_defor11,grid%defor22,grid%g_defor22, &
656                 grid%defor33,grid%g_defor33,grid%defor12,grid%g_defor12, &
657                 grid%defor13,grid%g_defor13,grid%defor23,grid%g_defor23, &
658                 grid%u_2,grid%g_u_2,grid%v_2,grid%g_v_2,grid%w_2,grid%g_w_2, &
659                 grid%div,grid%g_div,grid%tke_2,grid%g_tke_2,grid%mut,grid%g_mut, &
660                 th_phy,g_th_phy,p_phy,g_p_phy,p8w,g_p8w,t8w,g_t8w,   &
661                 grid%z,grid%g_z,grid%fnm,                    & 
662                 grid%fnp,grid%cf1,grid%cf2,grid%cf3,         &     
663                 grid%msftx,grid%msfty,grid%xkmh,grid%g_xkmh, &
664                 grid%xkmv,grid%g_xkmv,grid%xkhv,grid%g_xkhv,grid%rdx,grid%rdy,   &
665                 grid%dx,grid%dy,grid%dt,grid%zx,grid%g_zx,grid%zy,grid%g_zy,     &
666                 grid%rdz,grid%g_rdz,grid%rdzw,grid%g_rdzw,grid%dn,               &
667                 grid%dnw,config_flags%mix_isotropic,         &
668                 grid%hfx,grid%g_hfx, grid%qfx,grid%g_qfx,    &
669                 moist(ims,kms,jms,P_QV),g_moist(ims,kms,jms,P_QV), &
670                 grid%ustm,grid%g_ustm, grid%rho,grid%g_rho,                  &
671                 ids, ide, jds, jde, kds, kde,                &
672                 ims, ime, jms, jme, kms, kme,                &
673                 grid%i_start(ij), grid%i_end(ij),            &
674                 grid%j_start(ij), grid%j_end(ij),            &
675                 k_start    , k_end                           )
677          ENDDO
678          !$OMP END PARALLEL DO
679 BENCH_END(tl_tke_rhs_tim)
681        ENDIF
683        IF(config_flags%diff_opt .eq. 2) THEN
685          IF (config_flags%bl_pbl_physics .eq. 0) THEN
687 BENCH_START(tl_vert_diff_tim)
688            !$OMP PARALLEL DO   &
689            !$OMP PRIVATE ( ij )
690            DO ij = 1 , grid%num_tiles
692              CALL wrf_debug ( 200 , ' call g_vertical_diffusion_2 ' )
693              CALL g_vertical_diffusion_2(ru_tendf,g_ru_tendf, &
694                   rv_tendf,g_rv_tendf, rw_tendf,g_rw_tendf,   &
695                   t_tendf,g_t_tendf, tke_tend,g_tke_tend,     &
696                   moist_tend,g_moist_tend,num_moist,             &
697                   chem_tend,g_chem_tend,num_chem,                &
698                   scalar_tend,g_scalar_tend,num_scalar,          &
699                   tracer_tend,g_tracer_tend,num_tracer,          &
700                   grid%u_2,grid%g_u_2,grid%v_2,grid%g_v_2,          &
701                   grid%t_2,grid%g_t_2,grid%u_base,grid%v_base,grid%t_base,grid%qv_base,&
702                   grid%mut,grid%g_mut,grid%tke_2,grid%g_tke_2,config_flags, &
703                   grid%defor13,grid%g_defor13,grid%defor23,grid%g_defor23,  &
704                   grid%defor33,grid%g_defor33,               &
705                   nba_mij,g_nba_mij, num_nba_mij,         &
706                   grid%div,grid%g_div, moist,g_moist, chem,g_chem, scalar,g_scalar, tracer,g_tracer, &
707                   grid%xkmv,grid%g_xkmv, grid%xkhv,grid%g_xkhv, config_flags%km_opt,                 &
708                   grid%fnm, grid%fnp, grid%dn, grid%dnw, grid%rdz,grid%g_rdz, grid%rdzw,grid%g_rdzw, &
709                   grid%hfx,grid%g_hfx, grid%qfx,grid%g_qfx, grid%ustm,grid%g_ustm, grid%rho,grid%g_rho,     &
710                   ids, ide, jds, jde, kds, kde,              &
711                   ims, ime, jms, jme, kms, kme,              &
712                   grid%i_start(ij), grid%i_end(ij),          &
713                   grid%j_start(ij), grid%j_end(ij),          &
714                   k_start, k_end                             )
716            ENDDO
717            !$OMP END PARALLEL DO
718 BENCH_END(tl_vert_diff_tim)
720          ENDIF
722 BENCH_START(tl_hor_diff_tim)
723          !$OMP PARALLEL DO   &
724          !$OMP PRIVATE ( ij )
725          DO ij = 1 , grid%num_tiles
727            CALL wrf_debug ( 200 , ' call g_horizontal_diffusion_2' )
728            CALL g_horizontal_diffusion_2( t_tendf,g_t_tendf, ru_tendf,g_ru_tendf, &
729                 rv_tendf,g_rv_tendf, rw_tendf,g_rw_tendf, &
730                 tke_tend,g_tke_tend,                     &
731                 moist_tend,g_moist_tend, num_moist,      &
732                 chem_tend,g_chem_tend, num_chem,         &
733                 scalar_tend,g_scalar_tend, num_scalar,   &
734                 tracer_tend,g_tracer_tend, num_tracer,   &
735                 grid%t_2,grid%g_t_2, th_phy,g_th_phy,    &
736                 grid%mut,grid%g_mut, grid%tke_2,grid%g_tke_2, config_flags, &
737                 grid%defor11,grid%g_defor11, grid%defor22,grid%g_defor22,   &
738                 grid%defor12,grid%g_defor12,  &
739                 grid%defor13,grid%g_defor13, grid%defor23,grid%g_defor23,   &
740                 nba_mij,g_nba_mij, num_nba_mij,         &
741                 grid%div,grid%g_div,                       &
742                 moist,g_moist, chem,g_chem, scalar,g_scalar,tracer,g_tracer, &
743                 grid%msfux,grid%msfuy, grid%msfvx,grid%msfvy, grid%msftx,  &
744                 grid%msfty, grid%xkmh,grid%g_xkmh, grid%xkhh,grid%g_xkhh, config_flags%km_opt, &
745                 grid%rdx, grid%rdy, grid%rdz,grid%g_rdz, grid%rdzw,grid%g_rdzw,                &
746                 grid%fnm, grid%fnp, grid%cf1, grid%cf2, grid%cf3,          &
747                 grid%zx,grid%g_zx, grid%zy,grid%g_zy, grid%dn, grid%dnw,                       &
748                 ids, ide, jds, jde, kds, kde,          &
749                 ims, ime, jms, jme, kms, kme,          &
750                 grid%i_start(ij), grid%i_end(ij),      &
751                 grid%j_start(ij), grid%j_end(ij),      &
752                 k_start    , k_end                    )
753          ENDDO
754          !$OMP END PARALLEL DO
755 BENCH_END(tl_hor_diff_tim)
756        ENDIF
758        IF ( grid%obs_nudge_opt .EQ. 1 .AND. grid%xtime <= grid%fdda_end ) THEN
759 # ifdef DM_PARALLEL
760 #       include "HALO_OBS_NUDGE.inc"
761 #endif
762 !***********************************************************************
763 ! This section for obs nudging
764          !$OMP PARALLEL DO   &
765          !$OMP PRIVATE ( ij )
767          DO ij = 1 , grid%num_tiles
769 !!!!! Need to code g_fddaobs_driver for full wrf+. Ning Pan
770            CALL fddaobs_driver (grid%grid_id, model_config_rec%grid_id, &
771                    model_config_rec%parent_id, config_flags%restart,    &
772                    config_flags,                                        &
773                    grid%obs_nudge_opt,                                  &
774                    grid%obs_ipf_errob,                                  &
775                    grid%obs_ipf_nudob,                                  &
776                    grid%fdda_start,                                     &
777                    grid%fdda_end,                                       &
778                    grid%obs_nudge_wind,                                 &
779                    grid%obs_nudge_temp,                                 &
780                    grid%obs_nudge_mois,                                 &
781                    grid%obs_nudge_pstr,                                 &
782                    grid%obs_coef_wind,                                  &
783                    grid%obs_coef_temp,                                  &
784                    grid%obs_coef_mois,                                  &
785                    grid%obs_coef_pstr,                                  &             
786                    grid%obs_rinxy,                                      &
787                    grid%obs_rinsig,                                     &
788                    grid%obs_npfi,                                       &
789                    grid%obs_ionf,                                       &
790                    grid%obs_prt_max,                                    &
791                    grid%obs_prt_freq,                                   &
792                    grid%obs_idynin,                                     &
793                    grid%obs_dtramp,                                     &
794                    grid%parent_grid_ratio,                              &
795                    grid%max_dom, grid%itimestep,                        &
796                    grid%xtime,                                          &
797                    grid%dt, grid%gmt, grid%julday, grid%fdob,           &
798                    grid%max_obs,                                        &
799                    model_config_rec%nobs_ndg_vars,                      &
800                    model_config_rec%nobs_err_flds,                      &
801                    grid%fdob%nstat, grid%fdob%varobs, grid%fdob%errf,   &
802                    grid%dx, grid%KPBL,grid%HT,                          &
803                    grid%mut, grid%muu, grid%muv, grid%c1h, grid%c2h,    &
804                    grid%msftx, grid%msfty, grid%msfux, grid%msfuy, grid%msfvx, grid%msfvy, &
805                    p_phy, t_tendf, t0,                                  &
806                    grid%u_2, grid%v_2, grid%t_2,                        &
807                    moist(ims,kms,jms,P_QV),                             &
808                    grid%pb, grid%p_top, grid%p, grid%phb, grid%ph_2,    &
809                    grid%uratx, grid%vratx, grid%tratx,                  &
810                    ru_tendf, rv_tendf,                                  &
811                    moist_tend(ims,kms,jms,P_QV), grid%obs_savwt,        &
812                    grid%regime, grid%pblh, grid%z_at_w, grid%z,         &
813                    ids,ide, jds,jde, kds,kde,                           &
814                    ims,ime, jms,jme, kms,kme,                           &
815                    grid%i_start(ij), min(grid%i_end(ij),ide-1),         &
816                    grid%j_start(ij), min(grid%j_end(ij),jde-1),         &
817                    k_start    , min(k_end,kde-1)                     )
819          ENDDO
820          !$OMP END PARALLEL DO
821        ENDIF  ! obs_nudge_opt .eq. 1
823 !***********************************************************************
825   END SUBROUTINE g_first_rk_step_part2
827 END MODULE g_module_first_rk_step_part2