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

Last change on this file since 4313 was 4301, checked in by oliver.maas, 4 years ago

Deleted parameter recycling_yshift. y-shift in case of non-cyclic boundary conditions and turbulent_inflow = .TRUE. is now steered by parameter y_shift, that is also used in case of cyclic boundary conditions.

  • Property svn:keywords set to Id
File size: 77.3 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-2019 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: read_restart_data_mod.f90 4301 2019-11-22 12:09:09Z suehring $
27! removed recycling_yshift
28!
29! 4227 2019-09-10 18:04:34Z gronemeier
30! implement new palm_date_time_mod and increased binary version
31!
32! 4146 2019-08-07 07:47:36Z gronemeier
33! Corrected "Former revisions" section
34!
35! 4131 2019-08-02 11:06:18Z monakurppa
36! Allocate hom and hom_sum to allow profile output for salsa variables.
37!
38! 4101 2019-07-17 15:14:26Z gronemeier
39! remove old_dt
40!
41! 4039 2019-06-18 10:32:41Z suehring
42! input of uu_av, vv_av, ww_av added
43!
44! 4017 2019-06-06 12:16:46Z schwenkel
45! bugfix for r3998, allocation of 3d temporary arrays of various dimensions revised
46!
47! 3998 2019-05-23 13:38:11Z suehring
48! Formatting adjustment
49!
50! 3994 2019-05-22 18:08:09Z suehring
51! output of turbulence intensity added
52!
53! 3988 2019-05-22 11:32:37Z kanani
54! + time_virtual_measurement (to enable steering of output interval)
55!
56! 3936 2019-04-26 15:38:02Z kanani
57! Enable time-averaged output of theta_2m* with restarts
58!
59! 3767 2019-02-27 08:18:02Z raasch
60! unused variables removed from rrd-subroutines parameter list
61!
62! 3766 2019-02-26 16:23:41Z raasch
63! first argument removed from module_interface_rrd_*
64!
65! 3668 2019-01-14 12:49:24Z maronga
66! Removed most_method and increased binary version
67!
68! 3655 2019-01-07 16:51:22Z knoop
69! Implementation of the PALM module interface
70!
71! 2894 2018-03-15 09:17:58Z Giersch
72! Initial revision
73!
74!
75! Description:
76! ------------
77!> Reads restart data from restart-file(s) (binary format).
78!>
79!> @todo: Revise max_pr_cs (profiles for chemistry)
80!> @todo: Modularize reading of restart data for diagnostic quantities, which
81!>        is not possible with the current module-interface structure
82!------------------------------------------------------------------------------!
83 MODULE read_restart_data_mod
84
85
86    USE arrays_3d,                                                             &
87        ONLY:  inflow_damping_factor, mean_inflow_profiles, pt_init,           &
88               q_init, ref_state, sa_init, s_init, u_init, ug, v_init, vg,     &
89               e, kh, km, p, pt, q, ql, s, u, u_m_l, u_m_n, u_m_r, u_m_s,      &
90               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
91
92    USE averaging
93
94    USE chem_modules,                                                                              &
95       ONLY: max_pr_cs
96
97    USE control_parameters
98
99    USE cpulog,                                                                &
100        ONLY:  cpu_log, log_point_s
101
102    USE diagnostic_output_quantities_mod,                                      &
103        ONLY:  ti_av, uu_av, vv_av, ww_av
104
105    USE grid_variables,                                                        &
106        ONLY:  dx, dy
107
108    USE indices,                                                               &
109        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nx_on_file, ny, nys, nysg, nyn, &
110               nyng, ny_on_file, nz, nzb, nzt
111
112    USE kinds
113
114    USE model_1d_mod,                                                          &
115        ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
116
117    USE module_interface,                                                      &
118        ONLY:  module_interface_rrd_global,                                    &
119               module_interface_rrd_local
120
121    USE netcdf_interface,                                                      &
122        ONLY:  netcdf_precision, output_for_t0
123
124    USE pegrid
125
126    USE radiation_model_mod,                                                   &
127        ONLY:  time_radiation
128
129    USE random_function_mod,                                                   &
130        ONLY:  random_iv, random_iy
131
132    USE random_generator_parallel,                                             &
133        ONLY:  id_random_array, seq_random_array
134
135    USE spectra_mod,                                                           &
136        ONLY:  average_count_sp, spectrum_x, spectrum_y
137
138    USE surface_mod,                                                           &
139        ONLY :  surface_rrd_local
140
141    USE statistics,                                                            &
142        ONLY:  statistic_regions, hom, hom_sum, pr_palm, u_max, u_max_ijk,     &
143               v_max, v_max_ijk, w_max, w_max_ijk, z_i
144
145    USE vertical_nesting_mod,                                                  &
146        ONLY:  vnest_init
147
148    USE virtual_measurement_mod,                                               &
149        ONLY:  time_virtual_measurement
150
151
152    IMPLICIT NONE
153
154
155    INTERFACE rrd_global
156       MODULE PROCEDURE rrd_global
157    END INTERFACE rrd_global
158
159    INTERFACE rrd_read_parts_of_global
160       MODULE PROCEDURE rrd_read_parts_of_global
161    END INTERFACE rrd_read_parts_of_global
162
163    INTERFACE rrd_local
164       MODULE PROCEDURE rrd_local
165    END INTERFACE rrd_local
166
167    INTERFACE rrd_skip_global
168       MODULE PROCEDURE rrd_skip_global
169    END INTERFACE rrd_skip_global
170
171
172    PUBLIC rrd_global, rrd_read_parts_of_global, rrd_local, rrd_skip_global
173
174
175 CONTAINS
176
177!------------------------------------------------------------------------------!
178! Description:
179! ------------
180!> Reads values of global control variables from restart-file (binary format)
181!> created by PE0 of the previous run
182!------------------------------------------------------------------------------!
183    SUBROUTINE rrd_global
184
185
186       CHARACTER (LEN=10) ::  binary_version_global, version_on_file
187
188       LOGICAL ::  found 
189
190
191       CALL check_open( 13 )
192!
193!--    Make version number check first
194       READ ( 13 )  length
195       READ ( 13 )  restart_string(1:length)
196       READ ( 13 )  version_on_file
197
198       binary_version_global = '4.9'
199       IF ( TRIM( version_on_file ) /= TRIM( binary_version_global ) )  THEN
200          WRITE( message_string, * ) 'version mismatch concerning ',           &
201                                     'binary_version_global:',                 &
202                                     '&version on file    = "',                &
203                                     TRIM( version_on_file ), '"',             &
204                                     '&version on program = "',                &
205                                     TRIM( binary_version_global ), '"'
206          CALL message( 'rrd_global', 'PA0296', 1, 2, 0, 6, 0 )
207       ENDIF
208
209!
210!--    Read number of PEs and horizontal index bounds of all PEs used in the
211!--    previous run
212       READ ( 13 )  length
213       READ ( 13 )  restart_string(1:length)
214
215       IF ( TRIM( restart_string(1:length) ) /= 'numprocs' )  THEN
216          WRITE( message_string, * ) 'numprocs not found in data from prior ', &
217                                     'run on PE ', myid
218          CALL message( 'rrd_global', 'PA0297', 1, 2, 0, 6, 0 )
219       ENDIF
220       READ ( 13 )  numprocs_previous_run
221
222       IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
223          ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
224       ENDIF
225
226       READ ( 13 )  length
227       READ ( 13 )  restart_string(1:length)
228
229       IF ( restart_string(1:length) /= 'hor_index_bounds' )  THEN
230          WRITE( message_string, * ) 'hor_index_bounds not found in data ',    &
231                                     'from prior run on PE ', myid
232          CALL message( 'rrd_global', 'PA0298', 1, 2, 0, 6, 0 )
233       ENDIF
234       READ ( 13 )  hor_index_bounds_previous_run
235
236!
237!--    Read vertical number of gridpoints and number of different areas used
238!--    for computing statistics. Allocate arrays depending on these values,
239!--    which are needed for the following read instructions.
240       READ ( 13 )  length
241       READ ( 13 )  restart_string(1:length)
242
243       IF ( restart_string(1:length) /= 'nz' )  THEN
244          WRITE( message_string, * ) 'nz not found in data from prior run ',   &
245                                     'on PE ', myid
246          CALL message( 'rrd_global', 'PA0299', 1, 2, 0, 6, 0 )
247       ENDIF
248       READ ( 13 )  nz
249
250       READ ( 13 )  length
251       READ ( 13 )  restart_string(1:length)
252
253       IF ( restart_string(1:length) /= 'max_pr_user' )  THEN
254          WRITE( message_string, * ) 'max_pr_user not found in data from ',    &
255                                     'prior run on PE ', myid
256          CALL message( 'rrd_global', 'PA0300', 1, 2, 0, 6, 0 )
257       ENDIF
258       READ ( 13 )  max_pr_user    ! This value is checked against the number of
259                                   ! user profiles given for the current run
260                                   ! in routine user_parin (it has to match)
261
262       READ ( 13 )  length
263       READ ( 13 )  restart_string(1:length)
264
265       IF ( restart_string(1:length) /= 'statistic_regions' )  THEN
266          WRITE( message_string, * ) 'statistic_regions not found in data ',   &
267                                     'from prior run on PE ', myid
268          CALL message( 'rrd_global', 'PA0301', 1, 2, 0, 6, 0 )
269       ENDIF
270       READ ( 13 )  statistic_regions
271
272       IF ( .NOT. ALLOCATED( ug ) )  THEN
273          ALLOCATE( ug(0:nz+1), u_init(0:nz+1), vg(0:nz+1),                    &
274                    v_init(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),           &
275                    ref_state(0:nz+1), s_init(0:nz+1), sa_init(0:nz+1),        &
276                    hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),  &
277                    hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
278       ENDIF
279
280!
281!--    Now read all control parameters:
282!--    Caution: When the following read instructions have been changed, the
283!--    -------  version number stored in the variable binary_version_global has
284!--             to be increased. The same changes must also be done in
285!--             wrd_write_global.
286       READ ( 13 )  length
287       READ ( 13 )  restart_string(1:length)
288
289       DO WHILE ( restart_string(1:length) /= 'binary_version_local' )
290
291          found = .FALSE.
292
293          SELECT CASE ( restart_string(1:length) )
294
295             CASE ( 'advected_distance_x' )
296                READ ( 13 )  advected_distance_x
297             CASE ( 'advected_distance_y' )
298                READ ( 13 )  advected_distance_y
299             CASE ( 'alpha_surface' )
300                READ ( 13 )  alpha_surface
301             CASE ( 'average_count_pr' )
302                READ ( 13 )  average_count_pr
303             CASE ( 'average_count_sp' )
304                READ ( 13 )  average_count_sp
305             CASE ( 'average_count_3d' )
306                READ ( 13 )  average_count_3d
307             CASE ( 'bc_e_b' )
308                READ ( 13 )  bc_e_b
309             CASE ( 'bc_lr' )
310                READ ( 13 )  bc_lr
311             CASE ( 'bc_ns' )
312                READ ( 13 )  bc_ns
313             CASE ( 'bc_p_b' )
314                READ ( 13 )  bc_p_b
315             CASE ( 'bc_p_t' )
316                READ ( 13 )  bc_p_t
317             CASE ( 'bc_pt_b' )
318                READ ( 13 )  bc_pt_b
319             CASE ( 'bc_pt_t' )
320                READ ( 13 )  bc_pt_t
321             CASE ( 'bc_pt_t_val' )
322                READ ( 13 )  bc_pt_t_val
323             CASE ( 'bc_q_b' )
324                READ ( 13 )  bc_q_b
325             CASE ( 'bc_q_t' )
326                READ ( 13 )  bc_q_t
327             CASE ( 'bc_q_t_val' )
328                READ ( 13 )  bc_q_t_val
329             CASE ( 'bc_s_b' )
330                READ ( 13 )  bc_s_b
331             CASE ( 'bc_s_t' )
332                READ ( 13 )  bc_s_t
333             CASE ( 'bc_uv_b' )
334                READ ( 13 )  bc_uv_b
335             CASE ( 'bc_uv_t' )
336                READ ( 13 )  bc_uv_t
337             CASE ( 'building_height' )
338                READ ( 13 )  building_height
339             CASE ( 'building_length_x' )
340                READ ( 13 )  building_length_x
341             CASE ( 'building_length_y' )
342                READ ( 13 )  building_length_y
343             CASE ( 'building_wall_left' )
344                READ ( 13 )  building_wall_left
345             CASE ( 'building_wall_south' )
346                READ ( 13 )  building_wall_south
347             CASE ( 'call_psolver_at_all_substeps' )
348                READ ( 13 )  call_psolver_at_all_substeps
349             CASE ( 'canyon_height' )
350                READ ( 13 )  canyon_height
351             CASE ( 'canyon_wall_left' )
352                READ ( 13 )  canyon_wall_left
353             CASE ( 'canyon_wall_south' )
354                READ ( 13 )  canyon_wall_south
355             CASE ( 'canyon_width_x' )
356                READ ( 13 )  canyon_width_x
357             CASE ( 'canyon_width_y' )
358                READ ( 13 )  canyon_width_y
359             CASE ( 'cfl_factor' )
360                READ ( 13 )  cfl_factor
361             CASE ( 'cloud_droplets' )
362                READ ( 13 )  cloud_droplets
363             CASE ( 'collective_wait' )
364                READ ( 13 )  collective_wait
365             CASE ( 'conserve_volume_flow' )
366                READ ( 13 )  conserve_volume_flow
367             CASE ( 'conserve_volume_flow_mode' )
368                READ ( 13 )  conserve_volume_flow_mode
369             CASE ( 'constant_flux_layer' )
370                READ ( 13 )  constant_flux_layer
371             CASE ( 'coupling_start_time' )
372                READ ( 13 )  coupling_start_time
373             CASE ( 'current_timestep_number' )
374                READ ( 13 )  current_timestep_number
375             CASE ( 'cycle_mg' )
376                READ ( 13 )  cycle_mg
377             CASE ( 'damp_level_1d' )
378                READ ( 13 )  damp_level_1d
379             CASE ( 'origin_date_time' )
380                READ ( 13 )  origin_date_time
381             CASE ( 'dissipation_1d' )
382                READ ( 13 )  dissipation_1d
383             CASE ( 'do2d_xy_time_count' )
384                READ ( 13 )  do2d_xy_time_count
385             CASE ( 'do2d_xz_time_count' )
386                READ ( 13 )  do2d_xz_time_count
387             CASE ( 'do2d_yz_time_count' )
388                READ ( 13 )  do2d_yz_time_count
389             CASE ( 'do3d_time_count' )
390                READ ( 13 )  do3d_time_count
391             CASE ( 'dp_external' )
392                READ ( 13 )  dp_external
393             CASE ( 'dp_level_b' )
394                READ ( 13 )  dp_level_b
395             CASE ( 'dp_smooth' )
396                READ ( 13 )  dp_smooth
397             CASE ( 'dpdxy' )
398                READ ( 13 )  dpdxy
399             CASE ( 'dt_3d' )
400                READ ( 13 )  dt_3d
401             CASE ( 'dt_pr_1d' )
402                READ ( 13 )  dt_pr_1d
403             CASE ( 'dt_run_control_1d' )
404                READ ( 13 )  dt_run_control_1d
405             CASE ( 'dx' )
406                READ ( 13 )  dx
407             CASE ( 'dy' )
408                READ ( 13 )  dy
409             CASE ( 'dz' )
410                READ ( 13 )  dz
411             CASE ( 'dz_max' )
412                READ ( 13 )  dz_max
413             CASE ( 'dz_stretch_factor' )
414                READ ( 13 )  dz_stretch_factor
415             CASE ( 'dz_stretch_factor_array' )
416                READ ( 13 )  dz_stretch_factor_array
417             CASE ( 'dz_stretch_level' )
418                READ ( 13 )  dz_stretch_level
419             CASE ( 'dz_stretch_level_end' )
420                READ ( 13 )  dz_stretch_level_end
421             CASE ( 'dz_stretch_level_start' )
422                READ ( 13 )  dz_stretch_level_start
423             CASE ( 'e_min' )
424                READ ( 13 )  e_min
425             CASE ( 'end_time_1d' )
426                READ ( 13 )  end_time_1d
427             CASE ( 'fft_method' )
428                READ ( 13 )  fft_method
429             CASE ( 'first_call_lpm' )
430                READ ( 13 )  first_call_lpm
431             CASE ( 'galilei_transformation' )
432                READ ( 13 )  galilei_transformation
433             CASE ( 'hom' )
434                READ ( 13 )  hom
435             CASE ( 'hom_sum' )
436                READ ( 13 )  hom_sum
437             CASE ( 'humidity' )
438                READ ( 13 )  humidity
439             CASE ( 'inflow_damping_factor' )
440                IF ( .NOT. ALLOCATED( inflow_damping_factor ) )  THEN
441                   ALLOCATE( inflow_damping_factor(0:nz+1) )
442                ENDIF
443                READ ( 13 )  inflow_damping_factor
444             CASE ( 'inflow_damping_height' )
445                READ ( 13 )  inflow_damping_height
446             CASE ( 'inflow_damping_width' )
447                READ ( 13 )  inflow_damping_width
448             CASE ( 'inflow_disturbance_begin' )
449                READ ( 13 )  inflow_disturbance_begin
450             CASE ( 'inflow_disturbance_end' )
451                READ ( 13 )  inflow_disturbance_end
452             CASE ( 'km_constant' )
453                READ ( 13 )  km_constant
454             CASE ( 'large_scale_forcing' )
455                READ ( 13 )  large_scale_forcing
456             CASE ( 'large_scale_subsidence' )
457                READ ( 13 )  large_scale_subsidence
458             CASE ( 'latitude' )
459                READ ( 13 )  latitude
460             CASE ( 'longitude' )
461                READ ( 13 )  longitude
462             CASE ( 'loop_optimization' )
463                READ ( 13 )  loop_optimization
464             CASE ( 'masking_method' )
465                READ ( 13 )  masking_method
466             CASE ( 'mean_inflow_profiles' )
467                IF ( .NOT. ALLOCATED( mean_inflow_profiles ) )  THEN
468                   ALLOCATE( mean_inflow_profiles(0:nz+1,1:num_mean_inflow_profiles) )
469                ENDIF
470                READ ( 13 )  mean_inflow_profiles
471             CASE ( 'mg_cycles' )
472                READ ( 13 )  mg_cycles
473             CASE ( 'mg_switch_to_pe0_level' )
474                READ ( 13 )  mg_switch_to_pe0_level
475             CASE ( 'mixing_length_1d' )
476                READ ( 13 )  mixing_length_1d
477             CASE ( 'momentum_advec' )
478                READ ( 13 )  momentum_advec
479             CASE ( 'netcdf_precision' )
480                READ ( 13 )  netcdf_precision
481             CASE ( 'neutral' )
482                READ ( 13 )  neutral
483             CASE ( 'ngsrb' )
484                READ ( 13 )  ngsrb
485             CASE ( 'nsor' )
486                READ ( 13 )  nsor
487             CASE ( 'nsor_ini' )
488                READ ( 13 )  nsor_ini
489             CASE ( 'nudging' )
490                READ ( 13 )  nudging
491             CASE ( 'num_leg' )
492                READ ( 13 )  num_leg
493             CASE ( 'nx' )
494                READ ( 13 )  nx
495                nx_on_file = nx
496             CASE ( 'ny' )
497                READ ( 13 )  ny
498                ny_on_file = ny
499             CASE ( 'ocean_mode' )
500                READ ( 13 )  ocean_mode
501             CASE ( 'omega' )
502                READ ( 13 )  omega
503             CASE ( 'omega_sor' )
504                READ ( 13 )  omega_sor
505             CASE ( 'output_for_t0' )
506                READ (13)    output_for_t0
507             CASE ( 'passive_scalar' )
508                READ ( 13 )  passive_scalar
509             CASE ( 'prandtl_number' )
510                READ ( 13 )  prandtl_number
511             CASE ( 'psolver' )
512                READ ( 13 )  psolver
513             CASE ( 'pt_damping_factor' )
514                READ ( 13 )  pt_damping_factor
515             CASE ( 'pt_damping_width' )
516                READ ( 13 )  pt_damping_width
517             CASE ( 'pt_init' )
518                READ ( 13 )  pt_init
519             CASE ( 'pt_reference' )
520                READ ( 13 )  pt_reference
521             CASE ( 'pt_surface' )
522                READ ( 13 )  pt_surface
523             CASE ( 'pt_surface_initial_change' )
524                READ ( 13 )  pt_surface_initial_change
525             CASE ( 'pt_vertical_gradient' )
526                READ ( 13 )  pt_vertical_gradient
527             CASE ( 'pt_vertical_gradient_level' )
528                READ ( 13 )  pt_vertical_gradient_level
529             CASE ( 'pt_vertical_gradient_level_ind' )
530                READ ( 13 )  pt_vertical_gradient_level_ind
531             CASE ( 'q_init' )
532                READ ( 13 )  q_init
533             CASE ( 'q_surface' )
534                READ ( 13 )  q_surface
535             CASE ( 'q_surface_initial_change' )
536                READ ( 13 )  q_surface_initial_change
537             CASE ( 'q_vertical_gradient' )
538                READ ( 13 )  q_vertical_gradient
539             CASE ( 'q_vertical_gradient_level' )
540                READ ( 13 )  q_vertical_gradient_level
541             CASE ( 'q_vertical_gradient_level_ind' )
542                READ ( 13 )  q_vertical_gradient_level_ind
543             CASE ( 'random_generator' )
544                READ ( 13 )  random_generator
545             CASE ( 'random_heatflux' )
546                READ ( 13 )  random_heatflux
547             CASE ( 'rans_mode' )
548                READ ( 13 )  rans_mode
549             CASE ( 'rayleigh_damping_factor' )
550                READ ( 13 )  rayleigh_damping_factor
551             CASE ( 'rayleigh_damping_height' )
552                READ ( 13 )  rayleigh_damping_height
553             CASE ( 'recycling_width' )
554                READ ( 13 )  recycling_width
555             CASE ( 'ref_state' )
556                READ ( 13 )  ref_state
557             CASE ( 'reference_state' )
558                READ ( 13 )  reference_state
559             CASE ( 'residual_limit' )
560                READ ( 13 )  residual_limit
561             CASE ( 'roughness_length' )
562                READ ( 13 )  roughness_length
563             CASE ( 'run_coupled' )
564                READ ( 13 )  run_coupled
565             CASE ( 'runnr' )
566                READ ( 13 )  runnr
567             CASE ( 's_init' )
568                READ ( 13 )  s_init
569             CASE ( 's_surface' )
570                READ ( 13 )  s_surface
571             CASE ( 's_surface_initial_change' )
572                READ ( 13 )  s_surface_initial_change
573             CASE ( 's_vertical_gradient' )
574                READ ( 13 )  s_vertical_gradient
575             CASE ( 's_vertical_gradient_level' )
576                READ ( 13 )  s_vertical_gradient_level
577             CASE ( 's_vertical_gradient_level_ind' )
578                READ ( 13 )  s_vertical_gradient_level_ind
579             CASE ( 'scalar_advec' )
580                READ ( 13 )  scalar_advec
581             CASE ( 'simulated_time' )
582                READ ( 13 )  simulated_time
583             CASE ( 'spectrum_x' )
584                IF ( .NOT. ALLOCATED( spectrum_x ) )  THEN
585                   ALLOCATE( spectrum_x( 1:nx/2, 1:100, 1:10 ) )
586                ENDIF
587                READ ( 13 )  spectrum_x
588             CASE ( 'spectrum_y' )
589                IF ( .NOT. ALLOCATED( spectrum_y ) )  THEN
590                   ALLOCATE( spectrum_y( 1:ny/2, 1:100, 1:10 ) )
591                ENDIF
592                READ ( 13 )  spectrum_y
593             CASE ( 'spinup_time' )
594                READ ( 13 )  spinup_time
595             CASE ( 'surface_heatflux' )
596                READ ( 13 )  surface_heatflux
597             CASE ( 'surface_pressure' )
598                READ ( 13 )  surface_pressure
599             CASE ( 'surface_scalarflux' )
600                READ ( 13 )  surface_scalarflux
601             CASE ( 'surface_waterflux' )
602                READ ( 13 )  surface_waterflux
603             CASE ( 'time_coupling' )
604                READ ( 13 )  time_coupling
605             CASE ( 'time_disturb' )
606                READ ( 13 )  time_disturb
607             CASE ( 'time_do2d_xy' )
608                READ ( 13 )  time_do2d_xy
609             CASE ( 'time_do2d_xz' )
610                READ ( 13 )  time_do2d_xz
611             CASE ( 'time_do2d_yz' )
612                READ ( 13 )  time_do2d_yz
613             CASE ( 'time_do3d' )
614                READ ( 13 )  time_do3d
615             CASE ( 'time_do_av' )
616                READ ( 13 )  time_do_av
617             CASE ( 'time_do_sla' )
618                READ ( 13 )  time_do_sla
619             CASE ( 'time_domask' )
620                READ ( 13 )  time_domask
621             CASE ( 'time_dopr' )
622                READ ( 13 )  time_dopr
623             CASE ( 'time_dopr_av' )
624                READ ( 13 )  time_dopr_av
625             CASE ( 'time_dopr_listing' )
626                READ ( 13 )  time_dopr_listing
627             CASE ( 'time_dopts' )
628                READ ( 13 )  time_dopts
629             CASE ( 'time_dosp' )
630                READ ( 13 )  time_dosp
631             CASE ( 'time_dots' )
632                READ ( 13 )  time_dots
633             CASE ( 'time_radiation' )
634                READ ( 13 )  time_radiation
635             CASE ( 'time_restart' )
636                READ ( 13 )  time_restart
637             CASE ( 'time_run_control' )
638                READ ( 13 )  time_run_control
639             CASE ( 'time_since_reference_point' )
640                READ ( 13 )  time_since_reference_point
641             CASE ( 'time_virtual_measurement' )
642                READ ( 13 )  time_virtual_measurement
643             CASE ( 'timestep_scheme' )
644                READ ( 13 )  timestep_scheme
645             CASE ( 'top_heatflux' )
646                READ ( 13 )  top_heatflux
647             CASE ( 'top_momentumflux_u' )
648                READ ( 13 )  top_momentumflux_u
649             CASE ( 'top_momentumflux_v' )
650                READ ( 13 )  top_momentumflux_v
651             CASE ( 'top_scalarflux' )
652                READ ( 13 )  top_scalarflux
653             CASE ( 'topography' )
654                READ ( 13 )  topography
655             CASE ( 'topography_grid_convention' )
656                READ ( 13 )  topography_grid_convention
657             CASE ( 'tsc' )
658                READ ( 13 )  tsc
659             CASE ( 'tunnel_height' )
660                READ ( 13 )  tunnel_height
661             CASE ( 'tunnel_length' )
662                READ ( 13 )  tunnel_length
663             CASE ( 'tunnel_wall_depth' )
664                READ ( 13 )  tunnel_wall_depth
665             CASE ( 'tunnel_width_x' )
666                READ ( 13 )  tunnel_width_x
667             CASE ( 'tunnel_width_y' )
668                READ ( 13 )  tunnel_width_y
669             CASE ( 'turbulence_closure' )
670                READ ( 13 )  turbulence_closure
671             CASE ( 'turbulent_inflow' )
672                READ ( 13 )  turbulent_inflow
673             CASE ( 'u_bulk' )
674                READ ( 13 )  u_bulk
675             CASE ( 'u_init' )
676                READ ( 13 )  u_init
677             CASE ( 'u_max' )
678                READ ( 13 )  u_max
679             CASE ( 'u_max_ijk' )
680                READ ( 13 )  u_max_ijk
681             CASE ( 'ug' )
682                READ ( 13 )  ug
683             CASE ( 'ug_surface' )
684                READ ( 13 )  ug_surface
685             CASE ( 'ug_vertical_gradient' )
686                READ ( 13 )  ug_vertical_gradient
687             CASE ( 'ug_vertical_gradient_level' )
688                READ ( 13 )  ug_vertical_gradient_level
689             CASE ( 'ug_vertical_gradient_level_ind' )
690                READ ( 13 )  ug_vertical_gradient_level_ind
691             CASE ( 'use_surface_fluxes' )
692                READ ( 13 )  use_surface_fluxes
693             CASE ( 'use_top_fluxes' )
694                READ ( 13 )  use_top_fluxes
695             CASE ( 'use_ug_for_galilei_tr' )
696                READ ( 13 )  use_ug_for_galilei_tr
697             CASE ( 'use_upstream_for_tke' )
698                READ ( 13 )  use_upstream_for_tke
699             CASE ( 'v_bulk' )
700                READ ( 13 )  v_bulk
701             CASE ( 'v_init' )
702                READ ( 13 )  v_init
703             CASE ( 'v_max' )
704                READ ( 13 )  v_max
705             CASE ( 'v_max_ijk' )
706                READ ( 13 )  v_max_ijk
707             CASE ( 'vg' )
708                READ ( 13 )  vg
709             CASE ( 'vg_surface' )
710                READ ( 13 )  vg_surface
711             CASE ( 'vg_vertical_gradient' )
712                READ ( 13 )  vg_vertical_gradient
713             CASE ( 'vg_vertical_gradient_level' )
714                READ ( 13 )  vg_vertical_gradient_level
715             CASE ( 'vg_vertical_gradient_level_ind' )
716                READ ( 13 )  vg_vertical_gradient_level_ind
717             CASE ( 'virtual_flight' )
718                READ ( 13 )  virtual_flight
719             CASE ( 'vnest_init' )
720                READ ( 13 )  vnest_init
721             CASE ( 'volume_flow_area' )
722                READ ( 13 )  volume_flow_area
723             CASE ( 'volume_flow_initial' )
724                READ ( 13 )  volume_flow_initial
725             CASE ( 'subs_vertical_gradient' )
726                READ ( 13 )  subs_vertical_gradient
727             CASE ( 'subs_vertical_gradient_level' )
728                READ ( 13 )  subs_vertical_gradient_level
729             CASE ( 'subs_vertical_gradient_level_i' )
730                READ ( 13 )  subs_vertical_gradient_level_i
731             CASE ( 'w_max' )
732                READ ( 13 )  w_max
733             CASE ( 'w_max_ijk' )
734                READ ( 13 )  w_max_ijk
735             CASE ( 'wall_adjustment' )
736                READ ( 13 )  wall_adjustment
737             CASE ( 'wall_heatflux' )
738                READ ( 13 )  wall_heatflux
739             CASE ( 'wall_humidityflux' )
740                READ ( 13 )  wall_humidityflux
741             CASE ( 'wall_scalarflux' )
742                READ ( 13 )  wall_scalarflux
743             CASE ( 'y_shift' )
744                READ ( 13 )  y_shift
745             CASE ( 'z0h_factor' )
746                READ ( 13 )  z0h_factor
747             CASE ( 'zeta_max' )
748                READ ( 13 )  zeta_max
749             CASE ( 'zeta_min' )
750                READ ( 13 )  zeta_min
751             CASE ( 'z_i' )
752                READ ( 13 )  z_i
753
754             CASE DEFAULT
755!
756!--             Read global variables from of other modules
757                CALL module_interface_rrd_global( found )
758
759                IF ( .NOT. found )  THEN
760                   WRITE( message_string, * ) 'unknown variable named "',      &
761                                           restart_string(1:length),           &
762                                          '" found in global data from ',      & 
763                                          'prior run on PE ', myid
764                CALL message( 'rrd_global', 'PA0302', 1, 2, 0, 6, 0 )
765 
766                ENDIF
767
768          END SELECT
769!
770!--       Read next string
771          READ ( 13 )  length
772          READ ( 13 )  restart_string(1:length)   
773
774       ENDDO
775 
776
777    CALL close_file( 13 )
778
779   
780    END SUBROUTINE rrd_global
781
782
783
784!------------------------------------------------------------------------------!
785! Description:
786! ------------
787!> Skipping the global control variables from restart-file (binary format)
788!> except some information needed when reading restart data from a previous
789!> run which used a smaller total domain or/and a different domain decomposition
790!> (initializing_actions  == 'cyclic_fill').
791!------------------------------------------------------------------------------!
792
793    SUBROUTINE rrd_read_parts_of_global
794
795
796       CHARACTER (LEN=10) ::  version_on_file
797       CHARACTER (LEN=20) ::  momentum_advec_check
798       CHARACTER (LEN=20) ::  scalar_advec_check
799       CHARACTER (LEN=1)  ::  cdum
800
801       INTEGER(iwp) ::  max_pr_user_on_file
802       INTEGER(iwp) ::  nz_on_file
803       INTEGER(iwp) ::  statistic_regions_on_file
804       INTEGER(iwp) ::  tmp_mpru
805       INTEGER(iwp) ::  tmp_sr
806
807       REAL(wp), DIMENSION(:,:,:),   ALLOCATABLE ::  hom_sum_on_file
808       REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  hom_on_file
809
810
811       CALL check_open( 13 )
812
813       READ ( 13 )  length
814       READ ( 13 )  restart_string(1:length)
815       READ ( 13 )  version_on_file
816
817!
818!-- Read number of PEs and horizontal index bounds of all PEs used in previous
819!-- run
820       READ ( 13 )  length
821       READ ( 13 )  restart_string(1:length)
822
823       IF ( restart_string(1:length) /= 'numprocs' )  THEN
824          WRITE( message_string, * ) 'numprocs not found in data from prior ', &
825                                     'run on PE ', myid
826          CALL message( 'rrd_read_parts_of_global', 'PA0297', 1, 2, 0, 6, 0 )
827       ENDIF
828       READ ( 13 )  numprocs_previous_run
829
830       IF ( .NOT. ALLOCATED( hor_index_bounds_previous_run ) )  THEN
831          ALLOCATE( hor_index_bounds_previous_run(4,0:numprocs_previous_run-1) )
832       ENDIF
833
834       READ ( 13 )  length
835       READ ( 13 )  restart_string(1:length)
836
837       IF ( restart_string(1:length) /= 'hor_index_bounds' )  THEN
838          WRITE( message_string, * ) 'hor_index_bounds not found in data ',    &
839                                     'from prior run on PE ', myid
840          CALL message( 'rrd_read_parts_of_global', 'PA0298', 1, 2, 0, 6, 0 )
841       ENDIF
842       READ ( 13 )  hor_index_bounds_previous_run
843
844!
845!-- Read vertical number of gridpoints and number of different areas used
846!-- for computing statistics. Allocate arrays depending on these values,
847!-- which are needed for the following read instructions.
848       READ ( 13 )  length
849       READ ( 13 )  restart_string(1:length)
850
851       IF ( restart_string(1:length) /= 'nz' )  THEN
852          message_string = 'nz not found in restart data file'
853          CALL message( 'rrd_read_parts_of_global', 'PA0303', 1, 2, 0, 6, 0 )
854       ENDIF
855       READ ( 13 )  nz_on_file
856       IF ( nz_on_file /= nz )  THEN
857          WRITE( message_string, * ) 'mismatch concerning number of ',         &
858                                     'gridpoints along z:',                    &
859                                     '&nz on file    = "', nz_on_file, '"',    &
860                                     '&nz from run   = "', nz, '"'
861          CALL message( 'rrd_read_parts_of_global', 'PA0304', 1, 2, 0, 6, 0 )
862       ENDIF
863
864       READ ( 13 )  length
865       READ ( 13 )  restart_string(1:length)
866
867       IF ( restart_string(1:length) /= 'max_pr_user' )  THEN
868          message_string = 'max_pr_user not found in restart data file'
869          CALL message( 'rrd_read_parts_of_global', 'PA0305', 1, 2, 0, 6, 0 )
870       ENDIF
871       READ ( 13 )  max_pr_user_on_file
872       IF ( max_pr_user_on_file /= max_pr_user )  THEN
873          WRITE( message_string, * ) 'number of user profiles on res',         &
874                                     'tart data file differs from the ',       &
875                                     'current run:&max_pr_user on file    = "',&
876                                     max_pr_user_on_file, '"',                 &
877                                     '&max_pr_user from run   = "',            &
878                                     max_pr_user, '"'
879          CALL message( 'rrd_read_parts_of_global', 'PA0306', 0, 0, 0, 6, 0 )
880          tmp_mpru = MIN( max_pr_user_on_file, max_pr_user )
881       ELSE
882          tmp_mpru = max_pr_user
883       ENDIF
884
885       READ ( 13 )  length
886       READ ( 13 )  restart_string(1:length)
887
888       IF ( restart_string(1:length) /= 'statistic_regions' )  THEN
889          message_string = 'statistic_regions not found in restart data file'
890          CALL message( 'rrd_read_parts_of_global', 'PA0307', 1, 2, 0, 6, 0 )
891       ENDIF
892       READ ( 13 )  statistic_regions_on_file
893       IF ( statistic_regions_on_file /= statistic_regions )  THEN
894          WRITE( message_string, * ) 'statistic regions on restart data file ',&
895                                     'differ from the current run:',           &
896                                     '&statistic regions on file    = "',      &
897                                     statistic_regions_on_file, '"',           &
898                                     '&statistic regions from run   = "',      &
899                                      statistic_regions, '"',                  &
900                                     '&statistic data may be lost!'
901          CALL message( 'rrd_read_parts_of_global', 'PA0308', 0, 1, 0, 6, 0 )
902          tmp_sr = MIN( statistic_regions_on_file, statistic_regions )
903       ELSE
904          tmp_sr = statistic_regions
905       ENDIF
906
907!
908!-- Now read and check some control parameters and skip the rest
909       READ ( 13 )  length
910       READ ( 13 )  restart_string(1:length)
911
912       DO  WHILE ( restart_string(1:length) /= 'binary_version_local' )
913
914          SELECT CASE ( restart_string(1:length) )
915
916             CASE ( 'average_count_pr' )
917                READ ( 13 )  average_count_pr
918                IF ( average_count_pr /= 0 )  THEN
919                   WRITE( message_string, * ) 'inflow profiles not ',          &
920                                  'temporally averaged. &Averaging will be ',  &
921                                  'done now using', average_count_pr,          &
922                                  ' samples.'
923                   CALL message( 'rrd_read_parts_of_global', 'PA0309',         &
924                                 0, 1, 0, 6, 0 )
925                ENDIF
926
927             CASE ( 'hom' )
928                ALLOCATE( hom_on_file(0:nz+1,2,pr_palm+max_pr_user_on_file,    &
929                          0:statistic_regions_on_file) )
930                READ ( 13 )  hom_on_file
931                hom(:,:,1:pr_palm+tmp_mpru,0:tmp_sr) =                         &
932                             hom_on_file(:,:,1:pr_palm+tmp_mpru,0:tmp_sr)
933                DEALLOCATE( hom_on_file )
934
935             CASE ( 'hom_sum' )
936                ALLOCATE( hom_sum_on_file(0:nz+1,pr_palm+max_pr_user_on_file,  &
937                          0:statistic_regions_on_file) )
938                READ ( 13 )  hom_sum_on_file
939                hom_sum(:,1:pr_palm+tmp_mpru,0:tmp_sr) =                       &
940                             hom_sum_on_file(:,1:pr_palm+tmp_mpru,0:tmp_sr)
941                DEALLOCATE( hom_sum_on_file )
942
943             CASE ( 'momentum_advec' )
944                momentum_advec_check = momentum_advec
945                READ ( 13 )  momentum_advec
946                IF ( TRIM( momentum_advec_check ) /= TRIM( momentum_advec ) )  &
947                THEN
948                   WRITE( message_string, * ) 'momentum_advec of the restart ',&
949                                  'run differs from momentum_advec of the ',   &
950                                  'initial run.'
951                   CALL message( 'rrd_read_parts_of_global', 'PA0100',         &
952                                 1, 2, 0, 6, 0 )
953                ENDIF
954
955             CASE ( 'nx' )
956                READ ( 13 )  nx_on_file
957
958             CASE ( 'ny' )
959                READ ( 13 )  ny_on_file
960
961             CASE ( 'ref_state' )
962                READ ( 13 )  ref_state
963
964             CASE ( 'scalar_advec' )
965                scalar_advec_check = scalar_advec
966                READ ( 13 )  scalar_advec
967                IF ( TRIM( scalar_advec_check ) /= TRIM( scalar_advec ) )      &
968                THEN
969                   WRITE( message_string, * ) 'scalar_advec of the restart ',  &
970                                  'run differs from scalar_advec of the ',     &
971                                  'initial run.'
972                   CALL message( 'rrd_read_parts_of_global', 'PA0101',         &
973                                 1, 2, 0, 6, 0 )
974                ENDIF
975
976             CASE DEFAULT
977
978                READ ( 13 )  cdum
979
980          END SELECT
981
982          READ ( 13 )  length
983          READ ( 13 )  restart_string(1:length)
984
985       ENDDO
986
987!
988!-- Calculate the temporal average of vertical profiles, if neccessary
989    IF ( average_count_pr /= 0 )  THEN
990       hom_sum = hom_sum / REAL( average_count_pr, KIND=wp )
991    ENDIF
992
993
994    CALL close_file( 13 )
995
996
997    END SUBROUTINE rrd_read_parts_of_global
998
999
1000! Description:
1001! ------------
1002!> Reads processor specific data of variables and arrays from restart file
1003!> (binary format).
1004!------------------------------------------------------------------------------!
1005 SUBROUTINE rrd_local
1006
1007
1008    CHARACTER (LEN=7)  ::  myid_char_save
1009    CHARACTER (LEN=10) ::  binary_version_local
1010    CHARACTER (LEN=10) ::  version_on_file
1011
1012    INTEGER(iwp) ::  files_to_be_opened  !<
1013    INTEGER(iwp) ::  i                   !<
1014    INTEGER(iwp) ::  j                   !<
1015    INTEGER(iwp) ::  k                   !<
1016    INTEGER(iwp) ::  myid_on_file        !<
1017    INTEGER(iwp) ::  numprocs_on_file    !<
1018    INTEGER(iwp) ::  nxlc                !<
1019    INTEGER(iwp) ::  nxlf                !<
1020    INTEGER(iwp) ::  nxlpr               !<
1021    INTEGER(iwp) ::  nxl_on_file         !<
1022    INTEGER(iwp) ::  nxrc                !<
1023    INTEGER(iwp) ::  nxrf                !<
1024    INTEGER(iwp) ::  nxrpr               !<
1025    INTEGER(iwp) ::  nxr_on_file         !<
1026    INTEGER(iwp) ::  nync                !<
1027    INTEGER(iwp) ::  nynf                !<
1028    INTEGER(iwp) ::  nynpr               !<
1029    INTEGER(iwp) ::  nyn_on_file         !<
1030    INTEGER(iwp) ::  nysc                !<
1031    INTEGER(iwp) ::  nysf                !<
1032    INTEGER(iwp) ::  nyspr               !<
1033    INTEGER(iwp) ::  nys_on_file         !<
1034    INTEGER(iwp) ::  nzb_on_file         !<
1035    INTEGER(iwp) ::  nzt_on_file         !<
1036    INTEGER(iwp) ::  offset_x            !<
1037    INTEGER(iwp) ::  offset_y            !<
1038    INTEGER(iwp) ::  shift_x             !<
1039    INTEGER(iwp) ::  shift_y             !<
1040
1041    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  file_list       !<
1042    INTEGER(iwp), DIMENSION(numprocs_previous_run) ::  overlap_count   !<
1043
1044    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa      !<
1045    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa      !<
1046    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa      !<
1047    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa      !<
1048    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa  !<
1049    INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya  !<
1050
1051    INTEGER(isp), DIMENSION(:,:),   ALLOCATABLE ::  tmp_2d_id_random   !< temporary array for storing random generator data
1052    INTEGER(isp), DIMENSION(:,:,:), ALLOCATABLE ::  tmp_2d_seq_random  !< temporary array for storing random generator data
1053
1054    LOGICAL ::  found
1055
1056    REAL(wp), DIMENSION(:,:),   ALLOCATABLE   ::  tmp_2d         !< temporary array for storing 2D data
1057    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d         !< temporary array for storing 3D data
1058    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_3d_non_standard !< temporary array for storing 3D data
1059                                                                 !< with non standard dimensions
1060
1061!
1062!-- Read data from previous model run.
1063    CALL cpu_log( log_point_s(14), 'rrd_local', 'start' )
1064
1065!
1066!-- Check which of the restart files contain data needed for the subdomain
1067!-- of this PE
1068    files_to_be_opened = 0
1069
1070    DO  i = 1, numprocs_previous_run
1071!
1072!--    Store array bounds of the previous run ("pr") in temporary scalars
1073       nxlpr = hor_index_bounds_previous_run(1,i-1)
1074       nxrpr = hor_index_bounds_previous_run(2,i-1)
1075       nyspr = hor_index_bounds_previous_run(3,i-1)
1076       nynpr = hor_index_bounds_previous_run(4,i-1)
1077
1078!
1079!--    Determine the offsets. They may be non-zero in case that the total domain
1080!--    on file is smaller than the current total domain.
1081       offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 )
1082       offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 )
1083
1084!
1085!--    Start with this offset and then check, if the subdomain on file
1086!--    matches another time(s) in the current subdomain by shifting it
1087!--    for nx_on_file+1, ny_on_file+1 respectively
1088   
1089       shift_y = 0
1090       j       = 0
1091       DO WHILE (  nyspr+shift_y <= nyn-offset_y )
1092         
1093          IF ( nynpr+shift_y >= nys-offset_y ) THEN
1094
1095             shift_x = 0
1096             DO WHILE ( nxlpr+shift_x <= nxr-offset_x )
1097               
1098                IF ( nxrpr+shift_x >= nxl-offset_x ) THEN
1099                   j = j +1
1100                   IF ( j > 1000 )  THEN
1101!
1102!--                   Array bound exceeded
1103                      message_string = 'data from subdomain of previous' //                        &
1104                                       ' run mapped more than 1000 times'
1105                      CALL message( 'rrd_local', 'PA0284', 2, 2, -1, 6, 1 )
1106                   ENDIF
1107
1108                   IF ( j == 1 )  THEN
1109                      files_to_be_opened = files_to_be_opened + 1
1110                      file_list(files_to_be_opened) = i-1
1111                   ENDIF
1112                     
1113                   offset_xa(files_to_be_opened,j) = offset_x + shift_x
1114                   offset_ya(files_to_be_opened,j) = offset_y + shift_y
1115!
1116!--                Index bounds of overlapping data
1117                   nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x, nxlpr )
1118                   nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x, nxrpr )
1119                   nysfa(files_to_be_opened,j) = MAX( nys-offset_y-shift_y, nyspr )
1120                   nynfa(files_to_be_opened,j) = MIN( nyn-offset_y-shift_y, nynpr )
1121
1122                ENDIF
1123
1124                shift_x = shift_x + ( nx_on_file + 1 )
1125             ENDDO
1126       
1127          ENDIF
1128             
1129          shift_y = shift_y + ( ny_on_file + 1 )             
1130       ENDDO
1131         
1132       IF ( j > 0 )  overlap_count(files_to_be_opened) = j
1133         
1134    ENDDO
1135   
1136!
1137!-- Save the id-string of the current process, since myid_char may now be used
1138!-- to open files created by PEs with other id.
1139    myid_char_save = myid_char
1140
1141    IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run )  THEN
1142       WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed ',                     &
1143                                  'in restart run & PE', myid, ' will read from files ',           &
1144                                  file_list(1:files_to_be_opened)
1145       CALL message( 'rrd_local', 'PA0285', 0, 0, 0, 6, 0 )
1146    ENDIF
1147
1148!
1149!-- Read data from all restart files determined above
1150    DO  i = 1, files_to_be_opened
1151 
1152       j = file_list(i)
1153!
1154!--    Set the filename (underscore followed by four digit processor id)
1155       WRITE (myid_char,'(''_'',I6.6)')  j
1156
1157!
1158!--    Open the restart file. If this file has been created by PE0 (_000000),
1159!--    the global variables at the beginning of the file have to be skipped
1160!--    first.
1161       CALL check_open( 13 )
1162       IF ( j == 0 )  CALL rrd_skip_global
1163
1164!
1165!--    First compare the version numbers
1166       READ ( 13 )  length
1167       READ ( 13 )  restart_string(1:length)
1168       READ ( 13 )  version_on_file
1169
1170       binary_version_local = '4.7'
1171       IF ( TRIM( version_on_file ) /= TRIM( binary_version_local ) )  THEN
1172          WRITE( message_string, * ) 'version mismatch concerning ',                               &
1173                                     'binary_version_local:',                                      &
1174                                     '&version on file    = "', TRIM( version_on_file ), '"',      &
1175                                     '&version in program = "', TRIM( binary_version_local ), '"'
1176          CALL message( 'rrd_local', 'PA0286', 1, 2, 0, 6, 0 )
1177       ENDIF
1178
1179!
1180!--    Read number of processors, processor-id, and array ranges.
1181!--    Compare the array ranges with those stored in the index bound array.
1182       READ ( 13 )  numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file, nys_on_file,         &
1183                    nyn_on_file, nzb_on_file, nzt_on_file
1184
1185       IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) )  THEN
1186          WRITE( message_string, * ) 'problem with index bound nxl on ',                           &
1187                                     'restart file "', myid_char, '"',                             &
1188                                     '&nxl = ', nxl_on_file, ' but it should be',                  &
1189                                     '&= ', hor_index_bounds_previous_run(1,j),                    &
1190                                     '&from the index bound information array'
1191          CALL message( 'rrd_local', 'PA0287', 2, 2, -1, 6, 1 )
1192       ENDIF
1193
1194       IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
1195           WRITE( message_string, * ) 'problem with index bound nxr on ',                          &
1196                                      'restart file "', myid_char, '"'  ,                          &
1197                                      ' nxr = ', nxr_on_file, ' but it should be',                 &
1198                                      ' = ', hor_index_bounds_previous_run(2,j),                   &
1199                                      ' from the index bound information array'
1200          CALL message( 'rrd_local', 'PA0288', 2, 2, -1, 6, 1 )
1201
1202       ENDIF
1203
1204       IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
1205          WRITE( message_string, * ) 'problem with index bound nys on ',                           &
1206                                     'restart file "', myid_char, '"',                             &
1207                                     '&nys = ', nys_on_file, ' but it should be',                  &
1208                                     '&= ', hor_index_bounds_previous_run(3,j),                    &
1209                                     '&from the index bound information array'
1210          CALL message( 'rrd_local', 'PA0289', 2, 2, -1, 6, 1 ) 
1211       ENDIF
1212
1213       IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
1214          WRITE( message_string, * ) 'problem with index bound nyn on ',                           &
1215                                     'restart file "', myid_char, '"',                             &
1216                                     '&nyn = ', nyn_on_file, ' but it should be',                  &
1217                                     '&= ', hor_index_bounds_previous_run(4,j),                    &
1218                                     '&from the index bound information array'
1219          CALL message( 'rrd_local', 'PA0290', 2, 2, -1, 6, 1 ) 
1220       ENDIF
1221
1222       IF ( nzb_on_file /= nzb )  THEN
1223          WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
1224                                     'from prior run on PE ', myid,                                &
1225                                     '&nzb on file = ', nzb_on_file,                               &
1226                                     '&nzb         = ', nzb
1227          CALL message( 'rrd_local', 'PA0291', 1, 2, 0, 6, 0 ) 
1228       ENDIF
1229
1230       IF ( nzt_on_file /= nzt )  THEN
1231          WRITE( message_string, * ) 'mismatch between actual data and data ',                     &
1232                                     'from prior run on PE ', myid,                                &
1233                                     '&nzt on file = ', nzt_on_file,                               &
1234                                     '&nzt         = ', nzt
1235          CALL message( 'rrd_local', 'PA0292', 1, 2, 0, 6, 0 ) 
1236       ENDIF
1237
1238!
1239!--    Allocate temporary arrays sized as the arrays on the restart file
1240       ALLOCATE( tmp_2d(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp),      &
1241                 tmp_3d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,                               &
1242                        nxl_on_file-nbgp:nxr_on_file+nbgp) )
1243
1244!
1245!--    Read arrays
1246!--    ATTENTION: If the following read commands have been altered, the
1247!--    ---------- version number of the variable binary_version_local must
1248!--               be altered, too. Furthermore, the output list of arrays in
1249!--               wrd_write_local must also be altered
1250!--               accordingly.
1251       READ ( 13 )  length
1252       READ ( 13 )  restart_string(1:length)
1253       
1254
1255!
1256!--    Loop over processor specific field data
1257       DO  WHILE ( restart_string(1:length) /= '*** end ***' )
1258
1259!
1260!--       Map data on file as often as needed (data are read only for k=1)
1261          DO  k = 1, overlap_count(i)
1262
1263             found = .FALSE.
1264             
1265!
1266!--          Get the index range of the subdomain on file which overlap with
1267!--          the current subdomain
1268             nxlf = nxlfa(i,k)
1269             nxlc = nxlfa(i,k) + offset_xa(i,k)
1270             nxrf = nxrfa(i,k)
1271             nxrc = nxrfa(i,k) + offset_xa(i,k)
1272             nysf = nysfa(i,k)
1273             nysc = nysfa(i,k) + offset_ya(i,k)
1274             nynf = nynfa(i,k)
1275             nync = nynfa(i,k) + offset_ya(i,k)
1276
1277
1278             SELECT CASE ( restart_string(1:length) )
1279
1280                CASE ( 'ghf_av' )
1281                   IF ( .NOT. ALLOCATED( ghf_av ) )  THEN
1282                      ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) )
1283                   ENDIF
1284                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1285                   ghf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1286                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1287
1288                CASE ( 'e' )
1289                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1290                   e(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1291                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1292
1293                CASE ( 'e_av' )
1294                   IF ( .NOT. ALLOCATED( e_av ) )  THEN
1295                      ALLOCATE( e_av(nzb:nzt+1,nys-nbgp:nyn+nbgp,                                  &
1296                                     nxl-nbgp:nxr+nbgp) )   
1297                   ENDIF
1298                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1299                   e_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1300                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1301
1302                CASE ( 'kh' )
1303                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1304                   kh(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1305                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1306
1307                CASE ( 'kh_av' )
1308                   IF ( .NOT. ALLOCATED( kh_av ) )  THEN
1309                      ALLOCATE( kh_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1310                   ENDIF
1311                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1312                   kh_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1313                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1314
1315                CASE ( 'km' )
1316                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1317                   km(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1318                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1319
1320                CASE ( 'km_av' )
1321                   IF ( .NOT. ALLOCATED( km_av ) )  THEN
1322                      ALLOCATE( km_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1323                   ENDIF
1324                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1325                   km_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1326                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1327
1328                CASE ( 'lpt_av' )
1329                   IF ( .NOT. ALLOCATED( lpt_av ) )  THEN
1330                      ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1331                   ENDIF
1332                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1333                   lpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
1334                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1335
1336                CASE ( 'lwp_av' )
1337                   IF ( .NOT. ALLOCATED( lwp_av ) )  THEN
1338                      ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) )
1339                   ENDIF
1340                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1341                   lwp_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1342                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1343
1344                CASE ( 'p' )
1345                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1346                   p(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1347                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1348
1349                CASE ( 'p_av' )
1350                   IF ( .NOT. ALLOCATED( p_av ) )  THEN
1351                      ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1352                   ENDIF
1353                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1354                   p_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1355                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1356
1357                CASE ( 'pt' )
1358                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1359                   pt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1360                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1361
1362                CASE ( 'pt_av' )
1363                   IF ( .NOT. ALLOCATED( pt_av ) )  THEN
1364                      ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1365                   ENDIF
1366                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1367                   pt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1368                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1369
1370                CASE ( 'pt_2m_av' )
1371                   IF ( .NOT. ALLOCATED( pt_2m_av ) )  THEN
1372                      ALLOCATE( pt_2m_av(nysg:nyng,nxlg:nxrg) )
1373                   ENDIF
1374                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1375                   pt_2m_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                            &
1376                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1377
1378                CASE ( 'q' )
1379                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1380                   q(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1381                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1382
1383                CASE ( 'q_av' )
1384                   IF ( .NOT. ALLOCATED( q_av ) )  THEN
1385                      ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ))
1386                   ENDIF
1387                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1388                   q_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1389                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1390
1391                CASE ( 'ql' )
1392                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1393                   ql(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                 &
1394                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1395
1396                CASE ( 'ql_av' )
1397                   IF ( .NOT. ALLOCATED( ql_av ) )  THEN
1398                      ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1399                   ENDIF
1400                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1401                   ql_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1402                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1403
1404                CASE ( 'qsws_av' )
1405                   IF ( .NOT. ALLOCATED( qsws_av ) )  THEN
1406                      ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) )
1407                   ENDIF 
1408                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1409                   qsws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
1410                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1411
1412                CASE ( 'qv_av' )
1413                   IF ( .NOT. ALLOCATED( qv_av ) )  THEN
1414                      ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1415                   ENDIF
1416                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1417                   qv_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                              &
1418                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1419
1420                CASE ( 'r_a_av' )
1421                   IF ( .NOT. ALLOCATED( r_a_av ) )  THEN
1422                      ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) )
1423                   ENDIF
1424                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1425                   r_a_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1426                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1427
1428                CASE ( 'random_iv' )  ! still unresolved issue
1429                   IF ( k == 1 )  READ ( 13 )  random_iv
1430                   IF ( k == 1 )  READ ( 13 )  random_iy
1431
1432                CASE ( 'seq_random_array' )
1433                   ALLOCATE( tmp_2d_id_random(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
1434                   ALLOCATE( tmp_2d_seq_random(5,nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) )
1435                   IF ( .NOT. ALLOCATED( id_random_array ) )  THEN
1436                      ALLOCATE( id_random_array(nys:nyn,nxl:nxr) )
1437                   ENDIF
1438                   IF ( .NOT. ALLOCATED( seq_random_array ) )  THEN
1439                      ALLOCATE( seq_random_array(5,nys:nyn,nxl:nxr) )
1440                   ENDIF
1441                   IF ( k == 1 )  READ ( 13 )  tmp_2d_id_random
1442                   IF ( k == 1 )  READ ( 13 )  tmp_2d_seq_random
1443                   id_random_array(nysc:nync,nxlc:nxrc) = tmp_2d_id_random(nysf:nynf,nxlf:nxrf)
1444                   seq_random_array(:,nysc:nync,nxlc:nxrc) = tmp_2d_seq_random(:,nysf:nynf,nxlf:nxrf)
1445                   DEALLOCATE( tmp_2d_id_random, tmp_2d_seq_random )
1446
1447                CASE ( 's' )
1448                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1449                   s(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1450                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1451
1452                CASE ( 's_av' )
1453                   IF ( .NOT. ALLOCATED( s_av ) )  THEN
1454                      ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
1455                   ENDIF
1456                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1457                   s_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1458                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1459
1460                CASE ( 'shf_av' )
1461                   IF ( .NOT. ALLOCATED( shf_av ) )  THEN
1462                      ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) )
1463                   ENDIF
1464                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1465                   shf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
1466                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1467                   
1468                CASE ( 'ssws_av' )
1469                   IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
1470                      ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) )
1471                   ENDIF 
1472                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1473                   ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                             &
1474                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1475
1476                CASE ( 'ti_av' )
1477                   IF ( .NOT. ALLOCATED( ti_av ) )  THEN
1478                      ALLOCATE( ti_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
1479                   ENDIF
1480                   IF ( k == 1 )  THEN
1481                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
1482                                                    nxl_on_file:nxr_on_file) )
1483                      READ ( 13 )  tmp_3d_non_standard
1484                   ENDIF
1485                   ti_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
1486
1487                CASE ( 'ts_av' )
1488                   IF ( .NOT. ALLOCATED( ts_av ) )  THEN
1489                      ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) )
1490                   ENDIF
1491                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1492                   ts_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
1493                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1494
1495                CASE ( 'tsurf_av' )
1496                   IF ( .NOT. ALLOCATED( tsurf_av ) )  THEN
1497                      ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) )
1498                   ENDIF
1499                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1500                   tsurf_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
1501                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1502
1503                CASE ( 'u' )
1504                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1505                   u(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1506                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1507
1508                CASE ( 'u_av' )
1509                   IF ( .NOT. ALLOCATED( u_av ) )  THEN
1510                      ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1511                   ENDIF
1512                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1513                   u_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1514                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1515                     
1516                CASE ( 'uu_av' )
1517                   IF ( .NOT. ALLOCATED( uu_av ) )  THEN
1518                      ALLOCATE( uu_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
1519                   ENDIF
1520                   IF ( k == 1 )  THEN
1521                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
1522                                                    nxl_on_file:nxr_on_file) )
1523                      READ ( 13 )  tmp_3d_non_standard
1524                   ENDIF
1525                   uu_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
1526
1527                CASE ( 'u_m_l' )
1528                   IF ( k == 1 )  THEN
1529                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
1530                                                    1:2) )
1531                      READ ( 13 )  tmp_3d_non_standard
1532                   ENDIF
1533                   IF ( bc_radiation_l )  THEN
1534                      u_m_l(:,nysc-nbgp:nync+nbgp,:) =  tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
1535                   ENDIF
1536
1537                CASE ( 'u_m_n' )
1538                   IF ( k == 1 )  THEN
1539                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
1540                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
1541                      READ ( 13 )  tmp_3d_non_standard
1542                   ENDIF
1543                   IF ( bc_radiation_n )  THEN
1544                      u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
1545                   ENDIF
1546
1547                CASE ( 'u_m_r' )
1548                   IF ( k == 1 )  THEN
1549                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
1550                                                    nx-1:nx) )
1551                      READ ( 13 )  tmp_3d_non_standard
1552                   ENDIF
1553                   IF ( bc_radiation_r )  THEN
1554                      u_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
1555                   ENDIF
1556
1557                CASE ( 'u_m_s' )
1558                   IF ( k == 1 )  THEN
1559                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
1560                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
1561                      READ ( 13 )  tmp_3d_non_standard
1562                   ENDIF
1563                   IF ( bc_radiation_s )  THEN
1564                      u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
1565                   ENDIF
1566
1567                CASE ( 'us_av' )
1568                   IF ( .NOT. ALLOCATED( us_av ) )  THEN
1569                      ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) )
1570                   ENDIF
1571                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1572                   us_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
1573                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1574
1575                CASE ( 'v' )
1576                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1577                   v(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1578                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1579
1580                CASE ( 'v_av' )
1581                   IF ( .NOT. ALLOCATED( v_av ) )  THEN
1582                      ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1583                   ENDIF
1584                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1585                   v_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1586                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1587                     
1588                CASE ( 'vv_av' )
1589                   IF ( .NOT. ALLOCATED( vv_av ) )  THEN
1590                      ALLOCATE( vv_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
1591                   ENDIF
1592                   IF ( k == 1 )  THEN
1593                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
1594                                                    nxl_on_file:nxr_on_file) )
1595                      READ ( 13 )  tmp_3d_non_standard
1596                   ENDIF
1597                   vv_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
1598
1599                CASE ( 'v_m_l' )
1600                   IF ( k == 1 )  THEN
1601                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
1602                                                    0:1) )
1603                      READ ( 13 )  tmp_3d_non_standard
1604                   ENDIF
1605                   IF ( bc_radiation_l )  THEN
1606                      v_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
1607                   ENDIF
1608
1609                CASE ( 'v_m_n' )
1610                   IF ( k == 1 )  THEN
1611                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
1612                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
1613                      READ ( 13 )  tmp_3d_non_standard
1614                   ENDIF
1615                   IF ( bc_radiation_n )  THEN
1616                      v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
1617                   ENDIF
1618
1619                CASE ( 'v_m_r' )
1620                   IF ( k == 1 )  THEN
1621                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
1622                                                    nx-1:nx) )
1623                      READ ( 13 )  tmp_3d_non_standard
1624                   ENDIF
1625                   IF ( bc_radiation_r )  THEN
1626                      v_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
1627                   ENDIF
1628
1629                CASE ( 'v_m_s' )
1630                   IF ( k == 1 )  THEN
1631                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,1:2,                                 &
1632                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
1633                      READ ( 13 )  tmp_3d_non_standard
1634                   ENDIF
1635                   IF ( bc_radiation_s )  THEN
1636                      v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
1637                   ENDIF
1638
1639                CASE ( 'vpt' )
1640                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1641                   vpt(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                &
1642                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1643
1644                CASE ( 'vpt_av' )
1645                   IF ( .NOT. ALLOCATED( vpt_av ) )  THEN
1646                      ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1647                   ENDIF
1648                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1649                   vpt_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                             &
1650                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1651
1652                CASE ( 'w' )
1653                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1654                   w(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                  &
1655                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1656
1657                CASE ( 'w_av' )
1658                   IF ( .NOT. ALLOCATED( w_av ) )  THEN
1659                      ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
1660                   ENDIF
1661                   IF ( k == 1 )  READ ( 13 )  tmp_3d
1662                   w_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                               &
1663                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1664                     
1665                CASE ( 'ww_av' )
1666                   IF ( .NOT. ALLOCATED( ww_av ) )  THEN
1667                      ALLOCATE( ww_av(nzb:nzt+1,nys:nyn,nxl:nxr) )
1668                   ENDIF
1669                   IF ( k == 1 )  THEN
1670                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file:nyn_on_file,             &
1671                                                    nxl_on_file:nxr_on_file) )
1672                      READ ( 13 )  tmp_3d_non_standard
1673                   ENDIF
1674                   ww_av(:,nysc:nync,nxlc:nxrc) = tmp_3d_non_standard(:,nysf:nynf,nxlf:nxrf)
1675
1676                CASE ( 'w_m_l' )
1677                   IF ( k == 1 )  THEN
1678                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
1679                                                    0:1) )
1680                      READ ( 13 )  tmp_3d_non_standard
1681                   ENDIF
1682                   IF ( bc_radiation_l )  THEN
1683                      w_m_l(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
1684                   ENDIF
1685
1686                CASE ( 'w_m_n' )
1687                   IF ( k == 1 )  THEN
1688                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,ny-1:ny,                             &
1689                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
1690                      READ ( 13 )  tmp_3d_non_standard
1691                   ENDIF
1692                   IF ( bc_radiation_n )  THEN
1693                      w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
1694                   ENDIF
1695
1696                CASE ( 'w_m_r' )
1697                   IF ( k == 1 )  THEN
1698                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,   &
1699                                                    nx-1:nx) )
1700                      READ ( 13 )  tmp_3d_non_standard
1701                   ENDIF
1702                   IF ( bc_radiation_r )  THEN
1703                      w_m_r(:,nysc-nbgp:nync+nbgp,:) = tmp_3d_non_standard(:,nysf-nbgp:nynf+nbgp,:)
1704                   ENDIF
1705
1706                CASE ( 'w_m_s' )
1707                   IF ( k == 1 )  THEN
1708                      ALLOCATE( tmp_3d_non_standard(nzb:nzt+1,0:1,                                 &
1709                                                    nxl_on_file-nbgp:nxr_on_file+nbgp) )
1710                      READ ( 13 )  tmp_3d_non_standard
1711                   ENDIF
1712                   IF ( bc_radiation_s )  THEN
1713                      w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) = tmp_3d_non_standard(:,:,nxlf-nbgp:nxrf+nbgp)
1714                   ENDIF
1715
1716                CASE ( 'z0_av' )
1717                   IF ( .NOT. ALLOCATED( z0_av ) )  THEN
1718                      ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) )
1719                   ENDIF
1720                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1721                   z0_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                               &
1722                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1723
1724                CASE ( 'z0h_av' )
1725                   IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
1726                      ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) )
1727                   ENDIF
1728                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1729                   z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
1730                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1731
1732                CASE ( 'z0q_av' )
1733                   IF ( .NOT. ALLOCATED( z0q_av ) )  THEN
1734                      ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) )
1735                   ENDIF
1736                   IF ( k == 1 )  READ ( 13 )  tmp_2d
1737                   z0q_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =                              &
1738                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
1739
1740                CASE DEFAULT
1741
1742!
1743!--                Read restart data of surfaces
1744                   IF ( .NOT. found )  CALL surface_rrd_local( k, nxlf, nxlc, nxl_on_file, nxrf,   &
1745                                                               nxr_on_file, nynf, nyn_on_file,     &
1746                                                               nysf, nysc, nys_on_file, found )
1747!
1748!--                Read restart data of other modules
1749                   IF ( .NOT. found ) CALL module_interface_rrd_local(                             &
1750                                                               k, nxlf, nxlc, nxl_on_file, nxrf,   &
1751                                                               nxrc, nxr_on_file, nynf, nync,      &
1752                                                               nyn_on_file, nysf, nysc,            &
1753                                                               nys_on_file, tmp_2d, tmp_3d, found )
1754
1755
1756                   IF ( .NOT. found )  THEN
1757                      WRITE( message_string, * ) 'unknown variable named "',                       &
1758                                                 restart_string(1:length),                         &
1759                                                '" found in subdomain data ',                      &
1760                                                'from prior run on PE ', myid
1761                      CALL message( 'rrd_local', 'PA0302', 1, 2, 0, 6, 0 )
1762 
1763                   ENDIF
1764
1765             END SELECT
1766
1767          ENDDO ! overlaploop
1768
1769!
1770!--       Deallocate non standard array needed for specific variables only
1771          IF ( ALLOCATED( tmp_3d_non_standard ) )  DEALLOCATE( tmp_3d_non_standard )
1772
1773!
1774!--       Read next character string
1775          READ ( 13 )  length
1776          READ ( 13 )  restart_string(1:length)
1777
1778       ENDDO ! dataloop
1779
1780!
1781!--    Close the restart file
1782       CALL close_file( 13 )
1783
1784       DEALLOCATE( tmp_2d, tmp_3d )
1785
1786    ENDDO  ! loop over restart files
1787
1788!
1789!-- Restore the original filename for the restart file to be written
1790    myid_char = myid_char_save
1791
1792!
1793!-- End of time measuring for reading binary data
1794    CALL cpu_log( log_point_s(14), 'rrd_local', 'stop' )
1795
1796 END SUBROUTINE rrd_local
1797
1798
1799!------------------------------------------------------------------------------!
1800! Description:
1801! ------------
1802!> Skipping the global control variables from restart-file (binary format)
1803!------------------------------------------------------------------------------!
1804
1805    SUBROUTINE rrd_skip_global
1806
1807
1808       CHARACTER (LEN=1) ::  cdum
1809
1810
1811       READ ( 13 )  length
1812       READ ( 13 )  restart_string(1:length)
1813
1814       DO  WHILE ( restart_string(1:length) /= 'binary_version_local' )
1815
1816          READ ( 13 )  cdum
1817          READ ( 13 )  length
1818          READ ( 13 )  restart_string(1:length)
1819
1820       ENDDO
1821
1822       BACKSPACE ( 13 )
1823       BACKSPACE ( 13 )
1824
1825
1826    END SUBROUTINE rrd_skip_global
1827
1828
1829 END MODULE read_restart_data_mod
Note: See TracBrowser for help on using the repository browser.