1 !WRF:MODEL_LAYER:PHYSICS
2 MODULE module_fddaobs_driver
4 ! This obs-nudging FDDA module (RTFDDA) is developed by the
5 ! NCAR/RAL/NSAP (National Security Application Programs), under the
6 ! sponsorship of ATEC (Army Test and Evaluation Commands). ATEC is
7 ! acknowledged for releasing this capability for WRF community
8 ! research applications.
10 ! The NCAR/RAL RTFDDA module was adapted, and significantly modified
11 ! from the obs-nudging module in the standard MM5V3.1 which was originally
12 ! developed by PSU (Stauffer and Seaman, 1994).
14 ! Yubao Liu (NCAR/RAL): lead developer of the RTFDDA module
15 ! Al Bourgeois (NCAR/RAL): lead engineer implementing RTFDDA into WRF-ARW
20 ! Liu, Y., A. Bourgeois, T. Warner, S. Swerdlin and J. Hacker, 2005: An
21 ! implementation of obs-nudging-based FDDA into WRF for supporting
22 ! ATEC test operations. 2005 WRF user workshop. Paper 10.7.
24 ! Liu, Y., A. Bourgeois, T. Warner, S. Swerdlin and W. Yu, 2006: An update
25 ! on "obs-nudging"-based FDDA for WRF-ARW: Verification using OSSE
26 ! and performance of real-time forecasts. 2006 WRF user workshop. Paper 4.7.
29 ! Stauffer, D.R., and N.L. Seaman, 1994: Multi-scale four-dimensional data
30 ! assimilation. J. Appl. Meteor., 33, 416-434.
32 ! http://www.rap.ucar.edu/projects/armyrange/references.html
37 !-----------------------------------------------------------------------
38 SUBROUTINE fddaobs_driver( inest, domid, parid, restart, &
40 nudge_opt, iprt_errob, iprt_nudob, &
42 nudge_wind, nudge_temp, nudge_mois, &
44 coef_wind, coef_temp, coef_mois, &
45 coef_pstr, rinxy, rinsig, &
47 obs_prt_max, obs_prt_freq, idynin, dtramp, &
48 parent_grid_ratio, maxdom, itimestep, &
54 max_obs, nobs_ndg_vars, &
55 nobs_err_flds, nstat, varobs, errf, dx, &
56 KPBL, HT, mut, muu, muv, &
57 msftx, msfty, msfux, msfuy, msfvx, msfvy, p_phy, t_tendf, fddat0, &
58 ub, vb, tb, qvb, pbase, ptop, pp, phb, ph, &
59 uratx, vratx, tratx, ru_tendf, rv_tendf, &
61 regime, pblh, z_at_w, &
63 ids,ide, jds,jde, kds,kde, & ! domain dims
64 ims,ime, jms,jme, kms,kme, & ! memory dims
65 its,ite, jts,jte, kts,kte ) ! tile dims
67 !-----------------------------------------------------------------------
69 ! USE module_bc seems to not be needed
70 USE module_model_constants, ONLY : g, rcp
71 USE module_fddaobs_rtfdda
73 ! This driver calls subroutines for fdda obs-nudging and
74 ! returns computed tendencies
77 !-----------------------------------------------------------------------
79 !-----------------------------------------------------------------------
80 ! taken from MM5 code - 03 Feb 2004.
81 !-----------------------------------------------------------------------
83 !=======================================================================
86 !-- KPBL vertical layer index for PBL top
87 !-- HT terrain height (m)
88 !-- p_phy pressure (Pa)
89 !-- t_tendf temperature tendency
91 INTEGER, intent(in) :: ids,ide, jds,jde, kds,kde ! domain dims.
92 INTEGER, intent(in) :: ims,ime, jms,jme, kms,kme ! memory dims.
93 INTEGER, intent(in) :: its,ite, jts,jte, kts,kte ! tile dims.
95 INTEGER, intent(in) :: inest
96 INTEGER, intent(in) :: maxdom
97 INTEGER, intent(in) :: domid(maxdom) ! Domain IDs
98 INTEGER, intent(in) :: parid(maxdom) ! Parent domain IDs
99 LOGICAL, intent(in) :: restart
100 TYPE(grid_config_rec_type), INTENT(IN ) :: config_flags
101 INTEGER, intent(in) :: itimestep
102 INTEGER, intent(in) :: nudge_opt
103 LOGICAL, intent(in) :: iprt_errob
104 LOGICAL, intent(in) :: iprt_nudob
105 REAL, intent(in) :: fdasta
106 REAL, intent(in) :: fdaend
107 INTEGER, intent(in) :: nudge_wind
108 INTEGER, intent(in) :: nudge_temp
109 INTEGER, intent(in) :: nudge_mois
110 INTEGER, intent(in) :: nudge_pstr
111 REAL, intent(in) :: coef_wind
112 REAL, intent(in) :: coef_temp
113 REAL, intent(in) :: coef_mois
114 REAL, intent(in) :: coef_pstr
115 REAL, intent(inout) :: rinxy
116 REAL, intent(inout) :: rinsig
117 INTEGER, intent(in) :: npfi
118 INTEGER, intent(in) :: ionf
119 INTEGER, intent(in) :: obs_prt_max ! max number of obs in printout
120 INTEGER, intent(in) :: obs_prt_freq ! frequency (in obs index) printout
121 INTEGER, intent(in) :: idynin
122 REAL, intent(inout) :: dtramp
123 INTEGER, intent(in) :: parent_grid_ratio
124 REAL, intent(in) :: xtime ! forecast time in minutes
125 REAL, intent(in) :: dt
126 REAL, intent(in) :: gmt
127 INTEGER, intent(in) :: julday
128 INTEGER, intent(in) :: max_obs ! max number of observations
129 INTEGER, intent(in) :: nobs_ndg_vars
130 INTEGER, intent(in) :: nobs_err_flds
131 INTEGER, intent(in) :: nstat
132 REAL, intent(inout) :: varobs(nobs_ndg_vars, max_obs)
133 REAL, intent(inout) :: errf(nobs_err_flds, max_obs)
134 REAL, intent(in) :: dx ! this-domain grid cell-size (m)
135 INTEGER, INTENT(IN) :: kpbl( ims:ime, jms:jme ) ! vertical layer index for PBL top
136 REAL, INTENT(IN) :: ht( ims:ime, jms:jme )
137 REAL, INTENT(IN) :: mut( ims:ime , jms:jme ) ! Air mass on t-grid
138 REAL, INTENT(IN) :: muu( ims:ime , jms:jme ) ! Air mass on u-grid
139 REAL, INTENT(IN) :: muv( ims:ime , jms:jme ) ! Air mass on v-grid
140 REAL, INTENT(IN) :: msftx( ims:ime , jms:jme ) ! Map scale on t-grid
141 REAL, INTENT(IN) :: msfty( ims:ime , jms:jme ) ! Map scale on t-grid
142 REAL, INTENT(IN) :: msfux( ims:ime , jms:jme ) ! Map scale on u-grid
143 REAL, INTENT(IN) :: msfuy( ims:ime , jms:jme ) ! Map scale on u-grid
144 REAL, INTENT(IN) :: msfvx( ims:ime , jms:jme ) ! Map scale on v-grid
145 REAL, INTENT(IN) :: msfvy( ims:ime , jms:jme ) ! Map scale on v-grid
147 REAL, INTENT(IN) :: p_phy( ims:ime, kms:kme, jms:jme )
148 REAL, INTENT(INOUT) :: t_tendf( ims:ime, kms:kme, jms:jme )
149 REAL, INTENT(IN) :: fddat0
150 REAL, INTENT(INOUT) :: savwt( nobs_ndg_vars, ims:ime, kms:kme, jms:jme )
151 REAL, INTENT(INOUT) :: regime( ims:ime, jms:jme )
152 REAL, INTENT(IN) :: pblh( ims:ime, jms:jme )
153 REAL, INTENT(IN) :: z_at_w( ims:ime, kms:kme, jms:jme ) ! Model ht(m) asl, f-levs
154 REAL, INTENT(IN) :: z( ims:ime, kms:kme, jms:jme ) ! Model ht(m) asl, h-levs
157 TYPE(fdob_type), intent(inout) :: fdob
160 REAL, INTENT(IN) :: ub( ims:ime, kms:kme, jms:jme )
161 REAL, INTENT(IN) :: vb( ims:ime, kms:kme, jms:jme )
162 REAL, INTENT(IN) :: tb( ims:ime, kms:kme, jms:jme )
163 REAL, INTENT(IN) :: qvb( ims:ime, kms:kme, jms:jme )
164 REAL, INTENT(IN) :: pbase( ims:ime, kms:kme, jms:jme ) ! Base press. (Pa)
165 REAL, INTENT(IN) :: ptop
166 REAL, INTENT(IN) :: pp( ims:ime, kms:kme, jms:jme ) ! Press. pert. (Pa)
167 REAL, INTENT(IN) :: phb( ims:ime, kms:kme, jms:jme ) ! Base geopotential
168 REAL, INTENT(IN) :: ph( ims:ime, kms:kme, jms:jme ) ! Perturbation geopotential
169 REAL, INTENT(IN) :: uratx( ims:ime, jms:jme ) ! On mass points
170 REAL, INTENT(IN) :: vratx( ims:ime, jms:jme ) ! "
171 REAL, INTENT(IN) :: tratx( ims:ime, jms:jme ) ! "
172 REAL, INTENT(INOUT) :: ru_tendf( ims:ime, kms:kme, jms:jme )
173 REAL, INTENT(INOUT) :: rv_tendf( ims:ime, kms:kme, jms:jme )
174 REAL, INTENT(INOUT) :: moist_tend( ims:ime, kms:kme, jms:jme )
177 logical :: nudge_flag ! Flag for doing nudging
178 integer :: KTAU ! Forecast timestep
179 real :: dtmin ! dt in minutes
180 integer :: i, j, k ! Loop counters.
181 integer :: idom ! Loop counter.
182 integer :: nsta ! Number of observation stations
183 integer :: infr ! Frequency for obs input and error calc
184 integer :: idarst ! Flag for calling sub errob on restart
185 real :: dtr ! Abs value of dtramp (for dynamic init)
186 real :: tconst ! Reciprocal of dtr
187 real :: vih_uv(its:ite,jts:jte,2) ! Vert infl heights abv grd for LML obs (wind)
188 real :: vih_t (its:ite,jts:jte,2) ! Vert infl heights abv grd for LML obs (temp)
189 real :: vih_q (its:ite,jts:jte,2) ! Vert infl heights abv grd for LML obs (mois)
190 integer :: vik_uv(its:ite,jts:jte,2) ! Vert infl k-levels for LML obs (wind)
191 integer :: vik_t (its:ite,jts:jte,2) ! Vert infl k-levels for LML obs (temp)
192 integer :: vik_q (its:ite,jts:jte,2) ! Vert infl k-levels for LML obs (mois)
193 real :: z_at_p( kms:kme ) ! Height at p levels
195 real :: HTIJ(ids:ide, jds:jde) = 0. ! Terrain ht on global grid
197 character(len=200) :: msg ! Argument to wrf_message
200 nudge_flag = (nudge_opt .eq. 1)
202 if (.not. nudge_flag) return
204 !----------------------------------------------------------------------
205 ! *************** BEGIN FDDA SETUP SECTION ***************
207 ! Calculate forecast time.
209 ktau = itimestep - 1 !ktau corresponds to xtime
211 ! Set NSTA to zero on startup, or else retrieve value from last pass.
212 IF(ktau.EQ.fdob%ktaur) THEN
214 write(msg,'(a,i2,a)') 'OBS NUDGING is requested on a total of ', &
215 fdob%domain_tot,' domain(s).'
216 call wrf_message(msg)
223 infr = ionf*(parent_grid_ratio**fdob%levidn(inest))
226 IF(restart .AND. ktau.EQ.fdob%ktaur) idarst=1
228 CALL wrf_debug(100,'in PSU FDDA scheme')
230 ! Make sure regime array is set over entire grid
231 ! (ajb: Copied code from fddagd)
232 IF( config_flags%bl_pbl_physics /= 1 &
233 .AND. config_flags%bl_pbl_physics /= 5 &
234 .AND. config_flags%bl_pbl_physics /= 6 &
235 .AND. config_flags%bl_pbl_physics /= 7 &
236 .AND. config_flags%bl_pbl_physics /= 99 ) THEN
239 IF( pblh(i,j) > z_at_w(i,2,j)-ht(i,j) ) THEN
248 ! Compute VIF heights for each grid column (used for LML obs)
249 if(fdob%sfc_scheme_vert.EQ.0) then
250 if(nudge_wind.EQ.1 .AND. NSTA.GT.0) then
251 CALL compute_VIH( fdob%vif_uv, fdob%vif_max, &
252 fdob%vif_fullmin, fdob%vif_rampmin, &
255 ids,ide, jds,jde, kds,kde, &
256 ims,ime, jms,jme, kms,kme, &
257 its,ite, jts,jte, kts,kte )
259 if(nudge_temp.EQ.1 .AND. NSTA.GT.0) then
260 CALL compute_VIH( fdob%vif_t, fdob%vif_max, &
261 fdob%vif_fullmin, fdob%vif_rampmin, &
264 ids,ide, jds,jde, kds,kde, &
265 ims,ime, jms,jme, kms,kme, &
266 its,ite, jts,jte, kts,kte )
268 if(nudge_mois.EQ.1 .AND. NSTA.GT.0) then
269 CALL compute_VIH( fdob%vif_q, fdob%vif_max, &
270 fdob%vif_fullmin, fdob%vif_rampmin, &
273 ids,ide, jds,jde, kds,kde, &
274 ims,ime, jms,jme, kms,kme, &
275 its,ite, jts,jte, kts,kte )
278 !********************* END AJB MOVE TO SLAB ***************************
280 ! COMPUTE ERROR BETWEEN OBSERVATIONS and MODEL
282 IF( MOD(ktau,infr).EQ.0 .OR. idarst.EQ.1) THEN
284 CALL errob(inest, ub, vb, tb, fddat0, qvb, pbase, pp, rcp, &
286 uratx, vratx, tratx, kpbl, &
287 nobs_ndg_vars, nobs_err_flds, max_obs, maxdom, &
288 fdob%levidn, parid, fdob%nstat, fdob%nstaw, &
289 nudge_wind, nudge_temp, nudge_mois, nudge_pstr, &
290 fdob%timeob, fdob%rio, fdob%rjo, fdob%rko, &
291 varobs, errf, ktau, xtime, &
292 parent_grid_ratio, npfi, &
293 obs_prt_max, obs_prt_freq, iprt_errob, &
294 fdob%obsprt, fdob%stnidprt, &
295 fdob%latprt, fdob%lonprt, &
296 fdob%mlatprt, fdob%mlonprt, &
297 ids,ide, jds,jde, kds,kde, &
298 ims,ime, jms,jme, kms,kme, &
299 its,ite, jts,jte, kts,kte)
304 IF(idynin.EQ.1.AND.nudge_opt.EQ.1) THEN
307 ! FDAEND(IN) IS THE TIME IN MINUTES TO END THE DYNAMIC INITIALIZATION CY
308 IF(xtime.LT.fdaend-dtr)THEN
310 ELSEIF(xtime.GE.fdaend-dtr.AND.xtime.LE.fdaend) THEN
311 fdob%tfaci=(fdaend-xtime)*tconst
315 IF(ktau.EQ.fdob%ktaur.OR.MOD(ktau,10).EQ.0) THEN
317 PRINT*,' DYNINOBS: IN,KTAU,XTIME,FDAEND,DTRAMP,DTR,TCONST', &
318 ',TFACI: ',INEST,KTAU,XTIME,FDAEND,DTRAMP,DTR,TCONST, &
324 ! MEIXU: collect terrain array HT into a global array HTIJ
325 CALL loc2glob(HT, HTIJ, "2D", "REAL", &
326 ids,ide, jds,jde, kds,kde, &
327 ims,ime, jms,jme, kms,kme )
331 ! *************** END FDDA SETUP SECTION ***************
332 !----------------------------------------------------------------------
334 !----------------------------------------------------------------------
335 ! *************** BEGIN NUDGING SECTION ***************
339 ! IF NUDGING SURFACE WINDS IN THE BOUNDARY LAYER, IF IWINDS(INEST+2)=1
340 ! USE A SIMILARITY CORRECTION BASED ON ROUGHNESS TO APPLY 10M
341 ! WIND TO THE SURFACE LAYER (K=KL) AT 40M. TO DO THIS WE MUST
342 ! STORE ROUGHNESS AND REGIME FOR EACH J SLICE AFTER THE CALL TO
343 ! HIRPBL FOR LATER USE IN BLNUDGD.
345 !--- OBS NUDGING FOR TEMP AND MOISTURE
348 IF(J .GT. 2 .and. J .LT. jde-1) THEN
349 IF(nudge_temp.EQ.1 .AND. NSTA.GT.0) &
351 ! write(6,*) 'calling nudob: IVAR=3, J = ',j
352 CALL nudob(J, 3, t_tendf(ims,kms,j), &
353 inest, restart, ktau, fdob%ktaur, xtime, &
354 mut(ims,j), msftx(ims,j), msfty(ims,j), &
355 nobs_ndg_vars, nobs_err_flds, max_obs, maxdom, &
356 npfi, ionf, rinxy, fdob%window, &
358 fdob%sfcfact, fdob%sfcfacr, &
361 fdob%rinfmn, fdob%rinfmx, fdob%pfree, &
362 fdob%dcon, fdob%tfaci, &
363 fdob%sfc_scheme_horiz, fdob%sfc_scheme_vert, &
364 fdob%max_sndng_gap, &
365 fdob%lev_in_ob, fdob%plfo, fdob%nlevs_ob, &
366 parent_grid_ratio, dx, dtmin, fdob%rio, fdob%rjo, &
367 fdob%rko, fdob%timeob, varobs, errf, &
368 pbase(ims,kms,j), ptop, pp(ims,kms,j), &
369 nudge_wind, nudge_temp, nudge_mois, &
370 coef_wind, coef_temp, coef_mois, &
371 savwt(1,ims,kms,j), kpbl(ims,j), 0, &
372 vih_t(its,j,1), vih_t(its,j,2), ht(ims,j), &
375 ids,ide, jds,jde, kds,kde, & ! domain dims
376 ims,ime, jms,jme, kms,kme, & ! memory dims
377 its,ite, jts,jte, kts,kte ) ! tile dims
378 ! write(6,*) 'return from nudob: IVAR=3, J = ',j
381 IF(nudge_mois.EQ.1 .AND. NSTA.GT.0) &
383 ! write(6,*) 'calling nudob: IVAR=4, J = ',j
384 CALL nudob(J, 4, moist_tend(ims,kms,j), &
385 inest, restart, ktau, fdob%ktaur, xtime, &
386 mut(ims,j), msftx(ims,j), msfty(ims,j), &
387 nobs_ndg_vars, nobs_err_flds, max_obs, maxdom, &
388 npfi, ionf, rinxy, fdob%window, &
390 fdob%sfcfact, fdob%sfcfacr, &
393 fdob%rinfmn, fdob%rinfmx, fdob%pfree, &
394 fdob%dcon, fdob%tfaci, &
395 fdob%sfc_scheme_horiz, fdob%sfc_scheme_vert, &
396 fdob%max_sndng_gap, &
397 fdob%lev_in_ob, fdob%plfo, fdob%nlevs_ob, &
398 parent_grid_ratio, dx, dtmin, fdob%rio, fdob%rjo, &
399 fdob%rko, fdob%timeob, varobs, errf, &
400 pbase(ims,kms,j), ptop, pp(ims,kms,j), &
401 nudge_wind, nudge_temp, nudge_mois, &
402 coef_wind, coef_temp, coef_mois, &
403 savwt(1,ims,kms,j), kpbl(ims,j), 0, &
404 vih_q(its,j,1), vih_q(its,j,2), ht(ims,j), &
407 ids,ide, jds,jde, kds,kde, & ! domain dims
408 ims,ime, jms,jme, kms,kme, & ! memory dims
409 its,ite, jts,jte, kts,kte ) ! tile dims
410 ! write(6,*) 'return from nudob: IVAR=4, J = ',j
414 IF(nudge_wind.EQ.1 .AND. NSTA.GT.0) &
416 ! write(6,*) 'calling nudob: IVAR=1, J = ',j
417 CALL nudob(J, 1, ru_tendf(ims,kms,j), &
418 inest, restart, ktau, fdob%ktaur, xtime, &
419 muu(ims,j), msfux(ims,j), msfuy(ims,j), &
420 nobs_ndg_vars, nobs_err_flds, max_obs, maxdom, &
421 npfi, ionf, rinxy, fdob%window, &
423 fdob%sfcfact, fdob%sfcfacr, &
426 fdob%rinfmn, fdob%rinfmx, fdob%pfree, &
427 fdob%dcon, fdob%tfaci, &
428 fdob%sfc_scheme_horiz, fdob%sfc_scheme_vert, &
429 fdob%max_sndng_gap, &
430 fdob%lev_in_ob, fdob%plfo, fdob%nlevs_ob, &
431 parent_grid_ratio, dx, dtmin, fdob%rio, fdob%rjo, &
432 fdob%rko, fdob%timeob, varobs, errf, &
433 pbase(ims,kms,j), ptop, pp(ims,kms,j), &
434 nudge_wind, nudge_temp, nudge_mois, &
435 coef_wind, coef_temp, coef_mois, &
436 savwt(1,ims,kms,j), kpbl(ims,j), 0, &
437 vih_uv(its,j,1), vih_uv(its,j,2), ht(ims,j), &
440 ids,ide, jds,jde, kds,kde, & ! domain dims
441 ims,ime, jms,jme, kms,kme, & ! memory dims
442 its,ite, jts,jte, kts,kte ) ! tile dims
443 ! write(6,*) 'return from nudob: IVAR=1, J = ',j
445 ! write(6,*) 'calling nudob: IVAR=2, J = ',j
446 CALL nudob(J, 2, rv_tendf(ims,kms,j), &
447 inest, restart, ktau, fdob%ktaur, xtime, &
448 muv(ims,j), msfvx(ims,j), msfvy(ims,j), &
449 nobs_ndg_vars, nobs_err_flds, max_obs, maxdom, &
450 npfi, ionf, rinxy, fdob%window, &
452 fdob%sfcfact, fdob%sfcfacr, &
455 fdob%rinfmn, fdob%rinfmx, fdob%pfree, &
456 fdob%dcon, fdob%tfaci, &
457 fdob%sfc_scheme_horiz, fdob%sfc_scheme_vert, &
458 fdob%max_sndng_gap, &
459 fdob%lev_in_ob, fdob%plfo, fdob%nlevs_ob, &
460 parent_grid_ratio, dx, dtmin, fdob%rio, fdob%rjo, &
461 fdob%rko, fdob%timeob, varobs, errf, &
462 pbase(ims,kms,j), ptop, pp(ims,kms,j), &
463 nudge_wind, nudge_temp, nudge_mois, &
464 coef_wind, coef_temp, coef_mois, &
465 savwt(1,ims,kms,j), kpbl(ims,j), 0, &
466 vih_uv(its,j,1), vih_uv(its,j,2), ht(ims,j), &
469 ids,ide, jds,jde, kds,kde, & ! domain dims
470 ims,ime, jms,jme, kms,kme, & ! memory dims
471 its,ite, jts,jte, kts,kte ) ! tile dims
472 ! write(6,*) 'return from nudob: IVAR=2, J = ',j
480 END SUBROUTINE fddaobs_driver
482 SUBROUTINE compute_VIH(vif, hmax, fullmin, rampmin, &
483 regime, pblh, terrh, z, vih, &
484 ids,ide, jds,jde, kds,kde, & ! domain dims
485 ims,ime, jms,jme, kms,kme, &
486 its,ite, jts,jte, kts,kte)
488 USE module_fddaobs_rtfdda
491 !*******************************************************************************
492 !***** COMPUTE HEIGHTS FOR SURFACE OBS VERTICAL INFLUENCE FUNCTION *****
493 !*******************************************************************************
495 REAL, INTENT(IN) :: vif(6) ! Vert infl params for regimes
496 REAL, INTENT(IN) :: hmax ! Max height to apply nudging
497 REAL, INTENT(IN) :: fullmin ! Min height of full nudging
498 REAL, INTENT(IN) :: rampmin ! Min height to ramp full-to-0
499 REAL, INTENT(IN) :: regime(ims:ime,jms:jme) ! Stability regime
500 REAL, INTENT(IN) :: pblh(ims:ime,jms:jme) ! PBL height (m)
501 REAL, INTENT(IN) :: terrh(ims:ime,jms:jme) ! Terrain ht (m)
502 REAL, INTENT(IN) :: z(ims:ime,kms:kme,jms:jme) ! Ht (m) above sl (half levs)
503 REAL, INTENT(OUT) :: vih(its:ite,jts:jte,2) ! Vt infl hts abv grd for LML obs
504 ! INTEGER, INTENT(OUT) :: vik(its:ite,jts:jte,2) ! Vert infl k-levels for LML obs
505 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde ! domain dims.
506 INTEGER, INTENT(IN) :: ims,ime, jms,jme, kms,kme ! memory dims.
507 INTEGER, INTENT(IN) :: its,ite, jts,jte, kts,kte ! tile dims.
510 real :: fullr(its:ite) ! Height up to full vertical weighting
511 real :: rampr(its:ite) ! Height of ramp-down to zero weighting
512 character(len=200) :: msg ! Argument to wrf_message
513 integer:: i, j ! Loop counters
520 ! Set fullr and rampr values according to regimes
523 if(regime(i,j).eq.1.0) then ! REGIME 1
526 elseif(regime(i,j).eq.2.0) then ! REGIME 2
529 elseif(regime(i,j).eq.3.0 .or. regime(i,j).eq.4.0) then ! REGIME 4
533 write(msg,'(a,f5.1,2(a,i4))') 'Unknown regime type ', regime(i,j), &
534 ' at grid coordinate i = ',i,' j = ',j
535 call wrf_message(msg)
536 call wrf_error_fatal ( 'fddaobs_driver: compute_VIH STOP' )
542 ! Get vert infl heights for LML obs, from fullr, rampr, and pblh
543 CALL get_vif_hts_slab(fullr, rampr, pblh(ims,j), &
544 hmax, fullmin, rampmin, &
545 vih(its,j,1), vih(its,j,2), &
548 END SUBROUTINE compute_VIH
550 SUBROUTINE get_vif_hts_slab(fullr, rampr, pblh, hmax, fullmin, rampmin, &
551 ht1, ht2, ims,ime, its,ite)
552 ! Compute VIF heights
556 REAL, INTENT(IN) :: fullr(its:ite) ! Height up to full vertical weighting
557 REAL, INTENT(IN) :: rampr(its:ite) ! Height of ramp-down to zero weighting
558 REAL, INTENT(IN) :: pblh(ims:ime) ! PBL height (m)
559 REAL, INTENT(IN) :: hmax ! Max height to apply nudging
560 REAL, INTENT(IN) :: fullmin ! Min height of full nudging
561 REAL, INTENT(IN) :: rampmin ! Min height to ramp full-to-0
562 REAL, INTENT(OUT) :: ht1(its:ite) ! Vert infl fcn height 1
563 REAL, INTENT(OUT) :: ht2(its:ite) ! Vert infl fcn height 2
564 INTEGER, INTENT(IN) :: ims,ime ! Memory dims.
565 INTEGER, INTENT(IN) :: its,ite ! Tile dims.
572 ! Determine lower height (below which the VIF=1 for full weighting)
573 if(fullr(i).ge.0.0) then ! fullr is height from ground
575 else ! fullr is relative to pbl (-5000 bias)
576 ht1(i) = pblh(i) - (fullr(i)+5000.)
579 ! Height ht1 can be no smaller than fullmin
580 ht1(i) = max(fullmin,ht1(i))
582 ! Determine upper height (to which the VIF ramps down to zero weighting)
583 ! NOTE: Height of ramp-down (ht2-ht1) can be no smaller than rampmin
585 if(rampr(i).ge.0.0) then
586 ! rampr is height from ht1
587 ht2(i) = ht1(i) + max(rampmin,rampr(i))
589 ! rampr is relative to pbl (-5000 bias)
590 ht2(i) = max( ht1(i)+rampmin, pblh(i)-(rampr(i)+5000.) )
594 ht1(i) = min(ht1(i), hmax-rampmin)
595 ht2(i) = min(ht2(i), hmax)
597 END SUBROUTINE get_vif_hts_slab
599 SUBROUTINE get_vik_slab( h, hlevs, ht, vik, ims,ime, kms,kme, its,ite, kts,kte )
601 ! Compute VIK values from heights on j-slab
605 REAL, INTENT(IN) :: h(its:ite) ! height (m) above ground, on j-slab
606 REAL, INTENT(IN) :: hlevs(ims:ime,kms:kme) ! hgt (m) abv grd at modl levs (slab)
607 REAL, INTENT(IN) :: ht(ims:ime) ! terrain height (m) (slab)
608 INTEGER, INTENT(OUT):: vik(its:ite) ! vert infl k levels (slab)
609 INTEGER, INTENT(IN) :: ims,ime, kms,kme ! memory dims
610 INTEGER, INTENT(IN) :: its,ite, kts,kte ! tile dims
615 real :: ht_ag(kts:kte)
619 ! Get column of height-above-ground values for this i coord
621 ht_ag(k) = hlevs(i,k) - ht(i)
623 ! Get k levels that correspond to height values
624 vik(i) = ht_to_k( h(i), ht_ag, kts,kte )
626 END SUBROUTINE get_vik_slab
628 INTEGER FUNCTION ht_to_k( h, hlevs, kts,kte )
631 REAL, INTENT(IN) :: h ! height value (m)
632 REAL, INTENT(IN) :: hlevs(kts:kte) ! model height levels
633 INTEGER, INTENT(IN) :: kts,kte ! tile dims
636 INTEGER :: k ! loop counter
637 INTEGER :: klo ! lower k bound
639 KLEVS: do k = kts, kte
641 if(h .le. hlevs(k)) then
646 ht_to_k = min0(kte,klo)
650 END MODULE module_fddaobs_driver