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

Last change on this file since 4195 was 4191, checked in by gronemeier, 5 years ago

bugfix: add recycling_method_for_thermodynamic_quantities to inipar namelist

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