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

Last change on this file since 4249 was 4227, checked in by gronemeier, 5 years ago

implement new palm_date_time_mod; replaced namelist parameters time_utc_init and day_of_year_init by origin_date_time

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