Calculates the initial profiles for U, V, TH & Q if required.
161 type(model_state_type),
intent(inout) :: current_state
162 type(vertical_grid_configuration_type),
intent(inout) :: vertical_grid
169 real(kind=DEFAULT_PRECISION),
dimension(:,:),
allocatable :: f_init_pl_q
170 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_init_pl_q
171 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_init_pl_theta
172 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_init_pl_theta
173 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_init_pl_u
174 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_init_pl_u
175 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_init_pl_v
176 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_init_pl_v
178 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_thref
179 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_thref
181 logical :: l_init_pl_u
182 logical :: l_init_pl_v
183 logical :: l_init_pl_theta
184 logical :: l_init_pl_q
186 logical :: l_matchthref
188 character(len=STRING_LENGTH),
dimension(:),
allocatable :: names_init_pl_q
190 real(kind=DEFAULT_PRECISION),
allocatable :: f_init_pl_q_tmp(:)
191 real(kind=DEFAULT_PRECISION),
allocatable :: zgrid(:)
193 real(kind=DEFAULT_PRECISION) :: zztop
195 allocate(zgrid(current_state%local_grid%local_domain_end_index(z_index)))
197 zztop = current_state%global_grid%top(z_index)
200 vertical_grid%q_init = 0.0_default_precision
201 vertical_grid%u_init = 0.0_default_precision
202 vertical_grid%v_init = 0.0_default_precision
203 vertical_grid%theta_init = 0.0_default_precision
205 l_init_pl_theta=options_get_logical(current_state%options_database,
"l_init_pl_theta")
206 l_init_pl_q=options_get_logical(current_state%options_database,
"l_init_pl_q")
207 if (l_init_pl_q)
then 208 allocate(names_init_pl_q(options_get_array_size(current_state%options_database,
"names_init_pl_q")))
209 call options_get_string_array(current_state%options_database,
"names_init_pl_q", names_init_pl_q)
211 l_init_pl_u=options_get_logical(current_state%options_database,
"l_init_pl_u")
212 l_init_pl_v=options_get_logical(current_state%options_database,
"l_init_pl_v")
214 l_thref=options_get_logical(current_state%options_database,
"l_thref")
215 l_matchthref=options_get_logical(current_state%options_database,
"l_matchthref")
218 if (.not. l_matchthref)
then 219 allocate(z_thref(options_get_array_size(current_state%options_database,
"z_thref")), &
220 f_thref(options_get_array_size(current_state%options_database,
"f_thref")))
221 call options_get_real_array(current_state%options_database,
"z_thref", z_thref)
222 call options_get_real_array(current_state%options_database,
"f_thref", f_thref)
223 call check_top(zztop, z_thref(
size(z_thref)),
'z_thref')
224 zgrid=current_state%global_grid%configuration%vertical%zn(:)
225 call piecewise_linear_1d(z_thref(1:
size(z_thref)), f_thref(1:
size(f_thref)), zgrid, &
226 current_state%global_grid%configuration%vertical%thref)
227 deallocate(z_thref, f_thref)
230 current_state%global_grid%configuration%vertical%thref(:)=current_state%thref0
233 if (l_init_pl_theta)
then 234 allocate(z_init_pl_theta(options_get_array_size(current_state%options_database,
"z_init_pl_theta")), &
235 f_init_pl_theta(options_get_array_size(current_state%options_database,
"f_init_pl_theta")))
236 call options_get_real_array(current_state%options_database,
"z_init_pl_theta", z_init_pl_theta)
237 call options_get_real_array(current_state%options_database,
"f_init_pl_theta", f_init_pl_theta)
238 call check_top(zztop, z_init_pl_theta(
size(z_init_pl_theta)),
'z_init_pl_theta')
239 zgrid=current_state%global_grid%configuration%vertical%zn(:)
240 call piecewise_linear_1d(z_init_pl_theta(1:
size(z_init_pl_theta)), f_init_pl_theta(1:
size(f_init_pl_theta)), zgrid, &
241 current_state%global_grid%configuration%vertical%theta_init)
242 if (l_matchthref)
then 243 if(.not. current_state%use_anelastic_equations)
then 244 call log_master_log(log_error,
"Non-anelastic equation set and l_maththref are incompatible")
246 current_state%global_grid%configuration%vertical%thref = current_state%global_grid%configuration%vertical%theta_init
248 if (.not. current_state%continuation_run)
then 249 do i=current_state%local_grid%local_domain_start_index(x_index), current_state%local_grid%local_domain_end_index(x_index)
250 do j=current_state%local_grid%local_domain_start_index(y_index), current_state%local_grid%local_domain_end_index(y_index)
251 current_state%th%data(:,j,i) = current_state%global_grid%configuration%vertical%theta_init(:) - &
252 current_state%global_grid%configuration%vertical%thref(:)
256 deallocate(z_init_pl_theta, f_init_pl_theta)
260 allocate(z_init_pl_u(options_get_array_size(current_state%options_database,
"z_init_pl_u")), &
261 f_init_pl_u(options_get_array_size(current_state%options_database,
"f_init_pl_u")))
262 call options_get_real_array(current_state%options_database,
"z_init_pl_u", z_init_pl_u)
263 call options_get_real_array(current_state%options_database,
"f_init_pl_u", f_init_pl_u)
264 call check_top(zztop, z_init_pl_u(
size(z_init_pl_u)),
'z_init_pl_u')
265 zgrid=current_state%global_grid%configuration%vertical%zn(:)
266 call piecewise_linear_1d(z_init_pl_u(1:
size(z_init_pl_u)), f_init_pl_u(1:
size(f_init_pl_u)), &
267 zgrid, current_state%global_grid%configuration%vertical%u_init)
268 if (.not. current_state%continuation_run)
then 269 do i=current_state%local_grid%local_domain_start_index(x_index), current_state%local_grid%local_domain_end_index(x_index)
270 do j=current_state%local_grid%local_domain_start_index(y_index), current_state%local_grid%local_domain_end_index(y_index)
271 current_state%u%data(:,j,i) = current_state%global_grid%configuration%vertical%u_init(:)
275 deallocate(z_init_pl_u, f_init_pl_u)
279 allocate(z_init_pl_v(options_get_array_size(current_state%options_database,
"z_init_pl_v")), &
280 f_init_pl_v(options_get_array_size(current_state%options_database,
"f_init_pl_v")))
281 call options_get_real_array(current_state%options_database,
"z_init_pl_v", z_init_pl_v)
282 call options_get_real_array(current_state%options_database,
"f_init_pl_v", f_init_pl_v)
283 call check_top(zztop, z_init_pl_v(
size(z_init_pl_v)),
'z_init_pl_v')
284 zgrid=current_state%global_grid%configuration%vertical%zn(:)
285 call piecewise_linear_1d(z_init_pl_v(1:
size(z_init_pl_v)), f_init_pl_v(1:
size(f_init_pl_v)), &
286 zgrid, current_state%global_grid%configuration%vertical%v_init)
287 if (.not. current_state%continuation_run)
then 288 do i=current_state%local_grid%local_domain_start_index(x_index), current_state%local_grid%local_domain_end_index(x_index)
289 do j=current_state%local_grid%local_domain_start_index(y_index), current_state%local_grid%local_domain_end_index(y_index)
290 current_state%v%data(:,j,i) = current_state%global_grid%configuration%vertical%v_init(:)
294 deallocate(z_init_pl_v, f_init_pl_v)
298 nq_init=
size(names_init_pl_q)
299 allocate(z_init_pl_q(options_get_array_size(current_state%options_database,
"z_init_pl_q")))
300 call options_get_real_array(current_state%options_database,
"z_init_pl_q", z_init_pl_q)
301 nzq=
size(z_init_pl_q)
302 call check_top(zztop, z_init_pl_q(nzq),
'z_init_pl_q')
303 zgrid=current_state%global_grid%configuration%vertical%zn(:)
304 allocate(f_init_pl_q_tmp(nq_init*nzq))
305 call options_get_real_array(current_state%options_database,
"f_init_pl_q", f_init_pl_q_tmp)
306 allocate(f_init_pl_q(nzq, nq_init))
307 f_init_pl_q(1:nzq, 1:nq_init)=reshape(f_init_pl_q_tmp, (/nzq, nq_init/))
309 iq=get_q_index(trim(names_init_pl_q(n)),
'piecewise_initialization')
310 call piecewise_linear_1d(z_init_pl_q(1:nzq), f_init_pl_q(1:nzq,n), zgrid, &
311 current_state%global_grid%configuration%vertical%q_init(:,iq))
312 if (.not. current_state%continuation_run)
then 313 do i=current_state%local_grid%local_domain_start_index(x_index), &
314 current_state%local_grid%local_domain_end_index(x_index)
315 do j=current_state%local_grid%local_domain_start_index(y_index), &
316 current_state%local_grid%local_domain_end_index(y_index)
317 current_state%q(iq)%data(:,j,i) = current_state%global_grid%configuration%vertical%q_init(:, iq)
322 deallocate(f_init_pl_q_tmp, z_init_pl_q, f_init_pl_q, names_init_pl_q)