updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / da / da_4dvar / da_tl_model.inc
blobb048cb391e9c95526e662ff7e596b5f7f1ca5b80
1 subroutine da_tl_model ()
3    !-----------------------------------------------------------------------
4    ! Purpose: Acrivate tangent linear  model
5    !    Author: Xin Zhang,  MMM/ESSL/NCAR,  Date: 05/19/2010
6    !-----------------------------------------------------------------------
8    implicit none
10    integer :: time_step, fid, ierr, i, j, alarmid, gwd_opt
11    character (len=80)     :: inpname 
13    if (trace_use_dull) call da_trace_entry("da_tl_model")
15 #ifdef _OPENMP
16    call setfeenv()
17 #endif
19    ! Set up perturbation output at each slots
20    model_config_rec%auxhist8_outname = "tl_d<domain>_<date>"
21    call nl_set_auxhist8_interval_s ( head_grid%id, var4d_bin ) 
22    call nl_set_auxhist8_begin_s ( head_grid%id, 0 )
23    call nl_set_auxhist8_end_h ( head_grid%id, 999 )
24    call nl_set_io_form_auxhist8 ( head_grid%id, 2 )
25    call nl_set_frames_per_auxhist8 ( head_grid%id, 1 )
28    ! Set up basic states reading
29    model_config_rec%auxinput6_inname = "auxhist6_d<domain>_<date>"
30    call nl_get_time_step ( head_grid%id, time_step )
31    call nl_set_auxinput6_interval_s (head_grid%id, time_step )
32    call nl_set_io_form_auxinput6 ( head_grid%id, 2 )
33    call nl_set_frames_per_auxinput6 ( head_grid%id, 1 )
34    call nl_get_gwd_opt ( head_grid%id, gwd_opt )
36    ! Set all perturbation to ZERO
38    head_grid%g_scalar = 0.0
39    head_grid%g_tke_2 = 0.0
40    head_grid%g_al = 0.0
41    head_grid%g_ustm = 0.0
42    head_grid%g_hfx = 0.0
43    head_grid%g_qfx = 0.0
44    head_grid%g_h_diabatic = 0.0
46    head_grid%g_u_1 = 0.0
47    head_grid%g_v_1 = 0.0
48    head_grid%g_w_1 = 0.0
49    head_grid%g_t_1 = 0.0
50    head_grid%g_ph_1 = 0.0
51    head_grid%g_mu_1 = 0.0
52    head_grid%g_tke_1 = 0.0
54    head_grid%g_ru = 0.0
55    head_grid%g_rv = 0.0
56    head_grid%g_rw = 0.0
57    head_grid%g_ww = 0.0
58    head_grid%g_alt = 0.0
59    head_grid%g_php = 0.0
60    head_grid%g_mut = 0.0
61    head_grid%g_muu = 0.0
62    head_grid%g_muv = 0.0
63    head_grid%g_p_hyd_w = 0.0
64    head_grid%g_p_hyd = 0.0
65    head_grid%g_z_at_w = 0.0
66    head_grid%g_z = 0.0
67    head_grid%g_zx = 0.0
68    head_grid%g_zy = 0.0
69    head_grid%g_rdz = 0.0
70    head_grid%g_rdzw = 0.0
71    head_grid%g_div = 0.0
72    head_grid%g_nba_mij = 0.0
73    head_grid%g_nba_rij = 0.0
74    head_grid%g_defor11 = 0.0
75    head_grid%g_defor22 = 0.0
76    head_grid%g_defor33 = 0.0
77    head_grid%g_defor12 = 0.0
78    head_grid%g_defor13 = 0.0
79    head_grid%g_defor23 = 0.0
80    head_grid%g_bn2 = 0.0
81    head_grid%g_xkmh = 0.0
82    head_grid%g_xkmv = 0.0
83    head_grid%g_xkhh = 0.0
84    head_grid%g_xkhv = 0.0
85    head_grid%g_ru_tend = 0.0
86    head_grid%g_rv_tend = 0.0
87    head_grid%g_u_save = 0.0
88    head_grid%g_v_save = 0.0
89    head_grid%g_t_save = 0.0
90    head_grid%g_rthften = 0.0
91    head_grid%g_rqvften = 0.0
92    head_grid%g_rthcuten = 0.0
93    head_grid%g_rqvcuten = 0.0
94    head_grid%g_muts = 0.0
95    head_grid%g_mudf = 0.0
96    head_grid%g_ru_m = 0.0
97    head_grid%g_rv_m = 0.0
98    head_grid%g_ww_m = 0.0
100    IF ( gwd_opt .EQ. 1 ) THEN
101       head_grid%g_dtaux3d = 0.0
102       head_grid%g_dtauy3d = 0.0
103       head_grid%g_dusfcg = 0.0
104       head_grid%g_dvsfcg = 0.0
105    ENDIF
107    head_grid%g_rainnc  = 0.0
108    head_grid%g_rainncv = 0.0
109    head_grid%g_rainc  = 0.0
110    head_grid%g_raincv = 0.0
111    head_grid%g_pratec = 0.0
114    ! Set the physics options to what they are in TL and AD
115    if (original_mp_physics .NE. 0 .and. original_mp_physics .NE. 98 .and. original_mp_physics .NE. 99) &
116       call nl_set_mp_physics (head_grid%id, original_mp_physics_ad) 
117    call nl_set_ra_lw_physics (head_grid%id, 0)
118    call nl_set_ra_sw_physics (head_grid%id, 0)
119    call nl_set_sf_sfclay_physics (head_grid%id, 0)
120    if (original_bl_pbl_physics .gt. 0) &
121       call nl_set_bl_pbl_physics (head_grid%id, 98)
122    if (original_cu_physics .gt. 0) then
123       call nl_set_cu_physics (head_grid%id, 98) 
124       head_grid%cudt = 0
125    endif
126    !call nl_set_mp_zero_out (head_grid%id, 0)
127    !call nl_set_sf_surface_physics (head_grid%id, 1)
128    call nl_set_ifsnow (head_grid%id, 1)
129    call nl_set_icloud (head_grid%id, 0)
130    !call nl_set_isfflx (head_grid%id, 0)
132    ! WRF model time-stepping.  Calls integrate().
133    call nl_set_var4d_run (head_grid%id, .true.)
134    call wrf_run_tl
135         
136    ! restore the physics options to the originals
137    call nl_set_mp_physics (head_grid%id, original_mp_physics) 
138    call nl_set_ra_lw_physics (head_grid%id, original_ra_lw_physics)
139    call nl_set_ra_sw_physics (head_grid%id, original_ra_sw_physics)
140    call nl_set_sf_sfclay_physics (head_grid%id, original_sf_sfclay_physics)
141    call nl_set_bl_pbl_physics (head_grid%id, original_bl_pbl_physics)
142    call nl_set_cu_physics (head_grid%id, original_cu_physics)
143    head_grid%cudt = original_cudt
144    !call nl_set_mp_zero_out (head_grid%id, original_mp_zero_out)
145    !call nl_set_sf_surface_physics (head_grid%id, original_sf_surface_physics)
146    call nl_set_ifsnow (head_grid%id, original_ifsnow)
147    call nl_set_icloud (head_grid%id, original_icloud)
148    !call nl_set_isfflx (head_grid%id, original_isfflx)
150    ! Turn off auxinput2 reading and auxhist8 output
152    call nl_set_auxinput6_interval_s (head_grid%id, 0 )
153    call nl_set_auxhist8_interval_s ( head_grid%id, 0 )
155    IF ( ASSOCIATED( head_grid%domain_clock ) ) THEN
156      IF ( head_grid%domain_clock_created ) THEN
157        CALL WRFU_ClockDestroy( head_grid%domain_clock )
158        head_grid%domain_clock_created = .FALSE.
159      ENDIF
160    ENDIF
161    IF ( ASSOCIATED( head_grid%alarms ) .AND. &
162         ASSOCIATED( head_grid%alarms_created ) ) THEN
163      DO alarmid = 1, MAX_WRF_ALARMS
164        IF ( head_grid%alarms_created( alarmid ) ) THEN
165          CALL WRFU_AlarmDestroy( head_grid%alarms( alarmid ) )
166          head_grid%alarms_created( alarmid ) = .FALSE.
167        ENDIF
168      ENDDO
169    ENDIF
170    call Setup_Timekeeping ( head_grid )
172    if (trace_use_dull) call da_trace_exit("da_tl_model")
174 end subroutine da_tl_model