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 !<DESCRIPTION>
50 ! RSL is required for WRF nesting options.
51 ! The non-MPI build that allows nesting is only supported on machines
52 ! with the -DSTUBMPI option. Check to see if the WRF model is being asked
53 ! for a for a multi-domain run (max_dom > 1, from the namelist). If so,
54 ! then we check to make sure that we are under the parallel
55 ! run option or we are on an acceptable machine.
56 !</DESCRIPTION>
57
58 if (max_dom > 1) then
59 #if (! defined(DM_PARALLEL) && ! defined(STUBMPI))
60 call da_error(__FILE__,__LINE__, &
61 (/'nesting requires either an MPI build or use of the -DSTUBMPI option'/))
62 #endif
63 end if
64
65 !<DESCRIPTION>
66 ! The top-most domain in the simulation is then allocated and configured
67 ! by calling <a href=alloc_and_configure_domain.html>alloc_and_configure_domain</a>.
68 ! Here, in the case of this root domain, the routine is passed the
69 ! globally accessible pointer to type(domain), head_grid, defined in
70 ! frame/module_domain.F. The parent is null and the child index is given
71 ! as negative, signifying none. Afterwards, because the call to
72 ! alloc_and_configure_domain may modify the model configuration data
73 ! stored in model_config_rec, the configuration information is again
74 ! repacked into a buffer, broadcast, and unpacked on each task (for
75 ! DM_PARALLEL compiles). The call to <a
76 ! href=setup_timekeeping.html>setup_timekeeping</a> for head_grid relies
77 ! on this configuration information, and it must occur after the second
78 ! broadcast of the configuration information.
79 !
80 !</DESCRIPTION>
81
82 call da_trace("da_wrfvar_init2",message="calling alloc_and_configure_domain")
83 call alloc_and_configure_domain (domain_id = 1 , &
84 grid = head_grid , &
85 parent = null_domain , &
86 kid = -1 )
87
88 call da_trace("da_wrfvar_init2",message="calling model_to_grid_config_rec")
89 call model_to_grid_config_rec (head_grid%id , model_config_rec , config_flags)
90
91 call da_trace("da_wrfvar_init2",message="calling set_scalar_indices_from_config")
92 call set_scalar_indices_from_config (head_grid%id , idum1, idum2)
93
94 call da_trace("da_wrfvar_init2",message="calling init_wrfio")
95 call init_wrfio
96
97 #ifdef DM_PARALLEL
98 call get_config_as_buffer(configbuf, configbuflen, nbytes)
99 call wrf_dm_bcast_bytes(configbuf, nbytes)
100 call set_config_as_buffer(configbuf, configbuflen)
101 #endif
102
103 call setup_timekeeping (head_grid)
104
105 !<DESCRIPTION>
106 ! The head grid is initialized with read-in data through the call to <a
107 ! href=med_initialdata_input.html>med_initialdata_input</a>, which is
108 ! passed the pointer head_grid and a locally declared configuration data
109 ! structure, config_flags, that is set by a call to <a
110 ! href=model_to_grid_config_rec.html>model_to_grid_config_rec</a>. It is
111 ! also necessary that the indices into the 4d tracer arrays such as
112 ! moisture be set with a call to <a
113 ! href=set_scalar_indices_from_config.html>set_scalar_indices_from_config</a>
114 ! prior to the call to initialize the domain. Both of these calls are
115 ! told which domain they are setting up for by passing in the integer id
116 ! of the head domain as <tt>head_grid%id</tt>, which is 1 for the
117 ! top-most domain.
118 !
119 ! In the case that write_restart_at_0h is set to true in the namelist,
120 ! the model simply generates a restart file using the just read-in data
121 ! and then shuts down. This is used for ensemble breeding, and is not
122 ! typically enabled.
123 !
124 !</DESCRIPTION>
125
126 ! call med_initialdata_input(head_grid , config_flags,'fg01')
127
128 if ((config_flags%real_data_init_type == 1) .or. &
129 (config_flags%real_data_init_type == 3)) then
130 call da_med_initialdata_input(head_grid , config_flags,'fg01')
131 end if
132
133 ! JRB
134 ! call da_warning(__FILE__,__LINE__,(/"Fix me"/))
135 ! head_grid%start_subtime = head_grid%start_time
136 ! head_grid%stop_subtime = head_grid%stop_time
137
138 if (rootproc) then
139 call da_get_unit(cost_unit)
140 call da_get_unit(grad_unit)
141 call da_get_unit(stats_unit)
142 call da_get_unit(jo_unit)
143 call da_get_unit(check_max_iv_unit)
144 open(unit=cost_unit,file="cost_fn",status="replace")
145 open(unit=grad_unit,file="grad_fn",status="replace")
146 open(unit=stats_unit,file="statistics",status="replace")
147 open(unit=jo_unit,file="jo",status="replace")
148 open(unit=check_max_iv_unit,file="check_max_iv",status="replace")
149 end if
150
151 if (trace_use) call da_trace_exit("da_wrfvar_init2")
152
153 end subroutine da_wrfvar_init2
154
155