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

Last change on this file since 4496 was 4495, checked in by raasch, 4 years ago

restart data handling with MPI-IO added, first part

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