source: palm/trunk/SOURCE/parin.f90 @ 4180

Last change on this file since 4180 was 4180, checked in by scharf, 5 years ago

removed comments in 'Former revisions' section that are older than 01.01.2019

  • Property svn:keywords set to Id
File size: 34.6 KB
Line 
1!> @file parin.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2019 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: parin.f90 4180 2019-08-21 14:37:54Z scharf $
27! added recycle_absolute_quantities to initialization_parameters namelist
28!
29! 4173 2019-08-20 12:04:06Z gronemeier
30! add vdi_internal_controls
31!
32! 4131 2019-08-02 11:06:18Z monakurppa
33! Allocate hom and hom_sum to allow profile output for salsa variables.
34!
35! 4079 2019-07-09 18:04:41Z suehring
36! +monotonic_limiter_z
37!
38! 4022 2019-06-12 11:52:39Z suehring
39! Change default top boundary condition for pressure to Neumann in offline
40! nesting case
41!
42! 4017 2019-06-06 12:16:46Z schwenkel
43! Introduce alternative switch for debug output during timestepping
44!
45! 3885 2019-04-11 11:29:34Z kanani
46! Changes related to global restructuring of location messages and introduction
47! of additional debug messages
48!
49! 3806 2019-03-21 12:45:50Z raasch
50! additional check for lateral boundary conditions added
51!
52! 3747 2019-02-16 15:15:23Z gronemeier
53! removed setting of parameter region
54!
55! 3746 2019-02-16 12:41:27Z gronemeier
56! Removed most_method
57!
58! 3649 2019-01-02 16:52:21Z suehring
59! Delete debug-print statements
60!
61!
62! Description:
63! ------------
64!> This subroutine reads variables controling the run from the NAMELIST files
65!>
66!> @todo: Revise max_pr_cs (profiles for chemistry)
67!------------------------------------------------------------------------------!
68 SUBROUTINE parin
69 
70
71    USE arrays_3d,                                                             &
72        ONLY:  pt_init, q_init, ref_state, s_init, sa_init,                    &
73               ug, u_init, v_init, vg
74
75    USE chem_modules
76
77    USE control_parameters
78
79    USE cpulog,                                                                &
80        ONLY:  cpu_log_barrierwait
81
82    USE date_and_time_mod,                                                     &
83        ONLY:  date_init, day_of_year_init, time_utc_init
84
85    USE grid_variables,                                                        &
86        ONLY:  dx, dy
87
88    USE indices,                                                               &
89        ONLY:  nx, ny, nz
90
91    USE kinds
92
93    USE model_1d_mod,                                                          &
94        ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
95
96    USE module_interface,                                                      &
97        ONLY:  module_interface_parin
98
99    USE netcdf_interface,                                                      &
100        ONLY:  netcdf_data_format, netcdf_deflate, netcdf_precision
101
102    USE pegrid
103
104    USE pmc_interface,                                                         &
105        ONLY:  nested_run, nesting_mode
106
107    USE profil_parameter,                                                      &
108        ONLY:  cross_profiles, profile_columns, profile_rows
109
110    USE progress_bar,                                                          &
111        ONLY :  progress_bar_disabled
112
113    USE read_restart_data_mod,                                                 &
114        ONLY:  rrd_global
115
116    USE statistics,                                                            &
117        ONLY:  hom, hom_sum, pr_palm, statistic_regions
118
119    USE turbulence_closure_mod,                                                &
120        ONLY:  rans_const_c, rans_const_sigma
121
122    USE vertical_nesting_mod,                                                  &
123        ONLY:  vnest_start_time
124
125
126    IMPLICIT NONE
127
128    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
129
130    INTEGER(iwp) ::  global_id      !< process id with respect to MPI_COMM_WORLD
131    INTEGER(iwp) ::  global_procs   !< # of procs with respect to MPI_COMM_WORLD
132    INTEGER(iwp) ::  i              !<
133    INTEGER(iwp) ::  ioerr          !< error flag for open/read/write
134
135    NAMELIST /inipar/  alpha_surface, approximation, bc_e_b,     &
136                       bc_lr, bc_ns, bc_p_b, bc_p_t, bc_pt_b, bc_pt_t, bc_q_b, &
137             bc_q_t,bc_s_b, bc_s_t, bc_uv_b, bc_uv_t,                 &
138             building_height, building_length_x,          &
139             building_length_y, building_wall_left, building_wall_south,       &
140             calc_soil_moisture_during_spinup,                                 &
141             call_psolver_at_all_substeps,  &
142             canyon_height,                                                    &
143             canyon_width_x, canyon_width_y, canyon_wall_left,                 &
144             canyon_wall_south, cfl_factor, cloud_droplets,   &
145             collective_wait, complex_terrain,           &
146             conserve_volume_flow,                                             &
147             conserve_volume_flow_mode, constant_flux_layer,                   &
148             coupling_start_time,             &
149             cycle_mg, damp_level_1d,                                          &
150             data_output_during_spinup,                                        &
151             date_init,                                                        &
152             day_of_year_init,                                                 &
153             dissipation_1d,                                                   &
154             dp_external, dp_level_b, dp_smooth, dpdxy,    &
155             dt, dt_pr_1d, dt_run_control_1d, dt_spinup, dx, dy, dz, dz_max,   &
156             dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
157             dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
158             e_min, fft_method, flux_input_mode, flux_output_mode,             &
159             galilei_transformation, humidity,                                 &
160             inflow_damping_height, inflow_damping_width,                      &
161             inflow_disturbance_begin, inflow_disturbance_end,                 &
162             initializing_actions, km_constant,                                &
163             large_scale_forcing, large_scale_subsidence, latitude,            &
164             longitude,                                 &
165             loop_optimization, lsf_exception, masking_method, mg_cycles,      &
166             mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
167             monotonic_limiter_z,                                              &
168             netcdf_precision, neutral, ngsrb,                                 &
169             nsor, nsor_ini, nudging, nx, ny, nz, ocean_mode, omega,           &
170             omega_sor, outflow_source_plane, passive_scalar,                  &
171             prandtl_number, psolver, pt_damping_factor,        &
172             pt_damping_width, pt_reference, pt_surface,                       &
173             pt_surface_initial_change, pt_vertical_gradient,                  &
174             pt_vertical_gradient_level, q_surface, q_surface_initial_change,  &
175             q_vertical_gradient, q_vertical_gradient_level,                   &
176             random_generator, random_heatflux, rans_const_c, rans_const_sigma,&
177             rayleigh_damping_factor, rayleigh_damping_height,                 &
178             recycling_width, recycling_yshift,                                &
179             reference_state, residual_limit,                                  &
180             roughness_length,                                                 &
181             scalar_advec,   &
182             scalar_rayleigh_damping,                              &
183             spinup_time, spinup_pt_amplitude, spinup_pt_mean,                 &
184             statistic_regions, subs_vertical_gradient,                        &
185             subs_vertical_gradient_level, surface_heatflux, surface_pressure, &
186             surface_scalarflux, surface_waterflux,                            &
187             s_surface, s_surface_initial_change, s_vertical_gradient,         &
188             s_vertical_gradient_level, time_utc_init, timestep_scheme,        &
189             topography, topography_grid_convention, top_heatflux,             &
190             top_momentumflux_u, top_momentumflux_v,                           &
191             top_scalarflux, transpose_compute_overlap,                        &
192             tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,     &
193             tunnel_wall_depth, turbulence_closure,                            &
194             turbulent_inflow, turbulent_outflow,                              &
195             use_subsidence_tendencies, ug_surface, ug_vertical_gradient,      &
196             use_free_convection_scaling,                                      &
197             ug_vertical_gradient_level, use_surface_fluxes, use_cmax,         &
198             use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke,      &
199             uv_heights, u_bulk, u_profile, vdi_checks, vg_surface,            &
200             vg_vertical_gradient,  &
201             vg_vertical_gradient_level, v_bulk, v_profile,&
202             wall_adjustment, wall_heatflux, wall_humidityflux,                &
203             wall_scalarflux, y_shift, zeta_max, zeta_min,  &
204             z0h_factor
205
206    NAMELIST /initialization_parameters/  alpha_surface,                       &
207             approximation, bc_e_b,                                            &
208             bc_lr, bc_ns, bc_p_b, bc_p_t, bc_pt_b, bc_pt_t, bc_q_b,           &
209             bc_q_t,bc_s_b, bc_s_t, bc_uv_b, bc_uv_t,                          &
210             building_height, building_length_x,                               &
211             building_length_y, building_wall_left, building_wall_south,       &
212             calc_soil_moisture_during_spinup,                                 &
213             call_psolver_at_all_substeps,                                     &
214             canyon_height,                                                    &
215             canyon_width_x, canyon_width_y, canyon_wall_left,                 &
216             canyon_wall_south, cfl_factor, cloud_droplets,                    &
217             collective_wait, complex_terrain,                                 &
218             conserve_volume_flow,                                             &
219             conserve_volume_flow_mode, constant_flux_layer,                   &
220             coupling_start_time,                                              &
221             cycle_mg, damp_level_1d,                                          &
222             data_output_during_spinup,                                        &
223             date_init,                                                        &
224             day_of_year_init,                                                 &
225             dissipation_1d,                                                   &
226             dp_external, dp_level_b, dp_smooth, dpdxy,                        &
227             dt, dt_pr_1d, dt_run_control_1d, dt_spinup, dx, dy, dz, dz_max,   &
228             dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
229             dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
230             e_min, fft_method, flux_input_mode, flux_output_mode,             &
231             galilei_transformation, humidity,                                 &
232             inflow_damping_height, inflow_damping_width,                      &
233             inflow_disturbance_begin, inflow_disturbance_end,                 &
234             initializing_actions, km_constant,                                &
235             large_scale_forcing, large_scale_subsidence, latitude,            &
236             longitude,                                                        &
237             loop_optimization, lsf_exception, masking_method, mg_cycles,      &
238             mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
239             monotonic_limiter_z,                                              &
240             netcdf_precision, neutral, ngsrb,                                 &
241             nsor, nsor_ini, nudging, nx, ny, nz, ocean_mode, omega,           &
242             omega_sor, outflow_source_plane, passive_scalar,                  &
243             prandtl_number, psolver, pt_damping_factor,                       &
244             pt_damping_width, pt_reference, pt_surface,                       &
245             pt_surface_initial_change, pt_vertical_gradient,                  &
246             pt_vertical_gradient_level, q_surface, q_surface_initial_change,  &
247             q_vertical_gradient, q_vertical_gradient_level,                   &
248             random_generator, random_heatflux, rans_const_c, rans_const_sigma,&
249             rayleigh_damping_factor, rayleigh_damping_height,                 &
250             recycling_width, recycling_yshift, recycle_absolute_quantities,   &
251             reference_state, residual_limit,                                  &
252             roughness_length, scalar_advec,                                   &
253             scalar_rayleigh_damping,                                          &
254             spinup_time, spinup_pt_amplitude, spinup_pt_mean,                 &
255             statistic_regions, subs_vertical_gradient,                        &
256             subs_vertical_gradient_level, surface_heatflux, surface_pressure, &
257             surface_scalarflux, surface_waterflux,                            &
258             s_surface, s_surface_initial_change, s_vertical_gradient,         &
259             s_vertical_gradient_level, time_utc_init, timestep_scheme,        &
260             topography, topography_grid_convention, top_heatflux,             &
261             top_momentumflux_u, top_momentumflux_v,                           &
262             top_scalarflux, transpose_compute_overlap,                        &
263             tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,     &
264             tunnel_wall_depth, turbulence_closure,                            &
265             turbulent_inflow, turbulent_outflow,                              &
266             use_subsidence_tendencies, ug_surface, ug_vertical_gradient,      &
267             ug_vertical_gradient_level, use_surface_fluxes, use_cmax,         &
268             use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke,      &
269             use_free_convection_scaling,                                      &
270             uv_heights, u_bulk, u_profile, vdi_checks,                        &
271             vg_surface, vg_vertical_gradient,  &
272             vg_vertical_gradient_level, v_bulk, v_profile,                    &
273             wall_adjustment, wall_heatflux, wall_humidityflux,                &
274             wall_scalarflux, y_shift, zeta_max, zeta_min, z0h_factor
275             
276    NAMELIST /d3par/  averaging_interval, averaging_interval_pr,               &
277             cpu_log_barrierwait, create_disturbances,                         &
278             cross_profiles, data_output, data_output_masks,                   &
279             data_output_pr, data_output_2d_on_each_pe,                        &
280             debug_output,                                                     &
281             debug_output_timestep,                                            &
282             disturbance_amplitude,                                            &
283             disturbance_energy_limit, disturbance_level_b,                    &
284             disturbance_level_t, do2d_at_begin, do3d_at_begin,                &
285             dt, dt_averaging_input, dt_averaging_input_pr,                    &
286             dt_coupling, dt_data_output, dt_data_output_av, dt_disturb,       &
287             dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy,         &
288             dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart,              &
289             dt_run_control,end_time, force_print_header, mask_k_over_surface, &
290             mask_scale_x,                                                     &
291             mask_scale_y, mask_scale_z, mask_x, mask_y, mask_z, mask_x_loop,  &
292             mask_y_loop, mask_z_loop, netcdf_data_format, netcdf_deflate,     &
293             normalizing_region, npex, npey, nz_do3d,                          &
294             profile_columns, profile_rows,     &
295             restart_time, section_xy, section_xz, section_yz,                 &
296             skip_time_data_output, skip_time_data_output_av, skip_time_dopr,  &
297             skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz,          &
298             skip_time_do3d, skip_time_domask, synchronous_exchange,           &
299             termination_time_needed, vnest_start_time
300
301    NAMELIST /runtime_parameters/  averaging_interval, averaging_interval_pr,  &
302             cpu_log_barrierwait, create_disturbances,                         &
303             cross_profiles, data_output, data_output_masks,                   &
304             data_output_pr, data_output_2d_on_each_pe,                        &
305             debug_output,                                                     &
306             debug_output_timestep,                                            &
307             disturbance_amplitude,                                            &
308             disturbance_energy_limit, disturbance_level_b,                    &
309             disturbance_level_t, do2d_at_begin, do3d_at_begin,                &
310             dt, dt_averaging_input, dt_averaging_input_pr,                    &
311             dt_coupling, dt_data_output, dt_data_output_av, dt_disturb,       &
312             dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy,         &
313             dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart,              &
314             dt_run_control,end_time, force_print_header, mask_k_over_surface, &
315             mask_scale_x,                                                     &
316             mask_scale_y, mask_scale_z, mask_x, mask_y, mask_z, mask_x_loop,  &
317             mask_y_loop, mask_z_loop, netcdf_data_format, netcdf_deflate,     &
318             normalizing_region, npex, npey, nz_do3d,                          &
319             profile_columns, profile_rows,     &
320             restart_time, section_xy, section_xz, section_yz,                 &
321             skip_time_data_output, skip_time_data_output_av, skip_time_dopr,  &
322             skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz,          &
323             skip_time_do3d, skip_time_domask, synchronous_exchange,           &
324             termination_time_needed, vnest_start_time
325
326    NAMELIST /envpar/  progress_bar_disabled, host,                            &
327                       maximum_cpu_time_allowed, maximum_parallel_io_streams,  &
328                       read_svf, revision, run_identifier, tasks_per_node,     &
329                       write_binary, write_svf
330
331!
332!-- First read values of environment variables (this NAMELIST file is
333!-- generated by palmrun)
334    CALL location_message( 'reading environment parameters from ENVPAR', 'start' )
335
336    OPEN ( 90, FILE='ENVPAR', STATUS='OLD', FORM='FORMATTED', IOSTAT=ioerr )
337
338    IF ( ioerr /= 0 )  THEN
339       message_string = 'local file ENVPAR not found' //                       &
340                        '&some variables for steering may not be properly set'
341       CALL message( 'parin', 'PA0276', 0, 1, 0, 6, 0 )
342    ELSE
343       READ ( 90, envpar, IOSTAT=ioerr )
344       IF ( ioerr < 0 )  THEN
345          message_string = 'no envpar-NAMELIST found in local file '  //       &
346                           'ENVPAR& or some variables for steering may '  //   &
347                           'not be properly set'
348          CALL message( 'parin', 'PA0278', 0, 1, 0, 6, 0 )
349       ELSEIF ( ioerr > 0 )  THEN
350          message_string = 'errors in local file ENVPAR' //                    &
351                           '&some variables for steering may not be properly set'
352          CALL message( 'parin', 'PA0277', 0, 1, 0, 6, 0 )
353       ENDIF
354       CLOSE ( 90 )
355    ENDIF
356
357    CALL location_message( 'reading environment parameters from ENVPAR', 'finished' )
358!
359!-- Calculate the number of groups into which parallel I/O is split.
360!-- The default for files which are opened by all PEs (or where each
361!-- PE opens his own independent file) is, that all PEs are doing input/output
362!-- in parallel at the same time. This might cause performance or even more
363!-- severe problems depending on the configuration of the underlying file
364!-- system.
365!-- Calculation of the number of blocks and the I/O group must be based on all
366!-- PEs involved in this run. Since myid and numprocs are related to the
367!-- comm2d communicator, which gives only a subset of all PEs in case of
368!-- nested runs, that information must be inquired again from the global
369!-- communicator.
370!-- First, set the default:
371#if defined( __parallel )
372    CALL MPI_COMM_RANK( MPI_COMM_WORLD, global_id, ierr )
373    CALL MPI_COMM_SIZE( MPI_COMM_WORLD, global_procs, ierr )
374#else
375    global_id    = 0
376    global_procs = 1
377#endif
378    IF ( maximum_parallel_io_streams == -1  .OR.                               &
379         maximum_parallel_io_streams > global_procs )  THEN
380       maximum_parallel_io_streams = global_procs
381    ENDIF
382!
383!-- Now calculate the number of io_blocks and the io_group to which the
384!-- respective PE belongs. I/O of the groups is done in serial, but in parallel
385!-- for all PEs belonging to the same group.
386    io_blocks = global_procs / maximum_parallel_io_streams
387    io_group  = MOD( global_id+1, io_blocks )
388   
389    CALL location_message( 'reading NAMELIST parameters from PARIN', 'start' )
390!
391!-- Data is read in parallel by groups of PEs
392    DO  i = 0, io_blocks-1
393       IF ( i == io_group )  THEN
394
395!
396!--       Open the NAMELIST-file which is send with this job
397          CALL check_open( 11 )
398
399!
400!--       Read the control parameters for initialization.
401!--       The namelist "inipar" must be provided in the NAMELIST-file.
402          READ ( 11, initialization_parameters, ERR=10, END=11 )
403          GOTO 14
404         
405 10       BACKSPACE( 11 )
406          READ( 11 , '(A)') line
407          CALL parin_fail_message( 'initialization_parameters', line )
408
409 11       REWIND ( 11 )
410          READ ( 11, inipar, ERR=12, END=13 )
411 
412          message_string = 'namelist inipar is deprecated and will be ' //    &
413                          'removed in near future. & Please use namelist ' // &
414                          'initialization_parameters instead'
415          CALL message( 'parin', 'PA0017', 0, 1, 0, 6, 0 )
416 
417          GOTO 14
418 
419 12       BACKSPACE( 11 )
420          READ( 11 , '(A)') line
421          CALL parin_fail_message( 'inipar', line )
422
423 13       message_string = 'no initialization_parameters-namelist found'
424          CALL message( 'parin', 'PA0272', 1, 2, 0, 6, 0 )
425
426!
427!--       Try to read runtime parameters given by the user for this run
428!--       (namelist "runtime_parameters"). The namelist "runtime_parmeters"   
429!--       can be omitted. In that case default values are used for the         
430!--       parameters.
431 14       line = ' '
432
433          REWIND ( 11 )
434          line = ' '
435          DO WHILE ( INDEX( line, '&runtime_parameters' ) == 0 )
436             READ ( 11, '(A)', END=16 )  line
437          ENDDO
438          BACKSPACE ( 11 )
439
440!
441!--       Read namelist
442          READ ( 11, runtime_parameters, ERR = 15 )
443          GOTO 18
444
445 15       BACKSPACE( 11 )
446          READ( 11 , '(A)') line
447          CALL parin_fail_message( 'runtime_parameters', line )
448
449 16       REWIND ( 11 )
450          line = ' '
451          DO WHILE ( INDEX( line, '&d3par' ) == 0 )
452             READ ( 11, '(A)', END=18 )  line
453          ENDDO
454          BACKSPACE ( 11 )
455
456!
457!--       Read namelist
458          READ ( 11, d3par, ERR = 17, END = 18 )
459
460          message_string = 'namelist d3par is deprecated and will be ' //      &
461                          'removed in near future. &Please use namelist ' //   &
462                          'runtime_parameters instead'
463          CALL message( 'parin', 'PA0487', 0, 1, 0, 6, 0 )
464
465          GOTO 18
466
467 17       BACKSPACE( 11 )
468          READ( 11 , '(A)') line
469          CALL parin_fail_message( 'd3par', line )
470
471 18       CONTINUE
472
473!
474!--       Check for module namelists and read them
475          CALL module_interface_parin
476
477!
478!--       If required, read control parameters from restart file (produced by
479!--       a prior run). All PEs are reading from file created by PE0 (see
480!--       check_open)
481          IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
482
483             CALL rrd_global
484!
485!--          Increment the run count
486             runnr = runnr + 1
487!
488!--          In case of a restart run, the number of user-defined profiles on
489!--          the restart file (already stored in max_pr_user) has to match the
490!--          one given for the current run. max_pr_user_tmp is calculated in
491!--          user_parin and max_pr_user is read in via rrd_global.
492             IF ( max_pr_user /= max_pr_user_tmp )  THEN
493                WRITE( message_string, * ) 'the number of user-defined ',      &
494                      'profiles given in data_output_pr (', max_pr_user_tmp,   &
495                      ') does not match the one ',                             &
496                      'found in the restart file (', max_pr_user, ')'
497                CALL message( 'user_parin', 'UI0009', 1, 2, 0, 6, 0 )
498             ENDIF
499          ELSE
500             max_pr_user = max_pr_user_tmp
501          ENDIF
502!
503!--       Activate spinup
504          IF ( land_surface .OR. urban_surface )  THEN
505             IF ( spinup_time > 0.0_wp )  THEN
506                coupling_start_time = spinup_time
507                time_since_reference_point = simulated_time - coupling_start_time
508                IF ( spinup_pt_mean == 9999999.9_wp )  THEN
509                   spinup_pt_mean = pt_surface
510                ENDIF
511                end_time = end_time + spinup_time
512                IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
513                   spinup = .TRUE.
514                ELSEIF (        TRIM( initializing_actions ) == 'read_restart_data'      &
515                         .AND.  time_since_reference_point > 0.0_wp )  THEN
516                   data_output_during_spinup = .FALSE.  !< required for correct ntdim calculation
517                                                        !< in check_parameters for restart run
518                ENDIF
519             ENDIF
520          ENDIF
521
522!
523!--       In case of nested runs, explicitly set nesting boundary conditions.
524!--       This will overwrite the user settings and basic defaults.
525!--       bc_lr and bc_ns always need to be cyclic for vertical nesting.
526          IF ( nested_run )  THEN
527             IF ( nesting_mode == 'vertical' )  THEN
528                IF (bc_lr /= 'cyclic' .OR. bc_ns /= 'cyclic' )  THEN
529                   WRITE ( message_string, *) 'bc_lr and bc_ns were set to ,', &
530                        'cyclic for vertical nesting'
531                   CALL message( 'parin', 'PA0428', 0, 0, 0, 6, 0 )
532                   bc_lr   = 'cyclic'
533                   bc_ns   = 'cyclic'
534                ENDIF
535                IF ( child_domain )  THEN
536                   bc_uv_t  = 'nested'
537                   bc_pt_t  = 'nested'
538                   bc_q_t   = 'nested'
539                   bc_s_t   = 'nested'
540                   bc_cs_t  = 'nested'
541                   bc_p_t   = 'neumann' 
542                ENDIF
543!
544!--          For other nesting modes only set boundary conditions for
545!--          nested domains.
546             ELSE
547                IF ( child_domain )  THEN
548                   bc_lr    = 'nested'
549                   bc_ns    = 'nested'
550                   bc_uv_t  = 'nested'
551                   bc_pt_t  = 'nested'
552                   bc_q_t   = 'nested'
553                   bc_s_t   = 'nested'
554                   bc_cs_t  = 'nested'
555                   bc_p_t   = 'neumann'
556                ENDIF
557             ENDIF
558          ENDIF
559!
560!--       Set boundary conditions also in case the model is offline-nested in
561!--       larger-scale models.
562          IF ( nesting_offline )  THEN
563             bc_lr    = 'nesting_offline'
564             bc_ns    = 'nesting_offline'
565             bc_uv_t  = 'nesting_offline'
566             bc_pt_t  = 'nesting_offline'
567             bc_q_t   = 'nesting_offline'
568           !  bc_s_t   = 'nesting_offline'  ! scalar boundary condition is not clear yet
569           !  bc_cs_t  = 'nesting_offline'  ! same for chemical species
570             bc_p_t   = 'neumann'
571          ENDIF
572
573!         
574!--       In case of nested runs, make sure that initializing_actions =
575!--       'set_constant_profiles' even though the constant-profiles
576!--       initializations for the prognostic variables will be overwritten
577!--       by pmci_child_initialize and pmci_parent_initialize. This is,
578!--       however, important e.g. to make sure that diagnostic variables
579!--       are set properly. An exception is made in case of restart runs and
580!--       if user decides to do everything by its own.
581          IF ( child_domain  .AND.  .NOT. (                                    &
582               TRIM( initializing_actions ) == 'read_restart_data'      .OR.   &
583               TRIM( initializing_actions ) == 'set_constant_profiles'  .OR.   &
584               TRIM( initializing_actions ) == 'by_user' ) )  THEN
585             message_string = 'initializing_actions = ' //                     &
586                              TRIM( initializing_actions ) // ' has been ' //  &
587                              'changed to set_constant_profiles in child ' //  &
588                              'domain.' 
589             CALL message( 'parin', 'PA0492', 0, 0, 0, 6, 0 )
590
591             initializing_actions = 'set_constant_profiles'
592          ENDIF           
593!
594!--       Check validity of lateral boundary conditions. This has to be done
595!--       here because they are already used in init_pegrid and init_grid and
596!--       therefore cannot be check in check_parameters
597          IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
598               bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'  .AND. &
599               bc_lr /= 'nesting_offline' )  THEN
600             message_string = 'unknown boundary condition: bc_lr = "' // &
601                              TRIM( bc_lr ) // '"'
602             CALL message( 'parin', 'PA0049', 1, 2, 0, 6, 0 )
603          ENDIF
604          IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
605               bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'  .AND. &
606               bc_ns /= 'nesting_offline' )  THEN
607             message_string = 'unknown boundary condition: bc_ns = "' // &
608                              TRIM( bc_ns ) // '"'
609             CALL message( 'parin', 'PA0050', 1, 2, 0, 6, 0 )
610          ENDIF
611!
612!--       Set internal variables used for speed optimization in if clauses
613          IF ( bc_lr /= 'cyclic' )               bc_lr_cyc    = .FALSE.
614          IF ( bc_lr == 'dirichlet/radiation' )  bc_lr_dirrad = .TRUE.
615          IF ( bc_lr == 'radiation/dirichlet' )  bc_lr_raddir = .TRUE.
616          IF ( bc_ns /= 'cyclic' )               bc_ns_cyc    = .FALSE.
617          IF ( bc_ns == 'dirichlet/radiation' )  bc_ns_dirrad = .TRUE.
618          IF ( bc_ns == 'radiation/dirichlet' )  bc_ns_raddir = .TRUE.
619!
620!--       Radiation-Dirichlet conditions are allowed along one of the horizontal directions only.
621!--       In general, such conditions along x and y may work, but require a) some code changes
622!--       (e.g. concerning allocation of c_u, c_v ... arrays), and b) a careful model setup by the
623!--       user, in order to guarantee that there is a clearly defined outflow at two sides.
624!--       Otherwise, the radiation condition may produce wrong results.
625          IF ( ( bc_lr_dirrad .OR. bc_lr_raddir )  .AND.  ( bc_ns_dirrad .OR. bc_ns_raddir ) )  THEN
626             message_string = 'bc_lr = "' // TRIM( bc_lr ) // '" and bc_ns = "' //                 &
627                              TRIM( bc_ns ) // '" are not allowed to be set at the same time'
628             CALL message( 'parin', 'PA0589', 1, 2, 0, 6, 0 )
629          ENDIF
630!
631!--       Check in case of initial run, if the grid point numbers are well
632!--       defined and allocate some arrays which are already needed in
633!--       init_pegrid or check_parameters. During restart jobs, these arrays
634!--       will be allocated in rrd_global. All other arrays are allocated
635!--       in init_3d_model.
636          IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
637
638             IF ( nx <= 0 )  THEN
639                WRITE( message_string, * ) 'no value or wrong value given',    &
640                                           ' for nx: nx=', nx
641                CALL message( 'parin', 'PA0273', 1, 2, 0, 6, 0 )
642             ENDIF
643             IF ( ny <= 0 )  THEN
644                WRITE( message_string, * ) 'no value or wrong value given',    &
645                                           ' for ny: ny=', ny
646                CALL message( 'parin', 'PA0274', 1, 2, 0, 6, 0 )
647             ENDIF
648             IF ( nz <= 0 )  THEN
649                WRITE( message_string, * ) 'no value or wrong value given',    &
650                                           ' for nz: nz=', nz
651                CALL message( 'parin', 'PA0275', 1, 2, 0, 6, 0 )
652             ENDIF
653
654!
655!--          As a side condition, routine flow_statistics require at least 14
656!--          vertical grid levels (they are used to store time-series data)
657!>           @todo   Remove this restriction
658             IF ( nz < 14 )  THEN
659                WRITE( message_string, * ) 'nz >= 14 is required'
660                CALL message( 'parin', 'PA0362', 1, 2, 0, 6, 0 )
661             ENDIF
662
663!
664!--          ATTENTION: in case of changes to the following statement please
665!--                  also check the allocate statement in routine rrd_global
666             ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),        &
667                       ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
668                       u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),             &
669                    hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),  &
670                    hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
671
672             hom = 0.0_wp
673
674          ENDIF
675
676!
677!--       NAMELIST-file is not needed anymore
678          CALL close_file( 11 )
679
680       ENDIF
681#if defined( __parallel )
682       CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
683#endif
684    ENDDO
685
686    CALL location_message( 'reading NAMELIST parameters from PARIN', 'finished' )
687
688 END SUBROUTINE parin
Note: See TracBrowser for help on using the repository browser.