source: palm/trunk/SOURCE/read_restart_data_mod.f90 @ 4590

Last change on this file since 4590 was 4590, checked in by suehring, 4 years ago

Biomet: Enable restart via mpi-IO; Restart: Bugfix in allocation of hom and hom_sum in case of mpi-io restart when chemistry or salsa are employed

  • Property svn:keywords set to Id
File size: 115.4 KB
RevLine 
[2894]1!> @file read_restart_data_mod.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!
[4360]17! Copyright 1997-2020 Leibniz Universitaet Hannover
[2894]18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
[4590]22!
23!
[2894]24! Former revisions:
25! -----------------
26! $Id: read_restart_data_mod.f90 4590 2020-07-06 14:34:59Z suehring $
[4590]27! Bugfix in allocation of hom and hom_sum in case of mpi-io restart when
28! chemistry or salsa are employed
29!
30! 4580 2020-06-29 07:54:21Z raasch
[4580]31! data handling with MPI-IO for cyclic-fill added (so far only for global data)
32!
33! 4564 2020-06-12 14:03:36Z raasch
[4564]34! Vertical nesting method of Huq et al. (2019) removed
35!
36! 4539 2020-05-18 14:05:17Z raasch
[4539]37! location message added
38!
39! 4536 2020-05-17 17:24:13Z raasch
[4536]40! binary version incremented
41!
42! 4534 2020-05-14 18:35:22Z raasch
[4534]43! adjustments for I/O on reduced number of cores using shared memory MPI
44!
45! 4518 2020-05-04 15:44:28Z suehring
[4518]46! Move input of diagnostic output quantities to doq_rrd_local
47!
48! 4517 2020-05-03 14:29:30Z raasch
[4514]49! qsurf and ssurf added
50!
51! 4498 2020-04-15 14:26:31Z raasch
[4498]52! argument removed from rd_mpi_io_open
53!
54! 4496 2020-04-15 08:37:26Z raasch
[4496]55! bugfix: MPI barrier removed, coupling character added to input filename
56!
57! 4495 2020-04-13 20:11:20Z raasch
[4495]58! restart data handling with MPI-IO added
59!
60! 4435 2020-03-03 10:38:41Z raasch
[4435]61! bugfix for message that reports about files that are read from in case that the virtual PE grid
62! has chenged (in case of large number of files format was exceeded), detailed messages about the
63! files are now output to the debug file
64!
65! 4431 2020-02-27 23:23:01Z gronemeier
[4431]66! added u_center_av, v_center_av, wspeed_av
67!
68! 4360 2020-01-07 11:25:50Z suehring
[4356]69! Change automatic arrays to allocatable ones in rrd_local, in order to avoid
[4431]70! memory problems due to too small stack size for large jobs with intel
[4356]71! compiler. (J.Resler)
[4431]72!
[4356]73! 4331 2019-12-10 18:25:02Z suehring
[4331]74! Enable restart data for 2-m potential temperature output
[4431]75!
[4331]76! 4301 2019-11-22 12:09:09Z oliver.maas
[4301]77! removed recycling_yshift
[4431]78!
[4301]79! 4227 2019-09-10 18:04:34Z gronemeier
[4227]80! implement new palm_date_time_mod and increased binary version
[4431]81!
[4227]82! 4146 2019-08-07 07:47:36Z gronemeier
[4182]83! Corrected "Former revisions" section
[4431]84!
[4182]85! 4131 2019-08-02 11:06:18Z monakurppa
[4131]86! Allocate hom and hom_sum to allow profile output for salsa variables.
[4431]87!
[4131]88! 4101 2019-07-17 15:14:26Z gronemeier
[4101]89! remove old_dt
[4431]90!
[4101]91! 4039 2019-06-18 10:32:41Z suehring
[4039]92! input of uu_av, vv_av, ww_av added
[4431]93!
[4039]94! 4017 2019-06-06 12:16:46Z schwenkel
[4009]95! bugfix for r3998, allocation of 3d temporary arrays of various dimensions revised
[4431]96!
[4009]97! 3998 2019-05-23 13:38:11Z suehring
[3998]98! Formatting adjustment
[4431]99!
[3998]100! 3994 2019-05-22 18:08:09Z suehring
[3994]101! output of turbulence intensity added
[4431]102!
[3994]103! 3988 2019-05-22 11:32:37Z kanani
[3988]104! + time_virtual_measurement (to enable steering of output interval)
[4431]105!
[3988]106! 3936 2019-04-26 15:38:02Z kanani
[3936]107! Enable time-averaged output of theta_2m* with restarts
[4431]108!
[3936]109! 3767 2019-02-27 08:18:02Z raasch
[3767]110! unused variables removed from rrd-subroutines parameter list
[4431]111!
[3767]112! 3766 2019-02-26 16:23:41Z raasch
[3766]113! first argument removed from module_interface_rrd_*
[4431]114!
[3766]115! 3668 2019-01-14 12:49:24Z maronga
[3668]116! Removed most_method and increased binary version
[4431]117!
[3668]118! 3655 2019-01-07 16:51:22Z knoop
[3637]119! Implementation of the PALM module interface
[4431]120!
[4182]121! 2894 2018-03-15 09:17:58Z Giersch
122! Initial revision
[2894]123!
[4431]124!
[2894]125! Description:
126! ------------
127!> Reads restart data from restart-file(s) (binary format).
[3298]128!>
129!> @todo: Revise max_pr_cs (profiles for chemistry)
[4039]130!> @todo: Modularize reading of restart data for diagnostic quantities, which
131!>        is not possible with the current module-interface structure
[2894]132!------------------------------------------------------------------------------!
133 MODULE read_restart_data_mod
134
135
[3637]136    USE arrays_3d,                                                             &
137        ONLY:  inflow_damping_factor, mean_inflow_profiles, pt_init,           &
138               q_init, ref_state, sa_init, s_init, u_init, ug, v_init, vg,     &
139               e, kh, km, p, pt, q, ql, s, u, u_m_l, u_m_n, u_m_r, u_m_s,      &
140               v, v_m_l, v_m_n, v_m_r, v_m_s, vpt, w, w_m_l, w_m_n, w_m_r, w_m_s
[2894]141
[3637]142    USE averaging
143
[4495]144    USE bulk_cloud_model_mod,                                                                      &
145        ONLY:  bulk_cloud_model
146
[3298]147    USE chem_modules,                                                                              &
148       ONLY: max_pr_cs
149
[3637]150    USE control_parameters
[3298]151
[3637]152    USE cpulog,                                                                &
153        ONLY:  cpu_log, log_point_s
154
155    USE grid_variables,                                                        &
156        ONLY:  dx, dy
157
[4495]158    USE gust_mod,                                                                                  &
159        ONLY:  gust_module_enabled
160
[3637]161    USE indices,                                                               &
162        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nx_on_file, ny, nys, nysg, nyn, &
163               nyng, ny_on_file, nz, nzb, nzt
164
165    USE kinds
166
167    USE model_1d_mod,                                                          &
168        ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
169
170    USE module_interface,                                                      &
171        ONLY:  module_interface_rrd_global,                                    &
172               module_interface_rrd_local
173
174    USE netcdf_interface,                                                      &
175        ONLY:  netcdf_precision, output_for_t0
176
[4495]177    USE particle_attributes,                                                                       &
178        ONLY:  particle_advection
179
[3637]180    USE pegrid
181
182    USE radiation_model_mod,                                                   &
183        ONLY:  time_radiation
184
185    USE random_function_mod,                                                   &
186        ONLY:  random_iv, random_iy
187
188    USE random_generator_parallel,                                             &
189        ONLY:  id_random_array, seq_random_array
190
[4495]191    USE restart_data_mpi_io_mod,                                                                   &
192        ONLY:  rd_mpi_io_check_array, rd_mpi_io_close, rd_mpi_io_open, rrd_mpi_io,                 &
193               rrd_mpi_io_global_array
194
[3637]195    USE spectra_mod,                                                           &
196        ONLY:  average_count_sp, spectrum_x, spectrum_y
197
198    USE surface_mod,                                                           &
199        ONLY :  surface_rrd_local
200
201    USE statistics,                                                            &
202        ONLY:  statistic_regions, hom, hom_sum, pr_palm, u_max, u_max_ijk,     &
203               v_max, v_max_ijk, w_max, w_max_ijk, z_i
204
[4495]205    USE user,                                                                                      &
206        ONLY:  user_module_enabled
207
[3988]208    USE virtual_measurement_mod,                                               &
209        ONLY:  time_virtual_measurement
[3637]210
[3988]211
[2894]212    IMPLICIT NONE
213
214
215    INTERFACE rrd_global
216       MODULE PROCEDURE rrd_global
217    END INTERFACE rrd_global
218
219    INTERFACE rrd_read_parts_of_global
220       MODULE PROCEDURE rrd_read_parts_of_global
221    END INTERFACE rrd_read_parts_of_global
222
223    INTERFACE rrd_local
224       MODULE PROCEDURE rrd_local
225    END INTERFACE rrd_local
226
227    INTERFACE rrd_skip_global
228       MODULE PROCEDURE rrd_skip_global
229    END INTERFACE rrd_skip_global
230
231
[3294]232    PUBLIC rrd_global, rrd_read_parts_of_global, rrd_local, rrd_skip_global
[2894]233
234
235 CONTAINS
236
[3294]237!------------------------------------------------------------------------------!
[2894]238! Description:
239! ------------
[4431]240!> Reads values of global control variables from restart-file (binary format)
[2894]241!> created by PE0 of the previous run
242!------------------------------------------------------------------------------!
[4495]243 SUBROUTINE rrd_global
[2894]244
245
[4495]246    CHARACTER(LEN=10) ::  binary_version_global  !<
247    CHARACTER(LEN=10) ::  version_on_file        !<
248    CHARACTER(LEN=20) ::  tmp_name               !< temporary variable
[2894]249
[4495]250    INTEGER ::  i                                !< loop index
[2894]251
[4495]252    LOGICAL ::  array_found                      !<
253    LOGICAL ::  found                            !<
[2894]254
[4495]255
256    CALL location_message( 'read global restart data', 'start' )
257
258    IF ( TRIM( restart_data_format_input ) == 'fortran_binary' )  THEN
259!
260!--    Input in Fortran binary format
[2894]261       CALL check_open( 13 )
262!
[3294]263!--    Make version number check first
[2894]264       READ ( 13 )  length
265       READ ( 13 )  restart_string(1:length)
266       READ ( 13 )  version_on_file
267
[4536]268       binary_version_global = '5.0'
[2894]269       IF ( TRIM( version_on_file ) /= TRIM( binary_version_global ) )  THEN
[3045]270          WRITE( message_string, * ) 'version mismatch concerning ',           &
271                                     'binary_version_global:',                 &
[3046]272                                     '&version on file    = "',                &
[2894]273                                     TRIM( version_on_file ), '"',             &
[3046]274                                     '&version on program = "',                &
[2894]275                                     TRIM( binary_version_global ), '"'
276          CALL message( 'rrd_global', 'PA0296', 1, 2, 0, 6, 0 )
277       ENDIF
278
279!
[3294]280!--    Read number of PEs and horizontal index bounds of all PEs used in the
281!--    previous run
[2894]282       READ ( 13 )  length
283       READ ( 13 )  restart_string(1:length)
284
285       IF ( TRIM( restart_string(1:length) ) /= 'numprocs' )  THEN
286          WRITE( message_string, * ) 'numprocs not found in data from prior ', &
287                                     'run on PE ', myid
288          CALL message( 'rrd_global', 'PA0297', 1, 2, 0, 6, 0 )
289       ENDIF
290       READ ( 13 )  numprocs_previous_run
291
292       IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
293          ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
294       ENDIF
295
296       READ ( 13 )  length
297       READ ( 13 )  restart_string(1:length)
298
299       IF ( restart_string(1:length) /= 'hor_index_bounds' )  THEN
300          WRITE( message_string, * ) 'hor_index_bounds not found in data ',    &
301                                     'from prior run on PE ', myid
302          CALL message( 'rrd_global', 'PA0298', 1, 2, 0, 6, 0 )
303       ENDIF
304       READ ( 13 )  hor_index_bounds_previous_run
305
306!
[3294]307!--    Read vertical number of gridpoints and number of different areas used
308!--    for computing statistics. Allocate arrays depending on these values,
309!--    which are needed for the following read instructions.
[2894]310       READ ( 13 )  length
311       READ ( 13 )  restart_string(1:length)
312
313       IF ( restart_string(1:length) /= 'nz' )  THEN
314          WRITE( message_string, * ) 'nz not found in data from prior run ',   &
315                                     'on PE ', myid
316          CALL message( 'rrd_global', 'PA0299', 1, 2, 0, 6, 0 )
317       ENDIF
318       READ ( 13 )  nz
319
320       READ ( 13 )  length
321       READ ( 13 )  restart_string(1:length)
322
323       IF ( restart_string(1:length) /= 'max_pr_user' )  THEN
324          WRITE( message_string, * ) 'max_pr_user not found in data from ',    &
325                                     'prior run on PE ', myid
326          CALL message( 'rrd_global', 'PA0300', 1, 2, 0, 6, 0 )
327       ENDIF
328       READ ( 13 )  max_pr_user    ! This value is checked against the number of
329                                   ! user profiles given for the current run
330                                   ! in routine user_parin (it has to match)
331
332       READ ( 13 )  length
333       READ ( 13 )  restart_string(1:length)
334
335       IF ( restart_string(1:length) /= 'statistic_regions' )  THEN
336          WRITE( message_string, * ) 'statistic_regions not found in data ',   &
337                                     'from prior run on PE ', myid
338          CALL message( 'rrd_global', 'PA0301', 1, 2, 0, 6, 0 )
339       ENDIF
340       READ ( 13 )  statistic_regions
[3294]341
[4495]342!
343!--    The following global arrays (better to say, they have the same size and values on each
344!--    subdomain) are by default allocated in routine parin, but not in case of restarts!
[2894]345       IF ( .NOT. ALLOCATED( ug ) )  THEN
[4495]346          ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1),                                        &
347                    v_init(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),                               &
348                    ref_state(0:nz+1), s_init(0:nz+1), sa_init(0:nz+1),                            &
[4131]349                    hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),  &
350                    hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
[2894]351       ENDIF
352
353!
[3294]354!--    Now read all control parameters:
355!--    Caution: When the following read instructions have been changed, the
356!--    -------  version number stored in the variable binary_version_global has
357!--             to be increased. The same changes must also be done in
358!--             wrd_write_global.
[2894]359       READ ( 13 )  length
360       READ ( 13 )  restart_string(1:length)
361
362       DO WHILE ( restart_string(1:length) /= 'binary_version_local' )
363
364          found = .FALSE.
365
366          SELECT CASE ( restart_string(1:length) )
367
368             CASE ( 'advected_distance_x' )
369                READ ( 13 )  advected_distance_x
370             CASE ( 'advected_distance_y' )
371                READ ( 13 )  advected_distance_y
372             CASE ( 'alpha_surface' )
373                READ ( 13 )  alpha_surface
374             CASE ( 'average_count_pr' )
375                READ ( 13 )  average_count_pr
376             CASE ( 'average_count_sp' )
377                READ ( 13 )  average_count_sp
378             CASE ( 'average_count_3d' )
379                READ ( 13 )  average_count_3d
380             CASE ( 'bc_e_b' )
381                READ ( 13 )  bc_e_b
382             CASE ( 'bc_lr' )
383                READ ( 13 )  bc_lr
384             CASE ( 'bc_ns' )
385                READ ( 13 )  bc_ns
386             CASE ( 'bc_p_b' )
387                READ ( 13 )  bc_p_b
388             CASE ( 'bc_p_t' )
389                READ ( 13 )  bc_p_t
390             CASE ( 'bc_pt_b' )
391                READ ( 13 )  bc_pt_b
392             CASE ( 'bc_pt_t' )
393                READ ( 13 )  bc_pt_t
394             CASE ( 'bc_pt_t_val' )
395                READ ( 13 )  bc_pt_t_val
396             CASE ( 'bc_q_b' )
397                READ ( 13 )  bc_q_b
398             CASE ( 'bc_q_t' )
399                READ ( 13 )  bc_q_t
400             CASE ( 'bc_q_t_val' )
401                READ ( 13 )  bc_q_t_val
402             CASE ( 'bc_s_b' )
403                READ ( 13 )  bc_s_b
404             CASE ( 'bc_s_t' )
405                READ ( 13 )  bc_s_t
406             CASE ( 'bc_uv_b' )
407                READ ( 13 )  bc_uv_b
408             CASE ( 'bc_uv_t' )
409                READ ( 13 )  bc_uv_t
410             CASE ( 'building_height' )
411                READ ( 13 )  building_height
412             CASE ( 'building_length_x' )
413                READ ( 13 )  building_length_x
414             CASE ( 'building_length_y' )
415                READ ( 13 )  building_length_y
416             CASE ( 'building_wall_left' )
417                READ ( 13 )  building_wall_left
418             CASE ( 'building_wall_south' )
419                READ ( 13 )  building_wall_south
420             CASE ( 'call_psolver_at_all_substeps' )
421                READ ( 13 )  call_psolver_at_all_substeps
422             CASE ( 'canyon_height' )
423                READ ( 13 )  canyon_height
424             CASE ( 'canyon_wall_left' )
425                READ ( 13 )  canyon_wall_left
426             CASE ( 'canyon_wall_south' )
427                READ ( 13 )  canyon_wall_south
428             CASE ( 'canyon_width_x' )
429                READ ( 13 )  canyon_width_x
430             CASE ( 'canyon_width_y' )
431                READ ( 13 )  canyon_width_y
432             CASE ( 'cfl_factor' )
433                READ ( 13 )  cfl_factor
434             CASE ( 'cloud_droplets' )
435                READ ( 13 )  cloud_droplets
436             CASE ( 'collective_wait' )
437                READ ( 13 )  collective_wait
438             CASE ( 'conserve_volume_flow' )
439                READ ( 13 )  conserve_volume_flow
440             CASE ( 'conserve_volume_flow_mode' )
441                READ ( 13 )  conserve_volume_flow_mode
442             CASE ( 'constant_flux_layer' )
443                READ ( 13 )  constant_flux_layer
444             CASE ( 'coupling_start_time' )
445                READ ( 13 )  coupling_start_time
446             CASE ( 'current_timestep_number' )
447                READ ( 13 )  current_timestep_number
448             CASE ( 'cycle_mg' )
449                READ ( 13 )  cycle_mg
450             CASE ( 'damp_level_1d' )
451                READ ( 13 )  damp_level_1d
[4227]452             CASE ( 'origin_date_time' )
453                READ ( 13 )  origin_date_time
[2894]454             CASE ( 'dissipation_1d' )
455                READ ( 13 )  dissipation_1d
456             CASE ( 'do2d_xy_time_count' )
457                READ ( 13 )  do2d_xy_time_count
458             CASE ( 'do2d_xz_time_count' )
459                READ ( 13 )  do2d_xz_time_count
460             CASE ( 'do2d_yz_time_count' )
461                READ ( 13 )  do2d_yz_time_count
462             CASE ( 'do3d_time_count' )
463                READ ( 13 )  do3d_time_count
464             CASE ( 'dp_external' )
465                READ ( 13 )  dp_external
466             CASE ( 'dp_level_b' )
467                READ ( 13 )  dp_level_b
468             CASE ( 'dp_smooth' )
469                READ ( 13 )  dp_smooth
470             CASE ( 'dpdxy' )
471                READ ( 13 )  dpdxy
472             CASE ( 'dt_3d' )
473                READ ( 13 )  dt_3d
474             CASE ( 'dt_pr_1d' )
475                READ ( 13 )  dt_pr_1d
476             CASE ( 'dt_run_control_1d' )
477                READ ( 13 )  dt_run_control_1d
478             CASE ( 'dx' )
479                READ ( 13 )  dx
480             CASE ( 'dy' )
481                READ ( 13 )  dy
482             CASE ( 'dz' )
483                READ ( 13 )  dz
484             CASE ( 'dz_max' )
485                READ ( 13 )  dz_max
486             CASE ( 'dz_stretch_factor' )
487                READ ( 13 )  dz_stretch_factor
[3065]488             CASE ( 'dz_stretch_factor_array' )
489                READ ( 13 )  dz_stretch_factor_array
[2894]490             CASE ( 'dz_stretch_level' )
491                READ ( 13 )  dz_stretch_level
[3065]492             CASE ( 'dz_stretch_level_end' )
493                READ ( 13 )  dz_stretch_level_end
494             CASE ( 'dz_stretch_level_start' )
495                READ ( 13 )  dz_stretch_level_start
[2894]496             CASE ( 'e_min' )
497                READ ( 13 )  e_min
498             CASE ( 'end_time_1d' )
499                READ ( 13 )  end_time_1d
500             CASE ( 'fft_method' )
501                READ ( 13 )  fft_method
502             CASE ( 'first_call_lpm' )
503                READ ( 13 )  first_call_lpm
504             CASE ( 'galilei_transformation' )
505                READ ( 13 )  galilei_transformation
506             CASE ( 'hom' )
507                READ ( 13 )  hom
508             CASE ( 'hom_sum' )
509                READ ( 13 )  hom_sum
510             CASE ( 'humidity' )
511                READ ( 13 )  humidity
512             CASE ( 'inflow_damping_factor' )
513                IF ( .NOT. ALLOCATED( inflow_damping_factor ) )  THEN
514                   ALLOCATE( inflow_damping_factor(0:nz+1) )
515                ENDIF
516                READ ( 13 )  inflow_damping_factor
517             CASE ( 'inflow_damping_height' )
518                READ ( 13 )  inflow_damping_height
519             CASE ( 'inflow_damping_width' )
520                READ ( 13 )  inflow_damping_width
521             CASE ( 'inflow_disturbance_begin' )
522                READ ( 13 )  inflow_disturbance_begin
523             CASE ( 'inflow_disturbance_end' )
524                READ ( 13 )  inflow_disturbance_end
525             CASE ( 'km_constant' )
526                READ ( 13 )  km_constant
527             CASE ( 'large_scale_forcing' )
528                READ ( 13 )  large_scale_forcing
529             CASE ( 'large_scale_subsidence' )
530                READ ( 13 )  large_scale_subsidence
531             CASE ( 'latitude' )
532                READ ( 13 )  latitude
533             CASE ( 'longitude' )
534                READ ( 13 )  longitude
535             CASE ( 'loop_optimization' )
536                READ ( 13 )  loop_optimization
537             CASE ( 'masking_method' )
538                READ ( 13 )  masking_method
539             CASE ( 'mean_inflow_profiles' )
540                IF ( .NOT. ALLOCATED( mean_inflow_profiles ) )  THEN
[3288]541                   ALLOCATE( mean_inflow_profiles(0:nz+1,1:num_mean_inflow_profiles) )
[2894]542                ENDIF
543                READ ( 13 )  mean_inflow_profiles
544             CASE ( 'mg_cycles' )
545                READ ( 13 )  mg_cycles
546             CASE ( 'mg_switch_to_pe0_level' )
547                READ ( 13 )  mg_switch_to_pe0_level
548             CASE ( 'mixing_length_1d' )
549                READ ( 13 )  mixing_length_1d
550             CASE ( 'momentum_advec' )
551                READ ( 13 )  momentum_advec
552             CASE ( 'netcdf_precision' )
553                READ ( 13 )  netcdf_precision
554             CASE ( 'neutral' )
555                READ ( 13 )  neutral
556             CASE ( 'ngsrb' )
557                READ ( 13 )  ngsrb
558             CASE ( 'nsor' )
559                READ ( 13 )  nsor
560             CASE ( 'nsor_ini' )
561                READ ( 13 )  nsor_ini
562             CASE ( 'nudging' )
563                READ ( 13 )  nudging
564             CASE ( 'num_leg' )
565                READ ( 13 )  num_leg
566             CASE ( 'nx' )
567                READ ( 13 )  nx
568                nx_on_file = nx
569             CASE ( 'ny' )
570                READ ( 13 )  ny
571                ny_on_file = ny
[3294]572             CASE ( 'ocean_mode' )
573                READ ( 13 )  ocean_mode
[2894]574             CASE ( 'omega' )
575                READ ( 13 )  omega
576             CASE ( 'omega_sor' )
577                READ ( 13 )  omega_sor
578             CASE ( 'output_for_t0' )
579                READ (13)    output_for_t0
580             CASE ( 'passive_scalar' )
581                READ ( 13 )  passive_scalar
582             CASE ( 'prandtl_number' )
583                READ ( 13 )  prandtl_number
584             CASE ( 'psolver' )
585                READ ( 13 )  psolver
586             CASE ( 'pt_damping_factor' )
587                READ ( 13 )  pt_damping_factor
588             CASE ( 'pt_damping_width' )
589                READ ( 13 )  pt_damping_width
590             CASE ( 'pt_init' )
591                READ ( 13 )  pt_init
592             CASE ( 'pt_reference' )
593                READ ( 13 )  pt_reference
594             CASE ( 'pt_surface' )
595                READ ( 13 )  pt_surface
596             CASE ( 'pt_surface_initial_change' )
597                READ ( 13 )  pt_surface_initial_change
598             CASE ( 'pt_vertical_gradient' )
599                READ ( 13 )  pt_vertical_gradient
600             CASE ( 'pt_vertical_gradient_level' )
601                READ ( 13 )  pt_vertical_gradient_level
602             CASE ( 'pt_vertical_gradient_level_ind' )
603                READ ( 13 )  pt_vertical_gradient_level_ind
604             CASE ( 'q_init' )
605                READ ( 13 )  q_init
606             CASE ( 'q_surface' )
607                READ ( 13 )  q_surface
608             CASE ( 'q_surface_initial_change' )
609                READ ( 13 )  q_surface_initial_change
610             CASE ( 'q_vertical_gradient' )
611                READ ( 13 )  q_vertical_gradient
612             CASE ( 'q_vertical_gradient_level' )
613                READ ( 13 )  q_vertical_gradient_level
614             CASE ( 'q_vertical_gradient_level_ind' )
615                READ ( 13 )  q_vertical_gradient_level_ind
616             CASE ( 'random_generator' )
617                READ ( 13 )  random_generator
618             CASE ( 'random_heatflux' )
619                READ ( 13 )  random_heatflux
620             CASE ( 'rans_mode' )
621                READ ( 13 )  rans_mode
622             CASE ( 'rayleigh_damping_factor' )
623                READ ( 13 )  rayleigh_damping_factor
624             CASE ( 'rayleigh_damping_height' )
625                READ ( 13 )  rayleigh_damping_height
626             CASE ( 'recycling_width' )
627                READ ( 13 )  recycling_width
628             CASE ( 'ref_state' )
629                READ ( 13 )  ref_state
630             CASE ( 'reference_state' )
631                READ ( 13 )  reference_state
632             CASE ( 'residual_limit' )
633                READ ( 13 )  residual_limit
634             CASE ( 'roughness_length' )
635                READ ( 13 )  roughness_length
636             CASE ( 'run_coupled' )
637                READ ( 13 )  run_coupled
638             CASE ( 'runnr' )
639                READ ( 13 )  runnr
640             CASE ( 's_init' )
641                READ ( 13 )  s_init
642             CASE ( 's_surface' )
643                READ ( 13 )  s_surface
644             CASE ( 's_surface_initial_change' )
645                READ ( 13 )  s_surface_initial_change
646             CASE ( 's_vertical_gradient' )
647                READ ( 13 )  s_vertical_gradient
648             CASE ( 's_vertical_gradient_level' )
649                READ ( 13 )  s_vertical_gradient_level
650             CASE ( 's_vertical_gradient_level_ind' )
651                READ ( 13 )  s_vertical_gradient_level_ind
652             CASE ( 'scalar_advec' )
653                READ ( 13 )  scalar_advec
654             CASE ( 'simulated_time' )
655                READ ( 13 )  simulated_time
[2956]656             CASE ( 'spectrum_x' )
657                IF ( .NOT. ALLOCATED( spectrum_x ) )  THEN
658                   ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ) )
659                ENDIF
660                READ ( 13 )  spectrum_x
661             CASE ( 'spectrum_y' )
662                IF ( .NOT. ALLOCATED( spectrum_y ) )  THEN
663                   ALLOCATE( spectrum_y( 1:ny/2, 1:100, 1:10 ) )
664                ENDIF
665                READ ( 13 )  spectrum_y
[2921]666             CASE ( 'spinup_time' )
667                READ ( 13 )  spinup_time
[4495]668             CASE ( 'subs_vertical_gradient' )
669                READ ( 13 )  subs_vertical_gradient
670             CASE ( 'subs_vertical_gradient_level' )
671                READ ( 13 )  subs_vertical_gradient_level
672             CASE ( 'subs_vertical_gradient_level_i' )
673                READ ( 13 )  subs_vertical_gradient_level_i
[2894]674             CASE ( 'surface_heatflux' )
675                READ ( 13 )  surface_heatflux
676             CASE ( 'surface_pressure' )
677                READ ( 13 )  surface_pressure
678             CASE ( 'surface_scalarflux' )
679                READ ( 13 )  surface_scalarflux
680             CASE ( 'surface_waterflux' )
681                READ ( 13 )  surface_waterflux
682             CASE ( 'time_coupling' )
683                READ ( 13 )  time_coupling
684             CASE ( 'time_disturb' )
685                READ ( 13 )  time_disturb
686             CASE ( 'time_do2d_xy' )
687                READ ( 13 )  time_do2d_xy
688             CASE ( 'time_do2d_xz' )
689                READ ( 13 )  time_do2d_xz
690             CASE ( 'time_do2d_yz' )
691                READ ( 13 )  time_do2d_yz
692             CASE ( 'time_do3d' )
693                READ ( 13 )  time_do3d
694             CASE ( 'time_do_av' )
695                READ ( 13 )  time_do_av
696             CASE ( 'time_do_sla' )
697                READ ( 13 )  time_do_sla
698             CASE ( 'time_domask' )
699                READ ( 13 )  time_domask
700             CASE ( 'time_dopr' )
701                READ ( 13 )  time_dopr
702             CASE ( 'time_dopr_av' )
703                READ ( 13 )  time_dopr_av
704             CASE ( 'time_dopr_listing' )
705                READ ( 13 )  time_dopr_listing
706             CASE ( 'time_dopts' )
707                READ ( 13 )  time_dopts
708             CASE ( 'time_dosp' )
709                READ ( 13 )  time_dosp
710             CASE ( 'time_dots' )
711                READ ( 13 )  time_dots
712             CASE ( 'time_radiation' )
713                READ ( 13 )  time_radiation
714             CASE ( 'time_restart' )
715                READ ( 13 )  time_restart
716             CASE ( 'time_run_control' )
717                READ ( 13 )  time_run_control
718             CASE ( 'time_since_reference_point' )
719                READ ( 13 )  time_since_reference_point
[3988]720             CASE ( 'time_virtual_measurement' )
721                READ ( 13 )  time_virtual_measurement
[2894]722             CASE ( 'timestep_scheme' )
723                READ ( 13 )  timestep_scheme
724             CASE ( 'top_heatflux' )
725                READ ( 13 )  top_heatflux
726             CASE ( 'top_momentumflux_u' )
727                READ ( 13 )  top_momentumflux_u
728             CASE ( 'top_momentumflux_v' )
729                READ ( 13 )  top_momentumflux_v
730             CASE ( 'top_scalarflux' )
731                READ ( 13 )  top_scalarflux
732             CASE ( 'topography' )
733                READ ( 13 )  topography
734             CASE ( 'topography_grid_convention' )
735                READ ( 13 )  topography_grid_convention
736             CASE ( 'tsc' )
737                READ ( 13 )  tsc
738             CASE ( 'tunnel_height' )
739                READ ( 13 )  tunnel_height
740             CASE ( 'tunnel_length' )
741                READ ( 13 )  tunnel_length
742             CASE ( 'tunnel_wall_depth' )
743                READ ( 13 )  tunnel_wall_depth
744             CASE ( 'tunnel_width_x' )
745                READ ( 13 )  tunnel_width_x
746             CASE ( 'tunnel_width_y' )
747                READ ( 13 )  tunnel_width_y
748             CASE ( 'turbulence_closure' )
749                READ ( 13 )  turbulence_closure
750             CASE ( 'turbulent_inflow' )
751                READ ( 13 )  turbulent_inflow
752             CASE ( 'u_bulk' )
753                READ ( 13 )  u_bulk
754             CASE ( 'u_init' )
755                READ ( 13 )  u_init
756             CASE ( 'u_max' )
757                READ ( 13 )  u_max
758             CASE ( 'u_max_ijk' )
759                READ ( 13 )  u_max_ijk
760             CASE ( 'ug' )
761                READ ( 13 )  ug
762             CASE ( 'ug_surface' )
763                READ ( 13 )  ug_surface
764             CASE ( 'ug_vertical_gradient' )
765                READ ( 13 )  ug_vertical_gradient
766             CASE ( 'ug_vertical_gradient_level' )
767                READ ( 13 )  ug_vertical_gradient_level
768             CASE ( 'ug_vertical_gradient_level_ind' )
769                READ ( 13 )  ug_vertical_gradient_level_ind
770             CASE ( 'use_surface_fluxes' )
771                READ ( 13 )  use_surface_fluxes
772             CASE ( 'use_top_fluxes' )
773                READ ( 13 )  use_top_fluxes
774             CASE ( 'use_ug_for_galilei_tr' )
775                READ ( 13 )  use_ug_for_galilei_tr
776             CASE ( 'use_upstream_for_tke' )
777                READ ( 13 )  use_upstream_for_tke
778             CASE ( 'v_bulk' )
779                READ ( 13 )  v_bulk
780             CASE ( 'v_init' )
781                READ ( 13 )  v_init
782             CASE ( 'v_max' )
783                READ ( 13 )  v_max
784             CASE ( 'v_max_ijk' )
785                READ ( 13 )  v_max_ijk
786             CASE ( 'vg' )
787                READ ( 13 )  vg
788             CASE ( 'vg_surface' )
789                READ ( 13 )  vg_surface
790             CASE ( 'vg_vertical_gradient' )
791                READ ( 13 )  vg_vertical_gradient
792             CASE ( 'vg_vertical_gradient_level' )
793                READ ( 13 )  vg_vertical_gradient_level
794             CASE ( 'vg_vertical_gradient_level_ind' )
795                READ ( 13 )  vg_vertical_gradient_level_ind
796             CASE ( 'virtual_flight' )
797                READ ( 13 )  virtual_flight
798             CASE ( 'volume_flow_area' )
799                READ ( 13 )  volume_flow_area
800             CASE ( 'volume_flow_initial' )
801                READ ( 13 )  volume_flow_initial
802             CASE ( 'w_max' )
803                READ ( 13 )  w_max
804             CASE ( 'w_max_ijk' )
805                READ ( 13 )  w_max_ijk
806             CASE ( 'wall_adjustment' )
807                READ ( 13 )  wall_adjustment
808             CASE ( 'wall_heatflux' )
809                READ ( 13 )  wall_heatflux
810             CASE ( 'wall_humidityflux' )
811                READ ( 13 )  wall_humidityflux
812             CASE ( 'wall_scalarflux' )
813                READ ( 13 )  wall_scalarflux
814             CASE ( 'y_shift' )
815                READ ( 13 )  y_shift
816             CASE ( 'z0h_factor' )
817                READ ( 13 )  z0h_factor
818             CASE ( 'zeta_max' )
819                READ ( 13 )  zeta_max
820             CASE ( 'zeta_min' )
821                READ ( 13 )  zeta_min
[3003]822             CASE ( 'z_i' )
823                READ ( 13 )  z_i
[2894]824
825             CASE DEFAULT
[3294]826!
827!--             Read global variables from of other modules
[3766]828                CALL module_interface_rrd_global( found )
[2894]829
830                IF ( .NOT. found )  THEN
831                   WRITE( message_string, * ) 'unknown variable named "',      &
832                                           restart_string(1:length),           &
[4431]833                                          '" found in global data from ',      &
[2894]834                                          'prior run on PE ', myid
835                CALL message( 'rrd_global', 'PA0302', 1, 2, 0, 6, 0 )
[4431]836
[2894]837                ENDIF
838
839          END SELECT
840!
841!--       Read next string
842          READ ( 13 )  length
[4431]843          READ ( 13 )  restart_string(1:length)
[2894]844
[4495]845       ENDDO  ! End of loop for reading the restart string
846
847       CALL close_file( 13 )
848
[4534]849    ELSEIF ( restart_data_format_input(1:3) == 'mpi' )  THEN
[4495]850!
851!--    Read global restart data using MPI-IO
852!--    ATTENTION: Arrays need to be read with routine rrd_mpi_io_global_array!
853!--    Caution: When any of the following read instructions have been changed, the
854!--    -------  version number stored in the variable binary_version_global has
855!--             to be increased. The same changes must also be done in
856!--             wrd_write_global.
857!
858!--    Open the MPI-IO restart file.
[4534]859       CALL rd_mpi_io_open( 'read', 'BININ' // TRIM( coupling_char ),                              &
860                            open_for_global_io_only = .TRUE. )
[4495]861
862!
863!--    Make version number check first
864       CALL rrd_mpi_io( 'binary_version_global',  version_on_file )
865
866       binary_version_global = '5.0'
867       IF ( TRIM( version_on_file ) /= TRIM( binary_version_global ) )  THEN
868          WRITE( message_string, * ) 'version mismatch concerning binary_version_global:',         &
869                                     '&version on file    = "', TRIM( version_on_file ), '"',      &
870                                     '&version in program = "', TRIM( binary_version_global ), '"'
871          CALL message( 'rrd_global', 'PA0296', 1, 2, 0, 6, 0 )
872       ENDIF
873
874       CALL rrd_mpi_io( 'numprocs',  numprocs_previous_run )
875       CALL rrd_mpi_io( 'nz' , nz )
876       CALL rrd_mpi_io( 'max_pr_user',  max_pr_user )
877       CALL rrd_mpi_io( 'statistic_regions', statistic_regions )
878
879!
880!--    The following global arrays (better to say, they have the same size and values on each
881!--    subdomain) are by default allocated in routine parin, but not in case of restarts!
882       IF ( .NOT. ALLOCATED( ug ) )  THEN
883           ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1),                                       &
884                     v_init(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),                              &
885                     ref_state(0:nz+1), s_init(0:nz+1), sa_init(0:nz+1),                           &
[4590]886                     hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions), &
887                     hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
[4495]888       ENDIF
889
890       CALL rrd_mpi_io( 'advected_distance_x',  advected_distance_x )
891       CALL rrd_mpi_io( 'advected_distance_y', advected_distance_y )
892       CALL rrd_mpi_io( 'alpha_surface', alpha_surface )
893       CALL rrd_mpi_io( 'average_count_pr', average_count_pr )
894       CALL rrd_mpi_io( 'average_count_sp', average_count_sp )
895       CALL rrd_mpi_io( 'average_count_3d', average_count_3d )
896       CALL rrd_mpi_io( 'bc_e_b', bc_e_b )
897       CALL rrd_mpi_io( 'bc_lr', bc_lr )
898       CALL rrd_mpi_io( 'bc_ns', bc_ns )
899       CALL rrd_mpi_io( 'bc_p_b', bc_p_b )
900       CALL rrd_mpi_io( 'bc_p_t', bc_p_t )
901       CALL rrd_mpi_io( 'bc_pt_b', bc_pt_b )
902       CALL rrd_mpi_io( 'bc_pt_t', bc_pt_t )
903       CALL rrd_mpi_io( 'bc_pt_t_val', bc_pt_t_val )
904       CALL rrd_mpi_io( 'bc_q_b', bc_q_b )
905       CALL rrd_mpi_io( 'bc_q_t', bc_q_t )
906       CALL rrd_mpi_io( 'bc_q_t_val', bc_q_t_val )
907       CALL rrd_mpi_io( 'bc_s_b', bc_s_b )
908       CALL rrd_mpi_io( 'bc_s_t', bc_s_t )
909       CALL rrd_mpi_io( 'bc_uv_b', bc_uv_b )
910       CALL rrd_mpi_io( 'bc_uv_t', bc_uv_t )
911       CALL rrd_mpi_io( 'biometeorology', biometeorology )
912       CALL rrd_mpi_io( 'building_height', building_height )
913       CALL rrd_mpi_io( 'building_length_x', building_length_x )
914       CALL rrd_mpi_io( 'building_length_y', building_length_y )
915       CALL rrd_mpi_io( 'building_wall_left', building_wall_left )
916       CALL rrd_mpi_io( 'building_wall_south', building_wall_south )
917       CALL rrd_mpi_io( 'bulk_cloud_model', bulk_cloud_model )
918       CALL rrd_mpi_io( 'call_psolver_at_all_substeps', call_psolver_at_all_substeps )
919       CALL rrd_mpi_io( 'canyon_height', canyon_height )
920       CALL rrd_mpi_io( 'canyon_wall_left', canyon_wall_left )
921       CALL rrd_mpi_io( 'canyon_wall_south', canyon_wall_south )
922       CALL rrd_mpi_io( 'canyon_width_x',  canyon_width_x )
923       CALL rrd_mpi_io( 'canyon_width_y', canyon_width_y )
924       CALL rrd_mpi_io( 'cfl_factor', cfl_factor )
925       CALL rrd_mpi_io( 'cloud_droplets',  cloud_droplets )
926       CALL rrd_mpi_io( 'collective_wait', collective_wait )
927       CALL rrd_mpi_io( 'conserve_volume_flow', conserve_volume_flow )
928       CALL rrd_mpi_io( 'conserve_volume_flow_mode', conserve_volume_flow_mode )
929       CALL rrd_mpi_io( 'constant_flux_layer', constant_flux_layer )
930       CALL rrd_mpi_io( 'coupling_start_time', coupling_start_time )
931       CALL rrd_mpi_io( 'current_timestep_number', current_timestep_number )
932       CALL rrd_mpi_io( 'cycle_mg', cycle_mg )
933       CALL rrd_mpi_io( 'damp_level_1d', damp_level_1d )
934       CALL rrd_mpi_io( 'dissipation_1d', dissipation_1d )
935       CALL rrd_mpi_io_global_array( 'do2d_xy_time_count', do2d_xy_time_count )
936       CALL rrd_mpi_io_global_array( 'do2d_xz_time_count', do2d_xz_time_count )
937       CALL rrd_mpi_io_global_array( 'do2d_yz_time_count', do2d_yz_time_count )
938       CALL rrd_mpi_io_global_array( 'do3d_time_count', do3d_time_count )
939       CALL rrd_mpi_io( 'dp_external', dp_external )
940       CALL rrd_mpi_io( 'dp_level_b', dp_level_b )
941       CALL rrd_mpi_io( 'dp_smooth', dp_smooth )
942       CALL rrd_mpi_io_global_array( 'dpdxy', dpdxy )
943       CALL rrd_mpi_io( 'dt_3d', dt_3d )
944       CALL rrd_mpi_io( 'dt_pr_1d', dt_pr_1d )
945       CALL rrd_mpi_io( 'dt_run_control_1d', dt_run_control_1d )
946       CALL rrd_mpi_io( 'dx', dx )
947       CALL rrd_mpi_io( 'dy', dy )
948       CALL rrd_mpi_io_global_array( 'dz', dz )
949       CALL rrd_mpi_io( 'dz_max', dz_max )
950       CALL rrd_mpi_io( 'dz_stretch_factor', dz_stretch_factor )
951       CALL rrd_mpi_io_global_array( 'dz_stretch_factor_array', dz_stretch_factor_array )
952       CALL rrd_mpi_io( 'dz_stretch_level', dz_stretch_level )
953       CALL rrd_mpi_io_global_array( 'dz_stretch_level_end', dz_stretch_level_end )
954       CALL rrd_mpi_io_global_array( 'dz_stretch_level_start', dz_stretch_level_start )
955       CALL rrd_mpi_io( 'e_min', e_min )
956       CALL rrd_mpi_io( 'end_time_1d', end_time_1d )
957       CALL rrd_mpi_io( 'fft_method', fft_method )
958       CALL rrd_mpi_io( 'first_call_lpm', first_call_lpm )
959       CALL rrd_mpi_io( 'galilei_transformation', galilei_transformation )
960       CALL rrd_mpi_io( 'gust_module_enabled', gust_module_enabled )
961       CALL rrd_mpi_io_global_array( 'hom', hom )
962       CALL rrd_mpi_io_global_array( 'hom_sum', hom_sum )
963       CALL rrd_mpi_io( 'humidity', humidity )
964       CALL rd_mpi_io_check_array( 'inflow_damping_factor', found = array_found )
965       IF ( array_found )  THEN
966           IF ( .NOT. ALLOCATED( inflow_damping_factor ) )  THEN
967               ALLOCATE( inflow_damping_factor(0:nz+1) )
968           ENDIF
969           CALL rrd_mpi_io_global_array( 'inflow_damping_factor', inflow_damping_factor )
970       ENDIF
971       CALL rrd_mpi_io( 'inflow_damping_height', inflow_damping_height )
972       CALL rrd_mpi_io( 'inflow_damping_width', inflow_damping_width )
973       CALL rrd_mpi_io( 'inflow_disturbance_begin', inflow_disturbance_begin )
974       CALL rrd_mpi_io( 'inflow_disturbance_end', inflow_disturbance_end )
975       CALL rrd_mpi_io( 'km_constant', km_constant )
976       CALL rrd_mpi_io( 'large_scale_forcing', large_scale_forcing )
977       CALL rrd_mpi_io( 'large_scale_subsidence', large_scale_subsidence )
978       CALL rrd_mpi_io( 'latitude', latitude )
979       CALL rrd_mpi_io( 'longitude', longitude )
980       CALL rrd_mpi_io( 'loop_optimization', loop_optimization )
981       CALL rrd_mpi_io( 'masking_method', masking_method )
982       CALL rd_mpi_io_check_array( 'mean_inflow_profiles', found = array_found )
983       IF ( array_found)  THEN
984          IF ( .NOT. ALLOCATED( mean_inflow_profiles ) )  THEN
985             ALLOCATE( mean_inflow_profiles(0:nz+1,7) )
986          ENDIF
987          CALL rrd_mpi_io_global_array( 'mean_inflow_profiles', mean_inflow_profiles )
988       ENDIF
989       CALL rrd_mpi_io( 'mg_cycles', mg_cycles )
990       CALL rrd_mpi_io( 'mg_switch_to_pe0_level', mg_switch_to_pe0_level )
991       CALL rrd_mpi_io( 'mixing_length_1d', mixing_length_1d )
992       CALL rrd_mpi_io( 'momentum_advec', momentum_advec )
993!
994!--    There is no module procedure for CHARACTER arrays
995       DO  i = 1, SIZE( netcdf_precision , 1 )
996          WRITE( tmp_name, '(A,I2.2)' )  'netcdf_precision_', i
997          CALL rrd_mpi_io( TRIM( tmp_name ), netcdf_precision(i) )
[2894]998       ENDDO
[4495]999       CALL rrd_mpi_io( 'neutral', neutral )
1000       CALL rrd_mpi_io( 'ngsrb', ngsrb )
1001       CALL rrd_mpi_io( 'nsor', nsor )
1002       CALL rrd_mpi_io( 'nsor_ini', nsor_ini )
1003       CALL rrd_mpi_io( 'nudging', nudging )
1004       CALL rrd_mpi_io( 'num_leg', num_leg )
1005       CALL rrd_mpi_io( 'nx', nx )
1006       nx_on_file = nx
1007       CALL rrd_mpi_io( 'ny', ny )
1008       ny_on_file = ny
1009       CALL rrd_mpi_io( 'ocean_mode', ocean_mode )
1010       CALL rrd_mpi_io( 'omega', omega )
1011       CALL rrd_mpi_io( 'omega_sor', omega_sor )
[4536]1012       CALL rrd_mpi_io( 'origin_date_time', origin_date_time )
[4495]1013       CALL rrd_mpi_io( 'output_for_t0', output_for_t0 )
1014       CALL rrd_mpi_io( 'particle_advection', particle_advection )
1015       CALL rrd_mpi_io( 'passive_scalar', passive_scalar )
1016       CALL rrd_mpi_io( 'prandtl_number', prandtl_number )
1017       CALL rrd_mpi_io( 'psolver', psolver )
1018       CALL rrd_mpi_io( 'pt_damping_factor', pt_damping_factor )
1019       CALL rrd_mpi_io( 'pt_damping_width', pt_damping_width )
1020       CALL rrd_mpi_io_global_array( 'pt_init', pt_init )
1021       CALL rrd_mpi_io( 'pt_reference', pt_reference )
1022       CALL rrd_mpi_io( 'pt_surface', pt_surface )
1023       CALL rrd_mpi_io( 'pt_surface_initial_change', pt_surface_initial_change )
1024       CALL rrd_mpi_io_global_array( 'pt_vertical_gradient', pt_vertical_gradient )
1025       CALL rrd_mpi_io_global_array( 'pt_vertical_gradient_level', pt_vertical_gradient_level )
1026       CALL rrd_mpi_io_global_array( 'pt_vertical_gradient_level_ind', pt_vertical_gradient_level_ind )
1027       CALL rrd_mpi_io_global_array( 'q_init', q_init )
1028       CALL rrd_mpi_io( 'q_surface', q_surface )
1029       CALL rrd_mpi_io( 'q_surface_initial_change', q_surface_initial_change )
1030       CALL rrd_mpi_io_global_array( 'q_vertical_gradient', q_vertical_gradient )
1031       CALL rrd_mpi_io_global_array( 'q_vertical_gradient_level', q_vertical_gradient_level )
1032       CALL rrd_mpi_io_global_array( 'q_vertical_gradient_level_ind', q_vertical_gradient_level_ind )
1033       CALL rrd_mpi_io( 'random_generator', random_generator )
1034       CALL rrd_mpi_io( 'random_heatflux', random_heatflux )
1035       CALL rrd_mpi_io( 'rans_mode', rans_mode )
1036       CALL rrd_mpi_io( 'rayleigh_damping_factor', rayleigh_damping_factor )
1037       CALL rrd_mpi_io( 'rayleigh_damping_height', rayleigh_damping_height )
1038       CALL rrd_mpi_io( 'recycling_width', recycling_width )
1039       CALL rrd_mpi_io_global_array( 'ref_state', ref_state )
1040       CALL rrd_mpi_io( 'reference_state', reference_state )
1041       CALL rrd_mpi_io( 'residual_limit', residual_limit )
1042       CALL rrd_mpi_io( 'roughness_length', roughness_length )
1043       CALL rrd_mpi_io( 'run_coupled', run_coupled )
1044       CALL rrd_mpi_io( 'runnr', runnr )
1045       CALL rrd_mpi_io_global_array( 's_init', s_init )
1046       CALL rrd_mpi_io( 's_surface', s_surface )
1047       CALL rrd_mpi_io( 's_surface_initial_change', s_surface_initial_change )
1048       CALL rrd_mpi_io_global_array( 's_vertical_gradient', s_vertical_gradient )
1049       CALL rrd_mpi_io_global_array( 's_vertical_gradient_level', s_vertical_gradient_level )
1050       CALL rrd_mpi_io_global_array( 's_vertical_gradient_level_ind', s_vertical_gradient_level_ind )
1051       CALL rrd_mpi_io( 'scalar_advec', scalar_advec )
1052       CALL rrd_mpi_io( 'simulated_time', simulated_time )
1053       CALL rd_mpi_io_check_array( 'spectrum_x', found = array_found )
1054       IF (array_found )  THEN
1055           IF ( .NOT. ALLOCATED( spectrum_x ) )  THEN
1056              ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ) )
1057           ENDIF
1058           CALL rrd_mpi_io( 'spectrum_y', spectrum_y )
1059       ENDIF
1060       CALL rd_mpi_io_check_array( 'spectrum_y', found = array_found )
1061       IF ( array_found )  THEN
1062           IF ( .NOT. ALLOCATED( spectrum_y ) )  THEN
1063              ALLOCATE( spectrum_y( 1:ny/2, 1:100, 1:10 ) )
1064           ENDIF
1065           CALL rrd_mpi_io( 'spectrum_y', spectrum_y )
1066       ENDIF
1067       CALL rrd_mpi_io( 'spinup_time ', spinup_time )
1068       CALL rrd_mpi_io_global_array( 'subs_vertical_gradient', subs_vertical_gradient )
1069       CALL rrd_mpi_io_global_array( 'subs_vertical_gradient_level', subs_vertical_gradient_level )
1070       CALL rrd_mpi_io_global_array( 'subs_vertical_gradient_level_i', subs_vertical_gradient_level_i )
1071       CALL rrd_mpi_io( 'surface_heatflux', surface_heatflux )
1072       CALL rrd_mpi_io( 'surface_pressure', surface_pressure )
1073       CALL rrd_mpi_io( 'surface_output', surface_output )
1074       CALL rrd_mpi_io( 'surface_scalarflux', surface_scalarflux )
1075       CALL rrd_mpi_io( 'surface_waterflux', surface_waterflux )
1076       CALL rrd_mpi_io( 'syn_turb_gen', syn_turb_gen )
1077       CALL rrd_mpi_io( 'time_coupling', time_coupling )
1078       CALL rrd_mpi_io( 'time_disturb', time_disturb )
1079       CALL rrd_mpi_io( 'time_do2d_xy', time_do2d_xy )
1080       CALL rrd_mpi_io( 'time_do2d_xz', time_do2d_xz )
1081       CALL rrd_mpi_io( 'time_do2d_yz', time_do2d_yz )
1082       CALL rrd_mpi_io( 'time_do3d', time_do3d )
1083       CALL rrd_mpi_io( 'time_do_av', time_do_av )
1084       CALL rrd_mpi_io( 'time_do_sla', time_do_sla )
1085       CALL rrd_mpi_io_global_array( 'time_domask', time_domask )
1086       CALL rrd_mpi_io( 'time_dopr', time_dopr )
1087       CALL rrd_mpi_io( 'time_dopr_av', time_dopr_av )
1088       CALL rrd_mpi_io( 'time_dopr_listing', time_dopr_listing )
1089       CALL rrd_mpi_io( 'time_dopts', time_dopts )
1090       CALL rrd_mpi_io( 'time_dosp', time_dosp )
1091       CALL rrd_mpi_io( 'time_dots', time_dots )
1092       CALL rrd_mpi_io( 'time_radiation', time_radiation )
1093       CALL rrd_mpi_io( 'time_restart', time_restart )
1094       CALL rrd_mpi_io( 'time_run_control', time_run_control )
1095       CALL rrd_mpi_io( 'time_since_reference_point', time_since_reference_point )
1096       CALL rrd_mpi_io( 'time_virtual_measurement', time_virtual_measurement )
1097       CALL rrd_mpi_io( 'timestep_scheme', timestep_scheme )
1098       CALL rrd_mpi_io( 'top_heatflux', top_heatflux )
1099       CALL rrd_mpi_io( 'top_momentumflux_u', top_momentumflux_u )
1100       CALL rrd_mpi_io( 'top_momentumflux_v', top_momentumflux_v )
1101       CALL rrd_mpi_io( 'top_scalarflux', top_scalarflux )
1102       CALL rrd_mpi_io( 'topography', topography )
1103       CALL rrd_mpi_io( 'topography_grid_convention', topography_grid_convention )
1104       CALL rrd_mpi_io_global_array( 'tsc', tsc )
1105       CALL rrd_mpi_io( 'tunnel_height', tunnel_height )
1106       CALL rrd_mpi_io( 'tunnel_length', tunnel_length )
1107       CALL rrd_mpi_io( 'tunnel_wall_depth', tunnel_wall_depth )
1108       CALL rrd_mpi_io( 'tunnel_width_x', tunnel_width_x )
1109       CALL rrd_mpi_io( 'tunnel_width_y', tunnel_width_y )
1110       CALL rrd_mpi_io( 'turbulence_closure', turbulence_closure )
1111       CALL rrd_mpi_io( 'turbulent_inflow', turbulent_inflow )
1112       CALL rrd_mpi_io( 'u_bulk', u_bulk )
1113       CALL rrd_mpi_io_global_array( 'u_init', u_init )
1114       CALL rrd_mpi_io( 'u_max', u_max )
1115       CALL rrd_mpi_io_global_array( 'u_max_ijk', u_max_ijk )
1116       CALL rrd_mpi_io_global_array( 'ug', ug )
1117       CALL rrd_mpi_io( 'ug_surface', ug_surface )
1118       CALL rrd_mpi_io_global_array( 'ug_vertical_gradient', ug_vertical_gradient )
1119       CALL rrd_mpi_io_global_array( 'ug_vertical_gradient_level', ug_vertical_gradient_level )
1120       CALL rrd_mpi_io_global_array( 'ug_vertical_gradient_level_ind', ug_vertical_gradient_level_ind )
1121       CALL rrd_mpi_io( 'use_surface_fluxes', use_surface_fluxes )
1122       CALL rrd_mpi_io( 'use_top_fluxes', use_top_fluxes )
1123       CALL rrd_mpi_io( 'use_ug_for_galilei_tr', use_ug_for_galilei_tr )
1124       CALL rrd_mpi_io( 'use_upstream_for_tke', use_upstream_for_tke )
1125       CALL rrd_mpi_io( 'user_module_enabled', user_module_enabled )
1126       CALL rrd_mpi_io( 'v_bulk', v_bulk )
1127       CALL rrd_mpi_io_global_array( 'v_init', v_init )
1128       CALL rrd_mpi_io( 'v_max', v_max )
1129       CALL rrd_mpi_io_global_array( 'v_max_ijk', v_max_ijk )
1130       CALL rrd_mpi_io_global_array( 'vg', vg )
1131       CALL rrd_mpi_io( 'vg_surface', vg_surface )
1132       CALL rrd_mpi_io_global_array( 'vg_vertical_gradient', vg_vertical_gradient )
1133       CALL rrd_mpi_io_global_array( 'vg_vertical_gradient_level', vg_vertical_gradient_level )
1134       CALL rrd_mpi_io_global_array( 'vg_vertical_gradient_level_ind', vg_vertical_gradient_level_ind )
1135       CALL rrd_mpi_io( 'virtual_flight', virtual_flight )
1136       CALL rrd_mpi_io_global_array( 'volume_flow_area', volume_flow_area )
1137       CALL rrd_mpi_io_global_array( 'volume_flow_initial', volume_flow_initial )
1138       CALL rrd_mpi_io( 'w_max', w_max )
1139       CALL rrd_mpi_io_global_array( 'w_max_ijk', w_max_ijk )
1140       CALL rrd_mpi_io( 'wall_adjustment', wall_adjustment )
1141       CALL rrd_mpi_io_global_array( 'wall_heatflux', wall_heatflux )
1142       CALL rrd_mpi_io_global_array( 'wall_humidityflux', wall_humidityflux )
1143       CALL rrd_mpi_io_global_array( 'wall_scalarflux', wall_scalarflux )
1144       CALL rrd_mpi_io( 'y_shift', y_shift )
1145       CALL rrd_mpi_io( 'z0h_factor', z0h_factor )
1146       CALL rrd_mpi_io( 'zeta_max', zeta_max )
1147       CALL rrd_mpi_io( 'zeta_min', zeta_min )
1148       CALL rrd_mpi_io_global_array( 'z_i', z_i )
[2894]1149
[4495]1150!
1151!--    Read global variables from of other modules
1152       CALL module_interface_rrd_global
[4431]1153
[4495]1154!
[4517]1155!--    Close restart file
[4495]1156       CALL rd_mpi_io_close
[2894]1157
[4495]1158    ENDIF
[2894]1159
[4495]1160    CALL location_message( 'read global restart data', 'finished' )
[2894]1161
[4495]1162 END SUBROUTINE rrd_global
[2894]1163
[4495]1164
1165
[2894]1166!------------------------------------------------------------------------------!
1167! Description:
1168! ------------
1169!> Skipping the global control variables from restart-file (binary format)
1170!> except some information needed when reading restart data from a previous
1171!> run which used a smaller total domain or/and a different domain decomposition
1172!> (initializing_actions  == 'cyclic_fill').
1173!------------------------------------------------------------------------------!
[4580]1174 SUBROUTINE rrd_read_parts_of_global
[2894]1175
1176
[4580]1177    CHARACTER (LEN=10) ::  version_on_file
1178    CHARACTER (LEN=20) ::  momentum_advec_check
1179    CHARACTER (LEN=20) ::  scalar_advec_check
1180    CHARACTER (LEN=1)  ::  cdum
[2894]1181
[4580]1182    INTEGER(iwp) ::  max_pr_user_on_file
1183    INTEGER(iwp) ::  nz_on_file
1184    INTEGER(iwp) ::  statistic_regions_on_file
1185    INTEGER(iwp) ::  tmp_mpru
1186    INTEGER(iwp) ::  tmp_sr
[2894]1187
[4580]1188    REAL(wp), DIMENSION(:,:,:),   ALLOCATABLE ::  hom_sum_on_file
1189    REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  hom_on_file
[2894]1190
1191
[4580]1192    IF ( TRIM( restart_data_format_input ) == 'fortran_binary' )  THEN
1193!
1194!--    Input in Fortran binary format
[2894]1195       CALL check_open( 13 )
1196
1197       READ ( 13 )  length
1198       READ ( 13 )  restart_string(1:length)
1199       READ ( 13 )  version_on_file
1200
1201!
[4580]1202!--    Read number of PEs and horizontal index bounds of all PEs used in previous run
[2894]1203       READ ( 13 )  length
1204       READ ( 13 )  restart_string(1:length)
1205
1206       IF ( restart_string(1:length) /= 'numprocs' )  THEN
1207          WRITE( message_string, * ) 'numprocs not found in data from prior ', &
1208                                     'run on PE ', myid
1209          CALL message( 'rrd_read_parts_of_global', 'PA0297', 1, 2, 0, 6, 0 )
1210       ENDIF
1211       READ ( 13 )  numprocs_previous_run
1212
1213       IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
1214          ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
1215       ENDIF
1216
1217       READ ( 13 )  length
1218       READ ( 13 )  restart_string(1:length)
1219
1220       IF ( restart_string(1:length) /= 'hor_index_bounds' )  THEN
1221          WRITE( message_string, * ) 'hor_index_bounds not found in data ',    &
1222                                     'from prior run on PE ', myid
1223          CALL message( 'rrd_read_parts_of_global', 'PA0298', 1, 2, 0, 6, 0 )
1224       ENDIF
1225       READ ( 13 )  hor_index_bounds_previous_run
1226
1227!
[4580]1228!--    Read vertical number of gridpoints and number of different areas used for computing
1229!--    statistics. Allocate arrays depending on these values, which are needed for the following
1230!--    read instructions.
[2894]1231       READ ( 13 )  length
1232       READ ( 13 )  restart_string(1:length)
1233
1234       IF ( restart_string(1:length) /= 'nz' )  THEN
1235          message_string = 'nz not found in restart data file'
1236          CALL message( 'rrd_read_parts_of_global', 'PA0303', 1, 2, 0, 6, 0 )
1237       ENDIF
1238       READ ( 13 )  nz_on_file
1239       IF ( nz_on_file /= nz )  THEN
1240          WRITE( message_string, * ) 'mismatch concerning number of ',         &
[3045]1241                                     'gridpoints along z:',                    &
[3046]1242                                     '&nz on file    = "', nz_on_file, '"',    &
1243                                     '&nz from run   = "', nz, '"'
[2894]1244          CALL message( 'rrd_read_parts_of_global', 'PA0304', 1, 2, 0, 6, 0 )
1245       ENDIF
1246
1247       READ ( 13 )  length
1248       READ ( 13 )  restart_string(1:length)
1249
1250       IF ( restart_string(1:length) /= 'max_pr_user' )  THEN
1251          message_string = 'max_pr_user not found in restart data file'
1252          CALL message( 'rrd_read_parts_of_global', 'PA0305', 1, 2, 0, 6, 0 )
1253       ENDIF
1254       READ ( 13 )  max_pr_user_on_file
1255       IF ( max_pr_user_on_file /= max_pr_user )  THEN
1256          WRITE( message_string, * ) 'number of user profiles on res',         &
1257                                     'tart data file differs from the ',       &
[3046]1258                                     'current run:&max_pr_user on file    = "',&
[2894]1259                                     max_pr_user_on_file, '"',                 &
[3046]1260                                     '&max_pr_user from run   = "',            &
[2894]1261                                     max_pr_user, '"'
1262          CALL message( 'rrd_read_parts_of_global', 'PA0306', 0, 0, 0, 6, 0 )
1263          tmp_mpru = MIN( max_pr_user_on_file, max_pr_user )
1264       ELSE
1265          tmp_mpru = max_pr_user
1266       ENDIF
1267
1268       READ ( 13 )  length
1269       READ ( 13 )  restart_string(1:length)
1270
1271       IF ( restart_string(1:length) /= 'statistic_regions' )  THEN
1272          message_string = 'statistic_regions not found in restart data file'
1273          CALL message( 'rrd_read_parts_of_global', 'PA0307', 1, 2, 0, 6, 0 )
1274       ENDIF
1275       READ ( 13 )  statistic_regions_on_file
1276       IF ( statistic_regions_on_file /= statistic_regions )  THEN
1277          WRITE( message_string, * ) 'statistic regions on restart data file ',&
[3045]1278                                     'differ from the current run:',           &
[3046]1279                                     '&statistic regions on file    = "',      &
[2894]1280                                     statistic_regions_on_file, '"',           &
[3046]1281                                     '&statistic regions from run   = "',      &
[2894]1282                                      statistic_regions, '"',                  &
[3046]1283                                     '&statistic data may be lost!'
[2894]1284          CALL message( 'rrd_read_parts_of_global', 'PA0308', 0, 1, 0, 6, 0 )
1285          tmp_sr = MIN( statistic_regions_on_file, statistic_regions )
1286       ELSE
1287          tmp_sr = statistic_regions
1288       ENDIF
1289
1290!
[4580]1291!--    Now read and check some control parameters and skip the rest
[2894]1292       READ ( 13 )  length
1293       READ ( 13 )  restart_string(1:length)
1294
1295       DO  WHILE ( restart_string(1:length) /= 'binary_version_local' )
1296
1297          SELECT CASE ( restart_string(1:length) )
1298
1299             CASE ( 'average_count_pr' )
1300                READ ( 13 )  average_count_pr
1301                IF ( average_count_pr /= 0 )  THEN
1302                   WRITE( message_string, * ) 'inflow profiles not ',          &
[3046]1303                                  'temporally averaged. &Averaging will be ',  &
[3637]1304                                  'done now using', average_count_pr,          &
[2894]1305                                  ' samples.'
1306                   CALL message( 'rrd_read_parts_of_global', 'PA0309',         &
1307                                 0, 1, 0, 6, 0 )
1308                ENDIF
1309
1310             CASE ( 'hom' )
1311                ALLOCATE( hom_on_file(0:nz+1,2,pr_palm+max_pr_user_on_file,    &
1312                          0:statistic_regions_on_file) )
1313                READ ( 13 )  hom_on_file
1314                hom(:,:,1:pr_palm+tmp_mpru,0:tmp_sr) =                         &
1315                             hom_on_file(:,:,1:pr_palm+tmp_mpru,0:tmp_sr)
1316                DEALLOCATE( hom_on_file )
1317
1318             CASE ( 'hom_sum' )
1319                ALLOCATE( hom_sum_on_file(0:nz+1,pr_palm+max_pr_user_on_file,  &
1320                          0:statistic_regions_on_file) )
1321                READ ( 13 )  hom_sum_on_file
1322                hom_sum(:,1:pr_palm+tmp_mpru,0:tmp_sr) =                       &
1323                             hom_sum_on_file(:,1:pr_palm+tmp_mpru,0:tmp_sr)
1324                DEALLOCATE( hom_sum_on_file )
1325
1326             CASE ( 'momentum_advec' )
1327                momentum_advec_check = momentum_advec
1328                READ ( 13 )  momentum_advec
1329                IF ( TRIM( momentum_advec_check ) /= TRIM( momentum_advec ) )  &
1330                THEN
1331                   WRITE( message_string, * ) 'momentum_advec of the restart ',&
1332                                  'run differs from momentum_advec of the ',   &
1333                                  'initial run.'
1334                   CALL message( 'rrd_read_parts_of_global', 'PA0100',         &
1335                                 1, 2, 0, 6, 0 )
1336                ENDIF
1337
1338             CASE ( 'nx' )
1339                READ ( 13 )  nx_on_file
1340
1341             CASE ( 'ny' )
1342                READ ( 13 )  ny_on_file
1343
1344             CASE ( 'ref_state' )
1345                READ ( 13 )  ref_state
1346
1347             CASE ( 'scalar_advec' )
1348                scalar_advec_check = scalar_advec
1349                READ ( 13 )  scalar_advec
1350                IF ( TRIM( scalar_advec_check ) /= TRIM( scalar_advec ) )      &
1351                THEN
1352                   WRITE( message_string, * ) 'scalar_advec of the restart ',  &
1353                                  'run differs from scalar_advec of the ',     &
1354                                  'initial run.'
1355                   CALL message( 'rrd_read_parts_of_global', 'PA0101',         &
1356                                 1, 2, 0, 6, 0 )
1357                ENDIF
1358
1359             CASE DEFAULT
1360
1361                READ ( 13 )  cdum
1362
1363          END SELECT
1364
1365          READ ( 13 )  length
1366          READ ( 13 )  restart_string(1:length)
1367
1368       ENDDO
1369
[4580]1370       CALL close_file( 13 )
1371
1372    ELSEIF ( restart_data_format_input(1:3) == 'mpi' )  THEN
[2894]1373!
[4580]1374!--    Open the MPI-IO restart file.
1375       CALL rd_mpi_io_open( 'read', 'BININ' // TRIM( coupling_char ),                              &
1376                            open_for_global_io_only = .TRUE. )
1377
1378!
1379!--    Read vertical number of gridpoints and number of different areas used for computing
1380!--    statistics. Allocate arrays depending on these values, which are required for the following
1381!--    read instructions.
1382       CALL rrd_mpi_io( 'nz', nz_on_file )
1383       IF ( nz_on_file /= nz )  THEN
1384          WRITE( message_string, * ) 'mismatch concerning number of gridpoints along z:',          &
1385                                     '&nz on file    = "', nz_on_file, '"',                        &
1386                                     '&nz from run   = "', nz, '"'
1387          CALL message( 'rrd_read_parts_of_global', 'PA0304', 1, 2, 0, 6, 0 )
1388       ENDIF
1389
1390       CALL rrd_mpi_io( 'max_pr_user', max_pr_user_on_file )
1391       IF ( max_pr_user_on_file /= max_pr_user )  THEN
1392          WRITE( message_string, * ) 'number of user profiles on restart data file differs from ', &
1393                                     'the current run:&max_pr_user on file    = "',                &
1394                                     max_pr_user_on_file, '" &max_pr_user from run   = "',         &
1395                                     max_pr_user, '"'
1396          CALL message( 'rrd_read_parts_of_global', 'PA0306', 0, 0, 0, 6, 0 )
1397          tmp_mpru = MIN( max_pr_user_on_file, max_pr_user )
1398       ELSE
1399          tmp_mpru = max_pr_user
1400       ENDIF
1401
1402       CALL rrd_mpi_io( 'statistic_regions', statistic_regions_on_file )
1403       IF ( statistic_regions_on_file /= statistic_regions )  THEN
1404          WRITE( message_string, * ) 'statistic regions on restart data file ',&
1405                                     'differ from the current run:',           &
1406                                     '&statistic regions on file    = "',      &
1407                                     statistic_regions_on_file, '"',           &
1408                                     '&statistic regions from run   = "',      &
1409                                      statistic_regions, '"',                  &
1410                                     '&statistic data may be lost!'
1411          CALL message( 'rrd_read_parts_of_global', 'PA0308', 0, 1, 0, 6, 0 )
1412          tmp_sr = MIN( statistic_regions_on_file, statistic_regions )
1413       ELSE
1414          tmp_sr = statistic_regions
1415       ENDIF
1416
1417!
1418!--    Now read and check some control parameters and skip the rest.
1419       CALL rrd_mpi_io( 'average_count_pr', average_count_pr )
1420       IF ( average_count_pr /= 0 )  THEN
1421          WRITE( message_string, * ) 'inflow profiles not ',          &
1422                         'temporally averaged. &Averaging will be ',  &
1423                         'done now using', average_count_pr,          &
1424                         ' samples.'
1425          CALL message( 'rrd_read_parts_of_global', 'PA0309', 0, 1, 0, 6, 0 )
1426       ENDIF
1427
1428       ALLOCATE( hom_on_file(0:nz+1,2,pr_palm+max_pr_user_on_file,0:statistic_regions_on_file) )
1429       CALL rrd_mpi_io_global_array( 'hom', hom_on_file )
1430       hom(:,:,1:pr_palm+tmp_mpru,0:tmp_sr) = hom_on_file(:,:,1:pr_palm+tmp_mpru,0:tmp_sr)
1431       DEALLOCATE( hom_on_file )
1432
1433       ALLOCATE( hom_sum_on_file(0:nz+1,pr_palm+max_pr_user_on_file, 0:statistic_regions_on_file) )
1434       CALL rrd_mpi_io_global_array( 'hom_sum', hom_sum_on_file )
1435       hom_sum(:,1:pr_palm+tmp_mpru,0:tmp_sr) = hom_sum_on_file(:,1:pr_palm+tmp_mpru,0:tmp_sr)
1436       DEALLOCATE( hom_sum_on_file )
1437
1438       momentum_advec_check = momentum_advec
1439       CALL rrd_mpi_io( 'momentum_advec', momentum_advec )
1440       IF ( TRIM( momentum_advec_check ) /= TRIM( momentum_advec ) )  THEN
1441          WRITE( message_string, * ) 'momentum_advec of the restart ',&
1442                                  'run differs from momentum_advec of the ',   &
1443                                  'initial run.'
1444          CALL message( 'rrd_read_parts_of_global', 'PA0100', 1, 2, 0, 6, 0 )
1445       ENDIF
1446
1447       CALL rrd_mpi_io( 'nx', nx_on_file )
1448       CALL rrd_mpi_io( 'ny', ny_on_file )
1449       CALL rrd_mpi_io_global_array( 'ref_state', ref_state )
1450
1451       scalar_advec_check = scalar_advec
1452       CALL rrd_mpi_io( 'scalar_advec', scalar_advec )
1453       IF ( TRIM( scalar_advec_check ) /= TRIM( scalar_advec ) )  THEN
1454          WRITE( message_string, * ) 'scalar_advec of the restart ',  &
1455                                  'run differs from scalar_advec of the ',     &
1456                                  'initial run.'
1457          CALL message( 'rrd_read_parts_of_global', 'PA0101', 1, 2, 0, 6, 0 )
1458       ENDIF
1459
1460!
1461!--    Close restart file
1462       CALL rd_mpi_io_close
1463
1464    ENDIF
1465
1466!
[2894]1467!-- Calculate the temporal average of vertical profiles, if neccessary
1468    IF ( average_count_pr /= 0 )  THEN
1469       hom_sum = hom_sum / REAL( average_count_pr, KIND=wp )
1470    ENDIF
1471
[4580]1472 END SUBROUTINE rrd_read_parts_of_global
[2894]1473
1474
1475! Description:
1476! ------------
[4517]1477!> Reads processor (subdomain) specific data of variables and arrays from restart file
[2894]1478!> (binary format).
1479!------------------------------------------------------------------------------!
[3637]1480 SUBROUTINE rrd_local
[2894]1481
1482
1483    CHARACTER (LEN=7)  ::  myid_char_save
1484    CHARACTER (LEN=10) ::  binary_version_local
1485    CHARACTER (LEN=10) ::  version_on_file
[4517]1486    CHARACTER (LEN=20) ::  tmp_name               !< temporary variable
[2894]1487
1488    INTEGER(iwp) ::  files_to_be_opened  !<
1489    INTEGER(iwp) ::  i                   !<
1490    INTEGER(iwp) ::  j                   !<
1491    INTEGER(iwp) ::  k                   !<
1492    INTEGER(iwp) ::  myid_on_file        !<
1493    INTEGER(iwp) ::  numprocs_on_file    !<
1494    INTEGER(iwp) ::  nxlc                !<
1495    INTEGER(iwp) ::  nxlf                !<
1496    INTEGER(iwp) ::  nxlpr               !<
1497    INTEGER(iwp) ::  nxl_on_file         !<
1498    INTEGER(iwp) ::  nxrc                !<
1499    INTEGER(iwp) ::  nxrf                !<
1500    INTEGER(iwp) ::  nxrpr               !<
1501    INTEGER(iwp) ::  nxr_on_file         !<
1502    INTEGER(iwp) ::  nync                !<
1503    INTEGER(iwp) ::  nynf                !<
1504    INTEGER(iwp) ::  nynpr               !<
1505    INTEGER(iwp) ::  nyn_on_file         !<
1506    INTEGER(iwp) ::  nysc                !<
1507    INTEGER(iwp) ::  nysf                !<
1508    INTEGER(iwp) ::  nyspr               !<
1509    INTEGER(iwp) ::  nys_on_file         !<
1510    INTEGER(iwp) ::  nzb_on_file         !<
1511    INTEGER(iwp) ::  nzt_on_file         !<
1512    INTEGER(iwp) ::  offset_x            !<
1513    INTEGER(iwp) ::  offset_y            !<
1514    INTEGER(iwp) ::  shift_x             !<
1515    INTEGER(iwp) ::  shift_y             !<
1516
1517    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  file_list       !<
1518    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  overlap_count   !<
1519
[4356]1520    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nxlfa      !<
1521    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nxrfa      !<
1522    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nynfa      !<
1523    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nysfa      !<
1524    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  offset_xa  !<
1525    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  offset_ya  !<
[2894]1526
1527    INTEGER(isp), DIMENSION(:,:),   ALLOCATABLE ::  tmp_2d_id_random   !< temporary array for storing random generator data
1528    INTEGER(isp), DIMENSION(:,:,:), ALLOCATABLE ::  tmp_2d_seq_random  !< temporary array for storing random generator data
1529
[4517]1530    LOGICAL ::  array_found                      !<
1531    LOGICAL ::  found                            !<
[2894]1532
[3998]1533    REAL(wp), DIMENSION(:,:),   ALLOCATABLE   ::  tmp_2d         !< temporary array for storing 2D data
1534    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d         !< temporary array for storing 3D data
[4009]1535    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d_non_standard !< temporary array for storing 3D data
1536                                                                 !< with non standard dimensions
[2894]1537
1538!
1539!-- Read data from previous model run.
[4539]1540    CALL cpu_log( log_point_s(14), 'read-restart-data-local', 'start' )
[4517]1541
[4539]1542    CALL location_message( 'reading local restart data', 'start' )
1543
[4517]1544    IF ( TRIM( restart_data_format_input ) == 'fortran_binary' )  THEN
[4356]1545!
[4517]1546!--    Input in Fortran binary format
[2894]1547
1548!
[4580]1549!--    Allocate temporary buffer arrays. In previous versions, they were
[4517]1550!--    declared as automated arrays, causing memory problems when these
1551!--    were allocate on stack.
1552       ALLOCATE( nxlfa(numprocs_previous_run,1000) )
1553       ALLOCATE( nxrfa(numprocs_previous_run,1000) )
1554       ALLOCATE( nynfa(numprocs_previous_run,1000) )
1555       ALLOCATE( nysfa(numprocs_previous_run,1000) )
1556       ALLOCATE( offset_xa(numprocs_previous_run,1000) )
1557       ALLOCATE( offset_ya(numprocs_previous_run,1000) )
[2894]1558
1559!
[4517]1560!--    Check which of the restart files contain data needed for the subdomain
1561!--    of this PE
1562       files_to_be_opened = 0
[2894]1563
[4517]1564       DO  i = 1, numprocs_previous_run
[2894]1565!
[4517]1566!--       Store array bounds of the previous run ("pr") in temporary scalars
1567          nxlpr = hor_index_bounds_previous_run(1,i-1)
1568          nxrpr = hor_index_bounds_previous_run(2,i-1)
1569          nyspr = hor_index_bounds_previous_run(3,i-1)
1570          nynpr = hor_index_bounds_previous_run(4,i-1)
[2894]1571
1572!
[4517]1573!--       Determine the offsets. They may be non-zero in case that the total domain
1574!--       on file is smaller than the current total domain.
1575          offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 )
1576          offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 )
[4431]1577
[4517]1578!
1579!--       Start with this offset and then check, if the subdomain on file
1580!--       matches another time(s) in the current subdomain by shifting it
1581!--       for nx_on_file+1, ny_on_file+1 respectively
[2894]1582
[4517]1583          shift_y = 0
1584          j       = 0
1585          DO WHILE (  nyspr+shift_y <= nyn-offset_y )
[4431]1586
[4517]1587             IF ( nynpr+shift_y >= nys-offset_y ) THEN
[4431]1588
[4517]1589                shift_x = 0
1590                DO WHILE ( nxlpr+shift_x <= nxr-offset_x )
1591
1592                   IF ( nxrpr+shift_x >= nxl-offset_x ) THEN
1593                      j = j +1
1594                      IF ( j > 1000 )  THEN
[2894]1595!
[4517]1596!--                      Array bound exceeded
1597                         message_string = 'data from subdomain of previous' //                        &
1598                                          ' run mapped more than 1000 times'
1599                         CALL message( 'rrd_local', 'PA0284', 2, 2, -1, 6, 1 )
1600                      ENDIF
[2894]1601
[4517]1602                      IF ( j == 1 )  THEN
1603                         files_to_be_opened = files_to_be_opened + 1
1604                         file_list(files_to_be_opened) = i-1
1605                      ENDIF
[4431]1606
[4517]1607                      offset_xa(files_to_be_opened,j) = offset_x + shift_x
1608                      offset_ya(files_to_be_opened,j) = offset_y + shift_y
[2894]1609!
[4517]1610!--                   Index bounds of overlapping data
1611                      nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x, nxlpr )
1612                      nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x, nxrpr )
1613                      nysfa(files_to_be_opened,j) = MAX( nys-offset_y-shift_y, nyspr )
1614                      nynfa(files_to_be_opened,j) = MIN( nyn-offset_y-shift_y, nynpr )
[2894]1615
[4517]1616                   ENDIF
[2894]1617
[4517]1618                   shift_x = shift_x + ( nx_on_file + 1 )
1619                ENDDO
[4431]1620
[4517]1621             ENDIF
[4431]1622
[4517]1623             shift_y = shift_y + ( ny_on_file + 1 )
1624          ENDDO
[4431]1625
[4517]1626          IF ( j > 0 )  overlap_count(files_to_be_opened) = j
[4431]1627
[4517]1628       ENDDO
[4431]1629
[2894]1630!
[4517]1631!--    Save the id-string of the current process, since myid_char may now be used
1632!--    to open files created by PEs with other id.
1633       myid_char_save = myid_char
[2894]1634
[4517]1635       IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run )  THEN
1636          WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed in restart run. & ',   &
1637                                     'Set debug_output =.T. to get a list of files from which the & ',&
1638                                     'single PEs will read respectively'
1639          CALL message( 'rrd_local', 'PA0285', 0, 0, 0, 6, 0 )
1640          IF ( debug_output )  THEN
1641             IF ( files_to_be_opened <= 120 )  THEN
1642                WRITE( debug_string, '(2A,1X,120(I6.6,1X))' )                                         &
1643                     'number of PEs or virtual PE-grid changed in restart run.  PE will read from ',  &
1644                     'files ', file_list(1:files_to_be_opened)
1645             ELSE
1646                WRITE( debug_string, '(3A,1X,120(I6.6,1X),A)' )                                      &
1647                     'number of PEs or virtual PE-grid changed in restart run.  PE will read from ',  &
1648                     'files ', file_list(1:120), '... and more'
1649             ENDIF
1650             CALL debug_message( 'rrd_local', 'info' )
[4435]1651          ENDIF
1652       ENDIF
[2894]1653
1654!
[4517]1655!--    Read data from all restart files determined above
1656       DO  i = 1, files_to_be_opened
[4431]1657
[4517]1658          j = file_list(i)
[2894]1659!
[4517]1660!--       Set the filename (underscore followed by four digit processor id)
1661          WRITE (myid_char,'(''_'',I6.6)')  j
[2894]1662
1663!
[4517]1664!--       Open the restart file. If this file has been created by PE0 (_000000),
1665!--       the global variables at the beginning of the file have to be skipped
1666!--       first.
1667          CALL check_open( 13 )
1668          IF ( j == 0 )  CALL rrd_skip_global
[2894]1669
1670!
[4517]1671!--       First compare the version numbers
1672          READ ( 13 )  length
1673          READ ( 13 )  restart_string(1:length)
1674          READ ( 13 )  version_on_file
[2894]1675
[4536]1676          binary_version_local = '5.0'
[4517]1677          IF ( TRIM( version_on_file ) /= TRIM( binary_version_local ) )  THEN
1678             WRITE( message_string, * ) 'version mismatch concerning ',                               &
1679                                        'binary_version_local:',                                      &
1680                                        '&version on file    = "', TRIM( version_on_file ), '"',      &
1681                                        '&version in program = "', TRIM( binary_version_local ), '"'
1682             CALL message( 'rrd_local', 'PA0286', 1, 2, 0, 6, 0 )
1683          ENDIF
[2894]1684
1685!
[4517]1686!--       Read number of processors, processor-id, and array ranges.
1687!--       Compare the array ranges with those stored in the index bound array.
1688          READ ( 13 )  numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file, nys_on_file,         &
1689                       nyn_on_file, nzb_on_file, nzt_on_file
[2894]1690
[4517]1691          IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) )  THEN
1692             WRITE( message_string, * ) 'problem with index bound nxl on ',                           &
1693                                        'restart file "', myid_char, '"',                             &
1694                                        '&nxl = ', nxl_on_file, ' but it should be',                  &
1695                                        '&= ', hor_index_bounds_previous_run(1,j),                    &
1696                                        '&from the index bound information array'
1697             CALL message( 'rrd_local', 'PA0287', 2, 2, -1, 6, 1 )
1698          ENDIF
[2894]1699
[4517]1700          IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
1701              WRITE( message_string, * ) 'problem with index bound nxr on ',                          &
1702                                         'restart file "', myid_char, '"'  ,                          &
1703                                         ' nxr = ', nxr_on_file, ' but it should be',                 &
1704                                         ' = ', hor_index_bounds_previous_run(2,j),                   &
1705                                         ' from the index bound information array'
1706             CALL message( 'rrd_local', 'PA0288', 2, 2, -1, 6, 1 )
[2894]1707
[4517]1708          ENDIF
[2894]1709
[4517]1710          IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
1711             WRITE( message_string, * ) 'problem with index bound nys on ',                           &
1712                                        'restart file "', myid_char, '"',                             &
1713                                        '&nys = ', nys_on_file, ' but it should be',                  &
1714                                        '&= ', hor_index_bounds_previous_run(3,j),                    &
1715                                        '&from the index bound information array'
1716             CALL message( 'rrd_local', 'PA0289', 2, 2, -1, 6, 1 )
1717          ENDIF
[2894]1718
[4517]1719          IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
1720             WRITE( message_string, * ) 'problem with index bound nyn on ',                           &
1721                                        'restart file "', myid_char, '"',                             &
1722                                        '&nyn = ', nyn_on_file, ' but it should be',                  &
1723                                        '&= ', hor_index_bounds_previous_run(4,j),                    &
1724                                        '&from the index bound information array'
1725             CALL message( 'rrd_local', 'PA0290', 2, 2, -1, 6, 1 )
1726          ENDIF
[2894]1727
[4517]1728          IF ( nzb_on_file /= nzb )  THEN
1729             WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
1730                                        'from prior run on PE ', myid,                                &
1731                                        '&nzb on file = ', nzb_on_file,                               &
1732                                        '&nzb         = ', nzb
1733             CALL message( 'rrd_local', 'PA0291', 1, 2, 0, 6, 0 )
1734          ENDIF
[2894]1735
[4517]1736          IF ( nzt_on_file /= nzt )  THEN
1737             WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
1738                                        'from prior run on PE ', myid,                                &
1739                                        '&nzt on file = ', nzt_on_file,                               &
1740                                        '&nzt         = ', nzt
1741             CALL message( 'rrd_local', 'PA0292', 1, 2, 0, 6, 0 )
1742          ENDIF
[2894]1743
1744!
[4517]1745!--       Allocate temporary arrays sized as the arrays on the restart file
1746          ALLOCATE( tmp_2d(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp),      &
1747                    tmp_3d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,                               &
1748                           nxl_on_file-nbgp:nxr_on_file+nbgp) )
[2894]1749
1750!
[4517]1751!--       Read arrays
1752!--       ATTENTION: If the following read commands have been altered, the
1753!--       ---------- version number of the variable binary_version_local must
1754!--                  be altered, too. Furthermore, the output list of arrays in
1755!--                  wrd_write_local must also be altered
1756!--                  accordingly.
1757          READ ( 13 )  length
1758          READ ( 13 )  restart_string(1:length)
[2894]1759
[4431]1760
[2894]1761!
[4517]1762!--       Loop over processor specific field data
1763          DO  WHILE ( restart_string(1:length) /= '*** end ***' )
[2894]1764
1765!
[4517]1766!--          Map data on file as often as needed (data are read only for k=1)
1767             DO  k = 1, overlap_count(i)
[2894]1768
[4517]1769                found = .FALSE.
[4431]1770
[2894]1771!
[4517]1772!--             Get the index range of the subdomain on file which overlap with
1773!--             the current subdomain
1774                nxlf = nxlfa(i,k)
1775                nxlc = nxlfa(i,k) + offset_xa(i,k)
1776                nxrf = nxrfa(i,k)
1777                nxrc = nxrfa(i,k) + offset_xa(i,k)
1778                nysf = nysfa(i,k)
1779                nysc = nysfa(i,k) + offset_ya(i,k)
1780                nynf = nynfa(i,k)
1781                nync = nynfa(i,k) + offset_ya(i,k)
[2894]1782
1783
[4517]1784                SELECT CASE ( restart_string(1:length) )
[2894]1785
[4517]1786                   CASE ( 'ghf_av' )
1787                      IF ( .NOT. ALLOCATED( ghf_av ) )  THEN
1788                         ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
1789                      ENDIF
1790                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1791                      ghf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1792                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1793
[4517]1794                   CASE ( 'e' )
1795                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1796                      e(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1797                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1798
[4517]1799                   CASE ( 'e_av' )
1800                      IF ( .NOT. ALLOCATED( e_av ) )  THEN
1801                         ALLOCATE( e_av(nzb:nzt+1,nys-nbgp:nyn+nbgp,                                  &
1802                                        nxl-nbgp:nxr+nbgp) )
1803                      ENDIF
1804                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1805                      e_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1806                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1807
[4517]1808                   CASE ( 'kh' )
1809                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1810                      kh(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1811                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1812
[4517]1813                   CASE ( 'kh_av' )
1814                      IF ( .NOT. ALLOCATED( kh_av ) )  THEN
1815                         ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1816                      ENDIF
1817                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1818                      kh_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1819                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1820
[4517]1821                   CASE ( 'km' )
1822                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1823                      km(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1824                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1825
[4517]1826                   CASE ( 'km_av' )
1827                      IF ( .NOT. ALLOCATED( km_av ) )  THEN
1828                         ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1829                      ENDIF
1830                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1831                      km_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1832                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1833
[4517]1834                   CASE ( 'lpt_av' )
1835                      IF ( .NOT. ALLOCATED( lpt_av ) )  THEN
1836                         ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1837                      ENDIF
1838                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1839                      lpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
1840                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1841
[4517]1842                   CASE ( 'lwp_av' )
1843                      IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
1844                         ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
1845                      ENDIF
1846                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1847                      lwp_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1848                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1849
[4517]1850                   CASE ( 'p' )
1851                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1852                      p(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1853                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1854
[4517]1855                   CASE ( 'p_av' )
1856                      IF ( .NOT. ALLOCATED( p_av ) )  THEN
1857                         ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1858                      ENDIF
1859                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1860                      p_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1861                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1862
[4517]1863                   CASE ( 'pt' )
1864                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1865                      pt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1866                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1867
[4517]1868                   CASE ( 'pt_av' )
1869                      IF ( .NOT. ALLOCATED( pt_av ) )  THEN
1870                         ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1871                      ENDIF
1872                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1873                      pt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1874                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1875
[4517]1876                   CASE ( 'q' )
1877                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1878                      q(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1879                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1880
[4517]1881                   CASE ( 'q_av' )
1882                      IF ( .NOT. ALLOCATED( q_av ) )  THEN
1883                         ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1884                      ENDIF
1885                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1886                      q_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1887                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1888
[4517]1889                   CASE ( 'ql' )
1890                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1891                      ql(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1892                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1893
[4517]1894                   CASE ( 'ql_av' )
1895                      IF ( .NOT. ALLOCATED( ql_av ) )  THEN
1896                         ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1897                      ENDIF
1898                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1899                      ql_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1900                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1901
[4517]1902                   CASE ( 'qsurf_av' )
1903                      IF ( .NOT. ALLOCATED( qsurf_av ) )  THEN
1904                         ALLOCATE( qsurf_av(nysg:nyng,nxlg:nxrg) )
1905                      ENDIF
1906                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1907                      qsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
1908                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[4514]1909
[4517]1910                   CASE ( 'qsws_av' )
1911                      IF ( .NOT. ALLOCATED( qsws_av ) )  THEN
1912                         ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
1913                      ENDIF
1914                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1915                      qsws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
1916                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1917
[4517]1918                   CASE ( 'qv_av' )
1919                      IF ( .NOT. ALLOCATED( qv_av ) )  THEN
1920                         ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1921                      ENDIF
1922                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1923                      qv_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1924                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1925
[4517]1926                   CASE ( 'r_a_av' )
1927                      IF ( .NOT. ALLOCATED( r_a_av ) )  THEN
1928                         ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
1929                      ENDIF
1930                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1931                      r_a_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1932                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1933
[4517]1934                   CASE ( 'random_iv' )  ! still unresolved issue
1935                      IF ( k == 1 )  READ ( 13 )  random_iv
1936                      IF ( k == 1 )  READ ( 13 )  random_iy
[2894]1937
[4517]1938                   CASE ( 'seq_random_array' )
1939                      ALLOCATE( tmp_2d_id_random(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
1940                      ALLOCATE( tmp_2d_seq_random(5,nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
1941                      IF ( .NOT. ALLOCATED( id_random_array ) )  THEN
1942                         ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
1943                      ENDIF
1944                      IF ( .NOT. ALLOCATED( seq_random_array ) )  THEN
1945                         ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
1946                      ENDIF
1947                      IF ( k == 1 )  READ ( 13 )  tmp_2d_id_random
1948                      IF ( k == 1 )  READ ( 13 )  tmp_2d_seq_random
1949                      id_random_array(nysc:nync,nxlc:nxrc) = tmp_2d_id_random(nysf:nynf,nxlf:nxrf)
1950                      seq_random_array(:,nysc:nync,nxlc:nxrc) = tmp_2d_seq_random(:,nysf:nynf,nxlf:nxrf)
1951                      DEALLOCATE( tmp_2d_id_random, tmp_2d_seq_random )
[2894]1952
[4517]1953                   CASE ( 's' )
1954                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1955                      s(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1956                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1957
[4517]1958                   CASE ( 's_av' )
1959                      IF ( .NOT. ALLOCATED( s_av ) )  THEN
1960                         ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
1961                      ENDIF
1962                      IF ( k == 1 )  READ ( 13 )  tmp_3d
1963                      s_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1964                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1965
[4517]1966                   CASE ( 'shf_av' )
1967                      IF ( .NOT. ALLOCATED( shf_av ) )  THEN
1968                         ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
1969                      ENDIF
1970                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1971                      shf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
1972                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[4431]1973
[4517]1974                   CASE ( 'ssurf_av' )
1975                      IF ( .NOT. ALLOCATED( ssurf_av ) )  THEN
1976                         ALLOCATE( ssurf_av(nysg:nyng,nxlg:nxrg) )
1977                      ENDIF
1978                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1979                      ssurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
1980                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[4514]1981
[4517]1982                   CASE ( 'ssws_av' )
1983                      IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
1984                         ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
1985                      ENDIF
1986                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1987                      ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
1988                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[3994]1989
[4517]1990                   CASE ( 'ts_av' )
1991                      IF ( .NOT. ALLOCATED( ts_av ) )  THEN
1992                         ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
1993                      ENDIF
1994                      IF ( k == 1 )  READ ( 13 )  tmp_2d
1995                      ts_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
1996                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]1997
[4517]1998                   CASE ( 'tsurf_av' )
1999                      IF ( .NOT. ALLOCATED( tsurf_av ) )  THEN
2000                         ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
2001                      ENDIF
2002                      IF ( k == 1 )  READ ( 13 )  tmp_2d
2003                      tsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
2004                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2005
[4517]2006                   CASE ( 'u' )
2007                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2008                      u(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
2009                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2010
[4517]2011                   CASE ( 'u_av' )
2012                      IF ( .NOT. ALLOCATED( u_av ) )  THEN
2013                         ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2014                      ENDIF
2015                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2016                      u_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
2017                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[4431]2018
[4517]2019                   CASE ( 'u_m_l' )
2020                      IF ( k == 1 )  THEN
2021                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
2022                                                       1:2) )
2023                         READ ( 13 )  tmp_3d_non_standard
2024                      ENDIF
2025                      IF ( bc_radiation_l )  THEN
2026                         u_m_l(:,nysc-nbgp:nync+nbgp,:) =  tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
2027                      ENDIF
[2894]2028
[4517]2029                   CASE ( 'u_m_n' )
2030                      IF ( k == 1 )  THEN
2031                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
2032                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
2033                         READ ( 13 )  tmp_3d_non_standard
2034                      ENDIF
2035                      IF ( bc_radiation_n )  THEN
2036                         u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
2037                      ENDIF
[2894]2038
[4517]2039                   CASE ( 'u_m_r' )
2040                      IF ( k == 1 )  THEN
2041                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
2042                                                       nx-1:nx) )
2043                         READ ( 13 )  tmp_3d_non_standard
2044                      ENDIF
2045                      IF ( bc_radiation_r )  THEN
2046                         u_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
2047                      ENDIF
[2894]2048
[4517]2049                   CASE ( 'u_m_s' )
2050                      IF ( k == 1 )  THEN
2051                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
2052                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
2053                         READ ( 13 )  tmp_3d_non_standard
2054                      ENDIF
2055                      IF ( bc_radiation_s )  THEN
2056                         u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
2057                      ENDIF
[2894]2058
[4517]2059                   CASE ( 'us_av' )
2060                      IF ( .NOT. ALLOCATED( us_av ) )  THEN
2061                         ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
2062                      ENDIF
2063                      IF ( k == 1 )  READ ( 13 )  tmp_2d
2064                      us_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
2065                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2066
[4517]2067                   CASE ( 'v' )
2068                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2069                      v(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
2070                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2071
[4517]2072                   CASE ( 'v_av' )
2073                      IF ( .NOT. ALLOCATED( v_av ) )  THEN
2074                         ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2075                      ENDIF
2076                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2077                      v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
2078                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[4431]2079
[4517]2080                   CASE ( 'v_m_l' )
2081                      IF ( k == 1 )  THEN
2082                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
2083                                                       0:1) )
2084                         READ ( 13 )  tmp_3d_non_standard
2085                      ENDIF
2086                      IF ( bc_radiation_l )  THEN
2087                         v_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
2088                      ENDIF
[2894]2089
[4517]2090                   CASE ( 'v_m_n' )
2091                      IF ( k == 1 )  THEN
2092                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
2093                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
2094                         READ ( 13 )  tmp_3d_non_standard
2095                      ENDIF
2096                      IF ( bc_radiation_n )  THEN
2097                         v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
2098                      ENDIF
[2894]2099
[4517]2100                   CASE ( 'v_m_r' )
2101                      IF ( k == 1 )  THEN
2102                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
2103                                                       nx-1:nx) )
2104                         READ ( 13 )  tmp_3d_non_standard
2105                      ENDIF
2106                      IF ( bc_radiation_r )  THEN
2107                         v_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
2108                      ENDIF
[2894]2109
[4517]2110                   CASE ( 'v_m_s' )
2111                      IF ( k == 1 )  THEN
2112                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,1:2,                                 &
2113                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
2114                         READ ( 13 )  tmp_3d_non_standard
2115                      ENDIF
2116                      IF ( bc_radiation_s )  THEN
2117                         v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
2118                      ENDIF
[2894]2119
[4517]2120                   CASE ( 'vpt' )
2121                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2122                      vpt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                &
2123                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2124
[4517]2125                   CASE ( 'vpt_av' )
2126                      IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
2127                         ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2128                      ENDIF
2129                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2130                      vpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
2131                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2132
[4517]2133                   CASE ( 'w' )
2134                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2135                      w(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
2136                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2137
[4517]2138                   CASE ( 'w_av' )
2139                      IF ( .NOT. ALLOCATED( w_av ) )  THEN
2140                         ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2141                      ENDIF
2142                      IF ( k == 1 )  READ ( 13 )  tmp_3d
2143                      w_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
2144                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[4431]2145
[4517]2146                   CASE ( 'w_m_l' )
2147                      IF ( k == 1 )  THEN
2148                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
2149                                                       0:1) )
2150                         READ ( 13 )  tmp_3d_non_standard
2151                      ENDIF
2152                      IF ( bc_radiation_l )  THEN
2153                         w_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
2154                      ENDIF
[2894]2155
[4517]2156                   CASE ( 'w_m_n' )
2157                      IF ( k == 1 )  THEN
2158                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
2159                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
2160                         READ ( 13 )  tmp_3d_non_standard
2161                      ENDIF
2162                      IF ( bc_radiation_n )  THEN
2163                         w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
2164                      ENDIF
[2894]2165
[4517]2166                   CASE ( 'w_m_r' )
2167                      IF ( k == 1 )  THEN
2168                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
2169                                                       nx-1:nx) )
2170                         READ ( 13 )  tmp_3d_non_standard
2171                      ENDIF
2172                      IF ( bc_radiation_r )  THEN
2173                         w_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
2174                      ENDIF
[2894]2175
[4517]2176                   CASE ( 'w_m_s' )
2177                      IF ( k == 1 )  THEN
2178                         ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
2179                                                       nxl_on_file-nbgp:nxr_on_file+nbgp) )
2180                         READ ( 13 )  tmp_3d_non_standard
2181                      ENDIF
2182                      IF ( bc_radiation_s )  THEN
2183                         w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
2184                      ENDIF
[2894]2185
[4517]2186                   CASE ( 'z0_av' )
2187                      IF ( .NOT. ALLOCATED( z0_av ) )  THEN
2188                         ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
2189                      ENDIF
2190                      IF ( k == 1 )  READ ( 13 )  tmp_2d
2191                      z0_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
2192                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2193
[4517]2194                   CASE ( 'z0h_av' )
2195                      IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
2196                         ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
2197                      ENDIF
2198                      IF ( k == 1 )  READ ( 13 )  tmp_2d
2199                      z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
2200                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2201
[4517]2202                   CASE ( 'z0q_av' )
2203                      IF ( .NOT. ALLOCATED( z0q_av ) )  THEN
2204                         ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
2205                      ENDIF
2206                      IF ( k == 1 )  READ ( 13 )  tmp_2d
2207                      z0q_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
2208                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
[2894]2209
[4517]2210                   CASE DEFAULT
[2894]2211
2212!
[4517]2213!--                   Read restart data of surfaces
2214                      IF ( .NOT. found )  CALL surface_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf,   &
2215                                                                  nxr_on_file, nynf, nyn_on_file,     &
2216                                                                  nysf, nysc, nys_on_file, found )
[2912]2217!
[4517]2218!--                   Read restart data of other modules
2219                      IF ( .NOT. found ) CALL module_interface_rrd_local(                             &
2220                                                                  k, nxlf, nxlc, nxl_on_file, nxrf,   &
2221                                                                  nxrc, nxr_on_file, nynf, nync,      &
2222                                                                  nyn_on_file, nysf, nysc,            &
2223                                                                  nys_on_file, tmp_2d, tmp_3d, found )
[2894]2224
2225
[4517]2226                      IF ( .NOT. found )  THEN
2227                         WRITE( message_string, * ) 'unknown variable named "',                       &
2228                                                    restart_string(1:length),                         &
2229                                                   '" found in subdomain data ',                      &
2230                                                   'from prior run on PE ', myid
2231                         CALL message( 'rrd_local', 'PA0302', 1, 2, 0, 6, 0 )
[4431]2232
[4517]2233                      ENDIF
[2894]2234
[4517]2235                END SELECT
[2894]2236
[4517]2237             ENDDO ! overlaploop
[2894]2238
2239!
[4517]2240!--          Deallocate non standard array needed for specific variables only
2241             IF ( ALLOCATED( tmp_3d_non_standard ) )  DEALLOCATE( tmp_3d_non_standard )
[2894]2242
2243!
[4517]2244!--          Read next character string
2245             READ ( 13 )  length
2246             READ ( 13 )  restart_string(1:length)
[2894]2247
[4517]2248          ENDDO ! dataloop
[2894]2249!
[4517]2250!--       Close the restart file
2251          CALL close_file( 13 )
[2894]2252
[4517]2253          DEALLOCATE( tmp_2d, tmp_3d )
[2894]2254
[4517]2255       ENDDO  ! loop over restart files
[2894]2256!
[4517]2257!--    Deallocate temporary buffer arrays
2258       DEALLOCATE( nxlfa )
2259       DEALLOCATE( nxrfa )
2260       DEALLOCATE( nynfa )
2261       DEALLOCATE( nysfa )
2262       DEALLOCATE( offset_xa )
2263       DEALLOCATE( offset_ya )
[4356]2264!
[4517]2265!--    Restore the original filename for the restart file to be written
2266       myid_char = myid_char_save
[2894]2267
[4517]2268
[4534]2269    ELSEIF ( restart_data_format_input(1:3) == 'mpi' )  THEN
[4517]2270
[2894]2271!
[4517]2272!--    Read global restart data using MPI-IO
2273!
2274!--    Open the MPI-IO restart file.
2275       CALL rd_mpi_io_open( 'read', 'BININ' // TRIM( coupling_char ) )
2276
2277
2278       CALL rd_mpi_io_check_array( 'ghf_av' , found = array_found )
2279       IF ( array_found )  THEN
2280          IF (.NOT. ALLOCATED( ghf_av ) )  ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
2281          CALL rrd_mpi_io( 'ghf_av', ghf_av )
2282       ENDIF
2283
2284       CALL rrd_mpi_io( 'e', e )
2285
2286       CALL rd_mpi_io_check_array( 'e_av' , found = array_found )
2287       IF ( array_found  )  THEN
2288          IF ( .NOT. ALLOCATED( e_av ) )  ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2289          CALL rrd_mpi_io( 'e_av', e_av )
2290       ENDIF
2291
2292       CALL rrd_mpi_io( 'kh', kh )
2293
2294       CALL rd_mpi_io_check_array( 'kh_av' , found = array_found )
2295       IF ( array_found )  THEN
2296          IF ( .NOT. ALLOCATED( kh_av ) )  ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2297          CALL rrd_mpi_io( 'kh_av', kh_av )
2298       ENDIF
2299
2300       CALL rrd_mpi_io( 'km' , km)
2301
2302       CALL rd_mpi_io_check_array( 'km_av' , found = array_found )
2303       IF ( array_found )  THEN
2304          IF ( .NOT. ALLOCATED( km_av ) )  ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2305          CALL rrd_mpi_io( 'km_av', km_av )
2306       ENDIF
2307
2308       CALL rd_mpi_io_check_array( 'lpt_av' , found = array_found )
2309       IF ( array_found )  THEN
2310          IF ( .NOT. ALLOCATED( lpt_av ) )  ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2311          CALL rrd_mpi_io( 'lpt_av', lpt_av )
2312       ENDIF
2313
2314       CALL rd_mpi_io_check_array( 'lwp_av' , found = array_found )
2315       IF ( array_found )  THEN
2316          IF ( .NOT. ALLOCATED( lwp_av ) )  ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
2317          CALL rrd_mpi_io( 'lwp_av', lwp_av )
2318       ENDIF
2319
2320       CALL rrd_mpi_io( 'p', p)
2321
2322       CALL rd_mpi_io_check_array( 'p_av' , found = array_found )
2323       IF ( array_found )  THEN
2324          IF ( .NOT. ALLOCATED( p_av ) )  ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2325          CALL rrd_mpi_io( 'p_av', p_av )
2326       ENDIF
2327
2328       CALL rrd_mpi_io( 'pt', pt)
2329
2330       CALL rd_mpi_io_check_array( 'pt_av' , found = array_found )
2331       IF ( array_found )  THEN
2332          IF ( .NOT. ALLOCATED( pt_av ) )  ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2333          CALL rrd_mpi_io( 'pt_av', pt_av )
2334       ENDIF
2335
2336       CALL rd_mpi_io_check_array( 'q' , found = array_found )
2337       IF ( array_found )  THEN
2338          CALL rrd_mpi_io( 'q', q )
2339       ENDIF
2340
2341       CALL rd_mpi_io_check_array( 'q_av' , found = array_found )
2342       IF ( array_found )  THEN
2343          IF ( .NOT. ALLOCATED( q_av ) )  ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2344          CALL rrd_mpi_io( 'q_av', q_av )
2345       ENDIF
2346
2347       CALL rd_mpi_io_check_array( 'ql' , found = array_found )
2348       IF ( array_found )  THEN
2349          CALL rrd_mpi_io( 'ql', ql )
2350       ENDIF
2351
2352       CALL rd_mpi_io_check_array( 'ql_av' , found = array_found )
2353       IF ( array_found )  THEN
2354          IF ( .NOT. ALLOCATED( ql_av ) )  ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2355          CALL rrd_mpi_io( 'ql_av', ql_av )
2356       ENDIF
2357
2358       CALL rd_mpi_io_check_array( 'qsurf_av' , found = array_found )
2359       IF ( array_found )  THEN
2360          IF ( .NOT. ALLOCATED( qsurf_av ) )  ALLOCATE( qsurf_av(nysg:nyng,nxlg:nxrg) )
2361          CALL rrd_mpi_io( 'qsurf_av', qsurf_av )
2362       ENDIF
2363
2364       CALL rd_mpi_io_check_array( 'qsws_av' , found = array_found )
2365       IF ( array_found )  THEN
2366          IF ( .NOT. ALLOCATED( qsws_av ) )  ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
2367          CALL rrd_mpi_io( 'qsws_av', qsws_av )
2368       ENDIF
2369
2370       CALL rd_mpi_io_check_array( 'qv_av' , found = array_found )
2371       IF ( array_found )  THEN
2372          IF ( .NOT. ALLOCATED( qv_av ) )  ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2373          CALL rrd_mpi_io( 'qv_av', qv_av )
2374       ENDIF
2375
2376       CALL rd_mpi_io_check_array( 'r_a_av' , found = array_found )
2377       IF ( array_found )  THEN
2378          IF ( .NOT. ALLOCATED( r_a_av ) )  ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
2379          CALL rrd_mpi_io( 'r_a_av', r_a_av )
2380       ENDIF
2381
2382!
2383!--    ATTENTION: The random seeds are global data! If independent values for every PE are required,
2384!--    the general approach of PE indendent restart will be lost. That means that in general the
2385!--    parallel random number generator in random_generator_parallel_mod should be used!
2386       CALL rrd_mpi_io_global_array( 'random_iv', random_iv )
2387       CALL rrd_mpi_io( 'random_iy', random_iy )
2388
2389       CALL rd_mpi_io_check_array( 'id_random_array' , found = array_found )
2390       IF ( array_found )  THEN
2391          IF ( .NOT. ALLOCATED( id_random_array ) )  ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
2392          IF ( .NOT. ALLOCATED( seq_random_array ) )  ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
2393          CALL rrd_mpi_io( 'id_random_array', id_random_array)
2394          DO  i = 1, SIZE( seq_random_array, 1 )
2395             WRITE( tmp_name, '(A,I2.2)' )  'seq_random_array', i
2396             CALL rrd_mpi_io( TRIM(tmp_name), seq_random_array(i,:,:) )
2397          ENDDO
2398       ENDIF
2399
2400       CALL rd_mpi_io_check_array( 's' , found = array_found )
2401       IF ( array_found )  THEN
2402          CALL rrd_mpi_io( 's', s )
2403       ENDIF
2404
2405       CALL rd_mpi_io_check_array( 's_av' , found = array_found )
2406       IF ( array_found )  THEN
2407          IF ( .NOT. ALLOCATED( s_av ) )  ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2408          CALL rrd_mpi_io( 's_av', s_av )
2409       ENDIF
2410
2411       CALL rd_mpi_io_check_array( 'shf_av' , found = array_found )
2412       IF ( array_found )  THEN
2413          IF ( .NOT. ALLOCATED( shf_av ) )  ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
2414          CALL rrd_mpi_io( 'shf_av', shf_av )
2415       ENDIF
2416
2417       CALL rd_mpi_io_check_array( 'ssurf_av' , found = array_found )
2418       IF ( array_found )  THEN
2419          IF ( .NOT. ALLOCATED( ssurf_av ) )  ALLOCATE( ssurf_av(nysg:nyng,nxlg:nxrg) )
2420          CALL rrd_mpi_io( 'ssurf_av', ssurf_av )
2421       ENDIF
2422
2423       CALL rd_mpi_io_check_array( 'ssws_av' , found = array_found )
2424       IF ( array_found )  THEN
2425          IF ( .NOT. ALLOCATED( ssws_av ) )  ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
2426          CALL rrd_mpi_io( 'ssws_av', ssws_av )
2427       ENDIF
2428
2429       CALL rd_mpi_io_check_array( 'ts_av' , found = array_found )
2430       IF ( array_found )  THEN
2431          IF ( .NOT. ALLOCATED( ts_av ) )  ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
2432          CALL rrd_mpi_io( 'ts_av', ts_av )
2433       ENDIF
2434
2435       CALL rd_mpi_io_check_array( 'tsurf_av' , found = array_found )
2436       IF ( array_found )  THEN
2437          IF ( .NOT. ALLOCATED( tsurf_av ) )  ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
2438          CALL rrd_mpi_io( 'tsurf_av', tsurf_av )
2439       ENDIF
2440
2441       CALL rrd_mpi_io( 'u', u)
2442
2443       CALL rd_mpi_io_check_array( 'u_av' , found = array_found )
2444       IF ( array_found )  THEN
2445          IF ( .NOT. ALLOCATED( u_av ) )  ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2446          CALL rrd_mpi_io( 'u_av', u_av )
2447       ENDIF
2448
2449       CALL rd_mpi_io_check_array( 'u_m_l' , found = array_found )
2450       IF ( array_found )  THEN
2451          IF ( .NOT. ALLOCATED( u_m_l ) )  ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2452          CALL rrd_mpi_io( 'u_m_l', u_m_l )
2453       ENDIF
2454
2455       CALL rd_mpi_io_check_array( 'u_m_n' , found = array_found )
2456       IF ( array_found )  THEN
2457          IF ( .NOT. ALLOCATED( u_m_n ) )  ALLOCATE( u_m_n(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2458          CALL rrd_mpi_io( 'u_m_n', u_m_n )
2459       ENDIF
2460
2461       CALL rd_mpi_io_check_array( 'u_m_r' , found = array_found )
2462       IF ( array_found )  THEN
2463          IF ( .NOT. ALLOCATED( u_m_r ) )  ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2464          CALL rrd_mpi_io( 'u_m_r', u_m_r )
2465       ENDIF
2466
2467       CALL rd_mpi_io_check_array( 'u_m_s' , found = array_found )
2468       IF ( array_found )  THEN
2469          IF ( .NOT. ALLOCATED( u_m_s ) )  ALLOCATE( u_m_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2470          CALL rrd_mpi_io( 'u_m_s', u_m_s )
2471       ENDIF
2472
2473       CALL rd_mpi_io_check_array( 'us_av' , found = array_found )
2474       IF ( array_found )  THEN
2475          IF ( .NOT. ALLOCATED( us_av ) )  ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
2476          CALL rrd_mpi_io( 'us_av', us_av )
2477       ENDIF
2478
2479       CALL rrd_mpi_io( 'v', v )
2480
2481       CALL rd_mpi_io_check_array( 'v_av' , found = array_found )
2482       IF ( array_found )  THEN
2483          IF ( .NOT. ALLOCATED( v_av ) )  ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2484          CALL rrd_mpi_io( 'v_av', v_av )
2485       ENDIF
2486
2487       CALL rd_mpi_io_check_array( 'v_m_l' , found = array_found )
2488       IF ( array_found )  THEN
2489          IF ( .NOT. ALLOCATED( v_m_l ) )  ALLOCATE( v_m_l(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2490          CALL rrd_mpi_io( 'v_m_l', v_m_l )
2491       ENDIF
2492
2493       CALL rd_mpi_io_check_array( 'v_m_n' , found = array_found )
2494       IF ( array_found )  THEN
2495          IF ( .NOT. ALLOCATED( v_m_n ) )  ALLOCATE( v_m_n(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2496          CALL rrd_mpi_io( 'v_m_n', v_m_n )
2497       ENDIF
2498
2499       CALL rd_mpi_io_check_array( 'v_m_r' , found = array_found )
2500       IF ( array_found )  THEN
2501          IF ( .NOT. ALLOCATED( v_m_r ) )  ALLOCATE( v_m_r(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2502          CALL rrd_mpi_io( 'v_m_r', v_m_r )
2503       ENDIF
2504
2505       CALL rd_mpi_io_check_array( 'v_m_s' , found = array_found )
2506       IF ( array_found )  THEN
2507          IF ( .NOT. ALLOCATED( v_m_s ) )  ALLOCATE( v_m_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2508          CALL rrd_mpi_io( 'v_m_s', v_m_s )
2509       ENDIF
2510
2511       CALL rd_mpi_io_check_array( 'vpt' , found = array_found )
2512       IF ( array_found )  THEN
2513          CALL rrd_mpi_io( 'vpt',  vpt)
2514       ENDIF
2515
2516       CALL rd_mpi_io_check_array( 'vpt_av' , found = array_found )
2517       IF ( array_found )  THEN
2518          IF ( .NOT. ALLOCATED( vpt_av ) )  ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2519          CALL rrd_mpi_io( 'vpt_av', vpt_av )
2520       ENDIF
2521
2522       CALL rrd_mpi_io( 'w', w)
2523
2524       CALL rd_mpi_io_check_array( 'w_av' , found = array_found )
2525       IF ( array_found )  THEN
2526          IF ( .NOT. ALLOCATED( w_av ) )  ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2527          CALL rrd_mpi_io( 'w_av', w_av )
2528       ENDIF
2529
2530       CALL rd_mpi_io_check_array( 'w_m_l' , found = array_found )
2531       IF ( array_found )  THEN
2532          IF ( .NOT. ALLOCATED( w_m_l ) )  ALLOCATE( w_m_l(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2533          CALL rrd_mpi_io( 'w_m_l', w_m_l )
2534       ENDIF
2535
2536       CALL rd_mpi_io_check_array( 'w_m_n' , found = array_found )
2537       IF ( array_found )  THEN
2538          IF ( .NOT. ALLOCATED( w_m_n ) )  ALLOCATE( w_m_n(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2539          CALL rrd_mpi_io( 'w_m_n', w_m_n )
2540       ENDIF
2541
2542       CALL rd_mpi_io_check_array( 'w_m_r' , found = array_found )
2543       IF ( array_found )  THEN
2544          IF ( .NOT. ALLOCATED( w_m_r ) )  ALLOCATE( w_m_r(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2545          CALL rrd_mpi_io( 'w_m_r', w_m_r )
2546       ENDIF
2547
2548       CALL rd_mpi_io_check_array( 'w_m_s' , found = array_found )
2549       IF ( array_found )  THEN
2550          IF ( .NOT. ALLOCATED( w_m_s ) )  ALLOCATE( w_m_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
2551          CALL rrd_mpi_io( 'w_m_s', w_m_s )
2552       ENDIF
2553
2554       CALL rd_mpi_io_check_array( 'z0_av' , found = array_found )
2555       IF ( array_found )  THEN
2556          IF ( .NOT. ALLOCATED( z0_av ) )  ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
2557          CALL rrd_mpi_io( 'z0_av', z0_av )
2558       ENDIF
2559
2560       CALL rd_mpi_io_check_array( 'z0h_av' , found = array_found )
2561       IF ( array_found )  THEN
2562          IF ( .NOT. ALLOCATED( z0h_av ) )  ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
2563          CALL rrd_mpi_io( 'z0h_av', z0h_av )
2564       ENDIF
2565
2566       CALL rd_mpi_io_check_array( 'z0q_av' , found = array_found )
2567       IF ( array_found )  THEN
2568          IF ( .NOT. ALLOCATED( z0q_av ) )  ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
2569          CALL rrd_mpi_io( 'z0q_av', z0q_av )
2570       ENDIF
2571
2572!
2573!--    Read restart data of surfaces
2574       CALL surface_rrd_local
2575
2576!
2577!--    Read restart data of other modules
2578       CALL module_interface_rrd_local
2579
2580!
2581!--    Close restart file
2582       CALL rd_mpi_io_close
2583
2584    ENDIF
2585
[4539]2586    CALL location_message( 'reading local restart data', 'finished' )
[4517]2587!
[2894]2588!-- End of time measuring for reading binary data
[4539]2589    CALL cpu_log( log_point_s(14), 'read-restart-data-local', 'stop' )
[2894]2590
2591 END SUBROUTINE rrd_local
2592
2593
2594!------------------------------------------------------------------------------!
2595! Description:
2596! ------------
2597!> Skipping the global control variables from restart-file (binary format)
2598!------------------------------------------------------------------------------!
[4495]2599 SUBROUTINE rrd_skip_global
[2894]2600
2601
[4495]2602    CHARACTER (LEN=1) ::  cdum
[2894]2603
2604
[4495]2605    READ ( 13 )  length
2606    READ ( 13 )  restart_string(1:length)
[2894]2607
[4495]2608    DO  WHILE ( restart_string(1:length) /= 'binary_version_local' )
2609
2610       READ ( 13 )  cdum
[2894]2611       READ ( 13 )  length
2612       READ ( 13 )  restart_string(1:length)
2613
[4495]2614    ENDDO
[2894]2615
[4495]2616    BACKSPACE ( 13 )
2617    BACKSPACE ( 13 )
[2894]2618
2619
[4495]2620 END SUBROUTINE rrd_skip_global
[2894]2621
2622
2623 END MODULE read_restart_data_mod
Note: See TracBrowser for help on using the repository browser.