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

Last change on this file since 4505 was 4505, checked in by schwenkel, 4 years ago

Add flag for saturation check

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