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

Last change on this file since 2898 was 2894, checked in by Giersch, 6 years ago

Reading/Writing? data in case of restart runs revised

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