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

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