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

Last change on this file since 4828 was 4828, checked in by Giersch, 3 years ago

Copyright updated to year 2021, interface pmc_sort removed to accelarate the nesting code

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