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

Last change on this file since 4540 was 4536, checked in by raasch, 4 years ago

messages and debug output converted to PALM routines (restart_data_mpi_io_mod), binary version number set to 5.0, heeader output for restart data format added, restart data filesize and I/O transfer speed added in cpu_measures, handling of single restart files (created with MPI-I/O) added to palmrun, bugfix: preprocessor directive adjusted (virtual_measurement_mod), location message format changed

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