da_wrfvar_init2.inc

References to this file elsewhere.
1 subroutine da_wrfvar_init2
2 
3    !-------------------------------------------------------------------------
4    ! Purpose: WRFVAR initialization routine, part 2
5    !-------------------------------------------------------------------------
6 
7    implicit none
8 
9    integer :: i
10    character(len=80) :: filename
11 
12    if (trace_use) call da_trace_entry("da_wrfvar_init2")
13 
14    if (analysis_type(1:6) == "VERIFY" .or. analysis_type(1:6) == "verify") then
15       anal_type_verify=.true.
16    else
17       anal_type_verify=.false.
18    end if
19 
20    if (analysis_type(1:8) == "RANDOMCV" .or. analysis_type(1:8) == "randomcv") then
21       anal_type_randomcv=.true.
22    else
23       anal_type_randomcv=.false.
24    end if
25 
26    if (analysis_type(1:6) == "QC-OBS" .or. analysis_type(1:6) == "qc-obs") then
27       anal_type_qcobs=.true.
28    else
29       anal_type_qcobs=.false.
30    end if
31 
32    !<DESCRIPTION>
33    ! Among the configuration variables read from the namelist is
34    ! debug_level. This is retrieved using nl_get_debug_level (Registry
35    ! generated and defined in frame/module_configure.F).  The value is then
36    ! used to set the debug-print information level for use by <a
37    ! href=wrf_debug.html>wrf_debug</a> throughout the code. Debug_level
38    ! of zero (the default) causes no information to be printed when the
39    ! model runs. The higher the number (up to 1000) the more information is
40    ! printed.
41    ! 
42    !</DESCRIPTION>
43 
44    call nl_get_debug_level (1, debug_level)
45    call set_wrf_debug_level (debug_level)
46 
47    nullify(null_domain)
48 
49 
50    if (max_dom > 1) then
51       call da_error(__FILE__,__LINE__, (/'nesting not available for wrfvar'/))
52    end if
53 
54    !<DESCRIPTION>
55    ! The top-most domain in the simulation is then allocated and configured
56    ! by calling <a href=alloc_and_configure_domain.html>alloc_and_configure_domain</a>.
57    ! Here, in the case of this root domain, the routine is passed the
58    ! globally accessible pointer to type(domain), head_grid, defined in
59    ! frame/module_domain.F.  The parent is null and the child index is given
60    ! as negative, signifying none.  Afterwards, because the call to
61    ! alloc_and_configure_domain may modify the model configuration data
62    ! stored in model_config_rec, the configuration information is again
63    ! repacked into a buffer, broadcast, and unpacked on each task (for
64    ! DM_PARALLEL compiles). The call to <a
65    ! href=setup_timekeeping.html>setup_timekeeping</a> for head_grid relies
66    ! on this configuration information, and it must occur after the second
67    ! broadcast of the configuration information.
68    ! 
69    !</DESCRIPTION>
70 
71    call da_trace("da_wrfvar_init2",message="calling alloc_and_configure_domain")
72 
73    call alloc_and_configure_domain (domain_id=1, grid=head_grid, parent=null_domain, kid=-1)
74 
75    call da_trace("da_wrfvar_init2",message="calling model_to_grid_config_rec")
76    call model_to_grid_config_rec (head_grid%id, model_config_rec, config_flags)
77 
78    call da_trace("da_wrfvar_init2",message="calling set_scalar_indices_from_config")
79    call set_scalar_indices_from_config (head_grid%id , idum1, idum2)
80 
81    call da_trace("da_wrfvar_init2",message="calling init_wrfio")
82    call init_wrfio
83 
84 #ifdef DM_PARALLEL
85    call get_config_as_buffer (configbuf, configbuflen, nbytes)
86    call wrf_dm_bcast_bytes (configbuf, nbytes)
87    call set_config_as_buffer (configbuf, configbuflen)
88 #endif
89 
90    call setup_timekeeping (head_grid)
91 
92    !<DESCRIPTION>
93    ! The head grid is initialized with read-in data through the call to <a
94    ! href=med_initialdata_input.html>med_initialdata_input</a>, which is
95    ! passed the pointer head_grid and a locally declared configuration data
96    ! structure, config_flags, that is set by a call to <a
97    ! href=model_to_grid_config_rec.html>model_to_grid_config_rec</a>.  It is
98    ! also necessary that the indices into the 4d tracer arrays such as
99    ! moisture be set with a call to <a
100    ! href=set_scalar_indices_from_config.html>set_scalar_indices_from_config</a>
101    ! prior to the call to initialize the domain.  Both of these calls are
102    ! told which domain they are setting up for by passing in the integer id
103    ! of the head domain as <tt>head_grid%id</tt>, which is 1 for the
104    ! top-most domain.
105    ! 
106    ! In the case that write_restart_at_0h is set to true in the namelist,
107    ! the model simply generates a restart file using the just read-in data
108    ! and then shuts down. This is used for ensemble breeding, and is not
109    ! typically enabled.
110    ! 
111    !</DESCRIPTION>
112 
113    ! call med_initialdata_input(head_grid , config_flags,'fg01')
114 
115    if ((config_flags%real_data_init_type == 1) .or. &
116        (config_flags%real_data_init_type == 3)) then
117       call da_med_initialdata_input (head_grid, config_flags, 'fg01')
118    end if
119 
120    ! FIX?
121    ! call da_warning(__FILE__,__LINE__,(/"Fix me"/))
122    ! head_grid%start_subtime = head_grid%start_time
123    ! head_grid%stop_subtime = head_grid%stop_time
124 
125    if (rootproc) then
126       call da_get_unit (cost_unit)
127       call da_get_unit (grad_unit)
128       call da_get_unit (stats_unit)
129       call da_get_unit (jo_unit)
130       call da_get_unit (check_max_iv_unit)
131       open(unit=cost_unit,file="cost_fn",status="replace")
132       open(unit=grad_unit,file="grad_fn",status="replace")
133       open(unit=stats_unit,file="statistics",status="replace")
134       open(unit=jo_unit,file="jo",status="replace")
135       open(unit=check_max_iv_unit,file="check_max_iv",status="replace")
136    end if
137 
138    if (trace_use) call da_trace_exit("da_wrfvar_init2")
139 
140 end subroutine da_wrfvar_init2
141 
142