1 !WRF:MEDIATION_LAYER:PHYSICS
4 MODULE module_fddagd_driver
7 !------------------------------------------------------------------
8 SUBROUTINE fddagd_driver(itimestep,dt,xtime, &
10 RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN, &
11 RPHNDGDTEN,RQVNDGDTEN,RMUNDGDTEN, &
12 SDA_HFX, SDA_QFX, & !fasdas
14 u_ndg_old,v_ndg_old,t_ndg_old,ph_ndg_old, &
15 q_ndg_old,mu_ndg_old, &
16 u_ndg_new,v_ndg_new,t_ndg_new,ph_ndg_new, &
17 q_ndg_new,mu_ndg_new, &
18 u3d,v3d,th_phy,ph,rho,moist, &
19 p_phy,pi_phy,p8w,t_phy,dz8w,z,z_at_w, &
20 grid,config_flags,DX,n_moist, &
23 ids,ide, jds,jde, kds,kde, &
24 ims,ime, jms,jme, kms,kme, &
25 i_start,i_end, j_start,j_end, kts,kte, num_tiles, &
27 u10_ndg_old, v10_ndg_old, t2_ndg_old, th2_ndg_old, q2_ndg_old, &
28 rh_ndg_old, psl_ndg_old, ps_ndg_old, tob_ndg_old, odis_ndg_old, &
29 u10_ndg_new, v10_ndg_new, t2_ndg_new, th2_ndg_new, q2_ndg_new, &
30 rh_ndg_new, psl_ndg_new, ps_ndg_new, tob_ndg_new, odis_ndg_new, &
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 !------------------------------------------------------------------
38 USE module_state_description
39 USE module_model_constants
40 USE module_domain, ONLY : domain
42 ! *** add new modules of schemes here
44 USE module_fdda_psufddagd
45 USE module_fdda_spnudging
47 !------------------------------------------------------------------
49 !======================================================================
50 ! Grid structure in physics part of WRF
51 !----------------------------------------------------------------------
52 ! The horizontal velocities used in the physics are unstaggered
53 ! relative to temperature/moisture variables. All predicted
54 ! variables are carried at half levels except w, which is at full
55 ! levels. Some arrays with names (*8w) are at w (full) levels.
57 !----------------------------------------------------------------------
58 ! In WRF, kms (smallest number) is the bottom level and kme (largest
59 ! number) is the top level. In your scheme, if 1 is at the top level,
60 ! then you have to reverse the order in the k direction.
62 ! kme - half level (no data at this level)
63 ! kme ----- full level
65 ! kme-1 ----- full level
70 ! kms+2 ----- full level
72 ! kms+1 ----- full level
74 ! kms ----- full level
76 !======================================================================
77 !-- RUNDGDTEN U tendency due to
78 ! FDDA analysis nudging (m/s^2)
79 !-- RVNDGDTEN V tendency due to
80 ! FDDA analysis nudging (m/s^2)
81 !-- RTHNDGDTEN Theta tendency due to
82 ! FDDA analysis nudging (K/s)
83 !-- RPHNDGDTEN Geopotential tendency due to
84 ! FDDA analysis nudging (m^2/s^3)
85 !-- RQVNDGDTEN Qv tendency due to
86 ! FDDA analysis nudging (kg/kg/s)
87 !-- RMUNDGDTEN mu tendency due to
88 ! FDDA analysis nudging (Pa/s)
89 !-- itimestep number of time steps
90 !-- u3d u-velocity staggered on u points (m/s)
91 !-- v3d v-velocity staggered on v points (m/s)
92 !-- th_phy potential temperature (K)
93 !-- moist moisture array (4D - last index is species) (kg/kg)
94 !-- p_phy pressure (Pa)
95 !-- pi_phy exner function (dimensionless)
96 !-- p8w pressure at full levels (Pa)
97 !-- t_phy temperature (K)
98 !-- dz8w dz between full levels (m)
99 !-- z height above sea level (m)
101 !-- DX horizontal space interval (m)
102 !-- DT time step (second)
103 !-- n_moist number of moisture species
104 !-- STEPFG number of timesteps per FDDA re-calculation
105 !-- KPBL k-index of PBL top
106 !-- ids start index for i in domain
107 !-- ide end index for i in domain
108 !-- jds start index for j in domain
109 !-- jde end index for j in domain
110 !-- kds start index for k in domain
111 !-- kde end index for k in domain
112 !-- ims start index for i in memory
113 !-- ime end index for i in memory
114 !-- jms start index for j in memory
115 !-- jme end index for j in memory
116 !-- kms start index for k in memory
117 !-- kme end index for k in memory
118 !-- jts start index for j in tile
119 !-- jte end index for j in tile
120 !-- kts start index for k in tile
121 !-- kte end index for k in tile
123 !******************************************************************
124 !------------------------------------------------------------------
125 TYPE(grid_config_rec_type), INTENT(IN ) :: config_flags
126 TYPE(domain) , TARGET :: grid
129 INTEGER , INTENT(IN) :: id
131 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
132 ims,ime, jms,jme, kms,kme, &
133 kts,kte, num_tiles, &
134 ips,ipe,jps,jpe,kps,kpe, &
135 imsx,imex,jmsx,jmex,kmsx,kmex, &
136 ipsx,ipex,jpsx,jpex,kpsx,kpex, &
137 imsy,imey,jmsy,jmey,kmsy,kmey, &
138 ipsy,ipey,jpsy,jpey,kpsy,kpey, &
141 INTEGER, DIMENSION(num_tiles), INTENT(IN) :: &
142 & i_start,i_end,j_start,j_end
144 INTEGER, INTENT(IN ) :: itimestep,STEPFG
146 REAL, INTENT(IN ) :: DT,DX,XTIME
150 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
151 INTENT(IN ) :: p_phy, &
164 REAL, DIMENSION( ims:ime, kms:kme, jms:jme, n_moist ), &
169 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
170 INTENT(INOUT) :: RUNDGDTEN, &
178 REAL, DIMENSION( ims:ime, jms:jme ), &
179 INTENT(INOUT) :: SDA_HFX, &
181 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
182 INTENT(INOUT) :: HFX_FDDA
186 REAL, DIMENSION( ims:ime, jms:jme ), &
187 INTENT(INOUT) :: RMUNDGDTEN
189 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
190 INTENT(INOUT) :: u_ndg_old, &
200 REAL, DIMENSION( ims:ime, jms:jme ), &
201 INTENT(INOUT) :: mu_ndg_old, &
205 REAL, DIMENSION( ims:ime , jms:jme ), &
206 INTENT(IN ) :: pblh, &
210 REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT ) :: regime
212 REAL, DIMENSION( ims:ime, jms:jme ), &
213 INTENT(IN ) :: u10, &
218 REAL, DIMENSION( ims:ime, jms:jme ), &
219 INTENT(IN) :: u10_ndg_old, &
238 REAL, DIMENSION( ims:ime, jms:jme ), &
239 INTENT(IN) :: tob_ndg_old, &
245 INTEGER :: i,J,K,NK,jj,ij
246 CHARACTER (LEN=256) :: message
248 !------------------------------------------------------------------
250 if (config_flags%grid_fdda .eq. 0 .AND. config_flags%grid_sfdda .eq. 0) return
252 IF (itimestep == 1) THEN
254 IF( config_flags%grid_fdda .eq. 1 ) THEN
256 !$OMP PRIVATE ( ij,i,j,k )
257 DO ij = 1 , num_tiles
258 DO j=j_start(ij),j_end(ij)
259 DO i=i_start(ij),i_end(ij)
261 DO k=kts,kte !min(kte+1,kde) !BSINGH(PNNL)- Undefined behavior at k=kte+1
262 u_ndg_old(i,k,j) = u3d(i,k,j)
263 v_ndg_old(i,k,j) = v3d(i,k,j)
264 t_ndg_old(i,k,j) = th_phy(i,k,j) - 300.0
265 ph_ndg_old(i,k,j) = ph(i,k,j)
266 q_ndg_old(i,k,j) = moist(i,k,j,P_QV)
268 mu_ndg_old(i,j) = 0.0
275 ! IF( config_flags%grid_sfdda .eq. 1 ) THEN
276 ! DO ij = 1 , num_tiles
277 ! DO j=j_start(ij),j_end(ij)
278 ! DO i=i_start(ij),i_end(ij)
279 ! u10_ndg_old(i,j) = u10(i,j)
280 ! v10_ndg_old(i,j) = v10(i,j)
281 ! th2_ndg_old(i,j) = th2(i,j) - 300.0
282 ! q2_ndg_old(i,j) = q2(i,j)
288 !$OMP END PARALLEL DO
293 !GMM if fgdtzero = 1, tendencies are zero in between calls
295 IF (mod(itimestep-1,STEPFG) .eq. 0 .and. config_flags%fgdtzero .eq. 1) THEN
298 !$OMP PRIVATE ( ij,i,j,k )
299 DO ij = 1 , num_tiles
300 DO j=j_start(ij),j_end(ij)
301 DO i=i_start(ij),i_end(ij)
303 DO k=kts,min(kte+1,kde)
317 !$OMP END PARALLEL DO
321 IF (itimestep .eq. 1 .or. mod(itimestep,STEPFG) .eq. 0) THEN
324 !$OMP PRIVATE ( ij,i,j,k )
325 DO ij = 1 , num_tiles
326 DO j=j_start(ij),j_end(ij)
327 DO i=i_start(ij),i_end(ij)
329 DO k=kts,min(kte+1,kde)
343 !$OMP END PARALLEL DO
346 IF( config_flags%grid_fdda /= 0 ) THEN
347 fdda_select: SELECT CASE(config_flags%grid_fdda)
352 !Add error checks to ensure that user does not use analysis nudging
353 !options that WRF will read in but not fully utilize
356 !The begin time of analysis nudging must be the model start time
357 !It appears the WRF code that reads analysis nudging files respects
358 !the start time settings, but the actual nudging code does not. This
359 !leads one to nudge towards 0 in all fields (including potential
360 !temperature [K]) since the nudging code applies analysis nudging but has
361 !no data to nudge towards
362 IF( config_flags%gfdda_begin_y /= 0 ) THEN
363 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
364 'start time and so analysis nudging start time cannot be specified via gfdda_begin_y'
365 CALL wrf_error_fatal ( wrf_err_message )
367 IF( config_flags%gfdda_begin_d /= 0 ) THEN
368 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
369 'start time and so analysis nudging start time cannot be specified via gfdda_begin_d'
370 CALL wrf_error_fatal ( wrf_err_message )
372 IF( config_flags%gfdda_begin_h /= 0 ) THEN
373 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
374 'start time and so analysis nudging start time cannot be specified via gfdda_begin_h'
375 CALL wrf_error_fatal ( wrf_err_message )
377 IF( config_flags%gfdda_begin_m /= 0 ) THEN
378 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
379 'start time and so analysis nudging start time cannot be specified via gfdda_begin_m'
380 CALL wrf_error_fatal ( wrf_err_message )
382 IF( config_flags%gfdda_begin_s /= 0 ) THEN
383 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
384 'start time and so analysis nudging start time cannot be specified via gfdda_begin_s'
385 CALL wrf_error_fatal ( wrf_err_message )
389 !The end time of analysis nudging relative to the model start must be
391 IF( config_flags%gfdda_end_y /= 0 ) THEN
392 WRITE( wrf_err_message , * ) 'The option gfdda_end_y is ignored, use gfdda_end_h instead'
393 CALL wrf_error_fatal ( wrf_err_message )
395 IF( config_flags%gfdda_end_d /= 0 ) THEN
396 WRITE( wrf_err_message , * ) 'The option gfdda_end_d is ignored, use gfdda_end_h instead'
397 CALL wrf_error_fatal ( wrf_err_message )
399 IF( config_flags%gfdda_end_m /= 0 ) THEN
400 WRITE( wrf_err_message , * ) 'The option gfdda_end_m is ignored, use gfdda_end_h instead'
401 CALL wrf_error_fatal ( wrf_err_message )
403 IF( config_flags%gfdda_end_s /= 0 ) THEN
404 WRITE( wrf_err_message , * ) 'The option gfdda_end_s is ignored, use gfdda_end_h instead'
405 CALL wrf_error_fatal ( wrf_err_message )
408 !The interval between analyses must be specified in minutes
409 IF( config_flags%gfdda_interval_y /= 0 ) THEN
410 WRITE( wrf_err_message , * ) 'The option gfdda_interval_y is ignored, use gfdda_interval_m instead'
411 CALL wrf_error_fatal ( wrf_err_message )
413 IF( config_flags%gfdda_interval_d /= 0 ) THEN
414 WRITE( wrf_err_message , * ) 'The option gfdda_interval_d is ignored, use gfdda_interval_m instead'
415 CALL wrf_error_fatal ( wrf_err_message )
417 IF( config_flags%gfdda_interval_h /= 0 ) THEN
418 WRITE( wrf_err_message , * ) 'The option gfdda_interval_h is ignored, use gfdda_interval_m instead'
419 CALL wrf_error_fatal ( wrf_err_message )
421 IF( config_flags%gfdda_interval_s /= 0 ) THEN
422 WRITE( wrf_err_message , * ) 'The option gfdda_interval_s is ignored, use gfdda_interval_m instead'
423 CALL wrf_error_fatal ( wrf_err_message )
426 !If surface analysis nudging chosen check analogous surface analysis
427 !nudging namelist options
428 IF( config_flags%grid_sfdda /= 0 ) THEN
430 !The begin time of analysis nudging must be the model start time
431 !It appears the WRF code that reads analysis nudging files respects
432 !the start time settings, but the actual nudging code does not. This
433 !leads one to nudge towards 0 in all fields (including potential
434 !temperature [K]) since the nudging code applies analysis nudging but has
435 !no data to nudge towards
436 IF( config_flags%sgfdda_begin_y /= 0 ) THEN
437 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
438 'start time and so analysis nudging start time cannot be specified via sgfdda_begin_y'
439 CALL wrf_error_fatal ( wrf_err_message )
441 IF( config_flags%sgfdda_begin_d /= 0 ) THEN
442 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
443 'start time and so analysis nudging start time cannot be specified via sgfdda_begin_d'
444 CALL wrf_error_fatal ( wrf_err_message )
446 IF( config_flags%sgfdda_begin_h /= 0 ) THEN
447 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
448 'start time and so analysis nudging start time cannot be specified via sgfdda_begin_h'
449 CALL wrf_error_fatal ( wrf_err_message )
451 IF( config_flags%sgfdda_begin_m /= 0 ) THEN
452 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
453 'start time and so analysis nudging start time cannot be specified via sgfdda_begin_m'
454 CALL wrf_error_fatal ( wrf_err_message )
456 IF( config_flags%sgfdda_begin_s /= 0 ) THEN
457 WRITE( wrf_err_message , * ) 'WRF currently assumes analysis nudging starts at the model ',&
458 'start time and so analysis nudging start time cannot be specified via sgfdda_begin_s'
459 CALL wrf_error_fatal ( wrf_err_message )
463 !The end time of analysis nudging relative to the model start must be
465 IF( config_flags%sgfdda_end_y /= 0 ) THEN
466 WRITE( wrf_err_message , * ) 'The option sgfdda_end_y is ignored, use sgfdda_end_h instead'
467 CALL wrf_error_fatal ( wrf_err_message )
469 IF( config_flags%sgfdda_end_d /= 0 ) THEN
470 WRITE( wrf_err_message , * ) 'The option sgfdda_end_d is ignored, use sgfdda_end_h instead'
471 CALL wrf_error_fatal ( wrf_err_message )
473 IF( config_flags%sgfdda_end_m /= 0 ) THEN
474 WRITE( wrf_err_message , * ) 'The option sgfdda_end_m is ignored, use sgfdda_end_h instead'
475 CALL wrf_error_fatal ( wrf_err_message )
477 IF( config_flags%sgfdda_end_s /= 0 ) THEN
478 WRITE( wrf_err_message , * ) 'The option sgfdda_end_s is ignored, use sgfdda_end_h instead'
479 CALL wrf_error_fatal ( wrf_err_message )
482 !The interval between analyses must be specified in minutes
483 IF( config_flags%sgfdda_interval_y /= 0 ) THEN
484 WRITE( wrf_err_message , * ) 'The option sgfdda_interval_y is ignored, use sgfdda_interval_m instead'
485 CALL wrf_error_fatal ( wrf_err_message )
487 IF( config_flags%sgfdda_interval_d /= 0 ) THEN
488 WRITE( wrf_err_message , * ) 'The option sgfdda_interval_d is ignored, use sgfdda_interval_m instead'
489 CALL wrf_error_fatal ( wrf_err_message )
491 IF( config_flags%sgfdda_interval_h /= 0 ) THEN
492 WRITE( wrf_err_message , * ) 'The option sgfdda_interval_h is ignored, use sgfdda_interval_m instead'
493 CALL wrf_error_fatal ( wrf_err_message )
495 IF( config_flags%sgfdda_interval_s /= 0 ) THEN
496 WRITE( wrf_err_message , * ) 'The option sgfdda_interval_s is ignored, use sgfdda_interval_m instead'
497 CALL wrf_error_fatal ( wrf_err_message )
500 ENDIF !IF surface analysis nudging is anabled
504 !$OMP PRIVATE ( ij, i,j,k )
505 DO ij = 1 , num_tiles
506 CALL wrf_debug(100,'in PSU FDDA scheme')
508 IF( config_flags%sf_sfclay_physics /= sfclayscheme &
509 .AND. config_flags%sf_sfclay_physics /= mynnsfcscheme &
510 .AND. config_flags%sf_sfclay_physics /= pxsfcscheme &
511 .AND. config_flags%sf_sfclay_physics /= sfclayrevscheme ) THEN
512 DO j=MAX(j_start(ij)-1,jds),j_end(ij)
513 DO i=MAX(i_start(ij)-1,ids),i_end(ij)
514 IF( pblh(i,j) > z_at_w(i,2,j)-ht(i,j) ) THEN
523 CALL FDDAGD(itimestep,dx,dt,xtime, &
525 config_flags%auxinput10_interval_m, &
526 config_flags%auxinput10_end_h, &
527 config_flags%if_no_pbl_nudging_uv, &
528 config_flags%if_no_pbl_nudging_t, &
529 config_flags%if_no_pbl_nudging_q, &
530 config_flags%if_zfac_uv, &
531 config_flags%k_zfac_uv, &
532 config_flags%if_zfac_t, &
533 config_flags%k_zfac_t, &
534 config_flags%if_zfac_q, &
535 config_flags%k_zfac_q, &
537 config_flags%gt, config_flags%gq, &
538 config_flags%if_ramping, config_flags%dtramp_min, &
539 config_flags%grid_sfdda, &
540 config_flags%auxinput9_interval_m, &
541 config_flags%auxinput9_end_h, &
542 config_flags%guv_sfc, &
543 config_flags%gt_sfc, config_flags%gq_sfc, config_flags%rinblw, &
544 u3d,v3d,th_phy,t_phy, &
545 moist(ims,kms,jms,P_QV), &
547 u_ndg_old,v_ndg_old,t_ndg_old,q_ndg_old,mu_ndg_old, &
548 u_ndg_new,v_ndg_new,t_ndg_new,q_ndg_new,mu_ndg_new, &
549 u10_ndg_old, v10_ndg_old, t2_ndg_old, th2_ndg_old, q2_ndg_old, &
550 rh_ndg_old, psl_ndg_old, ps_ndg_old, tob_ndg_old, odis_ndg_old, &
551 u10_ndg_new, v10_ndg_new, t2_ndg_new, th2_ndg_new, q2_ndg_new, &
552 rh_ndg_new, psl_ndg_new, ps_ndg_new, tob_ndg_new, odis_ndg_new, &
553 RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN,RQVNDGDTEN,RMUNDGDTEN,&
557 config_flags%fasdas, SDA_HFX, SDA_QFX, &
562 pblh, ht, regime, znt, z, z_at_w, &
563 ids,ide, jds,jde, kds,kde, &
564 ims,ime, jms,jme, kms,kme, &
565 i_start(ij),i_end(ij),j_start(ij),j_end(ij),kts,kte )
568 !$OMP END PARALLEL DO
571 CALL wrf_debug(100,'in SPECTRAL NUDGING scheme')
572 CALL SPECTRAL_NUDGING(grid,itimestep,dt,xtime, &
574 config_flags%auxinput10_interval_m, &
575 config_flags%auxinput10_end_h, &
576 config_flags%if_no_pbl_nudging_uv, &
577 config_flags%if_no_pbl_nudging_t, &
578 config_flags%if_no_pbl_nudging_ph, &
579 config_flags%if_no_pbl_nudging_q, &
580 config_flags%if_zfac_uv, &
581 config_flags%k_zfac_uv, &
582 config_flags%dk_zfac_uv, &
583 config_flags%if_zfac_t, &
584 config_flags%k_zfac_t, &
585 config_flags%dk_zfac_t, &
586 config_flags%if_zfac_ph, &
587 config_flags%k_zfac_ph, &
588 config_flags%dk_zfac_ph, &
589 config_flags%if_zfac_q, &
590 config_flags%k_zfac_q, &
591 config_flags%dk_zfac_q, &
592 config_flags%ktrop, &
597 config_flags%if_ramping, config_flags%dtramp_min, &
598 config_flags%xwavenum, config_flags%ywavenum, &
599 u3d,v3d,th_phy,ph,moist(ims,kms,jms,P_QV), &
600 u_ndg_old,v_ndg_old,t_ndg_old,ph_ndg_old,q_ndg_old, &
601 u_ndg_new,v_ndg_new,t_ndg_new,ph_ndg_new,q_ndg_new, &
602 RUNDGDTEN,RVNDGDTEN,RTHNDGDTEN,RPHNDGDTEN,RQVNDGDTEN,&
603 pblh, ht, z, z_at_w, &
604 ids,ide, jds,jde, kds,kde, &
605 ims,ime, jms,jme, kms,kme, &
606 i_start,i_end,j_start,j_end,kts,kte, num_tiles, &
607 ips,ipe,jps,jpe,kps,kpe, &
608 imsx,imex,jmsx,jmex,kmsx,kmex, &
609 ipsx,ipex,jpsx,jpex,kpsx,kpex, &
610 imsy,imey,jmsy,jmey,kmsy,kmey, &
611 ipsy,ipey,jpsy,jpey,kpsy,kpey )
616 WRITE( wrf_err_message , * ) 'The fdda option does not exist: grid_fdda = ', config_flags%grid_fdda
617 CALL wrf_error_fatal ( wrf_err_message )
619 END SELECT fdda_select
625 END SUBROUTINE fddagd_driver
626 END MODULE module_fddagd_driver