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

Last change on this file since 4208 was 4196, checked in by gronemeier, 5 years ago

Consider rotation of model domain for claculation of Coriolis force:

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