Changeset 2894


Ignore:
Timestamp:
Mar 15, 2018 9:17:58 AM (7 years ago)
Author:
Giersch
Message:

Reading/Writing? data in case of restart runs revised

Location:
palm/trunk/SOURCE
Files:
5 added
5 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/Makefile

    r2847 r2894  
    2525# -----------------
    2626# $Id$
     27# read/write_3d_binary and read/write_var_list has been removed,
     28# read/write_restart_data_mod, wrd_write_string and
     29# user_read/write_restart_data_mod has been added, dependencies with respect to
     30# the aforementioned routines have been added/removed
     31#
     32# 2847 2018-03-02 21:45:58Z suehring
    2733# Changed format and enforced sorting
    2834#
     
    6672# virtual_flight_mod, synthetic_turbulence_generator_mod and
    6773# wind_turbine_model_mod were added to read_var_list
    68 # 
     74#
    6975# 2563 2017-10-19 15:36:10Z Giersch
    7076# wind_turbine_model_mod and synthetic_turbulence_generator_mod were added to
    71 # write_var_list and virtual_flight_mod was deleted from read_var_list  
    72 # 
     77# write_var_list and virtual_flight_mod was deleted from read_var_list
     78#
    7379# 2544 2017-10-13 18:09:32Z maronga
    7480# Added date_and_time_mod
     
    533539        random_gauss.f90 \
    534540        random_generator_parallel_mod.f90 \
    535         read_3d_binary.f90 \
    536         read_var_list.f90 \
     541        read_restart_data_mod.f90 \
    537542        run_control.f90 \
    538543        set_slicer_attributes_dvrp.f90 \
     
    585590        user_module.f90 \
    586591        user_parin.f90 \
    587         user_read_restart_data.f90 \
     592        user_read_restart_data_mod.f90 \
    588593        user_spectra.f90 \
    589594        user_statistics.f90 \
     595        user_write_restart_data_mod.f90 \
    590596        uv_exposure_model_mod.f90 \
    591597        vertical_nesting_mod.f90 \
    592598        virtual_flight_mod.f90 \
    593599        wind_turbine_model_mod.f90 \
    594         write_3d_binary.f90 \
    595         write_var_list.f90
     600        wrd_write_string.f90 \
     601        write_restart_data_mod.f90
    596602
    597603
     
    625631.f90.o:
    626632        $(F90) $(F90FLAGS) $(COPT) -c $<
    627 
    628633
    629634
     
    934939        random_function_mod.o \
    935940        random_generator_parallel_mod.o \
     941        read_restart_data_mod.o \
    936942        surface_layer_fluxes_mod.o \
    937943        surface_mod.o \
     
    11811187        pmc_interface_mod.o \
    11821188        pmc_particle_interface.o \
    1183         surface_layer_fluxes_mod.o
     1189        surface_layer_fluxes_mod.o \
     1190        write_restart_data_mod.o
    11841191parin.o: \
    11851192        chemistry_model_mod.o \
     
    11981205        progress_bar_mod.o \
    11991206        radiation_model_mod.o \
     1207        read_restart_data_mod.o \
    12001208        spectra_mod.o \
    12011209        synthetic_turbulence_generator_mod.o \
     
    13341342        mod_kinds.o \
    13351343        modules.o
    1336 read_3d_binary.o: \
     1344read_restart_data_mod.o: \
    13371345        chemistry_model_mod.o \
    1338         cpulog_mod.o \
    1339         gust_mod.o \
    1340         land_surface_model_mod.o \
    1341         mod_kinds.o \
    1342         modules.o \
     1346        cpulog_mod.o\
     1347        land_surface_model_mod.o \
     1348        microphysics_mod.o \
     1349        modules.o \
     1350        mod_kinds.o \
     1351        model_1d_mod.o \
     1352        netcdf_interface_mod.o \
    13431353        radiation_model_mod.o \
    1344         random_function_mod.o \
     1354        random_function_mod.o\
    13451355        random_generator_parallel_mod.o \
    13461356        spectra_mod.o \
    13471357        surface_mod.o \
    1348         urban_surface_mod.o
    1349 read_var_list.o: \
    1350         microphysics_mod.o \
    1351         model_1d_mod.o \
    1352         mod_kinds.o \
    1353         modules.o \
    1354         netcdf_interface_mod.o \
    1355         plant_canopy_model_mod.o \
    1356         spectra_mod.o \
    13571358        synthetic_turbulence_generator_mod.o \
    13581359        urban_surface_mod.o \
     1360        user_read_restart_data_mod.o \
    13591361        vertical_nesting_mod.o \
    13601362        virtual_flight_mod.o \
     
    16311633        modules.o \
    16321634        user_module.o
    1633 user_read_restart_data.o: \
    1634         mod_kinds.o \
     1635user_read_restart_data_mod.o: \
    16351636        modules.o \
    16361637        user_module.o
     
    16441645        modules.o \
    16451646        netcdf_interface_mod.o \
     1647        user_module.o
     1648user_write_restart_data_mod.o: \
    16461649        user_module.o
    16471650uv_exposure_model_mod.o: \
     
    16661669        mod_kinds.o \
    16671670        modules.o
    1668 write_3d_binary.o: \
    1669         cpulog_mod.o \
    1670         gust_mod.o \
    1671         mod_kinds.o \
    1672         modules.o \
     1671wrd_write_string.o: \
     1672        mod_kinds.o
     1673write_restart_data_mod.o: \
     1674        chemistry_model_mod.o \
     1675        land_surface_model_mod.o \
     1676        microphysics_mod.o \
     1677        mod_kinds.o \
     1678        mod_particle_attributes.o \
     1679        model_1d_mod.o \
     1680        modules.o \
     1681        netcdf_interface_mod.o \
    16731682        radiation_model_mod.o \
    16741683        random_function_mod.o \
    16751684        random_generator_parallel_mod.o \
    1676         spectra_mod.o \
    1677         surface_mod.o
    1678 write_var_list.o: \
    1679         chemistry_model_mod.o \
    1680         microphysics_mod.o \
    1681         model_1d_mod.o \
    1682         mod_kinds.o \
    1683         modules.o \
    1684         netcdf_interface_mod.o \
    1685         plant_canopy_model_mod.o\
    1686         spectra_mod.o \
     1685        spectra_mod.o surface_mod.o \
    16871686        synthetic_turbulence_generator_mod.o \
    16881687        urban_surface_mod.o \
     1688        user_write_restart_data_mod.o \
    16891689        vertical_nesting_mod.o \
    1690         virtual_flight_mod.o\
     1690        virtual_flight_mod.o \
    16911691        wind_turbine_model_mod.o
  • palm/trunk/SOURCE/chemistry_model_mod.f90

    r2815 r2894  
    2727! -----------------
    2828! $Id$
     29! Calculations of the index range of the subdomain on file which overlaps with
     30! the current subdomain are already done in read_restart_data_mod,
     31! chem_last_actions was renamed to chem_wrd_local, chem_read_restart_data was
     32! renamed to chem_rrd_local, chem_write_var_list was renamed to
     33! chem_wrd_global, chem_read_var_list was renamed to chem_rrd_global,
     34! chem_skip_var_list has been removed, variable named found has been
     35! introduced for checking if restart data was found, reading of restart strings
     36! has been moved completely to read_restart_data_mod, chem_rrd_local is already
     37! inside the overlap loop programmed in read_restart_data_mod, todo list has
     38! bees extended, redundant characters in chem_wrd_local have been removed,
     39! the marker *** end chemistry *** is not necessary anymore, strings and their
     40! respective lengths are written out and read now in case of restart runs to
     41! get rid of prescribed character lengths
     42!
     43! 2815 2018-02-19 11:29:57Z suehring
    2944! Bugfix in restart mechanism,
    3045! rename chem_tendency to chem_prognostic_equations,
     
    6580! ------------
    6681!> Chemistry model for PALM-4U
     82!> @todo Adjust chem_rrd_local to CASE structure of others modules. It is not
     83!>       allowed to use the chemistry model in a precursor run and additionally
     84!>       not using it in a main run
    6785!> @todo Update/clean-up todo list! (FK)
    6886!> @todo Set proper fill values (/= 0) for chem output arrays! (FK)
     
    208226   END INTERFACE chem_3d_data_averaging
    209227
    210    INTERFACE chem_last_actions
    211       MODULE PROCEDURE chem_last_actions
    212    END INTERFACE chem_last_actions
    213 
    214    INTERFACE chem_read_restart_data
    215       MODULE PROCEDURE chem_read_restart_data
    216    END INTERFACE chem_read_restart_data
     228   INTERFACE chem_wrd_local
     229      MODULE PROCEDURE chem_wrd_local
     230   END INTERFACE chem_wrd_local
     231
     232   INTERFACE chem_rrd_local
     233      MODULE PROCEDURE chem_rrd_local
     234   END INTERFACE chem_rrd_local
    217235
    218236   INTERFACE chem_prognostic_equations
     
    229247   END INTERFACE chem_emissions
    230248
    231 !    INTERFACE chem_write_var_list
    232 !       MODULE PROCEDURE chem_write_var_list
    233 !    END INTERFACE chem_write_var_list
    234 !
    235 !    INTERFACE chem_read_var_list
    236 !       MODULE PROCEDURE chem_read_var_list
    237 !    END INTERFACE chem_read_var_list
    238 !
    239 !    INTERFACE chem_skip_var_list
    240 !       MODULE PROCEDURE chem_skip_var_list
    241 !    END INTERFACE chem_skip_var_list
     249!    INTERFACE chem_wrd_global
     250!       MODULE PROCEDURE chem_wrd_global
     251!    END INTERFACE chem_wrd_global
     252!
     253!    INTERFACE chem_rrd_global
     254!       MODULE PROCEDURE chem_rrd_global
     255!    END INTERFACE chem_rrd_global
    242256
    243257
     
    245259          chem_check_data_output_pr, chem_data_output_3d,                      &
    246260          chem_define_netcdf_grid, chem_emissions, chem_header, chem_init,     &
    247           chem_init_profiles, chem_integrate, chem_last_actions,               &
     261          chem_init_profiles, chem_integrate, chem_wrd_local,                  &
    248262          chem_parin, chem_prognostic_equations,                               &
    249           chem_read_restart_data, chem_swap_timelevel
     263          chem_rrd_local, chem_swap_timelevel
    250264         
    251 
    252265
    253266 CONTAINS
     
    849862      air_chemistry = .TRUE.                   
    850863
    851 !
    852 !--   FK: Not in use/needed (yet), since chemistry_par namelist is always read in
    853 !       IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
    854 !          CALL chem_read_var_list
    855 !       ENDIF
    856864     
    857865 10   CONTINUE
     
    13091317!> Subroutine to write restart data for chemistry model
    13101318!------------------------------------------------------------------------------!
    1311  SUBROUTINE chem_last_actions
    1312  
    1313 
    1314     USE control_parameters
    1315    
    1316     USE kinds
     1319 SUBROUTINE chem_wrd_local
     1320
    13171321
    13181322    IMPLICIT NONE
    13191323
    13201324    INTEGER(iwp) ::  lsp !<
    1321     CHARACTER(LEN=20) ::  cspcs_name
    1322     CHARACTER(LEN=20) ::  cspcs_name_av
     1325
    13231326!      REAL(kind=wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg)   :: chems_conc
    13241327
    13251328
    1326     IF ( write_binary )  THEN
    1327        DO  lsp = 1, nspec
    1328           cspcs_name    = '                    '
    1329           cspcs_name_av = '                    '
    1330           cspcs_name    = TRIM(chem_species(lsp)%name)
    1331           cspcs_name_av = TRIM(chem_species(lsp)%name)//'_av'
    1332 
    1333           WRITE(14) cspcs_name   ; WRITE(14) chem_species(lsp)%conc
    1334           WRITE(14) cspcs_name_av; WRITE(14) chem_species(lsp)%conc_av
    1335        ENDDO
    1336    
    1337        WRITE ( 14 )       '*** end chem ***    '
    1338 
    1339     ENDIF
    1340 
    1341  END SUBROUTINE chem_last_actions
     1329    DO  lsp = 1, nspec
     1330
     1331       CALL wrd_write_string( TRIM( chem_species(lsp)%name ))
     1332       WRITE ( 14 )  chem_species(lsp)%conc
     1333
     1334       CALL wrd_write_string( TRIM( chem_species(lsp)%name )//'_av' )
     1335       WRITE ( 14 )  chem_species(lsp)%conc_av
     1336
     1337    ENDDO
     1338
     1339
     1340 END SUBROUTINE chem_wrd_local
    13421341
    13431342!------------------------------------------------------------------------------!
     
    13481347!------------------------------------------------------------------------------!
    13491348
    1350  SUBROUTINE chem_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
    1351                                     nynfa, nyn_on_file, nysfa, nys_on_file,    &
    1352                                     offset_xa, offset_ya, overlap_count,       &
    1353                                     tmp_2d, tmp_3d )   
     1349 SUBROUTINE chem_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,         &
     1350                            nxr_on_file, nynf, nync, nyn_on_file, nysf, nysc,  &
     1351                            nys_on_file, tmp_3d, found )   
    13541352                                     
    13551353    USE control_parameters
     
    13571355    USE indices
    13581356   
    1359     USE kinds
    1360    
    13611357    USE pegrid
    13621358
    13631359    IMPLICIT NONE
    13641360
    1365     CHARACTER (LEN=20) :: field_char !<   
    13661361    CHARACTER (LEN=20) :: spc_name_av !<   
    13671362       
     
    13801375    INTEGER(iwp) ::  nysf            !<
    13811376    INTEGER(iwp) ::  nys_on_file     !<   
    1382     INTEGER(iwp) ::  overlap_count   !<   
    1383 
    1384     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !<
    1385     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !<
    1386     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !<
    1387     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !<
    1388     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !<   
    1389     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !< 
    13901377   
    1391     LOGICAL ::  chem_found
    1392 !!
    1393     REAL(wp),                                                                  &
    1394        DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
    1395           tmp_2d   !< 2D array to temp store data
    1396 
    1397     REAL(wp),                                                                  &
    1398        DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
    1399           tmp_3d   !< 3D array to temp store data
    1400 
    1401 
    1402     IF ( initializing_actions == 'read_restart_data' )  THEN
    1403        READ ( 13 )  field_char
    1404        DO  WHILE ( TRIM( field_char ) /= '*** end chem ***    ' )
    1405 
    1406           DO  k = 1, overlap_count
    1407 
    1408              nxlf = nxlfa(i,k)
    1409              nxlc = nxlfa(i,k) + offset_xa(i,k)
    1410              nxrf = nxrfa(i,k)
    1411              nxrc = nxrfa(i,k) + offset_xa(i,k)
    1412              nysf = nysfa(i,k)
    1413              nysc = nysfa(i,k) + offset_ya(i,k)
    1414              nynf = nynfa(i,k)
    1415              nync = nynfa(i,k) + offset_ya(i,k)
    1416              
    1417 
    1418              chem_found = .FALSE.
    1419  
    1420              DO  lsp = 1, nspec
    1421 
    1422                 spc_name_av  =  TRIM(chem_species(lsp)%name)//'_av'   !< for time-averaged chemical conc.
    1423                 IF (TRIM( field_char ) == TRIM(chem_species(lsp)%name) )  THEN
    1424                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    1425                    chem_species(lsp)%conc(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
    1426                                    tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    1427                    chem_found = .TRUE.
    1428                 ELSEIF (TRIM( field_char ) == spc_name_av )  THEN
    1429                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    1430                    chem_species(lsp)%conc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
    1431                                       tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    1432                    chem_found = .TRUE.
    1433                 ENDIF
    1434 
    1435              ENDDO
    1436              IF (  .NOT.  chem_found )  THEN
    1437                 WRITE( message_string, * ) 'unknown variable named "',         &
    1438                                         TRIM( field_char ), '" found in',      &
    1439                                         '&data from prior run on PE ', myid
    1440                 CALL message( 'chem_read_restart_data', 'CM0008', 1, 2, 0, 6, 0 )
     1378    LOGICAL, INTENT(OUT)  :: found
     1379
     1380    REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !< 3D array to temp store data
     1381
     1382
     1383    found = .FALSE. 
     1384
     1385
     1386       IF ( ALLOCATED(chem_species) )  THEN
     1387
     1388          DO  lsp = 1, nspec
     1389
     1390              !< for time-averaged chemical conc.
     1391             spc_name_av  =  TRIM(chem_species(lsp)%name)//'_av'
     1392
     1393             IF (restart_string(1:length) == TRIM(chem_species(lsp)%name) )    &
     1394             THEN
     1395                !< read data into tmp_3d
     1396                IF ( k == 1 )  READ ( 13 )  tmp_3d 
     1397                !< fill ..%conc in the restart run   
     1398                chem_species(lsp)%conc(:,nysc-nbgp:nync+nbgp,                  &
     1399                                       nxlc-nbgp:nxrc+nbgp) =                  &
     1400                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     1401                found = .TRUE.
     1402             ELSEIF (restart_string(1:length) == spc_name_av )  THEN
     1403                IF ( k == 1 )  READ ( 13 )  tmp_3d
     1404                chem_species(lsp)%conc_av(:,nysc-nbgp:nync+nbgp,               &
     1405                                          nxlc-nbgp:nxrc+nbgp) =               &
     1406                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     1407                found = .TRUE.
    14411408             ENDIF
     1409
    14421410          ENDDO
    14431411
    1444           READ ( 13 )  field_char
    1445 
    1446        ENDDO
    1447 
    1448 !        IF (TRIM( field_char ) == TRIM('surface_csflux') )      THEN
    1449 !           READ ( 13 ) surface_csflux
    1450 !        ENDIF
    1451 
    1452     ENDIF
    1453 
    1454  END SUBROUTINE chem_read_restart_data
     1412       ENDIF
     1413
     1414
     1415 END SUBROUTINE chem_rrd_local
    14551416
    14561417
     
    17561717!       also in case of a restart run)
    17571718!------------------------------------------------------------------------------
    1758 !  SUBROUTINE chem_read_var_list
    1759 !
    1760 ! !   USE kinds
    1761 ! !   USE chem_modules
     1719!  SUBROUTINE chem_rrd_global
     1720!
     1721!    USE chem_modules
     1722!
     1723!    USE control_parameters,                                                   &
     1724!        ONLY: length, message_string, restart_string
    17621725!
    17631726!     
    17641727!     IMPLICIT NONE
    17651728!     
    1766 !     CHARACTER (LEN=30) ::  variable_chr !< dummy variable to read string
    17671729!     
    17681730!     
    1769 !     READ ( 13 )  variable_chr
    1770 !     DO  WHILE ( TRIM( variable_chr ) /= '*** end chemistry ***' )
    1771 !
    1772 !        SELECT CASE ( TRIM( variable_chr ) )
     1731!     DO
     1732!
     1733!        SELECT CASE ( restart_string(1:length) )
    17731734!       
    17741735!           CASE ( 'bc_cs_b' )
    17751736!              READ ( 13 )  bc_cs_b
    1776 !   
    1777 !       
     1737!
     1738!           CASE DEFAULT
     1739!
     1740!              EXIT
     1741!           
    17781742!        END SELECT
    17791743!       
    1780 !        READ ( 13 )  variable_chr
     1744!!
     1745!!--     Read next string and its length
     1746!        READ ( 13 )  length
     1747!        READ ( 13 )  restart_string(1:length)
    17811748!       
    17821749!     ENDDO
    17831750!     
    1784 !  END SUBROUTINE chem_read_var_list
    1785 
    1786 !------------------------------------------------------------------------------
    1787 ! Description:
    1788 ! ------------
    1789 !> Skipping the chemistry-module parameters from restart-file (binary format).
    1790 !  (FK: To make restarts work, I had to comment this routine. We actually
    1791 !       don't need it, since the namelist parameters are always read in,
    1792 !       also in case of a restart run)
    1793 !------------------------------------------------------------------------------
    1794 !  SUBROUTINE chem_skip_var_list
    1795 !       
    1796 !     IMPLICIT NONE
    1797 !           
    1798 !     CHARACTER (LEN=1)  ::  cdum
    1799 !     CHARACTER (LEN=30) ::  variable_chr
    1800 !           
    1801 !     READ ( 13 )  variable_chr
    1802 !
    1803 !     DO  WHILE ( TRIM( variable_chr ) /= '*** end chemistry ***' )
    1804 !
    1805 !        READ ( 13 )  cdum
    1806 !        READ ( 13 )  variable_chr
    1807 !
    1808 !     ENDDO   
    1809 !           
    1810 !  END SUBROUTINE chem_skip_var_list
     1751!  END SUBROUTINE chem_rrd_global
    18111752
    18121753
     
    18201761!       also in case of a restart run)
    18211762!------------------------------------------------------------------------------!
    1822 !  SUBROUTINE chem_write_var_list
     1763!  SUBROUTINE chem_wrd_global
    18231764!
    18241765!     USE chem_modules
     
    18351776! !-- (namelist parameters are anyway read in again in case of restart)
    18361777!     DO lsp = 1, nvar
    1837 !        WRITE ( 14 )  'conc_pr_init_'//chem_species(lsp)%name
     1778!        CALL wrd_write_string( 'conc_pr_init_'//chem_species(lsp)%name )
    18381779!        WRITE ( 14 )  chem_species(lsp)%conc_pr_init
    18391780!     ENDDO
    18401781!
    1841 !     WRITE ( 14 )     '*** end chemistry ***         '
    1842 !
    1843 !  END SUBROUTINE chem_write_var_list
     1782!
     1783!  END SUBROUTINE chem_wrd_global
    18441784
    18451785
  • palm/trunk/SOURCE/init_3d_model.f90

    r2867 r2894  
    2525! -----------------
    2626! $Id$
     27! Renamed routines with respect to reading restart data, file 13 is closed in
     28! rrd_read_parts_of_global now
     29!
     30! 2867 2018-03-09 09:40:23Z suehring
    2731! Further bugfix concerning call of user_init.
    2832!
     
    492496    USE random_generator_parallel,                                             &
    493497        ONLY:  init_parallel_random_generator
     498
     499    USE read_restart_data_mod,                                                 &
     500        ONLY:  rrd_read_parts_of_global, rrd_local                                     
    494501   
    495502    USE statistics,                                                            &
     
    16111618          DO  i = 0, io_blocks-1
    16121619             IF ( i == io_group )  THEN
    1613                 CALL read_parts_of_var_list
    1614                 CALL close_file( 13 )
     1620                CALL rrd_read_parts_of_global
    16151621             ENDIF
    16161622#if defined( __parallel )
     
    16221628
    16231629!
    1624 !--    Read binary data from restart file
     1630!--    Read processor specific binary data from restart file
    16251631       DO  i = 0, io_blocks-1
    16261632          IF ( i == io_group )  THEN
    1627              CALL read_3d_binary
     1633             CALL rrd_local
    16281634          ENDIF
    16291635#if defined( __parallel )
  • palm/trunk/SOURCE/land_surface_model_mod.f90

    r2881 r2894  
    2525! -----------------
    2626! $Id$
     27! Calculations of the index range of the subdomain on file which overlaps with
     28! the current subdomain are already done in read_restart_data_mod,
     29! lsm_read/write_restart_data was renamed to lsm_r/wrd_local, USE kinds has
     30! been removed in several routines, variable named found has been
     31! introduced for checking if restart data was found, reading of restart strings
     32! has been moved completely to read_restart_data_mod, lsm_rrd_local is already
     33! inside the overlap loop programmed in read_restart_data_mod, the marker ***
     34! end lsm *** is not necessary anymore, strings and their respective lengths
     35! are written out and read now in case of restart runs to get rid of prescribed
     36! character lengths, SAVE attribute added where necessary, deallocation and
     37! allocation of some arrays have been changed to take care of different restart
     38! files that can be opened (index i)
     39!
     40! 2881 2018-03-13 16:24:40Z suehring
    2741! Bugfix: wrong loop structure for soil moisture calculation
    2842!
     
    8599! radiation quantities belong to surface type now
    86100! surface fractions initialized
    87 ! Rename lsm_last_actions into lsm_write_restart_data (MS)
     101! Rename lsm_last_actions into lsm_wrd_subdomain (MS)
    88102!
    89103! 2608 2017-11-13 14:04:26Z schwenkel
     
    872886           lsm_data_output_2d, lsm_data_output_3d, lsm_energy_balance,         &
    873887           lsm_header, lsm_init, lsm_init_arrays, lsm_parin, lsm_soil_model,   &
    874            lsm_swap_timelevel, lsm_read_restart_data, lsm_write_restart_data
     888           lsm_swap_timelevel, lsm_rrd_local, lsm_wrd_local
    875889! !vegetat
    876890!-- Public parameters, constants and initial values
     
    945959    END INTERFACE lsm_swap_timelevel
    946960
    947     INTERFACE lsm_read_restart_data
    948        MODULE PROCEDURE lsm_read_restart_data
    949     END INTERFACE lsm_read_restart_data
    950 
    951     INTERFACE lsm_write_restart_data
    952        MODULE PROCEDURE lsm_write_restart_data
    953     END INTERFACE lsm_write_restart_data
     961    INTERFACE lsm_rrd_local
     962       MODULE PROCEDURE lsm_rrd_local
     963    END INTERFACE lsm_rrd_local
     964
     965    INTERFACE lsm_wrd_local
     966       MODULE PROCEDURE lsm_wrd_local
     967    END INTERFACE lsm_wrd_local
    954968
    955969 CONTAINS
     
    15911605          message_string = 'invalid soil layer configuration found ' //        &
    15921606                           '(dz_soil_center(k) = 0.0)'
    1593           CALL message( 'lsm_read_restart_data', 'PA0140', 1, 2, 0, 6, 0 )
     1607          CALL message( 'lsm_rrd_local', 'PA0140', 1, 2, 0, 6, 0 )
    15941608       ENDIF 
    15951609    ENDDO
     
    43014315          message_string = 'For non-pavement surfaces the combination ' //     &
    43024316                           ' lai = 0.0 and c_veg = 1.0 is not allowed.'
    4303           CALL message( 'lsm_read_restart_data', 'PA0999', 2, 2, 0, 6, 0 )
     4317          CALL message( 'lsm_rrd_local', 'PA0999', 2, 2, 0, 6, 0 )
    43044318       ENDIF
    43054319
     
    43104324             message_string = 'For non-pavement surfaces the combination ' //  &
    43114325                              ' lai = 0.0 and c_veg = 1.0 is not allowed.'
    4312              CALL message( 'lsm_read_restart_data', 'PA0999', 2, 2, 0, 6, 0 )
     4326             CALL message( 'lsm_rrd_local', 'PA0999', 2, 2, 0, 6, 0 )
    43134327          ENDIF
    43144328       ENDDO
     
    50155029    USE indices
    50165030
    5017     USE kinds
    5018 
    50195031    IMPLICIT NONE
    50205032
     
    53495361    USE indices
    53505362
    5351     USE kinds
    5352 
    53535363
    53545364    IMPLICIT NONE
     
    56085618
    56095619    USE indices
    5610 
    5611     USE kinds
    56125620
    56135621
     
    56885696! Description:
    56895697! ------------
    5690 !> Write restart data for land surface model
     5698!> Write restart data for land surface model. It is necessary to write
     5699!> start_index and end_index several times.
    56915700!------------------------------------------------------------------------------!
    5692  SUBROUTINE lsm_write_restart_data
    5693  
    5694 
    5695     USE control_parameters
     5701 SUBROUTINE lsm_wrd_local
    56965702       
    5697     USE kinds
    56985703
    56995704    IMPLICIT NONE
     
    57025707    INTEGER(iwp)      ::  l      !< index variable for surface orientation
    57035708
    5704     IF ( write_binary )  THEN
    5705 
    5706 
    5707        WRITE ( 14 ) 'ns_h_on_file_lsm    '
    5708        WRITE ( 14 ) surf_lsm_h%ns
    5709        WRITE ( 14 ) 'ns_v_on_file_lsm    '
    5710        WRITE ( 14 ) surf_lsm_v(0:3)%ns
    5711 
    5712        IF ( ALLOCATED( c_liq_av ) )  THEN
    5713           WRITE ( 14 )  'c_liq_av            ';  WRITE ( 14 ) c_liq_av
    5714        ENDIF
    5715        IF ( ALLOCATED( c_soil_av ) )  THEN
    5716           WRITE ( 14 )  'c_soil_av           ';  WRITE ( 14 ) c_soil_av
    5717        ENDIF
    5718        IF ( ALLOCATED( c_veg_av ) )  THEN
    5719           WRITE ( 14 )  'c_veg_av            ';  WRITE ( 14 ) c_veg_av
    5720        ENDIF
    5721        IF ( ALLOCATED( lai_av ) )  THEN
    5722           WRITE ( 14 )  'lai_av              ';  WRITE ( 14 )  lai_av
    5723        ENDIF
    5724        IF ( ALLOCATED( m_liq_av ) )  THEN
    5725           WRITE ( 14 )  'm_liq_av            ';  WRITE ( 14 )  m_liq_av
    5726        ENDIF
    5727        IF ( ALLOCATED( m_soil_av ) )  THEN
    5728           WRITE ( 14 )  'm_soil_av           ';  WRITE ( 14 )  m_soil_av
    5729        ENDIF
    5730        IF ( ALLOCATED( qsws_liq_av ) )  THEN
    5731           WRITE ( 14 )  'qsws_liq_av         ';  WRITE ( 14 )  qsws_liq_av
    5732        ENDIF 
    5733        IF ( ALLOCATED( qsws_soil_av ) )  THEN
    5734           WRITE ( 14 )  'qsws_soil_av        ';  WRITE ( 14 )  qsws_soil_av
    5735        ENDIF
    5736        IF ( ALLOCATED( qsws_veg_av ) )  THEN
    5737           WRITE ( 14 )  'qsws_veg_av         ';  WRITE ( 14 )  qsws_veg_av
    5738        ENDIF
    5739        IF ( ALLOCATED( t_soil_av ) )  THEN
    5740           WRITE ( 14 )  't_soil_av           ';  WRITE ( 14 )  t_soil_av
    5741        ENDIF
     5709    CALL wrd_write_string( 'ns_h_on_file_lsm' )
     5710    WRITE ( 14 )  surf_lsm_h%ns
     5711
     5712    CALL wrd_write_string( 'ns_v_on_file_lsm' )
     5713    WRITE ( 14 )  surf_lsm_v(0:3)%ns
     5714
     5715
     5716    IF ( ALLOCATED( c_liq_av ) )  THEN
     5717       CALL wrd_write_string( 'c_liq_av' )
     5718       WRITE ( 14 )  c_liq_av
     5719    ENDIF
     5720
     5721    IF ( ALLOCATED( c_soil_av ) )  THEN
     5722       CALL wrd_write_string( 'c_soil_av' )
     5723       WRITE ( 14 )  c_soil_av
     5724    ENDIF
     5725
     5726    IF ( ALLOCATED( c_veg_av ) )  THEN
     5727       CALL wrd_write_string( 'c_veg_av' )
     5728       WRITE ( 14 )  c_veg_av
     5729    ENDIF
     5730
     5731    IF ( ALLOCATED( lai_av ) )  THEN
     5732       CALL wrd_write_string( 'lai_av' )
     5733       WRITE ( 14 )  lai_av
     5734    ENDIF
     5735
     5736    IF ( ALLOCATED( m_liq_av ) )  THEN
     5737       CALL wrd_write_string( 'm_liq_av' )
     5738       WRITE ( 14 )  m_liq_av
     5739    ENDIF
     5740
     5741    IF ( ALLOCATED( m_soil_av ) )  THEN
     5742       CALL wrd_write_string( 'm_soil_av' )
     5743       WRITE ( 14 )  m_soil_av
     5744    ENDIF
     5745
     5746    IF ( ALLOCATED( qsws_liq_av ) )  THEN
     5747       CALL wrd_write_string( 'qsws_liq_av' )
     5748       WRITE ( 14 )  qsws_liq_av
     5749    ENDIF
     5750
     5751    IF ( ALLOCATED( qsws_soil_av ) )  THEN
     5752       CALL wrd_write_string( 'qsws_soil_av' )
     5753       WRITE ( 14 )  qsws_soil_av
     5754    ENDIF
     5755
     5756    IF ( ALLOCATED( qsws_veg_av ) )  THEN
     5757       CALL wrd_write_string( 'qsws_veg_av' )
     5758       WRITE ( 14 )  qsws_veg_av
     5759    ENDIF
     5760
     5761    IF ( ALLOCATED( t_soil_av ) )  THEN
     5762       CALL wrd_write_string( 't_soil_av' )
     5763       WRITE ( 14 )  t_soil_av
     5764    ENDIF
     5765
     5766    CALL wrd_write_string( 'lsm_start_index_h' )
     5767    WRITE ( 14 )  surf_lsm_h%start_index
     5768
     5769    CALL wrd_write_string( 'lsm_end_index_h' )
     5770    WRITE ( 14 )  surf_lsm_h%end_index
     5771
     5772    CALL wrd_write_string( 't_soil_h' )
     5773    WRITE ( 14 )  t_soil_h%var_2d
    57425774       
    5743        WRITE ( 14 ) 'lsm_start_index_h   '
    5744        WRITE ( 14 ) surf_lsm_h%start_index
    5745        WRITE ( 14 ) 'lsm_end_index_h     '
    5746        WRITE ( 14 ) surf_lsm_h%end_index
    5747        WRITE ( 14 ) 't_soil_h            '
    5748        WRITE ( 14 ) t_soil_h%var_2d
     5775
    57495776       
    5750        DO  l = 0, 3
    5751           WRITE ( 14 ) 'lsm_start_index_v   '
    5752           WRITE ( 14 ) surf_lsm_v(l)%start_index
    5753           WRITE ( 14 ) 'lsm_end_index_v     '
    5754           WRITE ( 14 ) surf_lsm_v(l)%end_index
    5755           WRITE( dum, '(I1)')  l         
    5756           WRITE ( 14 ) 't_soil_v(' // dum // ')         '
    5757           WRITE ( 14 ) t_soil_v(l)%var_2d         
    5758        ENDDO
    5759 
    5760        WRITE ( 14 ) 'lsm_start_index_h   '
    5761        WRITE ( 14 ) surf_lsm_h%start_index
    5762        WRITE ( 14 ) 'lsm_end_index_h     '
    5763        WRITE ( 14 ) surf_lsm_h%end_index
    5764        WRITE ( 14 ) 'm_soil_h            '
    5765        WRITE ( 14 ) m_soil_h%var_2d
     5777    DO  l = 0, 3
     5778
     5779       CALL wrd_write_string( 'lsm_start_index_v' )
     5780       WRITE ( 14 )  surf_lsm_v(l)%start_index
     5781
     5782       CALL wrd_write_string( 'lsm_end_index_v' )
     5783       WRITE ( 14 )  surf_lsm_v(l)%end_index
     5784
     5785       WRITE( dum, '(I1)')  l   
     5786
     5787       CALL wrd_write_string( 't_soil_v(' // dum // ')' )
     5788       WRITE ( 14 )  t_soil_v(l)%var_2d
     5789             
     5790    ENDDO
     5791
     5792    CALL wrd_write_string( 'lsm_start_index_h' )
     5793    WRITE ( 14 )  surf_lsm_h%start_index
     5794
     5795    CALL wrd_write_string( 'lsm_end_index_h' )
     5796    WRITE ( 14 )  surf_lsm_h%end_index
     5797
     5798    CALL wrd_write_string( 'm_soil_h' )
     5799    WRITE ( 14 )  m_soil_h%var_2d
     5800
     5801    DO  l = 0, 3
     5802
     5803       CALL wrd_write_string( 'lsm_start_index_v' )
     5804       WRITE ( 14 )  surf_lsm_v(l)%start_index
     5805
     5806       CALL wrd_write_string( 'lsm_end_index_v' )
     5807       WRITE ( 14 )  surf_lsm_v(l)%end_index
     5808
     5809       WRITE( dum, '(I1)')  l   
     5810
     5811       CALL wrd_write_string( 'm_soil_v(' // dum // ')' )
     5812       WRITE ( 14 )  m_soil_v(l)%var_2d
     5813     
     5814    ENDDO
     5815
     5816    CALL wrd_write_string( 'lsm_start_index_h' )
     5817    WRITE ( 14 )  surf_lsm_h%start_index
     5818
     5819    CALL wrd_write_string( 'lsm_end_index_h' )
     5820    WRITE ( 14 )  surf_lsm_h%end_index
     5821
     5822    CALL wrd_write_string( 'm_liq_h' )
     5823    WRITE ( 14 )  m_liq_h%var_1d
    57665824       
    5767        DO  l = 0, 3
    5768           WRITE ( 14 ) 'lsm_start_index_v   '
    5769           WRITE ( 14 ) surf_lsm_v(l)%start_index
    5770           WRITE ( 14 ) 'lsm_end_index_v     '
    5771           WRITE ( 14 ) surf_lsm_v(l)%end_index
    5772           WRITE( dum, '(I1)')  l         
    5773           WRITE ( 14 ) 'm_soil_v(' // dum // ')         '
    5774           WRITE ( 14 ) m_soil_v(l)%var_2d         
    5775        ENDDO
    5776 
    5777        WRITE ( 14 ) 'lsm_start_index_h   '
    5778        WRITE ( 14 ) surf_lsm_h%start_index
    5779        WRITE ( 14 ) 'lsm_end_index_h     '
    5780        WRITE ( 14 ) surf_lsm_h%end_index
    5781        WRITE ( 14 ) 'm_liq_h             '
    5782        WRITE ( 14 ) m_liq_h%var_1d
     5825    DO  l = 0, 3
     5826
     5827       CALL wrd_write_string( 'lsm_start_index_v' )
     5828       WRITE ( 14 )  surf_lsm_v(l)%start_index
     5829
     5830       CALL wrd_write_string( 'lsm_end_index_v' )
     5831       WRITE ( 14 )  surf_lsm_v(l)%end_index
     5832
     5833       WRITE( dum, '(I1)')  l   
     5834
     5835       CALL wrd_write_string( 'm_liq_v(' // dum // ')' )
     5836       WRITE ( 14 )  m_liq_v(l)%var_1d     
     5837               
     5838    ENDDO
     5839
     5840    CALL wrd_write_string( 'lsm_start_index_h' )
     5841    WRITE ( 14 )  surf_lsm_h%start_index
     5842
     5843    CALL wrd_write_string( 'lsm_end_index_h' )
     5844    WRITE ( 14 )  surf_lsm_h%end_index
     5845
     5846    CALL wrd_write_string( 't_surface_h' )
     5847    WRITE ( 14 )  t_surface_h%var_1d
     5848
     5849    DO  l = 0, 3
     5850
     5851       CALL wrd_write_string( 'lsm_start_index_v' )
     5852       WRITE ( 14 )  surf_lsm_v(l)%start_index
     5853
     5854       CALL wrd_write_string( 'lsm_end_index_v' )
     5855       WRITE ( 14 )  surf_lsm_v(l)%end_index
     5856
     5857       WRITE( dum, '(I1)')  l   
     5858
     5859       CALL wrd_write_string( 't_surface_v(' // dum // ')' )
     5860       WRITE ( 14 )  t_surface_v(l)%var_1d     
    57835861       
    5784        DO  l = 0, 3
    5785           WRITE ( 14 ) 'lsm_start_index_v   '
    5786           WRITE ( 14 ) surf_lsm_v(l)%start_index
    5787           WRITE ( 14 ) 'lsm_end_index_v     '
    5788           WRITE ( 14 ) surf_lsm_v(l)%end_index
    5789           WRITE( dum, '(I1)')  l         
    5790           WRITE ( 14 ) 'm_liq_v(' // dum // ')          '
    5791           WRITE ( 14 ) m_liq_v(l)%var_1d         
    5792        ENDDO
    5793 
    5794        WRITE ( 14 ) 'lsm_start_index_h   '
    5795        WRITE ( 14 ) surf_lsm_h%start_index
    5796        WRITE ( 14 ) 'lsm_end_index_h     '
    5797        WRITE ( 14 ) surf_lsm_h%end_index
    5798        WRITE ( 14 ) 't_surface_h         '
    5799        WRITE ( 14 ) t_surface_h%var_1d
    5800        
    5801        DO  l = 0, 3
    5802           WRITE ( 14 ) 'lsm_start_index_v   '
    5803           WRITE ( 14 ) surf_lsm_v(l)%start_index
    5804           WRITE ( 14 ) 'lsm_end_index_v     '
    5805           WRITE ( 14 ) surf_lsm_v(l)%end_index
    5806           WRITE( dum, '(I1)')  l         
    5807           WRITE ( 14 ) 't_surface_v(' // dum // ')      '
    5808           WRITE ( 14 ) t_surface_v(l)%var_1d         
    5809        ENDDO
    5810 
    5811 
    5812        WRITE ( 14 )  '*** end lsm ***     '
    5813 
    5814     ENDIF
    5815 
    5816  END SUBROUTINE lsm_write_restart_data
    5817 
    5818 
    5819 SUBROUTINE lsm_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file,   &
    5820                                      nynfa, nyn_on_file, nysfa, nys_on_file,   &
    5821                                      offset_xa, offset_ya, overlap_count,      &
    5822                                      tmp_2d )
     5862    ENDDO
     5863
     5864
     5865 END SUBROUTINE lsm_wrd_local
     5866
     5867
     5868!------------------------------------------------------------------------------!
     5869!
     5870! Description:
     5871! ------------
     5872!> Soubroutine reads lsm data from restart file(s)
     5873!------------------------------------------------------------------------------!
     5874SUBROUTINE lsm_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,           &
     5875                          nxr_on_file, nynf, nync, nyn_on_file, nysf, nysc,    &
     5876                          nys_on_file, tmp_2d, found )
    58235877 
    58245878
     
    58275881    USE indices
    58285882   
    5829     USE kinds
    5830    
    58315883    USE pegrid
    58325884
     5885
    58335886    IMPLICIT NONE
    5834 
    5835     CHARACTER (LEN=20) :: field_char   !<
    58365887
    58375888    INTEGER(iwp) ::  i                 !<
     
    58415892    INTEGER(iwp) ::  nxlc              !<
    58425893    INTEGER(iwp) ::  nxlf              !<
    5843     INTEGER(iwp) ::  nxl_on_file       !<
     5894    INTEGER(iwp) ::  nxl_on_file       !< index of left boundary on former local domain
    58445895    INTEGER(iwp) ::  nxrc              !<
    58455896    INTEGER(iwp) ::  nxrf              !<
    5846     INTEGER(iwp) ::  nxr_on_file       !<
     5897    INTEGER(iwp) ::  nxr_on_file       !< index of right boundary on former local domain
    58475898    INTEGER(iwp) ::  nync              !<
    58485899    INTEGER(iwp) ::  nynf              !<
    5849     INTEGER(iwp) ::  nyn_on_file       !<
     5900    INTEGER(iwp) ::  nyn_on_file       !< index of north boundary on former local domain
    58505901    INTEGER(iwp) ::  nysc              !<
    58515902    INTEGER(iwp) ::  nysf              !<
    5852     INTEGER(iwp) ::  nys_on_file       !<
    5853     INTEGER(iwp) ::  overlap_count     !<
     5903    INTEGER(iwp) ::  nys_on_file       !< index of south boundary on former local domain
    58545904
    58555905    INTEGER(iwp) ::  ns_v_on_file_lsm(0:3) !< number of vertical surface elements (natural type) on file
    58565906
    5857     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !<
    5858     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !<
    5859     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !<
    5860     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !<
    5861     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !<
    5862     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !<
    5863 
    5864     INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  start_index_on_file
    5865     INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  end_index_on_file
    5866 
    5867     REAL(wp),                                                                  &
    5868        DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: &
    5869           tmp_2d   !<
    5870 
    5871     REAL(wp),                                                                  &
    5872        DIMENSION(nzb_soil:nzt_soil+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: &
    5873           tmp_3d   !<
    5874 
    5875     REAL(wp),                                                                  &
    5876        DIMENSION(nzb_soil:nzt_soil,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: &
    5877           tmp_3d2   !<
    5878 
    5879     TYPE(surf_type_lsm) :: tmp_walltype_h_1d   !< temporary 1D array containing the respective surface variable stored on file, horizontal surfaces
    5880     TYPE(surf_type_lsm) :: tmp_walltype_h_2d   !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces
    5881     TYPE(surf_type_lsm) :: tmp_walltype_h_2d2  !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces
    5882 
    5883     TYPE(surf_type_lsm), DIMENSION(0:3) :: tmp_walltype_v_1d   !< temporary 1D array containing the respective surface variable stored on file, vertical surfaces
    5884     TYPE(surf_type_lsm), DIMENSION(0:3) :: tmp_walltype_v_2d   !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces
    5885     TYPE(surf_type_lsm), DIMENSION(0:3) :: tmp_walltype_v_2d2  !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces
    5886 
    5887    IF ( initializing_actions == 'read_restart_data' )  THEN
    5888       READ ( 13 )  field_char
    5889 
    5890 !
    5891 !--   At first, determine the number of surface elements (with certain orientation) on file
    5892       IF ( TRIM( field_char ) /= 'ns_h_on_file_lsm' )  THEN
    5893 !
    5894 !--      Add a proper error message
    5895       ENDIF
    5896       READ ( 13 ) ns_h_on_file_lsm
    5897 
    5898       READ ( 13 )  field_char
    5899       IF ( TRIM( field_char ) /= 'ns_v_on_file_lsm' )  THEN
    5900 !
    5901 !--      Add a proper error message
    5902       ENDIF
    5903       READ ( 13 ) ns_v_on_file_lsm
    5904 !
    5905 !--   Allocate temporary arrays to store surface data
    5906       ALLOCATE( tmp_walltype_h_1d%var_1d(1:ns_h_on_file_lsm)                     )
    5907       ALLOCATE( tmp_walltype_h_2d%var_2d(nzb_soil:nzt_soil+1,1:ns_h_on_file_lsm) )
    5908       ALLOCATE( tmp_walltype_h_2d2%var_2d(nzb_soil:nzt_soil,1:ns_h_on_file_lsm)  )
    5909 
    5910       DO  l = 0, 3
    5911          ALLOCATE( tmp_walltype_v_1d(l)%var_1d(1:ns_v_on_file_lsm(l))                    )
    5912          ALLOCATE( tmp_walltype_v_2d(l)%var_2d(nzb_soil:nzt_soil+1,1:ns_v_on_file_lsm(l)) )
    5913          ALLOCATE( tmp_walltype_v_2d2(l)%var_2d(nzb_soil:nzt_soil,1:ns_v_on_file_lsm(l)) )
    5914       ENDDO
    5915      
    5916       READ ( 13 )  field_char
    5917 
    5918       DO  WHILE ( TRIM( field_char ) /= '*** end lsm ***' )
    5919 
    5920          DO  k = 1, overlap_count
    5921 
    5922             nxlf = nxlfa(i,k)
    5923             nxlc = nxlfa(i,k) + offset_xa(i,k)
    5924             nxrf = nxrfa(i,k)
    5925             nxrc = nxrfa(i,k) + offset_xa(i,k)
    5926             nysf = nysfa(i,k)
    5927             nysc = nysfa(i,k) + offset_ya(i,k)
    5928             nynf = nynfa(i,k)
    5929             nync = nynfa(i,k) + offset_ya(i,k)
    5930 
    5931 
    5932             SELECT CASE ( TRIM( field_char ) )
    5933 
    5934 
    5935                 CASE ( 'c_liq_av' )
    5936                    IF ( .NOT. ALLOCATED( c_liq_av ) )  THEN
    5937                       ALLOCATE( c_liq_av(nysg:nyng,nxlg:nxrg) )
    5938                    ENDIF
    5939                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5940                    c_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
    5941                                   tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5942 
    5943                 CASE ( 'c_soil_av' )
    5944                    IF ( .NOT. ALLOCATED( c_soil_av ) )  THEN
    5945                       ALLOCATE( c_soil_av(nysg:nyng,nxlg:nxrg) )
    5946                    ENDIF
    5947                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5948                    c_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
    5949                                   tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5950 
    5951                 CASE ( 'c_veg_av' )
    5952                    IF ( .NOT. ALLOCATED( c_veg_av ) )  THEN
    5953                       ALLOCATE( c_veg_av(nysg:nyng,nxlg:nxrg) )
    5954                    ENDIF
    5955                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5956                    c_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
    5957                                   tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5958 
    5959                 CASE ( 'lai_av' )
    5960                    IF ( .NOT. ALLOCATED( lai_av ) )  THEN
    5961                       ALLOCATE( lai_av(nysg:nyng,nxlg:nxrg) )
    5962                    ENDIF
    5963                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5964                    lai_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
    5965                                   tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5966 
    5967                 CASE ( 'm_liq_av' )
    5968                    IF ( .NOT. ALLOCATED( m_liq_av ) )  THEN
    5969                       ALLOCATE( m_liq_av(nysg:nyng,nxlg:nxrg) )
    5970                    ENDIF
    5971                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5972                    m_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =         &
    5973                                   tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5974 
    5975                 CASE ( 'm_soil_av' )
    5976                    IF ( .NOT. ALLOCATED( m_soil_av ) )  THEN
    5977                       ALLOCATE( m_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
    5978                    ENDIF
    5979                    IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
    5980                    m_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
    5981                                     tmp_3d2(nzb_soil:nzt_soil,nysf             &
    5982                                     -nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5983 
    5984                 CASE ( 'qsws_liq_av' )
    5985                    IF ( .NOT. ALLOCATED( qsws_liq_av ) )  THEN
    5986                       ALLOCATE( qsws_liq_av(nysg:nyng,nxlg:nxrg) )
    5987                    ENDIF 
    5988                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5989                    qsws_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =     &
    5990                                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5991                 CASE ( 'qsws_soil_av' )
    5992                    IF ( .NOT. ALLOCATED( qsws_soil_av ) )  THEN
    5993                       ALLOCATE( qsws_soil_av(nysg:nyng,nxlg:nxrg) )
    5994                    ENDIF 
    5995                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    5996                    qsws_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =    &
    5997                                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    5998 
    5999                 CASE ( 'qsws_veg_av' )
    6000                    IF ( .NOT. ALLOCATED( qsws_veg_av ) )  THEN
    6001                       ALLOCATE( qsws_veg_av(nysg:nyng,nxlg:nxrg) )
    6002                    ENDIF 
    6003                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    6004                    qsws_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =     &
    6005                                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    6006 
    6007                 CASE ( 't_soil_av' )
    6008                    IF ( .NOT. ALLOCATED( t_soil_av ) )  THEN
    6009                       ALLOCATE( t_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
    6010                    ENDIF
    6011                    IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
    6012                    t_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
    6013                                     tmp_3d2(:,nysf-nbgp:nynf+nbgp,             &
    6014                                     nxlf-nbgp:nxrf+nbgp)
    6015 
    6016                 CASE ( 'lsm_start_index_h', 'lsm_start_index_v'  )   
    6017                    IF ( k == 1 )                                               &
    6018                       READ ( 13 )  start_index_on_file
    6019                       
    6020                 CASE ( 'lsm_end_index_h', 'lsm_end_index_v' )   
    6021                    IF ( k == 1 )                                               &
    6022                       READ ( 13 )  end_index_on_file
    6023                
    6024                 CASE ( 't_soil_h' )
     5907    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  start_index_on_file
     5908    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  end_index_on_file
     5909
     5910    LOGICAL, INTENT(OUT)  :: found
     5911
     5912    REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_2d   !<
     5913
     5914    REAL(wp), DIMENSION(nzb_soil:nzt_soil+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !<
     5915
     5916    REAL(wp), DIMENSION(nzb_soil:nzt_soil,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d2   !<
     5917
     5918    TYPE(surf_type_lsm), SAVE :: tmp_walltype_h_1d   !< temporary 1D array containing the respective surface variable stored on file, horizontal surfaces
     5919    TYPE(surf_type_lsm), SAVE :: tmp_walltype_h_2d   !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces
     5920    TYPE(surf_type_lsm), SAVE :: tmp_walltype_h_2d2  !< temporary 2D array containing the respective surface variable stored on file, horizontal surfaces
     5921
     5922    TYPE(surf_type_lsm), DIMENSION(0:3), SAVE :: tmp_walltype_v_1d   !< temporary 1D array containing the respective surface variable stored on file, vertical surfaces
     5923    TYPE(surf_type_lsm), DIMENSION(0:3), SAVE :: tmp_walltype_v_2d   !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces
     5924    TYPE(surf_type_lsm), DIMENSION(0:3), SAVE :: tmp_walltype_v_2d2  !< temporary 2D array containing the respective surface variable stored on file, vertical surfaces
     5925
     5926
     5927    found = .TRUE.
     5928
     5929
     5930       SELECT CASE ( restart_string(1:length) )
     5931
     5932           CASE ( 'ns_h_on_file_lsm' )
     5933              IF ( k == 1 )  THEN
     5934                 READ ( 13 ) ns_h_on_file_lsm
     5935
     5936                 IF ( ALLOCATED( tmp_walltype_h_1d%var_1d ) )                  &
     5937                    DEALLOCATE( tmp_walltype_h_1d%var_1d )
     5938                 IF ( ALLOCATED( tmp_walltype_h_2d%var_2d ) )                  &   
     5939                    DEALLOCATE( tmp_walltype_h_2d%var_2d )
     5940                 IF ( ALLOCATED( tmp_walltype_h_2d2%var_2d ) )                 &
     5941                    DEALLOCATE( tmp_walltype_h_2d2%var_2d )
     5942
     5943!
     5944!--              Allocate temporary arrays to store surface data
     5945                 ALLOCATE( tmp_walltype_h_1d%var_1d(1:ns_h_on_file_lsm) )
     5946                 ALLOCATE( tmp_walltype_h_2d%var_2d(nzb_soil:nzt_soil+1,       &
     5947                                                    1:ns_h_on_file_lsm) )
     5948                 ALLOCATE( tmp_walltype_h_2d2%var_2d(nzb_soil:nzt_soil,        &
     5949                           1:ns_h_on_file_lsm)  )
     5950
     5951              ENDIF
     5952
     5953           CASE ( 'ns_v_on_file_lsm' )
     5954              IF ( k == 1 )  THEN
     5955                 READ ( 13 ) ns_v_on_file_lsm
     5956
     5957                 DO  l = 0, 3
     5958                    IF ( ALLOCATED( tmp_walltype_v_1d(l)%var_1d ) )            &
     5959                       DEALLOCATE( tmp_walltype_v_1d(l)%var_1d )
     5960                    IF ( ALLOCATED( tmp_walltype_v_2d(l)%var_2d ) )            &
     5961                       DEALLOCATE( tmp_walltype_v_2d(l)%var_2d )
     5962                    IF ( ALLOCATED( tmp_walltype_v_2d2(l)%var_2d ) )           &
     5963                       DEALLOCATE( tmp_walltype_v_2d2(l)%var_2d )
     5964                 ENDDO
     5965
     5966!
     5967!--              Allocate temporary arrays to store surface data
     5968                 DO  l = 0, 3
     5969                    ALLOCATE( tmp_walltype_v_1d(l)                             &
     5970                                 %var_1d(1:ns_v_on_file_lsm(l)) )
     5971                    ALLOCATE( tmp_walltype_v_2d(l)                             &
     5972                                 %var_2d(nzb_soil:nzt_soil+1,                  &
     5973                                         1:ns_v_on_file_lsm(l)) )
     5974                    ALLOCATE( tmp_walltype_v_2d2(l)                            &
     5975                                 %var_2d(nzb_soil:nzt_soil,                    &
     5976                                         1:ns_v_on_file_lsm(l))  )
     5977                 ENDDO
     5978
     5979              ENDIF
     5980
     5981
     5982           CASE ( 'c_liq_av' )
     5983              IF ( .NOT. ALLOCATED( c_liq_av ) )  THEN
     5984                 ALLOCATE( c_liq_av(nysg:nyng,nxlg:nxrg) )
     5985              ENDIF
     5986              IF ( k == 1 )  READ ( 13 )  tmp_2d
     5987              c_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
     5988                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     5989
     5990           CASE ( 'c_soil_av' )
     5991              IF ( .NOT. ALLOCATED( c_soil_av ) )  THEN
     5992                 ALLOCATE( c_soil_av(nysg:nyng,nxlg:nxrg) )
     5993              ENDIF
     5994              IF ( k == 1 )  READ ( 13 )  tmp_2d
     5995              c_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
     5996                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     5997
     5998           CASE ( 'c_veg_av' )
     5999              IF ( .NOT. ALLOCATED( c_veg_av ) )  THEN
     6000                 ALLOCATE( c_veg_av(nysg:nyng,nxlg:nxrg) )
     6001              ENDIF
     6002              IF ( k == 1 )  READ ( 13 )  tmp_2d
     6003              c_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
     6004                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6005
     6006           CASE ( 'lai_av' )
     6007              IF ( .NOT. ALLOCATED( lai_av ) )  THEN
     6008                 ALLOCATE( lai_av(nysg:nyng,nxlg:nxrg) )
     6009              ENDIF
     6010              IF ( k == 1 )  READ ( 13 )  tmp_2d
     6011              lai_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                &
     6012                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6013
     6014           CASE ( 'm_liq_av' )
     6015              IF ( .NOT. ALLOCATED( m_liq_av ) )  THEN
     6016                 ALLOCATE( m_liq_av(nysg:nyng,nxlg:nxrg) )
     6017              ENDIF
     6018              IF ( k == 1 )  READ ( 13 )  tmp_2d
     6019              m_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =              &
     6020                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6021
     6022           CASE ( 'm_soil_av' )
     6023              IF ( .NOT. ALLOCATED( m_soil_av ) )  THEN
     6024                 ALLOCATE( m_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
     6025              ENDIF
     6026              IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
     6027              m_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
     6028                 tmp_3d2(nzb_soil:nzt_soil,nysf                                &
     6029                         -nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6030
     6031           CASE ( 'qsws_liq_av' )
     6032              IF ( .NOT. ALLOCATED( qsws_liq_av ) )  THEN
     6033                 ALLOCATE( qsws_liq_av(nysg:nyng,nxlg:nxrg) )
     6034              ENDIF 
     6035              IF ( k == 1 )  READ ( 13 )  tmp_2d
     6036              qsws_liq_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
     6037                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6038           CASE ( 'qsws_soil_av' )
     6039              IF ( .NOT. ALLOCATED( qsws_soil_av ) )  THEN
     6040                 ALLOCATE( qsws_soil_av(nysg:nyng,nxlg:nxrg) )
     6041              ENDIF 
     6042              IF ( k == 1 )  READ ( 13 )  tmp_2d
     6043              qsws_soil_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =         &
     6044                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6045
     6046           CASE ( 'qsws_veg_av' )
     6047              IF ( .NOT. ALLOCATED( qsws_veg_av ) )  THEN
     6048                 ALLOCATE( qsws_veg_av(nysg:nyng,nxlg:nxrg) )
     6049              ENDIF 
     6050              IF ( k == 1 )  READ ( 13 )  tmp_2d
     6051              qsws_veg_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =          &
     6052                 tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     6053
     6054           CASE ( 't_soil_av' )
     6055              IF ( .NOT. ALLOCATED( t_soil_av ) )  THEN
     6056                 ALLOCATE( t_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) )
     6057              ENDIF
     6058              IF ( k == 1 )  READ ( 13 )  tmp_3d2(:,:,:)
     6059              t_soil_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
     6060                 tmp_3d2(:,nysf-nbgp:nynf+nbgp,                                &
     6061                         nxlf-nbgp:nxrf+nbgp)
     6062
     6063           CASE ( 'lsm_start_index_h', 'lsm_start_index_v'  )   
     6064                IF ( k == 1 )  THEN
     6065
     6066                   IF ( ALLOCATED( start_index_on_file ) )                     &
     6067                      DEALLOCATE( start_index_on_file )
     6068
     6069                   ALLOCATE ( start_index_on_file(nys_on_file:nyn_on_file,     &
     6070                   nxl_on_file:nxr_on_file) )
     6071
     6072                   READ ( 13 )  start_index_on_file
     6073
     6074                ENDIF
    60256075                 
    6026                    IF ( k == 1 )  THEN
    6027                       IF ( .NOT.  ALLOCATED( t_soil_h%var_2d ) )               &
    6028                          ALLOCATE( t_soil_h%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_h%ns) )
    6029                       READ ( 13 )  tmp_walltype_h_2d%var_2d
    6030                    ENDIF
    6031                    CALL surface_restore_elements(                              &
    6032                                               t_soil_h%var_2d,                 &
    6033                                               tmp_walltype_h_2d%var_2d,        &
    6034                                               surf_lsm_h%start_index,          &
    6035                                               start_index_on_file,             &
    6036                                               end_index_on_file,               &
    6037                                               nxlc, nysc,                      &
    6038                                               nxlf, nxrf, nysf, nynf,          &
    6039                                               nys_on_file, nyn_on_file,        &
    6040                                               nxl_on_file,nxr_on_file )
    6041 
    6042                 CASE ( 't_soil_v(0)' )
    6043                  
    6044                    IF ( k == 1 )  THEN
    6045                       IF ( .NOT.  ALLOCATED( t_soil_v(0)%var_2d ) )            &
    6046                          ALLOCATE( t_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(0)%ns) )
    6047                       READ ( 13 )  tmp_walltype_v_2d(0)%var_2d
    6048                    ENDIF
    6049                    CALL surface_restore_elements(                              &
    6050                                            t_soil_v(0)%var_2d,                 &
    6051                                            tmp_walltype_v_2d(0)%var_2d,        &
    6052                                            surf_lsm_v(0)%start_index,          &
    6053                                            start_index_on_file,                &
    6054                                            end_index_on_file,                  &
    6055                                            nxlc, nysc,                         &
    6056                                            nxlf, nxrf, nysf, nynf,             &
    6057                                            nys_on_file, nyn_on_file,           &
    6058                                            nxl_on_file,nxr_on_file )
    6059 
    6060                 CASE ( 't_soil_v(1)' )
    6061                  
    6062                    IF ( k == 1 )  THEN
    6063                       IF ( .NOT.  ALLOCATED( t_soil_v(1)%var_2d ) )            &
    6064                          ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(1)%ns) )
    6065                       READ ( 13 )  tmp_walltype_v_2d(1)%var_2d
    6066                    ENDIF
    6067                    CALL surface_restore_elements(                              &
    6068                                            t_soil_v(1)%var_2d,                 &
    6069                                            tmp_walltype_v_2d(1)%var_2d,        &
    6070                                            surf_lsm_v(1)%start_index,          &
    6071                                            start_index_on_file,                &
    6072                                            end_index_on_file,                  &
    6073                                            nxlc, nysc,                         &
    6074                                            nxlf, nxrf, nysf, nynf,             &
    6075                                            nys_on_file, nyn_on_file,           &
    6076                                            nxl_on_file,nxr_on_file )
    6077 
    6078                 CASE ( 't_soil_v(2)' )
    6079                  
    6080                    IF ( k == 1 )  THEN
    6081                       IF ( .NOT.  ALLOCATED( t_soil_v(2)%var_2d ) )            &
    6082                          ALLOCATE( t_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(2)%ns) )
    6083                       READ ( 13 )  tmp_walltype_v_2d(2)%var_2d
    6084                    ENDIF
    6085                    CALL surface_restore_elements(                              &
    6086                                            t_soil_v(2)%var_2d,                 &
    6087                                            tmp_walltype_v_2d(2)%var_2d,        &
    6088                                            surf_lsm_v(2)%start_index,          &
    6089                                            start_index_on_file,                &
    6090                                            end_index_on_file,                  &
    6091                                            nxlc, nysc,                         &
    6092                                            nxlf, nxrf, nysf, nynf,             &
    6093                                            nys_on_file, nyn_on_file,           &
    6094                                            nxl_on_file,nxr_on_file )
    6095 
    6096                 CASE ( 't_soil_v(3)' )
    6097                  
    6098                    IF ( k == 1 )  THEN
    6099                       IF ( .NOT.  ALLOCATED( t_soil_v(3)%var_2d ) )            &
    6100                          ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(3)%ns) )
    6101                       READ ( 13 )  tmp_walltype_v_2d(3)%var_2d
    6102                    ENDIF
    6103                    CALL surface_restore_elements(                              &
    6104                                            t_soil_v(3)%var_2d,                 &
    6105                                            tmp_walltype_v_2d(3)%var_2d,        &
    6106                                            surf_lsm_v(3)%start_index,          &
    6107                                            start_index_on_file,                &
    6108                                            end_index_on_file,                  &
    6109                                            nxlc, nysc,                         &
    6110                                            nxlf, nxrf, nysf, nynf,             &
    6111                                            nys_on_file, nyn_on_file,           &
    6112                                            nxl_on_file,nxr_on_file )
    6113 
    6114                 CASE ( 'm_soil_h' )
    6115                  
    6116                    IF ( k == 1 )  THEN
    6117                       IF ( .NOT.  ALLOCATED( m_soil_h%var_2d ) )               &
    6118                          ALLOCATE( m_soil_h%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_h%ns) )
    6119                       READ ( 13 )  tmp_walltype_h_2d2%var_2d
    6120                    ENDIF
    6121                    CALL surface_restore_elements(                              &
    6122                                              m_soil_h%var_2d,                  &
    6123                                              tmp_walltype_h_2d2%var_2d,        &
    6124                                              surf_lsm_h%start_index,           &
    6125                                              start_index_on_file,              &
    6126                                              end_index_on_file,                &
    6127                                              nxlc, nysc,                       &
    6128                                              nxlf, nxrf, nysf, nynf,           &
    6129                                              nys_on_file, nyn_on_file,         &
    6130                                              nxl_on_file,nxr_on_file )
    6131 
    6132                 CASE ( 'm_soil_v(0)' )
    6133                  
    6134                    IF ( k == 1 )  THEN
    6135                       IF ( .NOT.  ALLOCATED( m_soil_v(0)%var_2d ) )            &
    6136                          ALLOCATE( m_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(0)%ns) )
    6137                       READ ( 13 )  tmp_walltype_v_2d2(0)%var_2d
    6138                    ENDIF
    6139                    CALL surface_restore_elements(                              &
    6140                                           m_soil_v(0)%var_2d,                  &
    6141                                           tmp_walltype_v_2d2(0)%var_2d,        &
    6142                                           surf_lsm_v(0)%start_index,           &
    6143                                           start_index_on_file,                 &
    6144                                           end_index_on_file,                   &
    6145                                           nxlc, nysc,                          &
    6146                                           nxlf, nxrf, nysf, nynf,              &
    6147                                           nys_on_file, nyn_on_file,            &
    6148                                           nxl_on_file,nxr_on_file )
    6149 
    6150                 CASE ( 'm_soil_v(1)' )
    6151                  
    6152                    IF ( k == 1 )  THEN
    6153                       IF ( .NOT.  ALLOCATED( m_soil_v(1)%var_2d ) )            &
    6154                          ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(1)%ns) )
    6155                       READ ( 13 )  tmp_walltype_v_2d2(1)%var_2d
    6156                    ENDIF
    6157                    CALL surface_restore_elements(                              &
    6158                                           m_soil_v(1)%var_2d,                  &
    6159                                           tmp_walltype_v_2d2(1)%var_2d,        &
    6160                                           surf_lsm_v(1)%start_index,           &
    6161                                           start_index_on_file,                 &
    6162                                           end_index_on_file,                   &
    6163                                           nxlc, nysc,                          &
    6164                                           nxlf, nxrf, nysf, nynf,              &
    6165                                           nys_on_file, nyn_on_file,            &
    6166                                           nxl_on_file,nxr_on_file )
    6167 
    6168 
    6169                 CASE ( 'm_soil_v(2)' )
    6170                  
    6171                    IF ( k == 1 )  THEN
    6172                       IF ( .NOT.  ALLOCATED( m_soil_v(2)%var_2d ) )            &
    6173                          ALLOCATE( m_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(2)%ns) )
    6174                       READ ( 13 )  tmp_walltype_v_2d2(2)%var_2d
    6175                    ENDIF
    6176                    CALL surface_restore_elements(                              &
    6177                                           m_soil_v(2)%var_2d,                  &
    6178                                           tmp_walltype_v_2d2(2)%var_2d,        &
    6179                                           surf_lsm_v(2)%start_index,           &
    6180                                           start_index_on_file,                 &
    6181                                           end_index_on_file,                   &
    6182                                           nxlc, nysc,                          &
    6183                                           nxlf, nxrf, nysf, nynf,              &
    6184                                           nys_on_file, nyn_on_file,            &
    6185                                           nxl_on_file,nxr_on_file )
    6186 
    6187 
    6188                 CASE ( 'm_soil_v(3)' )
    6189                  
    6190                    IF ( k == 1 )  THEN
    6191                       IF ( .NOT.  ALLOCATED( m_soil_v(3)%var_2d ) )            &
    6192                          ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,1:surf_lsm_v(3)%ns) )
    6193                       READ ( 13 )  tmp_walltype_v_2d2(3)%var_2d
    6194                    ENDIF
    6195                    CALL surface_restore_elements(                              &
    6196                                           m_soil_v(3)%var_2d,                  &
    6197                                           tmp_walltype_v_2d2(3)%var_2d,        &
    6198                                           surf_lsm_v(3)%start_index,           &
    6199                                           start_index_on_file,                 &
    6200                                           end_index_on_file,                   &
    6201                                           nxlc, nysc,                          &
    6202                                           nxlf, nxrf, nysf, nynf,              &
    6203                                           nys_on_file, nyn_on_file,            &
    6204                                           nxl_on_file,nxr_on_file )
    6205 
    6206 
    6207                 CASE ( 'm_liq_h' )
    6208                  
    6209                    IF ( k == 1 )  THEN
    6210                       IF ( .NOT.  ALLOCATED( m_liq_h%var_1d ) )                &
    6211                          ALLOCATE( m_liq_h%var_1d(1:surf_lsm_h%ns) )
    6212                       READ ( 13 )  tmp_walltype_h_1d%var_1d
    6213                    ENDIF
    6214                    CALL surface_restore_elements(                              &
    6215                                               m_liq_h%var_1d,                  &
    6216                                               tmp_walltype_h_1d%var_1d,        &
    6217                                               surf_lsm_h%start_index,          &
    6218                                               start_index_on_file,             &
    6219                                               end_index_on_file,               &
    6220                                               nxlc, nysc,                      &
    6221                                               nxlf, nxrf, nysf, nynf,          &
    6222                                               nys_on_file, nyn_on_file,        &
    6223                                               nxl_on_file,nxr_on_file )
    6224 
    6225 
    6226                 CASE ( 'm_liq_v(0)' )
    6227                  
    6228                    IF ( k == 1 )  THEN
    6229                       IF ( .NOT.  ALLOCATED( m_liq_v(0)%var_1d ) )             &
    6230                          ALLOCATE( m_liq_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
    6231                       READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
    6232                    ENDIF
    6233                    CALL surface_restore_elements(                              &
    6234                                            m_liq_v(0)%var_1d,                  &
    6235                                            tmp_walltype_v_1d(0)%var_1d,        &
    6236                                            surf_lsm_v(0)%start_index,          &
    6237                                            start_index_on_file,                &
    6238                                            end_index_on_file,                  &
    6239                                            nxlc, nysc,                         &
    6240                                            nxlf, nxrf, nysf, nynf,             &
    6241                                            nys_on_file, nyn_on_file,           &
    6242                                            nxl_on_file,nxr_on_file )
    6243 
    6244 
    6245                 CASE ( 'm_liq_v(1)' )
    6246                  
    6247                    IF ( k == 1 )  THEN
    6248                       IF ( .NOT.  ALLOCATED( m_liq_v(1)%var_1d ) )             &
    6249                          ALLOCATE( m_liq_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
    6250                       READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
    6251                    ENDIF
    6252                    CALL surface_restore_elements(                              &
    6253                                            m_liq_v(1)%var_1d,                  &
    6254                                            tmp_walltype_v_1d(1)%var_1d,        &
    6255                                            surf_lsm_v(1)%start_index,          &
    6256                                            start_index_on_file,                &
    6257                                            end_index_on_file,                  &
    6258                                            nxlc, nysc,                         &
    6259                                            nxlf, nxrf, nysf, nynf,             &
    6260                                            nys_on_file, nyn_on_file,           &
    6261                                            nxl_on_file,nxr_on_file )
    6262 
    6263 
    6264                 CASE ( 'm_liq_v(2)' )
    6265                  
    6266                    IF ( k == 1 )  THEN
    6267                       IF ( .NOT.  ALLOCATED( m_liq_v(2)%var_1d ) )             &
    6268                          ALLOCATE( m_liq_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
    6269                       READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
    6270                    ENDIF
    6271                    CALL surface_restore_elements(                              &
    6272                                            m_liq_v(2)%var_1d,                  &
    6273                                            tmp_walltype_v_1d(2)%var_1d,        &
    6274                                            surf_lsm_v(2)%start_index,          &
    6275                                            start_index_on_file,                &
    6276                                            end_index_on_file,                  &
    6277                                            nxlc, nysc,                         &
    6278                                            nxlf, nxrf, nysf, nynf,             &
    6279                                            nys_on_file, nyn_on_file,           &
    6280                                            nxl_on_file,nxr_on_file )
    6281 
    6282                 CASE ( 'm_liq_v(3)' )
    6283                  
    6284                    IF ( k == 1 )  THEN
    6285                       IF ( .NOT.  ALLOCATED( m_liq_v(3)%var_1d ) )             &
    6286                          ALLOCATE( m_liq_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
    6287                       READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
    6288                    ENDIF
    6289                    CALL surface_restore_elements(                              &
    6290                                            m_liq_v(3)%var_1d,                  &
    6291                                            tmp_walltype_v_1d(3)%var_1d,        &
    6292                                            surf_lsm_v(3)%start_index,          &
    6293                                            start_index_on_file,                &
    6294                                            end_index_on_file,                  &
    6295                                            nxlc, nysc,                         &
    6296                                            nxlf, nxrf, nysf, nynf,             &
    6297                                            nys_on_file, nyn_on_file,           &
    6298                                            nxl_on_file,nxr_on_file )
    6299 
    6300 
    6301                 CASE ( 't_surface_h' )
    6302                  
    6303                    IF ( k == 1 )  THEN
    6304                       IF ( .NOT.  ALLOCATED( t_surface_h%var_1d ) )            &
    6305                          ALLOCATE( t_surface_h%var_1d(1:surf_lsm_h%ns) )
    6306                       READ ( 13 )  tmp_walltype_h_1d%var_1d
    6307                    ENDIF
    6308                    CALL surface_restore_elements(                              &
    6309                                               t_surface_h%var_1d,              &
    6310                                               tmp_walltype_h_1d%var_1d,        &
    6311                                               surf_lsm_h%start_index,          &
    6312                                               start_index_on_file,             &
    6313                                               end_index_on_file,               &
    6314                                               nxlc, nysc,                      &
    6315                                               nxlf, nxrf, nysf, nynf,          &
    6316                                               nys_on_file, nyn_on_file,        &
    6317                                               nxl_on_file,nxr_on_file )
    6318 
    6319                 CASE ( 't_surface_v(0)' )
    6320                  
    6321                    IF ( k == 1 )  THEN
    6322                       IF ( .NOT.  ALLOCATED( t_surface_v(0)%var_1d ) )         &
    6323                          ALLOCATE( t_surface_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
    6324                       READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
    6325                    ENDIF
    6326                    CALL surface_restore_elements(                              &
    6327                                            t_surface_v(0)%var_1d,              &
    6328                                            tmp_walltype_v_1d(0)%var_1d,        &
    6329                                            surf_lsm_v(0)%start_index,          &
    6330                                            start_index_on_file,                &
    6331                                            end_index_on_file,                  &
    6332                                            nxlc, nysc,                         &
    6333                                            nxlf, nxrf, nysf, nynf,             &
    6334                                            nys_on_file, nyn_on_file,           &
    6335                                            nxl_on_file,nxr_on_file )
    6336 
    6337                 CASE ( 't_surface_v(1)' )
    6338                  
    6339                    IF ( k == 1 )  THEN
    6340                       IF ( .NOT.  ALLOCATED( t_surface_v(1)%var_1d ) )         &
    6341                          ALLOCATE( t_surface_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
    6342                       READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
    6343                    ENDIF
    6344                    CALL surface_restore_elements(                              &
    6345                                            t_surface_v(1)%var_1d,              &
    6346                                            tmp_walltype_v_1d(1)%var_1d,        &
    6347                                            surf_lsm_v(1)%start_index,          &
    6348                                            start_index_on_file,                &
    6349                                            end_index_on_file,                  &
    6350                                            nxlc, nysc,                         &
    6351                                            nxlf, nxrf, nysf, nynf,             &
    6352                                            nys_on_file, nyn_on_file,           &
    6353                                            nxl_on_file,nxr_on_file )
    6354 
    6355                 CASE ( 't_surface_v(2)' )
    6356                  
    6357                    IF ( k == 1 )  THEN
    6358                       IF ( .NOT.  ALLOCATED( t_surface_v(2)%var_1d ) )         &
    6359                          ALLOCATE( t_surface_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
    6360                       READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
    6361                    ENDIF
    6362                    CALL surface_restore_elements(                              &
    6363                                            t_surface_v(2)%var_1d,              &
    6364                                            tmp_walltype_v_1d(2)%var_1d,        &
    6365                                            surf_lsm_v(2)%start_index,          &
    6366                                            start_index_on_file,                &
    6367                                            end_index_on_file,                  &
    6368                                            nxlc, nysc,                         &
    6369                                            nxlf, nxrf, nysf, nynf,             &
    6370                                            nys_on_file, nyn_on_file,           &
    6371                                            nxl_on_file,nxr_on_file )
    6372 
    6373                 CASE ( 't_surface_v(3)' )
    6374                  
    6375                    IF ( k == 1 )  THEN
    6376                       IF ( .NOT.  ALLOCATED( t_surface_v(3)%var_1d ) )         &
    6377                          ALLOCATE( t_surface_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
    6378                       READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
    6379                    ENDIF
    6380                    CALL surface_restore_elements(                              &
    6381                                            t_surface_v(3)%var_1d,              &
    6382                                            tmp_walltype_v_1d(3)%var_1d,        &
    6383                                            surf_lsm_v(3)%start_index,          &
    6384                                            start_index_on_file,                &
    6385                                            end_index_on_file,                  &
    6386                                            nxlc, nysc,                         &
    6387                                            nxlf, nxrf, nysf, nynf,             &
    6388                                            nys_on_file, nyn_on_file,           &
    6389                                            nxl_on_file,nxr_on_file )
    6390 
    6391                CASE DEFAULT
    6392                   WRITE( message_string, * ) 'unknown variable named "',       &
    6393                                         TRIM( field_char ), '" found in',      &
    6394                                         '&data from prior run on PE ', myid
    6395                   CALL message( 'lsm_read_restart_data', 'PA0302', 1, 2, 0, 6, &
    6396                                  0 )
    6397 
    6398             END SELECT
    6399 
    6400          ENDDO
    6401 
    6402          READ ( 13 )  field_char
    6403 
    6404       ENDDO
    6405    ENDIF
    6406 
    6407  END SUBROUTINE lsm_read_restart_data
     6076           CASE ( 'lsm_end_index_h', 'lsm_end_index_v' )   
     6077                IF ( k == 1 )  THEN
     6078
     6079                   IF ( ALLOCATED( end_index_on_file ) )                       &
     6080                      DEALLOCATE( end_index_on_file )
     6081
     6082                   ALLOCATE ( end_index_on_file(nys_on_file:nyn_on_file,       &
     6083                      nxl_on_file:nxr_on_file) )
     6084
     6085                   READ ( 13 )  end_index_on_file
     6086
     6087                ENDIF
     6088           
     6089           CASE ( 't_soil_h' )
     6090           
     6091              IF ( k == 1 )  THEN
     6092                 IF ( .NOT.  ALLOCATED( t_soil_h%var_2d ) )                    &
     6093                    ALLOCATE( t_soil_h%var_2d(nzb_soil:nzt_soil+1,             &
     6094                                              1:surf_lsm_h%ns) )
     6095                 READ ( 13 )  tmp_walltype_h_2d%var_2d
     6096              ENDIF
     6097              CALL surface_restore_elements(                                   &
     6098                                         t_soil_h%var_2d,                      &
     6099                                         tmp_walltype_h_2d%var_2d,             &
     6100                                         surf_lsm_h%start_index,               &
     6101                                         start_index_on_file,                  &
     6102                                         end_index_on_file,                    &
     6103                                         nxlc, nysc,                           &
     6104                                         nxlf, nxrf, nysf, nynf,               &
     6105                                         nys_on_file, nyn_on_file,             &
     6106                                         nxl_on_file,nxr_on_file )
     6107
     6108           CASE ( 't_soil_v(0)' )
     6109           
     6110              IF ( k == 1 )  THEN
     6111                 IF ( .NOT.  ALLOCATED( t_soil_v(0)%var_2d ) )                 &
     6112                    ALLOCATE( t_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,          &
     6113                                                 1:surf_lsm_v(0)%ns) )
     6114                 READ ( 13 )  tmp_walltype_v_2d(0)%var_2d
     6115              ENDIF
     6116              CALL surface_restore_elements(                                   &
     6117                                      t_soil_v(0)%var_2d,                      &
     6118                                      tmp_walltype_v_2d(0)%var_2d,             &
     6119                                      surf_lsm_v(0)%start_index,               & 
     6120                                      start_index_on_file,                     &
     6121                                      end_index_on_file,                       &
     6122                                      nxlc, nysc,                              &
     6123                                      nxlf, nxrf, nysf, nynf,                  &
     6124                                      nys_on_file, nyn_on_file,                &
     6125                                      nxl_on_file,nxr_on_file )
     6126
     6127           CASE ( 't_soil_v(1)' )
     6128           
     6129              IF ( k == 1 )  THEN
     6130                 IF ( .NOT.  ALLOCATED( t_soil_v(1)%var_2d ) )                 &
     6131                    ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
     6132                                                 1:surf_lsm_v(1)%ns) )
     6133                 READ ( 13 )  tmp_walltype_v_2d(1)%var_2d
     6134              ENDIF
     6135              CALL surface_restore_elements(                                   &
     6136                                      t_soil_v(1)%var_2d,                      &
     6137                                      tmp_walltype_v_2d(1)%var_2d,             &
     6138                                      surf_lsm_v(1)%start_index,               &   
     6139                                      start_index_on_file,                     &
     6140                                      end_index_on_file,                       &
     6141                                      nxlc, nysc,                              &
     6142                                      nxlf, nxrf, nysf, nynf,                  &
     6143                                      nys_on_file, nyn_on_file,                &
     6144                                      nxl_on_file,nxr_on_file )
     6145
     6146           CASE ( 't_soil_v(2)' )
     6147           
     6148              IF ( k == 1 )  THEN
     6149                 IF ( .NOT.  ALLOCATED( t_soil_v(2)%var_2d ) )                 &
     6150                    ALLOCATE( t_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,          &
     6151                                                 1:surf_lsm_v(2)%ns) )
     6152                 READ ( 13 )  tmp_walltype_v_2d(2)%var_2d
     6153              ENDIF
     6154              CALL surface_restore_elements(                                   &
     6155                                      t_soil_v(2)%var_2d,                      &
     6156                                      tmp_walltype_v_2d(2)%var_2d,             &
     6157                                      surf_lsm_v(2)%start_index,               &
     6158                                      start_index_on_file,                     &
     6159                                      end_index_on_file,                       &
     6160                                      nxlc, nysc,                              &
     6161                                      nxlf, nxrf, nysf, nynf,                  &
     6162                                      nys_on_file, nyn_on_file,                &
     6163                                      nxl_on_file,nxr_on_file )
     6164
     6165           CASE ( 't_soil_v(3)' )
     6166           
     6167              IF ( k == 1 )  THEN
     6168                 IF ( .NOT.  ALLOCATED( t_soil_v(3)%var_2d ) )                 &
     6169                    ALLOCATE( t_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
     6170                                                 1:surf_lsm_v(3)%ns) )
     6171                 READ ( 13 )  tmp_walltype_v_2d(3)%var_2d
     6172              ENDIF
     6173              CALL surface_restore_elements(                                   &
     6174                                      t_soil_v(3)%var_2d,                      &
     6175                                      tmp_walltype_v_2d(3)%var_2d,             &
     6176                                      surf_lsm_v(3)%start_index,               &
     6177                                      start_index_on_file,                     &
     6178                                      end_index_on_file,                       &
     6179                                      nxlc, nysc,                              &
     6180                                      nxlf, nxrf, nysf, nynf,                  &
     6181                                      nys_on_file, nyn_on_file,                &
     6182                                      nxl_on_file,nxr_on_file )
     6183
     6184           CASE ( 'm_soil_h' )
     6185           
     6186              IF ( k == 1 )  THEN
     6187                 IF ( .NOT.  ALLOCATED( m_soil_h%var_2d ) )                    &
     6188                    ALLOCATE( m_soil_h%var_2d(nzb_soil:nzt_soil+1,             &
     6189                                              1:surf_lsm_h%ns) )
     6190                 READ ( 13 )  tmp_walltype_h_2d2%var_2d
     6191              ENDIF
     6192              CALL surface_restore_elements(                                   &
     6193                                        m_soil_h%var_2d,                       &
     6194                                        tmp_walltype_h_2d2%var_2d,             &
     6195                                        surf_lsm_h%start_index,                & 
     6196                                        start_index_on_file,                   &
     6197                                        end_index_on_file,                     &
     6198                                        nxlc, nysc,                            &
     6199                                        nxlf, nxrf, nysf, nynf,                &
     6200                                        nys_on_file, nyn_on_file,              &
     6201                                        nxl_on_file,nxr_on_file )
     6202
     6203           CASE ( 'm_soil_v(0)' )
     6204           
     6205              IF ( k == 1 )  THEN
     6206                 IF ( .NOT.  ALLOCATED( m_soil_v(0)%var_2d ) )                 &
     6207                    ALLOCATE( m_soil_v(0)%var_2d(nzb_soil:nzt_soil+1,          &
     6208                                                 1:surf_lsm_v(0)%ns) )
     6209                 READ ( 13 )  tmp_walltype_v_2d2(0)%var_2d
     6210              ENDIF
     6211              CALL surface_restore_elements(                                   &
     6212                                     m_soil_v(0)%var_2d,                       &
     6213                                     tmp_walltype_v_2d2(0)%var_2d,             &
     6214                                     surf_lsm_v(0)%start_index,                &
     6215                                     start_index_on_file,                      &
     6216                                     end_index_on_file,                        &
     6217                                     nxlc, nysc,                               &
     6218                                     nxlf, nxrf, nysf, nynf,                   &
     6219                                     nys_on_file, nyn_on_file,                 &
     6220                                     nxl_on_file,nxr_on_file )
     6221
     6222           CASE ( 'm_soil_v(1)' )
     6223           
     6224              IF ( k == 1 )  THEN
     6225                 IF ( .NOT.  ALLOCATED( m_soil_v(1)%var_2d ) )                 &
     6226                    ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
     6227                                                 1:surf_lsm_v(1)%ns) )
     6228                 READ ( 13 )  tmp_walltype_v_2d2(1)%var_2d
     6229              ENDIF
     6230              CALL surface_restore_elements(                                   &
     6231                                     m_soil_v(1)%var_2d,                       &   
     6232                                     tmp_walltype_v_2d2(1)%var_2d,             &
     6233                                     surf_lsm_v(1)%start_index,                & 
     6234                                     start_index_on_file,                      &
     6235                                     end_index_on_file,                        &
     6236                                     nxlc, nysc,                               &
     6237                                     nxlf, nxrf, nysf, nynf,                   &
     6238                                     nys_on_file, nyn_on_file,                 &
     6239                                     nxl_on_file,nxr_on_file )
     6240
     6241
     6242           CASE ( 'm_soil_v(2)' )
     6243           
     6244              IF ( k == 1 )  THEN
     6245                 IF ( .NOT.  ALLOCATED( m_soil_v(2)%var_2d ) )                 &
     6246                    ALLOCATE( m_soil_v(2)%var_2d(nzb_soil:nzt_soil+1,          &
     6247                                                 1:surf_lsm_v(2)%ns) )
     6248                 READ ( 13 )  tmp_walltype_v_2d2(2)%var_2d
     6249              ENDIF
     6250              CALL surface_restore_elements(                                   &
     6251                                     m_soil_v(2)%var_2d,                       &
     6252                                     tmp_walltype_v_2d2(2)%var_2d,             &
     6253                                     surf_lsm_v(2)%start_index,                &   
     6254                                     start_index_on_file,                      &
     6255                                     end_index_on_file,                        &
     6256                                     nxlc, nysc,                               &
     6257                                     nxlf, nxrf, nysf, nynf,                   &
     6258                                     nys_on_file, nyn_on_file,                 &
     6259                                     nxl_on_file,nxr_on_file )
     6260
     6261
     6262           CASE ( 'm_soil_v(3)' )
     6263           
     6264              IF ( k == 1 )  THEN
     6265                 IF ( .NOT.  ALLOCATED( m_soil_v(3)%var_2d ) )                 &
     6266                    ALLOCATE( m_soil_v(1)%var_2d(nzb_soil:nzt_soil+1,          &
     6267                                                 1:surf_lsm_v(3)%ns) )
     6268                 READ ( 13 )  tmp_walltype_v_2d2(3)%var_2d
     6269              ENDIF
     6270              CALL surface_restore_elements(                                   &
     6271                                     m_soil_v(3)%var_2d,                       &
     6272                                     tmp_walltype_v_2d2(3)%var_2d,             &
     6273                                     surf_lsm_v(3)%start_index,                & 
     6274                                     start_index_on_file,                      &
     6275                                     end_index_on_file,                        &
     6276                                     nxlc, nysc,                               &
     6277                                     nxlf, nxrf, nysf, nynf,                   &
     6278                                     nys_on_file, nyn_on_file,                 &
     6279                                     nxl_on_file,nxr_on_file )
     6280
     6281
     6282           CASE ( 'm_liq_h' )
     6283           
     6284              IF ( k == 1 )  THEN
     6285                 IF ( .NOT.  ALLOCATED( m_liq_h%var_1d ) )                     &
     6286                    ALLOCATE( m_liq_h%var_1d(1:surf_lsm_h%ns) )
     6287                 READ ( 13 )  tmp_walltype_h_1d%var_1d
     6288              ENDIF
     6289              CALL surface_restore_elements(                                   &
     6290                                         m_liq_h%var_1d,                       &
     6291                                         tmp_walltype_h_1d%var_1d,             &
     6292                                         surf_lsm_h%start_index,               & 
     6293                                         start_index_on_file,                  &
     6294                                         end_index_on_file,                    &
     6295                                         nxlc, nysc,                           &
     6296                                         nxlf, nxrf, nysf, nynf,               &
     6297                                         nys_on_file, nyn_on_file,             &
     6298                                         nxl_on_file,nxr_on_file )
     6299
     6300
     6301           CASE ( 'm_liq_v(0)' )
     6302           
     6303              IF ( k == 1 )  THEN
     6304                 IF ( .NOT.  ALLOCATED( m_liq_v(0)%var_1d ) )                  &
     6305                    ALLOCATE( m_liq_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
     6306                 READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
     6307              ENDIF
     6308              CALL surface_restore_elements(                                   &
     6309                                      m_liq_v(0)%var_1d,                       &
     6310                                      tmp_walltype_v_1d(0)%var_1d,             &
     6311                                      surf_lsm_v(0)%start_index,               &
     6312                                      start_index_on_file,                     &
     6313                                      end_index_on_file,                       &
     6314                                      nxlc, nysc,                              &
     6315                                      nxlf, nxrf, nysf, nynf,                  &
     6316                                      nys_on_file, nyn_on_file,                &
     6317                                      nxl_on_file,nxr_on_file )
     6318
     6319
     6320           CASE ( 'm_liq_v(1)' )
     6321           
     6322              IF ( k == 1 )  THEN
     6323                 IF ( .NOT.  ALLOCATED( m_liq_v(1)%var_1d ) )                  &
     6324                    ALLOCATE( m_liq_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
     6325                 READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
     6326              ENDIF
     6327              CALL surface_restore_elements(                                   &
     6328                                      m_liq_v(1)%var_1d,                       &
     6329                                      tmp_walltype_v_1d(1)%var_1d,             &
     6330                                      surf_lsm_v(1)%start_index,               &
     6331                                      start_index_on_file,                     &
     6332                                      end_index_on_file,                       &
     6333                                      nxlc, nysc,                              &
     6334                                      nxlf, nxrf, nysf, nynf,                  &
     6335                                      nys_on_file, nyn_on_file,                &
     6336                                      nxl_on_file,nxr_on_file )
     6337
     6338
     6339           CASE ( 'm_liq_v(2)' )
     6340           
     6341              IF ( k == 1 )  THEN
     6342                 IF ( .NOT.  ALLOCATED( m_liq_v(2)%var_1d ) )                  &
     6343                    ALLOCATE( m_liq_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
     6344                 READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
     6345              ENDIF
     6346              CALL surface_restore_elements(                                   &
     6347                                      m_liq_v(2)%var_1d,                       &
     6348                                      tmp_walltype_v_1d(2)%var_1d,             &
     6349                                      surf_lsm_v(2)%start_index,               &
     6350                                      start_index_on_file,                     &
     6351                                      end_index_on_file,                       &
     6352                                      nxlc, nysc,                              &
     6353                                      nxlf, nxrf, nysf, nynf,                  &
     6354                                      nys_on_file, nyn_on_file,                &
     6355                                      nxl_on_file,nxr_on_file )
     6356
     6357           CASE ( 'm_liq_v(3)' )
     6358           
     6359              IF ( k == 1 )  THEN
     6360                 IF ( .NOT.  ALLOCATED( m_liq_v(3)%var_1d ) )                  &
     6361                    ALLOCATE( m_liq_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
     6362                 READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
     6363              ENDIF
     6364              CALL surface_restore_elements(                                   &
     6365                                      m_liq_v(3)%var_1d,                       &
     6366                                      tmp_walltype_v_1d(3)%var_1d,             &
     6367                                      surf_lsm_v(3)%start_index,               &
     6368                                      start_index_on_file,                     &
     6369                                      end_index_on_file,                       &
     6370                                      nxlc, nysc,                              &
     6371                                      nxlf, nxrf, nysf, nynf,                  &
     6372                                      nys_on_file, nyn_on_file,                &
     6373                                      nxl_on_file,nxr_on_file )
     6374
     6375
     6376           CASE ( 't_surface_h' )
     6377           
     6378              IF ( k == 1 )  THEN
     6379                 IF ( .NOT.  ALLOCATED( t_surface_h%var_1d ) )                 &
     6380                    ALLOCATE( t_surface_h%var_1d(1:surf_lsm_h%ns) )
     6381                 READ ( 13 )  tmp_walltype_h_1d%var_1d
     6382              ENDIF
     6383              CALL surface_restore_elements(                                   &
     6384                                         t_surface_h%var_1d,                   &
     6385                                         tmp_walltype_h_1d%var_1d,             &
     6386                                         surf_lsm_h%start_index,               &
     6387                                         start_index_on_file,                  &
     6388                                         end_index_on_file,                    &
     6389                                         nxlc, nysc,                           &
     6390                                         nxlf, nxrf, nysf, nynf,               &
     6391                                         nys_on_file, nyn_on_file,             &
     6392                                         nxl_on_file,nxr_on_file )
     6393
     6394           CASE ( 't_surface_v(0)' )
     6395           
     6396              IF ( k == 1 )  THEN
     6397                 IF ( .NOT.  ALLOCATED( t_surface_v(0)%var_1d ) )              &
     6398                    ALLOCATE( t_surface_v(0)%var_1d(1:surf_lsm_v(0)%ns) )
     6399                 READ ( 13 )  tmp_walltype_v_1d(0)%var_1d
     6400              ENDIF
     6401              CALL surface_restore_elements(                                   &
     6402                                      t_surface_v(0)%var_1d,                   &
     6403                                      tmp_walltype_v_1d(0)%var_1d,             &
     6404                                      surf_lsm_v(0)%start_index,               &
     6405                                      start_index_on_file,                     &
     6406                                      end_index_on_file,                       &
     6407                                      nxlc, nysc,                              &
     6408                                      nxlf, nxrf, nysf, nynf,                  &
     6409                                      nys_on_file, nyn_on_file,                &
     6410                                      nxl_on_file,nxr_on_file )
     6411
     6412           CASE ( 't_surface_v(1)' )
     6413           
     6414              IF ( k == 1 )  THEN
     6415                 IF ( .NOT.  ALLOCATED( t_surface_v(1)%var_1d ) )              &
     6416                    ALLOCATE( t_surface_v(1)%var_1d(1:surf_lsm_v(1)%ns) )
     6417                 READ ( 13 )  tmp_walltype_v_1d(1)%var_1d
     6418              ENDIF
     6419              CALL surface_restore_elements(                                   &
     6420                                      t_surface_v(1)%var_1d,                   &
     6421                                      tmp_walltype_v_1d(1)%var_1d,             &
     6422                                      surf_lsm_v(1)%start_index,               &
     6423                                      start_index_on_file,                     &
     6424                                      end_index_on_file,                       &
     6425                                      nxlc, nysc,                              &
     6426                                      nxlf, nxrf, nysf, nynf,                  &
     6427                                      nys_on_file, nyn_on_file,                &
     6428                                      nxl_on_file,nxr_on_file )
     6429
     6430           CASE ( 't_surface_v(2)' )
     6431           
     6432              IF ( k == 1 )  THEN
     6433                 IF ( .NOT.  ALLOCATED( t_surface_v(2)%var_1d ) )              &
     6434                    ALLOCATE( t_surface_v(2)%var_1d(1:surf_lsm_v(2)%ns) )
     6435                 READ ( 13 )  tmp_walltype_v_1d(2)%var_1d
     6436              ENDIF
     6437              CALL surface_restore_elements(                                   &
     6438                                      t_surface_v(2)%var_1d,                   &
     6439                                      tmp_walltype_v_1d(2)%var_1d,             &
     6440                                      surf_lsm_v(2)%start_index,               &
     6441                                      start_index_on_file,                     &
     6442                                      end_index_on_file,                       &
     6443                                      nxlc, nysc,                              &
     6444                                      nxlf, nxrf, nysf, nynf,                  &
     6445                                      nys_on_file, nyn_on_file,                &
     6446                                      nxl_on_file,nxr_on_file )
     6447
     6448           CASE ( 't_surface_v(3)' )
     6449           
     6450              IF ( k == 1 )  THEN
     6451                 IF ( .NOT.  ALLOCATED( t_surface_v(3)%var_1d ) )              &
     6452                    ALLOCATE( t_surface_v(3)%var_1d(1:surf_lsm_v(3)%ns) )
     6453                 READ ( 13 )  tmp_walltype_v_1d(3)%var_1d
     6454              ENDIF
     6455              CALL surface_restore_elements(                                   &
     6456                                      t_surface_v(3)%var_1d,                   &
     6457                                      tmp_walltype_v_1d(3)%var_1d,             &
     6458                                      surf_lsm_v(3)%start_index,               &   
     6459                                      start_index_on_file,                     &
     6460                                      end_index_on_file,                       &
     6461                                      nxlc, nysc,                              &
     6462                                      nxlf, nxrf, nysf, nynf,                  &
     6463                                      nys_on_file, nyn_on_file,                &
     6464                                      nxl_on_file,nxr_on_file )
     6465
     6466          CASE DEFAULT
     6467
     6468                found = .FALSE.
     6469
     6470       END SELECT
     6471
     6472
     6473 END SUBROUTINE lsm_rrd_local
    64086474
    64096475!------------------------------------------------------------------------------!
  • palm/trunk/SOURCE/modules.f90

    r2881 r2894  
    2525! -----------------
    2626! $Id$
     27! _prerun flags were removed, Control paramters restart_string and length have
     28! been added
     29!
     30! 2881 2018-03-13 16:24:40Z suehring
    2731! Added flag for switching on/off calculation of soil moisture
    2832!
     
    10771081    CHARACTER (LEN=80)   ::  run_identifier                               !< run identifier as given by mrun option -d, ENVPAR namelist parameter provided by mrun
    10781082    CHARACTER (LEN=100)  ::  initializing_actions = ' '                   !< namelist parameter
     1083    CHARACTER (LEN=100)  ::  restart_string = ' '                         !< for storing strings in case of writing/reading restart data
    10791084    CHARACTER (LEN=210)  ::  run_description_header                       !< string containing diverse run informations as run identifier, coupling mode, host, ensemble number, run date and time
    10801085    CHARACTER (LEN=1000) ::  message_string = ' '                         !< dynamic string for error message output
     
    11401145    INTEGER(iwp) ::  io_blocks = 1                     !< number of blocks for which I/O is done in sequence (total number of PEs / maximum_parallel_io_streams)
    11411146    INTEGER(iwp) ::  iran = -1234567                   !< integer random number used for flow disturbances
     1147    INTEGER(iwp) ::  length = 0                        !< integer that specifies the length of a string in case of writing/reading restart data
    11421148    INTEGER(iwp) ::  masks = 0                         !< counter for number of masked output quantities
    11431149    INTEGER(iwp) ::  maximum_grid_level                !< number of grid levels that the multigrid solver is using
     
    13011307    LOGICAL ::  synchronous_exchange = .FALSE.                   !< namelist parameter
    13021308    LOGICAL ::  syn_turb_gen = .FALSE.                           !< flag for synthetic turbulence generator module
    1303     LOGICAL ::  syn_turb_gen_prerun = .FALSE.                    !< Was restart data of the sythentic turbulence generator written out?
    13041309    LOGICAL ::  terminate_run = .FALSE.                          !< terminate run (cpu-time limit, restarts)?
    13051310    LOGICAL ::  topo_no_distinct = .FALSE.                       !< flag controlling classification of topography surfaces
     
    13201325    LOGICAL ::  uv_exposure = .FALSE.                            !< switch for uv exposure model
    13211326    LOGICAL ::  virtual_flight = .FALSE.                         !< use virtual flight model?
    1322     LOGICAL ::  virtual_flight_prerun = .FALSE.                  !< Was restart data of the virtual flight model written out?
    13231327    LOGICAL ::  wall_adjustment = .TRUE.                         !< namelist parameter
    13241328    LOGICAL ::  wind_turbine = .FALSE.                           !< flag for use of wind turbine model
    1325     LOGICAL ::  wind_turbine_prerun = .FALSE.                    !< Was restart data of the wtm model written out?
    13261329    LOGICAL ::  write_binary = .FALSE.                           !< ENVPAR namelist parameter to steer restart I/O (ENVPAR is created by mrun)
    13271330    LOGICAL ::  ws_scheme_sca = .FALSE.                          !< use Wicker-Skamarock scheme (scalar advection)?
  • palm/trunk/SOURCE/palm.f90

    r2801 r2894  
    2525! -----------------
    2626! $Id$
     27! Modified todo list, _write_restart_data/_last_actions has been renamed to
     28! _wrd_local, unit 14 will be opened now for each io_group
     29! write_3d_binary is called wrd_local now, wrd_global moved from wrd_local to
     30! palm.f90, unit 14 is closed directly after the wrd_local call, Module related
     31! routines for writing restart data have been moved to wrd_local
     32!
     33! 2801 2018-02-14 16:01:55Z suehring
    2734! Changed lpm from subroutine to module.
    2835! Introduce particle transfer in nested models.
     
    204211!>
    205212!> @todo create routine last_actions instead of calling lsm_last_actions etc.
    206 !> @todo eventually move CALL usm_write_restart_data to suitable location
    207213!> @todo move chem_init call to init_3d_model or to check_parameters
    208214!------------------------------------------------------------------------------!
     
    213219
    214220    USE chemistry_model_mod,                                                   &
    215         ONLY:  chem_init, chem_last_actions
     221        ONLY:  chem_init
    216222
    217223    USE chem_photolysis_mod,                                                   &
     
    222228               cloud_physics, constant_diffusion, coupling_char, coupling_mode,&
    223229               do2d_at_begin, do3d_at_begin, humidity, initializing_actions,   &
    224                io_blocks, io_group, land_surface, large_scale_forcing,         &
     230               io_blocks, io_group, large_scale_forcing,                       &
    225231               message_string, microphysics_morrison, microphysics_seifert,    &
    226232               nest_domain, neutral, nudging, passive_scalar, runnr,           &
    227                simulated_time, simulated_time_chr, spinup, urban_surface,      &
     233               simulated_time, simulated_time_chr, spinup,                     &
    228234               user_interface_current_revision,                                &
    229235               user_interface_required_revision, version, wall_heatflux,       &
     
    242248    USE kinds
    243249
    244     USE land_surface_model_mod,                                                &
    245         ONLY:  lsm_write_restart_data
    246 
    247250    USE particle_attributes,                                                   &
    248251        ONLY:  particle_advection
    249252
    250253    USE pegrid
     254
     255    USE pmc_particle_interface,                                                &
     256        ONLY: pmcp_g_alloc_win
    251257
    252258    USE pmc_interface,                                                         &
     
    255261               pmci_ensure_nest_mass_conservation
    256262
    257     USE pmc_particle_interface,                                                 &
    258         ONLY: pmcp_g_alloc_win
    259 
    260     USE radiation_model_mod,                                                   &
    261         ONLY:  radiation, radiation_last_actions
    262        
    263     USE urban_surface_mod,                                                     &
    264         ONLY:  usm_write_restart_data       
     263    USE write_restart_data_mod,                                                &
     264        ONLY:  wrd_global, wrd_local
     265
    265266
    266267    IMPLICIT NONE
     
    478479    IF ( write_binary )  THEN
    479480
    480        CALL cpu_log( log_point(22), 'write_3d_binary', 'start' )
     481       CALL cpu_log( log_point(22), 'wrd_local', 'start' )
    481482
    482483       CALL location_message( 'writing restart data', .FALSE. )
    483 
    484        CALL check_open( 14 )
    485484
    486485       DO  i = 0, io_blocks-1
    487486          IF ( i == io_group )  THEN
    488 !
    489 !--          Write flow field data
    490              CALL write_3d_binary
     487
     488!
     489!--          Open binary file
     490             CALL check_open( 14 )
     491!
     492!--          Write control parameters and other global variables for restart.
     493             IF ( myid == 0 )  CALL wrd_global
     494!
     495!--          Write processor specific flow field data for restart runs
     496             CALL wrd_local
     497!
     498!--          Close binary file
     499             CALL close_file( 14 )
     500
    491501          ENDIF
    492502#if defined( __parallel )
     
    497507       CALL location_message( 'finished', .TRUE. )
    498508
    499        CALL cpu_log( log_point(22), 'write_3d_binary', 'stop' )
    500 
    501 !
    502 !--    If required, write particle data
     509       CALL cpu_log( log_point(22), 'wrd_local', 'stop' )
     510
     511!
     512!--    If required, write particle data in own restart files
    503513       IF ( particle_advection )  CALL lpm_write_restart_file
    504514       
     
    509519    IF ( myid == 0 )  CALL header
    510520!
    511 !-- If required, final land surface and user-defined actions, and
     521!-- If required, final user-defined actions, and
    512522!-- last actions on the open files and close files. Unit 14 was opened
    513 !-- in write_3d_binary but it is closed here, to allow writing on this
     523!-- in wrd_local but it is closed here, to allow writing on this
    514524!-- unit in routine user_last_actions.
    515525    CALL cpu_log( log_point(4), 'last actions', 'start' )
    516     DO  i = 0, io_blocks-1
    517        IF ( i == io_group )  THEN
    518 
    519           IF ( urban_surface )  THEN
    520              CALL usm_write_restart_data
    521           ENDIF
    522           IF ( land_surface )  THEN
    523              CALL lsm_write_restart_data
    524           ENDIF
    525           IF ( radiation )  THEN
    526              CALL radiation_last_actions
    527           ENDIF
    528           IF ( air_chemistry )  THEN
    529              CALL chem_last_actions
    530           ENDIF
    531526         
    532           CALL user_last_actions
    533           IF ( write_binary )  CALL close_file( 14 )
    534        ENDIF
    535 #if defined( __parallel )
    536        CALL MPI_BARRIER( comm2d, ierr )
    537 #endif
    538     ENDDO
     527    CALL user_last_actions
    539528    CALL close_file( 0 )
    540529    CALL close_dvrp
     530
    541531    CALL cpu_log( log_point(4), 'last actions', 'stop' )
    542532
  • palm/trunk/SOURCE/parin.f90

    r2881 r2894  
    2525! -----------------
    2626! $Id$
     27! read_var_list has been renamed to rrd_global, all module related _parin
     28! routines are called before reading the global restart data to overwrite them
     29! in case of restart runs
     30!
     31! 2881 2018-03-13 16:24:40Z suehring
    2732! Added flag for switching on/off calculation of soil moisture
    2833!
     
    408413
    409414    USE radiation_model_mod,                                                   &
    410         ONLY: radiation_parin 
     415        ONLY: radiation_parin
     416
     417    USE read_restart_data_mod,                                                 &
     418        ONLY:  rrd_global     
    411419
    412420    USE spectra_mod,                                                           &
     
    614622
    615623!
     624!--       Try to read runtime parameters given by the user for this run
     625!--       (namelist "d3par"). The namelist "d3par" can be omitted. In that case
     626!--       default values are used for the parameters.
     627 12       line = ' '
     628
     629          REWIND ( 11 )
     630          line = ' '
     631          DO   WHILE ( INDEX( line, '&d3par' ) == 0 )
     632             READ ( 11, '(A)', END=20 )  line
     633          ENDDO
     634          BACKSPACE ( 11 )
     635
     636!
     637!--       Read namelist
     638          READ ( 11, d3par )
     639
     640 20       CONTINUE
     641
     642!
     643!--       Check if land surface model is used and read &lsm_par if required
     644          CALL lsm_parin
     645
     646!
     647!--       Check if urban surface model is used and read &urban_surface_par if required
     648          CALL usm_parin
     649
     650!
     651!--       Check if spectra shall be calculated and read spectra_par if required
     652          CALL spectra_parin
     653
     654!
     655!--       Check if radiation model is used and read &radiation_par if required
     656          CALL radiation_parin
     657
     658!
     659!--       Check if gust module is used and read &gust_par if required
     660          CALL gust_parin
     661 
     662 
     663!--       Check if plant canopy model is used and read &canopy_par if required
     664          CALL pcm_parin
     665 
     666!
     667!--       Read control parameters for optionally used model software packages
     668          CALL package_parin
     669
     670!
     671!--       Check if wind turbine model is used and read &wind_turbine_par if
     672!--       required
     673          CALL wtm_parin
     674!
     675!--       Check if virtual flights should be carried out and read &flight_par
     676!--       if required
     677          CALL flight_parin
     678!
     679!--       Check if synthetic turbulence generator is used and read stg_par if
     680!--       required
     681          CALL stg_parin
     682!
     683!--       Read chemistry variables
     684          CALL chem_parin
     685!
     686!--       Check if uv exposure model is used and read &uvexposure_par
     687          CALL uvem_parin
     688!
     689!--       Read user-defined variables
     690          CALL user_parin
     691
     692!
    616693!--       If required, read control parameters from restart file (produced by
    617694!--       a prior run). All PEs are reading from file created by PE0 (see
    618695!--       check_open)
    619  12       IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
    620              CALL read_var_list
    621 
     696          IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
     697
     698             CALL rrd_global
    622699!
    623700!--          Increment the run count
     
    724801
    725802!
    726 !--       Try to read runtime parameters given by the user for this run
    727 !--       (namelist "d3par"). The namelist "d3par" can be omitted. In that case
    728 !--       default values are used for the parameters.
    729           line = ' '
    730 
    731           REWIND ( 11 )
    732           line = ' '
    733           DO   WHILE ( INDEX( line, '&d3par' ) == 0 )
    734              READ ( 11, '(A)', END=20 )  line
    735           ENDDO
    736           BACKSPACE ( 11 )
    737 
    738 !
    739 !--       Read namelist
    740           READ ( 11, d3par )
    741 
    742  20       CONTINUE
    743 
    744 !
    745 !--       Check if land surface model is used and read &lsm_par if required
    746           CALL lsm_parin
    747 
    748 !
    749 !--       Check if urban surface model is used and read &urban_surface_par if required
    750           CALL usm_parin
    751 
    752 !
    753 !--       Check if spectra shall be calculated and read spectra_par if required
    754           CALL spectra_parin
    755 
    756 !
    757 !--       Check if radiation model is used and read &radiation_par if required
    758           CALL radiation_parin
    759 
    760 !
    761 !--       Check if gust module is used and read &gust_par if required
    762           CALL gust_parin
    763  
    764  
    765 !--       Check if plant canopy model is used and read &canopy_par if required
    766           CALL pcm_parin
    767  
    768 !
    769 !--       Read control parameters for optionally used model software packages
    770           CALL package_parin
    771 
    772 !
    773 !--       Check if wind turbine model is used and read &wind_turbine_par if
    774 !--       required
    775           CALL wtm_parin
    776 !
    777 !--       Check if virtual flights should be carried out and read &flight_par
    778 !--       if required
    779           CALL flight_parin
    780 !
    781 !--       Check if synthetic turbulence generator is used and read stg_par if
    782 !--       required
    783           CALL stg_parin
    784 !
    785 !--       Read chemistry variables
    786           CALL chem_parin
    787 !
    788 !--       Check if uv exposure model is used and read &uvexposure_par
    789           CALL uvem_parin
    790 !
    791 !--       Read user-defined variables
    792           CALL user_parin
    793 
    794 !
    795 !--       The restart file will be reopened when reading the subdomain data
    796           IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
    797              CALL close_file( 13 )
    798           ENDIF
    799 
    800 !
    801803!--       Check in case of initial run, if the grid point numbers are well
    802804!--       defined and allocate some arrays which are already needed in
    803805!--       init_pegrid or check_parameters. During restart jobs, these arrays
    804 !--       will be allocated in read_var_list. All other arrays are allocated
     806!--       will be allocated in rrd_global. All other arrays are allocated
    805807!--       in init_3d_model.
    806808          IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
     
    823825!
    824826!--          ATTENTION: in case of changes to the following statement please
    825 !--                  also check the allocate statement in routine read_var_list
     827!--                  also check the allocate statement in routine rrd_global
    826828             ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),        &
    827829                       ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
  • palm/trunk/SOURCE/radiation_model_mod.f90

    r2809 r2894  
    2525! -----------------
    2626! $Id$
     27! Calculations of the index range of the subdomain on file which overlaps with
     28! the current subdomain are already done in read_restart_data_mod
     29! radiation_read_restart_data was renamed to radiation_rrd_local and
     30! radiation_last_actions was renamed to radiation_wrd_local, variable named
     31! found has been introduced for checking if restart data was found, reading
     32! of restart strings has been moved completely to read_restart_data_mod,
     33! radiation_rrd_local is already inside the overlap loop programmed in
     34! read_restart_data_mod, the marker *** end rad *** is not necessary anymore,
     35! strings and their respective lengths are written out and read now in case of
     36! restart runs to get rid of prescribed character lengths (Giersch)
     37!
     38! 2809 2018-02-15 09:55:58Z suehring
    2739! Bugfix for gfortran: Replace the function C_SIZEOF with STORAGE_SIZE
    2840!
     
    809821    END INTERFACE radiation_tendency
    810822
    811     INTERFACE radiation_read_restart_data
    812        MODULE PROCEDURE radiation_read_restart_data
    813     END INTERFACE radiation_read_restart_data
    814 
    815     INTERFACE radiation_last_actions
    816        MODULE PROCEDURE radiation_last_actions
    817     END INTERFACE radiation_last_actions
     823    INTERFACE radiation_rrd_local
     824       MODULE PROCEDURE radiation_rrd_local
     825    END INTERFACE radiation_rrd_local
     826
     827    INTERFACE radiation_wrd_local
     828       MODULE PROCEDURE radiation_wrd_local
     829    END INTERFACE radiation_wrd_local
    818830
    819831    INTERFACE radiation_interaction
     
    853865           radiation_3d_data_averaging, radiation_tendency,                    &
    854866           radiation_data_output_2d, radiation_data_output_3d,                 &
    855            radiation_define_netcdf_grid, radiation_last_actions,               &
    856            radiation_read_restart_data, radiation_data_output_mask,            &
     867           radiation_define_netcdf_grid, radiation_wrd_local,                  &
     868           radiation_rrd_local, radiation_data_output_mask,                    &
    857869           radiation_radflux_gridbox, radiation_calc_svf, radiation_write_svf, &
    858870           radiation_interaction, radiation_interaction_init,                  &
     
    80308042! Description:
    80318043! ------------
    8032 !> Subroutine defines masked output variables
     8044!> Subroutine writes the respective restart data
    80338045!------------------------------------------------------------------------------!
    8034  SUBROUTINE radiation_last_actions
    8035  
    8036 
    8037     USE control_parameters
    8038        
    8039     USE kinds
     8046 SUBROUTINE radiation_wrd_local
     8047
    80408048
    80418049    IMPLICIT NONE
    80428050
    8043     IF ( write_binary )  THEN
    8044        IF ( ALLOCATED( rad_net_av ) )  THEN
    8045           WRITE ( 14 )  'rad_net_av          ';  WRITE ( 14 )  rad_net_av 
    8046        ENDIF 
    8047        IF ( ALLOCATED( rad_lw_in ) )  THEN
    8048           WRITE ( 14 )  'rad_lw_in           ';  WRITE ( 14 )  rad_lw_in 
    8049        ENDIF
    8050        IF ( ALLOCATED( rad_lw_in_av ) )  THEN
    8051           WRITE ( 14 )  'rad_lw_in_av        ';  WRITE ( 14 )  rad_lw_in_av 
    8052        ENDIF
    8053        IF ( ALLOCATED( rad_lw_out ) )  THEN
    8054           WRITE ( 14 )  'rad_lw_out          ';  WRITE ( 14 )  rad_lw_out
    8055        ENDIF
    8056        IF ( ALLOCATED( rad_lw_out_av ) )  THEN
    8057           WRITE ( 14 )  'rad_lw_out_av       ';  WRITE ( 14 )  rad_lw_out_av 
    8058        ENDIF
    8059        IF ( ALLOCATED( rad_lw_cs_hr ) )  THEN
    8060           WRITE ( 14 )  'rad_lw_cs_hr        ';  WRITE ( 14 )  rad_lw_cs_hr
    8061        ENDIF
    8062        IF ( ALLOCATED( rad_lw_cs_hr_av ) )  THEN
    8063           WRITE ( 14 )  'rad_lw_cs_hr_av     ';  WRITE ( 14 )  rad_lw_cs_hr_av
    8064        ENDIF
    8065        IF ( ALLOCATED( rad_lw_hr ) )  THEN
    8066           WRITE ( 14 )  'rad_lw_hr           ';  WRITE ( 14 )  rad_lw_hr
    8067        ENDIF
    8068        IF ( ALLOCATED( rad_lw_hr_av ) )  THEN
    8069           WRITE ( 14 )  'rad_lw_hr_av        ';  WRITE ( 14 )  rad_lw_hr_av
    8070        ENDIF
    8071        IF ( ALLOCATED( rad_sw_in ) )  THEN
    8072           WRITE ( 14 )  'rad_sw_in           ';  WRITE ( 14 )  rad_sw_in 
    8073        ENDIF
    8074        IF ( ALLOCATED( rad_sw_in_av ) )  THEN
    8075           WRITE ( 14 )  'rad_sw_in_av        ';  WRITE ( 14 )  rad_sw_in_av 
    8076        ENDIF
    8077        IF ( ALLOCATED( rad_sw_out ) )  THEN
    8078           WRITE ( 14 )  'rad_sw_out          ';  WRITE ( 14 )  rad_sw_out 
    8079        ENDIF
    8080        IF ( ALLOCATED( rad_sw_out_av ) )  THEN
    8081           WRITE ( 14 )  'rad_sw_out_av       ';  WRITE ( 14 )  rad_sw_out_av 
    8082        ENDIF
    8083        IF ( ALLOCATED( rad_sw_cs_hr ) )  THEN
    8084           WRITE ( 14 )  'rad_sw_cs_hr        ';  WRITE ( 14 )  rad_sw_cs_hr
    8085        ENDIF
    8086        IF ( ALLOCATED( rad_sw_cs_hr_av ) )  THEN
    8087           WRITE ( 14 )  'rad_sw_cs_hr_av     ';  WRITE ( 14 )  rad_sw_cs_hr_av
    8088        ENDIF
    8089        IF ( ALLOCATED( rad_sw_hr ) )  THEN
    8090           WRITE ( 14 )  'rad_sw_hr           ';  WRITE ( 14 )  rad_sw_hr
    8091        ENDIF
    8092        IF ( ALLOCATED( rad_sw_hr_av ) )  THEN
    8093           WRITE ( 14 )  'rad_sw_hr_av        ';  WRITE ( 14 )  rad_sw_hr_av
    8094        ENDIF
    8095 
    8096        WRITE ( 14 )  '*** end rad ***     '
    8097 
     8051
     8052    IF ( ALLOCATED( rad_net_av ) )  THEN
     8053       CALL wrd_write_string( 'rad_net_av' )
     8054       WRITE ( 14 )  rad_net_av
    80988055    ENDIF
    80998056
    8100  END SUBROUTINE radiation_last_actions
    8101 
    8102 
    8103 SUBROUTINE radiation_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,          &
    8104                                         nxr_on_file, nynfa, nyn_on_file, nysfa,&
    8105                                         nys_on_file, offset_xa, offset_ya,     &
    8106                                         overlap_count, tmp_2d, tmp_3d )
     8057    IF ( ALLOCATED( rad_lw_in ) )  THEN
     8058       CALL wrd_write_string( 'rad_lw_in' )
     8059       WRITE ( 14 )  rad_lw_in
     8060    ENDIF
     8061
     8062    IF ( ALLOCATED( rad_lw_in_av ) )  THEN
     8063       CALL wrd_write_string( 'rad_lw_in_av' )
     8064       WRITE ( 14 )  rad_lw_in_av
     8065    ENDIF
     8066
     8067    IF ( ALLOCATED( rad_lw_out ) )  THEN
     8068       CALL wrd_write_string( 'rad_lw_out' )
     8069       WRITE ( 14 )  rad_lw_out
     8070    ENDIF
     8071
     8072    IF ( ALLOCATED( rad_lw_out_av) )  THEN
     8073       CALL wrd_write_string( 'rad_lw_out_av' )
     8074       WRITE ( 14 )  rad_lw_out_av
     8075    ENDIF
     8076
     8077    IF ( ALLOCATED( rad_lw_cs_hr) )  THEN
     8078       CALL wrd_write_string( 'rad_lw_cs_hr' )
     8079       WRITE ( 14 )  rad_lw_cs_hr
     8080    ENDIF
     8081
     8082    IF ( ALLOCATED( rad_lw_cs_hr_av) )  THEN
     8083       CALL wrd_write_string( 'rad_lw_cs_hr_av' )
     8084       WRITE ( 14 )  rad_lw_cs_hr_av
     8085    ENDIF
     8086
     8087    IF ( ALLOCATED( rad_lw_hr) )  THEN
     8088       CALL wrd_write_string( 'rad_lw_hr' )
     8089       WRITE ( 14 )  rad_lw_hr
     8090    ENDIF
     8091
     8092    IF ( ALLOCATED( rad_lw_hr_av) )  THEN
     8093       CALL wrd_write_string( 'rad_lw_hr_av' )
     8094       WRITE ( 14 )  rad_lw_hr_av
     8095    ENDIF
     8096
     8097    IF ( ALLOCATED( rad_sw_in) )  THEN
     8098       CALL wrd_write_string( 'rad_sw_in' )
     8099       WRITE ( 14 )  rad_sw_in
     8100    ENDIF
     8101
     8102    IF ( ALLOCATED( rad_sw_in_av) )  THEN
     8103       CALL wrd_write_string( 'rad_sw_in_av' )
     8104       WRITE ( 14 )  rad_sw_in_av
     8105    ENDIF
     8106
     8107    IF ( ALLOCATED( rad_sw_out) )  THEN
     8108       CALL wrd_write_string( 'rad_sw_out' )
     8109       WRITE ( 14 )  rad_sw_out
     8110    ENDIF
     8111
     8112    IF ( ALLOCATED( rad_sw_out_av) )  THEN
     8113       CALL wrd_write_string( 'rad_sw_out_av' )
     8114       WRITE ( 14 )  rad_sw_out_av
     8115    ENDIF
     8116
     8117    IF ( ALLOCATED( rad_sw_cs_hr) )  THEN
     8118       CALL wrd_write_string( 'rad_sw_cs_hr' )
     8119       WRITE ( 14 )  rad_sw_cs_hr
     8120    ENDIF
     8121
     8122    IF ( ALLOCATED( rad_sw_cs_hr_av) )  THEN
     8123       CALL wrd_write_string( 'rad_sw_cs_hr_av' )
     8124       WRITE ( 14 )  rad_sw_cs_hr_av
     8125    ENDIF
     8126
     8127    IF ( ALLOCATED( rad_sw_hr) )  THEN
     8128       CALL wrd_write_string( 'rad_sw_hr' )
     8129       WRITE ( 14 )  rad_sw_hr
     8130    ENDIF
     8131
     8132    IF ( ALLOCATED( rad_sw_hr_av) )  THEN
     8133       CALL wrd_write_string( 'rad_sw_hr_av' )
     8134       WRITE ( 14 )  rad_sw_hr_av
     8135    ENDIF
     8136
     8137
     8138 END SUBROUTINE radiation_wrd_local
     8139
     8140
     8141SUBROUTINE radiation_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,     &
     8142                                nxr_on_file, nynf, nync, nyn_on_file, nysf,    &
     8143                                nysc, nys_on_file, tmp_2d, tmp_3d, found )
    81078144 
    81088145
     
    81158152    USE pegrid
    81168153
     8154
    81178155    IMPLICIT NONE
    8118 
    8119     CHARACTER (LEN=20) :: field_char   !<
    81208156
    81218157    INTEGER(iwp) ::  i               !<
     
    81338169    INTEGER(iwp) ::  nysf            !<
    81348170    INTEGER(iwp) ::  nys_on_file     !<
    8135     INTEGER(iwp) ::  overlap_count   !<
    8136 
    8137     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !<
    8138     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !<
    8139     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !<
    8140     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !<
    8141     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !<
    8142     INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !<
    8143 
    8144     REAL(wp),                                                                  &
    8145        DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
    8146           tmp_2d   !<
    8147 
    8148     REAL(wp),                                                                  &
    8149        DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
    8150           tmp_3d   !<
    8151 
    8152     REAL(wp),                                                                  &
    8153        DIMENSION(0:0,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) ::&
    8154           tmp_3d2   !<
    8155 
    8156 
    8157 
    8158    IF ( initializing_actions == 'read_restart_data' )  THEN
    8159       READ ( 13 )  field_char
    8160 
    8161       DO  WHILE ( TRIM( field_char ) /= '*** end rad ***' )
    8162 
    8163          DO  k = 1, overlap_count
    8164 
    8165             nxlf = nxlfa(i,k)
    8166             nxlc = nxlfa(i,k) + offset_xa(i,k)
    8167             nxrf = nxrfa(i,k)
    8168             nxrc = nxrfa(i,k) + offset_xa(i,k)
    8169             nysf = nysfa(i,k)
    8170             nysc = nysfa(i,k) + offset_ya(i,k)
    8171             nynf = nynfa(i,k)
    8172             nync = nynfa(i,k) + offset_ya(i,k)
    8173 
    8174 
    8175             SELECT CASE ( TRIM( field_char ) )
    8176 
    8177                 CASE ( 'rad_net_av' )
    8178                    IF ( .NOT. ALLOCATED( rad_net_av ) )  THEN
    8179                       ALLOCATE( rad_net_av(nysg:nyng,nxlg:nxrg) )
    8180                    ENDIF 
    8181                    IF ( k == 1 )  READ ( 13 )  tmp_2d
    8182                    rad_net_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =      &
    8183                                  tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8184                 CASE ( 'rad_lw_in' )
    8185                    IF ( .NOT. ALLOCATED( rad_lw_in ) )  THEN
    8186                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8187                            radiation_scheme == 'constant')  THEN
    8188                          ALLOCATE( rad_lw_in(0:0,nysg:nyng,nxlg:nxrg) )
    8189                       ELSE
    8190                          ALLOCATE( rad_lw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8191                       ENDIF
    8192                    ENDIF 
    8193                    IF ( k == 1 )  THEN
    8194                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8195                            radiation_scheme == 'constant')  THEN
    8196                          READ ( 13 )  tmp_3d2
    8197                          rad_lw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8198                             tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8199                       ELSE
    8200                          READ ( 13 )  tmp_3d
    8201                          rad_lw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8202                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8203                       ENDIF
    8204                    ENDIF
    8205 
    8206                 CASE ( 'rad_lw_in_av' )
    8207                    IF ( .NOT. ALLOCATED( rad_lw_in_av ) )  THEN
    8208                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8209                            radiation_scheme == 'constant')  THEN
    8210                          ALLOCATE( rad_lw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
    8211                       ELSE
    8212                          ALLOCATE( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8213                       ENDIF
    8214                    ENDIF 
    8215                    IF ( k == 1 )  THEN
    8216                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8217                            radiation_scheme == 'constant')  THEN
    8218                          READ ( 13 )  tmp_3d2
    8219                          rad_lw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8220                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8221                       ELSE
    8222                          READ ( 13 )  tmp_3d
    8223                          rad_lw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8224                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8225                       ENDIF
    8226                    ENDIF
    8227 
    8228                 CASE ( 'rad_lw_out' )
    8229                    IF ( .NOT. ALLOCATED( rad_lw_out ) )  THEN
    8230                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8231                            radiation_scheme == 'constant')  THEN
    8232                          ALLOCATE( rad_lw_out(0:0,nysg:nyng,nxlg:nxrg) )
    8233                       ELSE
    8234                          ALLOCATE( rad_lw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8235                       ENDIF
    8236                    ENDIF 
    8237                    IF ( k == 1 )  THEN
    8238                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8239                            radiation_scheme == 'constant')  THEN
    8240                          READ ( 13 )  tmp_3d2
    8241                          rad_lw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8242                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8243                       ELSE
    8244                          READ ( 13 )  tmp_3d
    8245                          rad_lw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8246                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8247                       ENDIF
    8248                    ENDIF
    8249 
    8250                 CASE ( 'rad_lw_out_av' )
    8251                    IF ( .NOT. ALLOCATED( rad_lw_out_av ) )  THEN
    8252                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8253                            radiation_scheme == 'constant')  THEN
    8254                          ALLOCATE( rad_lw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
    8255                       ELSE
    8256                          ALLOCATE( rad_lw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8257                       ENDIF
    8258                    ENDIF 
    8259                    IF ( k == 1 )  THEN
    8260                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8261                            radiation_scheme == 'constant')  THEN
    8262                          READ ( 13 )  tmp_3d2
    8263                          rad_lw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8264                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8265                       ELSE
    8266                          READ ( 13 )  tmp_3d
    8267                          rad_lw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8268                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8269                       ENDIF
    8270                    ENDIF
    8271 
    8272                 CASE ( 'rad_lw_cs_hr' )
    8273                    IF ( .NOT. ALLOCATED( rad_lw_cs_hr ) )  THEN
    8274                       ALLOCATE( rad_lw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8275                    ENDIF
    8276                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8277                    rad_lw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
    8278                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8279 
    8280                 CASE ( 'rad_lw_cs_hr_av' )
    8281                    IF ( .NOT. ALLOCATED( rad_lw_cs_hr_av ) )  THEN
    8282                       ALLOCATE( rad_lw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8283                    ENDIF
    8284                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8285                    rad_lw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
    8286                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8287 
    8288                 CASE ( 'rad_lw_hr' )
    8289                    IF ( .NOT. ALLOCATED( rad_lw_hr ) )  THEN
    8290                       ALLOCATE( rad_lw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8291                    ENDIF
    8292                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8293                    rad_lw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
    8294                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8295 
    8296                 CASE ( 'rad_lw_hr_av' )
    8297                    IF ( .NOT. ALLOCATED( rad_lw_hr_av ) )  THEN
    8298                       ALLOCATE( rad_lw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8299                    ENDIF
    8300                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8301                    rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
    8302                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8303 
    8304                 CASE ( 'rad_sw_in' )
    8305                    IF ( .NOT. ALLOCATED( rad_sw_in ) )  THEN
    8306                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8307                            radiation_scheme == 'constant')  THEN
    8308                          ALLOCATE( rad_sw_in(0:0,nysg:nyng,nxlg:nxrg) )
    8309                       ELSE
    8310                          ALLOCATE( rad_sw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8311                       ENDIF
    8312                    ENDIF 
    8313                    IF ( k == 1 )  THEN
    8314                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8315                            radiation_scheme == 'constant')  THEN
    8316                          READ ( 13 )  tmp_3d2
    8317                          rad_sw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8318                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8319                       ELSE
    8320                          READ ( 13 )  tmp_3d
    8321                          rad_sw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8322                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8323                       ENDIF
    8324                    ENDIF
    8325 
    8326                 CASE ( 'rad_sw_in_av' )
    8327                    IF ( .NOT. ALLOCATED( rad_sw_in_av ) )  THEN
    8328                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8329                            radiation_scheme == 'constant')  THEN
    8330                          ALLOCATE( rad_sw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
    8331                       ELSE
    8332                          ALLOCATE( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8333                       ENDIF
    8334                    ENDIF 
    8335                    IF ( k == 1 )  THEN
    8336                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8337                            radiation_scheme == 'constant')  THEN
    8338                          READ ( 13 )  tmp_3d2
    8339                          rad_sw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8340                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8341                       ELSE
    8342                          READ ( 13 )  tmp_3d
    8343                          rad_sw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8344                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8345                       ENDIF
    8346                    ENDIF
    8347 
    8348                 CASE ( 'rad_sw_out' )
    8349                    IF ( .NOT. ALLOCATED( rad_sw_out ) )  THEN
    8350                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8351                            radiation_scheme == 'constant')  THEN
    8352                          ALLOCATE( rad_sw_out(0:0,nysg:nyng,nxlg:nxrg) )
    8353                       ELSE
    8354                          ALLOCATE( rad_sw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8355                       ENDIF
    8356                    ENDIF 
    8357                    IF ( k == 1 )  THEN
    8358                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8359                            radiation_scheme == 'constant')  THEN
    8360                          READ ( 13 )  tmp_3d2
    8361                          rad_sw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8362                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8363                       ELSE
    8364                          READ ( 13 )  tmp_3d
    8365                          rad_sw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8366                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8367                       ENDIF
    8368                    ENDIF
    8369 
    8370                 CASE ( 'rad_sw_out_av' )
    8371                    IF ( .NOT. ALLOCATED( rad_sw_out_av ) )  THEN
    8372                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8373                            radiation_scheme == 'constant')  THEN
    8374                          ALLOCATE( rad_sw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
    8375                       ELSE
    8376                          ALLOCATE( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8377                       ENDIF
    8378                    ENDIF 
    8379                    IF ( k == 1 )  THEN
    8380                       IF ( radiation_scheme == 'clear-sky'  .OR.               &
    8381                            radiation_scheme == 'constant')  THEN
    8382                          READ ( 13 )  tmp_3d2
    8383                          rad_sw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8384                              tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8385                       ELSE
    8386                          READ ( 13 )  tmp_3d
    8387                          rad_sw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
    8388                              tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8389                       ENDIF
    8390                    ENDIF
    8391 
    8392                 CASE ( 'rad_sw_cs_hr' )
    8393                    IF ( .NOT. ALLOCATED( rad_sw_cs_hr ) )  THEN
    8394                       ALLOCATE( rad_sw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8395                    ENDIF
    8396                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8397                    rad_sw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
    8398                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8399 
    8400                 CASE ( 'rad_sw_cs_hr_av' )
    8401                    IF ( .NOT. ALLOCATED( rad_sw_cs_hr_av ) )  THEN
    8402                       ALLOCATE( rad_sw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8403                    ENDIF
    8404                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8405                    rad_sw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
    8406                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8407 
    8408                 CASE ( 'rad_sw_hr' )
    8409                    IF ( .NOT. ALLOCATED( rad_sw_hr ) )  THEN
    8410                       ALLOCATE( rad_sw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8411                    ENDIF
    8412                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8413                    rad_sw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =      &
    8414                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8415 
    8416                 CASE ( 'rad_sw_hr_av' )
    8417                    IF ( .NOT. ALLOCATED( rad_sw_hr_av ) )  THEN
    8418                       ALLOCATE( rad_sw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    8419                    ENDIF
    8420                    IF ( k == 1 )  READ ( 13 )  tmp_3d
    8421                    rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
    8422                            tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    8423 
    8424                CASE DEFAULT
    8425                   WRITE( message_string, * ) 'unknown variable named "',       &
    8426                                         TRIM( field_char ), '" found in',      &
    8427                                         '&data from prior run on PE ', myid
    8428                   CALL message( 'radiation_read_restart_data', 'PA0302', 1, 2, &
    8429                                 0, 6, 0 )
    8430 
    8431             END SELECT
    8432 
    8433          ENDDO
    8434 
    8435          READ ( 13 )  field_char
    8436 
    8437       ENDDO
    8438    ENDIF
    8439 
    8440  END SUBROUTINE radiation_read_restart_data
     8171
     8172    LOGICAL, INTENT(OUT)  :: found
     8173
     8174    REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_2d   !<
     8175
     8176    REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !<
     8177
     8178    REAL(wp), DIMENSION(0:0,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d2   !<
     8179
     8180
     8181    found = .TRUE.
     8182
     8183
     8184       SELECT CASE ( restart_string(1:length) )
     8185
     8186           CASE ( 'rad_net_av' )
     8187              IF ( .NOT. ALLOCATED( rad_net_av ) )  THEN
     8188                 ALLOCATE( rad_net_av(nysg:nyng,nxlg:nxrg) )
     8189              ENDIF 
     8190              IF ( k == 1 )  READ ( 13 )  tmp_2d
     8191              rad_net_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  =           &
     8192                            tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8193           CASE ( 'rad_lw_in' )
     8194              IF ( .NOT. ALLOCATED( rad_lw_in ) )  THEN
     8195                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8196                      radiation_scheme == 'constant')  THEN
     8197                    ALLOCATE( rad_lw_in(0:0,nysg:nyng,nxlg:nxrg) )
     8198                 ELSE
     8199                    ALLOCATE( rad_lw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8200                 ENDIF
     8201              ENDIF 
     8202              IF ( k == 1 )  THEN
     8203                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8204                      radiation_scheme == 'constant')  THEN
     8205                    READ ( 13 )  tmp_3d2
     8206                    rad_lw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
     8207                       tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8208                 ELSE
     8209                    READ ( 13 )  tmp_3d
     8210                    rad_lw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
     8211                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8212                 ENDIF
     8213              ENDIF
     8214
     8215           CASE ( 'rad_lw_in_av' )
     8216              IF ( .NOT. ALLOCATED( rad_lw_in_av ) )  THEN
     8217                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8218                      radiation_scheme == 'constant')  THEN
     8219                    ALLOCATE( rad_lw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
     8220                 ELSE
     8221                    ALLOCATE( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8222                 ENDIF
     8223              ENDIF 
     8224              IF ( k == 1 )  THEN
     8225                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8226                      radiation_scheme == 'constant')  THEN
     8227                    READ ( 13 )  tmp_3d2
     8228                    rad_lw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
     8229                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8230                 ELSE
     8231                    READ ( 13 )  tmp_3d
     8232                    rad_lw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
     8233                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8234                 ENDIF
     8235              ENDIF
     8236
     8237           CASE ( 'rad_lw_out' )
     8238              IF ( .NOT. ALLOCATED( rad_lw_out ) )  THEN
     8239                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8240                      radiation_scheme == 'constant')  THEN
     8241                    ALLOCATE( rad_lw_out(0:0,nysg:nyng,nxlg:nxrg) )
     8242                 ELSE
     8243                    ALLOCATE( rad_lw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8244                 ENDIF
     8245              ENDIF 
     8246              IF ( k == 1 )  THEN
     8247                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8248                      radiation_scheme == 'constant')  THEN
     8249                    READ ( 13 )  tmp_3d2
     8250                    rad_lw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
     8251                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8252                 ELSE
     8253                    READ ( 13 )  tmp_3d
     8254                    rad_lw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =    &
     8255                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8256                 ENDIF
     8257              ENDIF
     8258
     8259           CASE ( 'rad_lw_out_av' )
     8260              IF ( .NOT. ALLOCATED( rad_lw_out_av ) )  THEN
     8261                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8262                      radiation_scheme == 'constant')  THEN
     8263                    ALLOCATE( rad_lw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
     8264                 ELSE
     8265                    ALLOCATE( rad_lw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8266                 ENDIF
     8267              ENDIF 
     8268              IF ( k == 1 )  THEN
     8269                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8270                      radiation_scheme == 'constant')  THEN
     8271                    READ ( 13 )  tmp_3d2
     8272                    rad_lw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) &
     8273                       = tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8274                 ELSE
     8275                    READ ( 13 )  tmp_3d
     8276                    rad_lw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
     8277                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8278                 ENDIF
     8279              ENDIF
     8280
     8281           CASE ( 'rad_lw_cs_hr' )
     8282              IF ( .NOT. ALLOCATED( rad_lw_cs_hr ) )  THEN
     8283                 ALLOCATE( rad_lw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8284              ENDIF
     8285              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8286              rad_lw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
     8287                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8288
     8289           CASE ( 'rad_lw_cs_hr_av' )
     8290              IF ( .NOT. ALLOCATED( rad_lw_cs_hr_av ) )  THEN
     8291                 ALLOCATE( rad_lw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8292              ENDIF
     8293              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8294              rad_lw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
     8295                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8296
     8297           CASE ( 'rad_lw_hr' )
     8298              IF ( .NOT. ALLOCATED( rad_lw_hr ) )  THEN
     8299                 ALLOCATE( rad_lw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8300              ENDIF
     8301              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8302              rad_lw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
     8303                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8304
     8305           CASE ( 'rad_lw_hr_av' )
     8306              IF ( .NOT. ALLOCATED( rad_lw_hr_av ) )  THEN
     8307                 ALLOCATE( rad_lw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8308              ENDIF
     8309              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8310              rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
     8311                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8312
     8313           CASE ( 'rad_sw_in' )
     8314              IF ( .NOT. ALLOCATED( rad_sw_in ) )  THEN
     8315                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8316                      radiation_scheme == 'constant')  THEN
     8317                    ALLOCATE( rad_sw_in(0:0,nysg:nyng,nxlg:nxrg) )
     8318                 ELSE
     8319                    ALLOCATE( rad_sw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8320                 ENDIF
     8321              ENDIF 
     8322              IF ( k == 1 )  THEN
     8323                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8324                      radiation_scheme == 'constant')  THEN
     8325                    READ ( 13 )  tmp_3d2
     8326                    rad_sw_in(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =   &
     8327                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8328                 ELSE
     8329                    READ ( 13 )  tmp_3d
     8330                    rad_sw_in(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
     8331                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8332                 ENDIF
     8333              ENDIF
     8334
     8335           CASE ( 'rad_sw_in_av' )
     8336              IF ( .NOT. ALLOCATED( rad_sw_in_av ) )  THEN
     8337                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8338                      radiation_scheme == 'constant')  THEN
     8339                    ALLOCATE( rad_sw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
     8340                 ELSE
     8341                    ALLOCATE( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8342                 ENDIF
     8343              ENDIF 
     8344              IF ( k == 1 )  THEN
     8345                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8346                      radiation_scheme == 'constant')  THEN
     8347                    READ ( 13 )  tmp_3d2
     8348                    rad_sw_in_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =&
     8349                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8350                 ELSE
     8351                    READ ( 13 )  tmp_3d
     8352                    rad_sw_in_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
     8353                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8354                 ENDIF
     8355              ENDIF
     8356
     8357           CASE ( 'rad_sw_out' )
     8358              IF ( .NOT. ALLOCATED( rad_sw_out ) )  THEN
     8359                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8360                      radiation_scheme == 'constant')  THEN
     8361                    ALLOCATE( rad_sw_out(0:0,nysg:nyng,nxlg:nxrg) )
     8362                 ELSE
     8363                    ALLOCATE( rad_sw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8364                 ENDIF
     8365              ENDIF 
     8366              IF ( k == 1 )  THEN
     8367                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8368                      radiation_scheme == 'constant')  THEN
     8369                    READ ( 13 )  tmp_3d2
     8370                    rad_sw_out(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =  &
     8371                        tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8372                 ELSE
     8373                    READ ( 13 )  tmp_3d
     8374                    rad_sw_out(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =    &
     8375                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8376                 ENDIF
     8377              ENDIF
     8378
     8379           CASE ( 'rad_sw_out_av' )
     8380              IF ( .NOT. ALLOCATED( rad_sw_out_av ) )  THEN
     8381                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8382                      radiation_scheme == 'constant')  THEN
     8383                    ALLOCATE( rad_sw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
     8384                 ELSE
     8385                    ALLOCATE( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8386                 ENDIF
     8387              ENDIF 
     8388              IF ( k == 1 )  THEN
     8389                 IF ( radiation_scheme == 'clear-sky'  .OR.                    &
     8390                      radiation_scheme == 'constant')  THEN
     8391                    READ ( 13 )  tmp_3d2
     8392                    rad_sw_out_av(0:0,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) &
     8393                       = tmp_3d2(0:0,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8394                 ELSE
     8395                    READ ( 13 )  tmp_3d
     8396                    rad_sw_out_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
     8397                        tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8398                 ENDIF
     8399              ENDIF
     8400
     8401           CASE ( 'rad_sw_cs_hr' )
     8402              IF ( .NOT. ALLOCATED( rad_sw_cs_hr ) )  THEN
     8403                 ALLOCATE( rad_sw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8404              ENDIF
     8405              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8406              rad_sw_cs_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
     8407                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8408
     8409           CASE ( 'rad_sw_cs_hr_av' )
     8410              IF ( .NOT. ALLOCATED( rad_sw_cs_hr_av ) )  THEN
     8411                 ALLOCATE( rad_sw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8412              ENDIF
     8413              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8414              rad_sw_cs_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =     &
     8415                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8416
     8417           CASE ( 'rad_sw_hr' )
     8418              IF ( .NOT. ALLOCATED( rad_sw_hr ) )  THEN
     8419                 ALLOCATE( rad_sw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8420              ENDIF
     8421              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8422              rad_sw_hr(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =           &
     8423                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8424
     8425           CASE ( 'rad_sw_hr_av' )
     8426              IF ( .NOT. ALLOCATED( rad_sw_hr_av ) )  THEN
     8427                 ALLOCATE( rad_sw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     8428              ENDIF
     8429              IF ( k == 1 )  READ ( 13 )  tmp_3d
     8430              rad_lw_hr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =        &
     8431                      tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     8432
     8433           CASE DEFAULT
     8434
     8435              found = .FALSE.
     8436
     8437       END SELECT
     8438
     8439
     8440 END SUBROUTINE radiation_rrd_local
    84418441
    84428442
  • palm/trunk/SOURCE/sum_up_3d_data.f90

    r2817 r2894  
    2525! -----------------
    2626! $Id$
     27! Changed comment
     28!
     29! 2817 2018-02-19 16:32:21Z suehring
    2730! Preliminary gust module interface implemented
    2831!
     
    254257!-- time or the first time after average_3d_data has been called
    255258!-- (some or all of the arrays may have been already allocated
    256 !-- in read_3d_binary)
     259!-- in rrd_local)
    257260    IF ( average_count_3d == 0 )  THEN
    258261
  • palm/trunk/SOURCE/surface_mod.f90

    r2813 r2894  
    2626! -----------------
    2727! $Id$
     28! Calculations of the index range of the subdomain on file which overlaps with
     29! the current subdomain are already done in read_restart_data_mod,
     30! surface_read/write_restart_data was renamed to surface_r/wrd_local, variable
     31! named found has been introduced for checking if restart data was found,
     32! reading of restart strings has been moved completely to
     33! read_restart_data_mod, surface_rrd_local is already inside the overlap loop
     34! programmed in read_restart_data_mod, SAVE attribute added where necessary,
     35! deallocation and allocation of some arrays have been changed to take care of
     36! different restart files that can be opened (index i), the marker *** end
     37! surf *** is not necessary anymore, strings and their respective lengths are
     38! written out and read now in case of restart runs to get rid of prescribed
     39! character lengths (Giersch)
     40!
     41! 2813 2018-02-16 16:28:14Z suehring
    2842! Some more bugfixes concerning restart runs
    2943!
     
    432446    END INTERFACE init_surface_arrays
    433447
    434     INTERFACE surface_read_restart_data
    435        MODULE PROCEDURE surface_read_restart_data
    436     END INTERFACE surface_read_restart_data
    437 
    438     INTERFACE surface_write_restart_data
    439        MODULE PROCEDURE surface_write_restart_data
    440     END INTERFACE surface_write_restart_data
     448    INTERFACE surface_rrd_local
     449       MODULE PROCEDURE surface_rrd_local
     450    END INTERFACE surface_rrd_local
     451
     452    INTERFACE surface_wrd_local
     453       MODULE PROCEDURE surface_wrd_local
     454    END INTERFACE surface_wrd_local
    441455
    442456    INTERFACE surface_last_actions
     
    457471    PUBLIC get_topography_top_index, get_topography_top_index_ji, init_bc,     &
    458472           init_surfaces,                                                      &
    459            init_surface_arrays, surface_read_restart_data,                     &
    460            surface_restore_elements, surface_write_restart_data,               &
     473           init_surface_arrays, surface_rrd_local,                     &
     474           surface_restore_elements, surface_wrd_local,               &
    461475           surface_last_actions
    462476
     
    888902    END SUBROUTINE init_surface_arrays
    889903
     904
     905!------------------------------------------------------------------------------!
     906! Description:
     907! ------------
     908!> Deallocating memory for upward and downward-facing horizontal surface types,
     909!> except for top fluxes.
     910!------------------------------------------------------------------------------!
     911    SUBROUTINE deallocate_surface_attributes_h( surfaces )
     912
     913       IMPLICIT NONE
     914
     915
     916       TYPE(surf_type) ::  surfaces  !< respective surface type
     917
     918
     919       DEALLOCATE ( surfaces%start_index )
     920       DEALLOCATE ( surfaces%end_index )
     921!
     922!--    Indices to locate surface element
     923       DEALLOCATE ( surfaces%i )
     924       DEALLOCATE ( surfaces%j )
     925       DEALLOCATE ( surfaces%k )
     926!
     927!--    Surface-layer height
     928       DEALLOCATE ( surfaces%z_mo )
     929!
     930!--    Surface orientation
     931       DEALLOCATE ( surfaces%facing )
     932!
     933!--    Surface-parallel wind velocity
     934       DEALLOCATE ( surfaces%uvw_abs )
     935!
     936!--    Roughness
     937       DEALLOCATE ( surfaces%z0 )
     938       DEALLOCATE ( surfaces%z0h )
     939       DEALLOCATE ( surfaces%z0q )
     940!
     941!--    Friction velocity
     942       DEALLOCATE ( surfaces%us )
     943!
     944!--    Stability parameter
     945       DEALLOCATE ( surfaces%ol )
     946!
     947!--    Bulk Richardson number
     948       DEALLOCATE ( surfaces%rib )
     949!
     950!--    Vertical momentum fluxes of u and v
     951       DEALLOCATE ( surfaces%usws ) 
     952       DEALLOCATE ( surfaces%vsws ) 
     953!
     954!--    Required in production_e
     955       IF ( .NOT. constant_diffusion )  THEN   
     956          DEALLOCATE ( surfaces%u_0 ) 
     957          DEALLOCATE ( surfaces%v_0 )
     958       ENDIF
     959!
     960!--    Characteristic temperature and surface flux of sensible heat
     961       DEALLOCATE ( surfaces%ts )   
     962       DEALLOCATE ( surfaces%shf )   
     963!
     964!--    surface temperature
     965       DEALLOCATE ( surfaces%pt_surface )
     966!
     967!--    Characteristic humidity and surface flux of latent heat
     968       IF ( humidity )  THEN
     969          DEALLOCATE ( surfaces%qs )
     970          DEALLOCATE ( surfaces%qsws )     
     971       ENDIF
     972!
     973!--    Characteristic scalar and surface flux of scalar
     974       IF ( passive_scalar )  THEN
     975          DEALLOCATE ( surfaces%ss )   
     976          DEALLOCATE ( surfaces%ssws )
     977       ENDIF
     978!
     979!--    Scaling parameter (cs*) and surface flux of chemical species
     980       IF ( air_chemistry )  THEN
     981          DEALLOCATE ( surfaces%css )   
     982          DEALLOCATE ( surfaces%cssws )
     983       ENDIF
     984!
     985!--    Arrays for storing potential temperature and
     986!--    specific humidity at first grid level
     987       DEALLOCATE ( surfaces%pt1 )
     988       DEALLOCATE ( surfaces%qv1 )
     989!
     990!--       
     991       IF ( cloud_physics .AND. microphysics_morrison)  THEN
     992          DEALLOCATE ( surfaces%qcs )
     993          DEALLOCATE ( surfaces%ncs )
     994          DEALLOCATE ( surfaces%qcsws )
     995          DEALLOCATE ( surfaces%ncsws )
     996       ENDIF
     997!
     998!--       
     999       IF ( cloud_physics .AND. microphysics_seifert)  THEN
     1000          DEALLOCATE ( surfaces%qrs )
     1001          DEALLOCATE ( surfaces%nrs )
     1002          DEALLOCATE ( surfaces%qrsws )
     1003          DEALLOCATE ( surfaces%nrsws )
     1004       ENDIF
     1005!
     1006!--    Salinity surface flux
     1007       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
     1008
     1009    END SUBROUTINE deallocate_surface_attributes_h
     1010
     1011
    8901012!------------------------------------------------------------------------------!
    8911013! Description:
     
    9161038!--    might exist for given (j,i).
    9171039!--    If no surface of respective type exist at current (j,i), set indicies
    918 !--    such that loop in diffusion routines will not be entered. 
     1040!--    such that loop in diffusion routines will not be entered.
    9191041       ALLOCATE ( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
    9201042       ALLOCATE ( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l)   )
     
    10151137! Description:
    10161138! ------------
     1139!> Deallocating memory for model-top fluxes 
     1140!------------------------------------------------------------------------------!
     1141    SUBROUTINE deallocate_surface_attributes_h_top( surfaces )
     1142
     1143       IMPLICIT NONE
     1144
     1145
     1146       TYPE(surf_type) ::  surfaces !< respective surface type
     1147
     1148       DEALLOCATE ( surfaces%start_index )
     1149       DEALLOCATE ( surfaces%end_index )
     1150!
     1151!--    Indices to locate surface (model-top) element
     1152       DEALLOCATE ( surfaces%i )
     1153       DEALLOCATE ( surfaces%j )
     1154       DEALLOCATE ( surfaces%k )
     1155
     1156       IF ( .NOT. constant_diffusion )  THEN   
     1157          DEALLOCATE ( surfaces%u_0 ) 
     1158          DEALLOCATE ( surfaces%v_0 )
     1159       ENDIF
     1160!
     1161!--    Vertical momentum fluxes of u and v
     1162       DEALLOCATE ( surfaces%usws ) 
     1163       DEALLOCATE ( surfaces%vsws ) 
     1164!
     1165!--    Sensible heat flux
     1166       DEALLOCATE ( surfaces%shf )   
     1167!
     1168!--    Latent heat flux
     1169       IF ( humidity .OR. coupling_mode == 'ocean_to_atmosphere')  THEN
     1170          DEALLOCATE ( surfaces%qsws )     
     1171       ENDIF
     1172!
     1173!--    Scalar flux
     1174       IF ( passive_scalar )  THEN
     1175          DEALLOCATE ( surfaces%ssws )
     1176       ENDIF
     1177!
     1178!--    Chemical species flux
     1179       IF ( air_chemistry )  THEN
     1180          DEALLOCATE ( surfaces%cssws )
     1181       ENDIF
     1182!
     1183!--       
     1184       IF ( cloud_physics .AND. microphysics_morrison)  THEN
     1185          DEALLOCATE ( surfaces%qcsws )
     1186          DEALLOCATE ( surfaces%ncsws )
     1187       ENDIF
     1188!
     1189!--       
     1190       IF ( cloud_physics .AND. microphysics_seifert)  THEN
     1191          DEALLOCATE ( surfaces%qrsws )
     1192          DEALLOCATE ( surfaces%nrsws )
     1193       ENDIF
     1194!
     1195!--    Salinity flux
     1196       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
     1197
     1198    END SUBROUTINE deallocate_surface_attributes_h_top
     1199
     1200
     1201!------------------------------------------------------------------------------!
     1202! Description:
     1203! ------------
    10171204!> Allocating memory for model-top fluxes 
    10181205!------------------------------------------------------------------------------!
     
    10821269
    10831270    END SUBROUTINE allocate_surface_attributes_h_top
     1271
     1272
     1273!------------------------------------------------------------------------------!
     1274! Description:
     1275! ------------
     1276!> Deallocating memory for vertical surface types.
     1277!------------------------------------------------------------------------------!
     1278    SUBROUTINE deallocate_surface_attributes_v( surfaces )
     1279
     1280       IMPLICIT NONE
     1281
     1282
     1283       TYPE(surf_type) ::  surfaces !< respective surface type
     1284
     1285!
     1286!--    Allocate arrays for start and end index of vertical surface type
     1287!--    for each (j,i)-grid point. This is required in diffion_x, which is
     1288!--    called for each (j,i). In order to find the location where the
     1289!--    respective flux is store within the surface-type, start- and end-
     1290!--    index are stored for each (j,i). For example, each (j,i) can have
     1291!--    several entries where fluxes for vertical surfaces might be stored. 
     1292!--    In the flat case, where no vertical walls exit, set indicies such
     1293!--    that loop in diffusion routines will not be entered.
     1294       DEALLOCATE ( surfaces%start_index )
     1295       DEALLOCATE ( surfaces%end_index )
     1296!
     1297!--    Indices to locate surface element.
     1298       DEALLOCATE ( surfaces%i )
     1299       DEALLOCATE ( surfaces%j )
     1300       DEALLOCATE ( surfaces%k )
     1301!
     1302!--    Surface-layer height
     1303       DEALLOCATE ( surfaces%z_mo )
     1304!
     1305!--    Surface orientation
     1306       DEALLOCATE ( surfaces%facing )
     1307!
     1308!--    Surface parallel wind velocity
     1309       DEALLOCATE ( surfaces%uvw_abs )
     1310!
     1311!--    Roughness
     1312       DEALLOCATE ( surfaces%z0 )
     1313       DEALLOCATE ( surfaces%z0h )
     1314       DEALLOCATE ( surfaces%z0q )
     1315
     1316!
     1317!--    Friction velocity
     1318       DEALLOCATE ( surfaces%us )
     1319!
     1320!--    Allocate Obukhov length and bulk Richardson number. Actually, at
     1321!--    vertical surfaces these are only required for natural surfaces. 
     1322!--    for natural land surfaces
     1323       DEALLOCATE( surfaces%ol )
     1324       DEALLOCATE( surfaces%rib )
     1325!
     1326!--    Allocate arrays for surface momentum fluxes for u and v. For u at north-
     1327!--    and south-facing surfaces, for v at east- and west-facing surfaces.
     1328       DEALLOCATE ( surfaces%mom_flux_uv )
     1329!
     1330!--    Allocate array for surface momentum flux for w - wsus and wsvs
     1331       DEALLOCATE ( surfaces%mom_flux_w )
     1332!
     1333!--    Allocate array for surface momentum flux for subgrid-scale tke wsus and
     1334!--    wsvs; first index usvs or vsws, second index for wsus or wsvs, depending
     1335!--    on surface.
     1336       DEALLOCATE ( surfaces%mom_flux_tke ) 
     1337!
     1338!--    Characteristic temperature and surface flux of sensible heat
     1339       DEALLOCATE ( surfaces%ts )   
     1340       DEALLOCATE ( surfaces%shf )
     1341!
     1342!--    surface temperature
     1343       DEALLOCATE ( surfaces%pt_surface )
     1344!
     1345!--    Characteristic humidity and surface flux of latent heat
     1346       IF ( humidity )  THEN
     1347          DEALLOCATE ( surfaces%qs )
     1348          DEALLOCATE ( surfaces%qsws )     
     1349       ENDIF
     1350!
     1351!--    Characteristic scalar and surface flux of scalar
     1352       IF ( passive_scalar )  THEN
     1353          DEALLOCATE ( surfaces%ss )   
     1354          DEALLOCATE ( surfaces%ssws )
     1355       ENDIF
     1356!
     1357!--    Scaling parameter (cs*) and surface flux of chemical species
     1358       IF ( air_chemistry )  THEN
     1359             DEALLOCATE ( surfaces%css )   
     1360             DEALLOCATE ( surfaces%cssws )
     1361       ENDIF
     1362!
     1363!--    Arrays for storing potential temperature and
     1364!--    specific humidity at first grid level
     1365       DEALLOCATE ( surfaces%pt1 )
     1366       DEALLOCATE ( surfaces%qv1 )
     1367
     1368       IF ( cloud_physics .AND. microphysics_seifert)  THEN
     1369          DEALLOCATE ( surfaces%qcs )
     1370          DEALLOCATE ( surfaces%ncs )
     1371          DEALLOCATE ( surfaces%qcsws )
     1372          DEALLOCATE ( surfaces%ncsws )
     1373       ENDIF
     1374
     1375       IF ( cloud_physics .AND. microphysics_seifert)  THEN
     1376          DEALLOCATE ( surfaces%qrs )
     1377          DEALLOCATE ( surfaces%nrs )
     1378          DEALLOCATE ( surfaces%qrsws )
     1379          DEALLOCATE ( surfaces%nrsws )
     1380       ENDIF
     1381!
     1382!--    Salinity surface flux
     1383       IF ( ocean )  DEALLOCATE ( surfaces%sasws )
     1384
     1385    END SUBROUTINE deallocate_surface_attributes_v
     1386
    10841387
    10851388!------------------------------------------------------------------------------!
     
    12031506
    12041507    END SUBROUTINE allocate_surface_attributes_v
     1508
    12051509
    12061510!------------------------------------------------------------------------------!
     
    21752479!> type) onto a surface type, and writes binary data into restart files.
    21762480!------------------------------------------------------------------------------!
    2177     SUBROUTINE surface_write_restart_data
     2481    SUBROUTINE surface_wrd_local
     2482
    21782483
    21792484       IMPLICIT NONE
     
    26372942
    26382943
    2639        WRITE ( 14 )  'ns_h_on_file                  '
    2640        WRITE ( 14 )   ns_h_on_file
    2641        WRITE ( 14 )  'ns_v_on_file                  '
    2642        WRITE ( 14 )   ns_v_on_file
     2944       CALL wrd_write_string( 'ns_h_on_file' )
     2945       WRITE ( 14 )  ns_h_on_file
     2946
     2947       CALL wrd_write_string( 'ns_v_on_file' )
     2948       WRITE ( 14 )  ns_v_on_file
     2949
    26432950!
    26442951!--    Write required restart data.
     
    26462953       DO  l = 0, 2
    26472954          WRITE( dum, '(I1)')  l
    2648          
    2649           WRITE ( 14 )  'surf_h(' // dum // ')%start_index         ' 
    2650           WRITE ( 14 )   surf_h(l)%start_index
    2651           WRITE ( 14 )  'surf_h(' // dum // ')%end_index           ' 
    2652           WRITE ( 14 )   surf_h(l)%end_index
     2955
     2956          CALL wrd_write_string( 'surf_h(' // dum // ')%start_index' )
     2957          WRITE ( 14 )  surf_h(l)%start_index
     2958
     2959          CALL wrd_write_string( 'surf_h(' // dum // ')%end_index' )
     2960          WRITE ( 14 )  surf_h(l)%end_index
    26532961
    26542962          IF ( ALLOCATED ( surf_h(l)%us ) )  THEN
    2655              WRITE ( 14 )  'surf_h(' // dum // ')%us                  '
     2963             CALL wrd_write_string( 'surf_h(' // dum // ')%us' )
    26562964             WRITE ( 14 )  surf_h(l)%us
    2657           ENDIF
     2965          ENDIF
     2966
    26582967          IF ( ALLOCATED ( surf_h(l)%ts ) )  THEN
    2659              WRITE ( 14 )  'surf_h(' // dum // ')%ts                  '
     2968             CALL wrd_write_string( 'surf_h(' // dum // ')%ts' )
    26602969             WRITE ( 14 )  surf_h(l)%ts
    26612970          ENDIF
     2971         
    26622972          IF ( ALLOCATED ( surf_h(l)%qs ) )  THEN
    2663              WRITE ( 14 )  'surf_h(' // dum // ')%qs                  ' 
     2973             CALL wrd_write_string( 'surf_h(' // dum // ')%qs' ) 
    26642974             WRITE ( 14 )  surf_h(l)%qs
    26652975          ENDIF
     2976
    26662977          IF ( ALLOCATED ( surf_h(l)%ss ) )  THEN
    2667              WRITE ( 14 )  'surf_h(' // dum // ')%ss                  ' 
     2978             CALL wrd_write_string( 'surf_h(' // dum // ')%ss' ) 
    26682979             WRITE ( 14 )  surf_h(l)%ss
    26692980          ENDIF
     2981
    26702982          IF ( ALLOCATED ( surf_h(l)%qcs ) )  THEN 
    2671              WRITE ( 14 )  'surf_h(' // dum // ')%qcs                 '
     2983             CALL wrd_write_string( 'surf_h(' // dum // ')%qcs' )
    26722984             WRITE ( 14 )  surf_h(l)%qcs
    26732985          ENDIF
     2986
    26742987          IF ( ALLOCATED ( surf_h(l)%ncs ) )  THEN
    2675              WRITE ( 14 )  'surf_h(' // dum // ')%ncs                 '
     2988             CALL wrd_write_string( 'surf_h(' // dum // ')%ncs' )
    26762989             WRITE ( 14 )  surf_h(l)%ncs
    26772990          ENDIF
     2991
    26782992          IF ( ALLOCATED ( surf_h(l)%qrs ) )  THEN 
    2679              WRITE ( 14 )  'surf_h(' // dum // ')%qrs                 '
     2993             CALL wrd_write_string( 'surf_h(' // dum // ')%qrs' )
    26802994             WRITE ( 14 )  surf_h(l)%qrs
    26812995          ENDIF
     2996
    26822997          IF ( ALLOCATED ( surf_h(l)%nrs ) )  THEN
    2683              WRITE ( 14 )  'surf_h(' // dum // ')%nrs                 ' 
     2998             CALL wrd_write_string( 'surf_h(' // dum // ')%nrs' ) 
    26842999             WRITE ( 14 )  surf_h(l)%nrs
    26853000          ENDIF
     3001
    26863002          IF ( ALLOCATED ( surf_h(l)%ol ) )  THEN
    2687              WRITE ( 14 )  'surf_h(' // dum // ')%ol                  ' 
     3003             CALL wrd_write_string( 'surf_h(' // dum // ')%ol' ) 
    26883004             WRITE ( 14 )  surf_h(l)%ol
    2689           ENDIF
     3005          ENDIF
     3006
    26903007          IF ( ALLOCATED ( surf_h(l)%rib ) )  THEN
    2691              WRITE ( 14 )  'surf_h(' // dum // ')%rib                 '
     3008            CALL wrd_write_string( 'surf_h(' // dum // ')%rib' )
    26923009             WRITE ( 14 )  surf_h(l)%rib
    2693           ENDIF
     3010          ENDIF
     3011
    26943012          IF ( ALLOCATED ( surf_h(l)%pt_surface ) )  THEN
    2695              WRITE ( 14 )  'surf_h(' // dum // ')%pt_surface          '
     3013             CALL wrd_write_string( 'surf_h(' // dum // ')%pt_surface' )
    26963014             WRITE ( 14 )  surf_h(l)%pt_surface
    2697           ENDIF
     3015          ENDIF
     3016
    26983017          IF ( ALLOCATED ( surf_h(l)%usws ) )  THEN
    2699              WRITE ( 14 )  'surf_h(' // dum // ')%usws                '
     3018             CALL wrd_write_string( 'surf_h(' // dum // ')%usws' )
    27003019             WRITE ( 14 )  surf_h(l)%usws
    27013020          ENDIF
     3021
    27023022          IF ( ALLOCATED ( surf_h(l)%vsws ) )  THEN
    2703              WRITE ( 14 )  'surf_h(' // dum // ')%vsws                ' 
     3023             CALL wrd_write_string( 'surf_h(' // dum // ')%vsws' ) 
    27043024             WRITE ( 14 )  surf_h(l)%vsws
    27053025          ENDIF
     3026         
    27063027          IF ( ALLOCATED ( surf_h(l)%shf ) )  THEN
    2707              WRITE ( 14 )  'surf_h(' // dum // ')%shf                 '
     3028             CALL wrd_write_string( 'surf_h(' // dum // ')%shf' )
    27083029             WRITE ( 14 )  surf_h(l)%shf
    27093030          ENDIF
     3031
    27103032          IF ( ALLOCATED ( surf_h(l)%qsws ) )  THEN
    2711              WRITE ( 14 )  'surf_h(' // dum // ')%qsws                ' 
     3033             CALL wrd_write_string( 'surf_h(' // dum // ')%qsws' ) 
    27123034             WRITE ( 14 )  surf_h(l)%qsws
    27133035          ENDIF
     3036
    27143037          IF ( ALLOCATED ( surf_h(l)%ssws ) )  THEN
    2715              WRITE ( 14 )  'surf_h(' // dum // ')%ssws                ' 
     3038             CALL wrd_write_string( 'surf_h(' // dum // ')%ssws' ) 
    27163039             WRITE ( 14 )  surf_h(l)%ssws
    27173040          ENDIF
     3041
    27183042          IF ( ALLOCATED ( surf_h(l)%css ) )  THEN
    2719              WRITE ( 14 )  'surf_h(' // dum // ')%css                 '
     3043             CALL wrd_write_string( 'surf_h(' // dum // ')%css' )
    27203044             WRITE ( 14 )  surf_h(l)%css
    27213045          ENDIF
     3046
    27223047          IF ( ALLOCATED ( surf_h(l)%cssws ) )  THEN
    2723              WRITE ( 14 )  'surf_h(' // dum // ')%cssws               '
     3048             CALL wrd_write_string( 'surf_h(' // dum // ')%cssws' )
    27243049             WRITE ( 14 )  surf_h(l)%cssws
    27253050          ENDIF
     3051
    27263052          IF ( ALLOCATED ( surf_h(l)%qcsws ) )  THEN
    2727              WRITE ( 14 )  'surf_h(' // dum // ')%qcsws               ' 
     3053             CALL wrd_write_string( 'surf_h(' // dum // ')%qcsws' ) 
    27283054             WRITE ( 14 )  surf_h(l)%qcsws
    27293055          ENDIF
     3056
    27303057          IF ( ALLOCATED ( surf_h(l)%ncsws ) )  THEN
    2731              WRITE ( 14 )  'surf_h(' // dum // ')%ncsws               ' 
     3058             CALL wrd_write_string( 'surf_h(' // dum // ')%ncsws' ) 
    27323059             WRITE ( 14 )  surf_h(l)%ncsws
    27333060          ENDIF
     3061
    27343062          IF ( ALLOCATED ( surf_h(l)%qrsws ) )  THEN
    2735              WRITE ( 14 )  'surf_h(' // dum // ')%qrsws               ' 
     3063             CALL wrd_write_string( 'surf_h(' // dum // ')%qrsws' ) 
    27363064             WRITE ( 14 )  surf_h(l)%qrsws
    27373065          ENDIF
     3066
    27383067          IF ( ALLOCATED ( surf_h(l)%nrsws ) )  THEN
    2739              WRITE ( 14 )  'surf_h(' // dum // ')%nrsws               ' 
     3068             CALL wrd_write_string( 'surf_h(' // dum // ')%nrsws' ) 
    27403069             WRITE ( 14 )  surf_h(l)%nrsws
    27413070          ENDIF
     3071
    27423072          IF ( ALLOCATED ( surf_h(l)%sasws ) )  THEN
    2743              WRITE ( 14 )  'surf_h(' // dum // ')%sasws               '
     3073             CALL wrd_write_string( 'surf_h(' // dum // ')%sasws' )
    27443074             WRITE ( 14 )  surf_h(l)%sasws
    2745           ENDIF
     3075          ENDIF     
     3076 
    27463077       ENDDO
    27473078!
     
    27503081          WRITE( dum, '(I1)')  l
    27513082
    2752           WRITE ( 14 )  'surf_v(' // dum // ')%start_index         ' 
    2753           WRITE ( 14 )   surf_v(l)%start_index
    2754           WRITE ( 14 )  'surf_v(' // dum // ')%end_index           ' 
     3083          CALL wrd_write_string( 'surf_v(' // dum // ')%start_index' )
     3084          WRITE ( 14 )  surf_v(l)%start_index
     3085
     3086          CALL wrd_write_string( 'surf_v(' // dum // ')%end_index' )
    27553087          WRITE ( 14 )   surf_v(l)%end_index
    27563088
    27573089          IF ( ALLOCATED ( surf_v(l)%us ) )  THEN
    2758              WRITE ( 14 )  'surf_v(' // dum // ')%us                  ' 
     3090             CALL wrd_write_string( 'surf_v(' // dum // ')%us' ) 
    27593091             WRITE ( 14 )  surf_v(l)%us
    2760           ENDIF
     3092          ENDIF 
     3093
    27613094          IF ( ALLOCATED ( surf_v(l)%ts ) )  THEN
    2762              WRITE ( 14 )  'surf_v(' // dum // ')%ts                  '
     3095             CALL wrd_write_string( 'surf_v(' // dum // ')%ts' )
    27633096             WRITE ( 14 )  surf_v(l)%ts
    27643097          ENDIF
     3098
    27653099          IF ( ALLOCATED ( surf_v(l)%qs ) )  THEN
    2766              WRITE ( 14 )  'surf_v(' // dum // ')%qs                  ' 
     3100             CALL wrd_write_string( 'surf_v(' // dum // ')%qs' ) 
    27673101             WRITE ( 14 )  surf_v(l)%qs
    2768           ENDIF
     3102          ENDIF 
     3103
    27693104          IF ( ALLOCATED ( surf_v(l)%ss ) )  THEN
    2770              WRITE ( 14 )  'surf_v(' // dum // ')%ss                  '
     3105             CALL wrd_write_string( 'surf_v(' // dum // ')%ss' )
    27713106             WRITE ( 14 )  surf_v(l)%ss
    2772           ENDIF
     3107          ENDIF 
     3108         
    27733109          IF ( ALLOCATED ( surf_v(l)%qcs ) )  THEN
    2774              WRITE ( 14 )  'surf_v(' // dum // ')%qcs                 '
     3110             CALL wrd_write_string( 'surf_v(' // dum // ')%qcs' )
    27753111             WRITE ( 14 )  surf_v(l)%qcs
    27763112          ENDIF
     3113
    27773114          IF ( ALLOCATED ( surf_v(l)%ncs ) )  THEN
    2778              WRITE ( 14 )  'surf_v(' // dum // ')%ncs                 '
     3115             CALL wrd_write_string( 'surf_v(' // dum // ')%ncs' )
    27793116             WRITE ( 14 )  surf_v(l)%ncs
    27803117          ENDIF
     3118
    27813119          IF ( ALLOCATED ( surf_v(l)%qrs ) )  THEN
    2782              WRITE ( 14 )  'surf_v(' // dum // ')%qrs                 ' 
     3120             CALL wrd_write_string( 'surf_v(' // dum // ')%qrs' ) 
    27833121             WRITE ( 14 )  surf_v(l)%qrs
    27843122          ENDIF
     3123
    27853124          IF ( ALLOCATED ( surf_v(l)%nrs ) )  THEN
    2786              WRITE ( 14 )  'surf_v(' // dum // ')%nrs                 '
     3125             CALL wrd_write_string( 'surf_v(' // dum // ')%nrs' )
    27873126             WRITE ( 14 )  surf_v(l)%nrs
    2788           ENDIF
     3127          ENDIF 
     3128
    27893129          IF ( ALLOCATED ( surf_v(l)%ol ) )  THEN
    2790              WRITE ( 14 )  'surf_v(' // dum // ')%ol                  ' 
     3130             CALL wrd_write_string( 'surf_v(' // dum // ')%ol' ) 
    27913131             WRITE ( 14 )  surf_v(l)%ol
    27923132          ENDIF
     3133
    27933134          IF ( ALLOCATED ( surf_v(l)%rib ) )  THEN
    2794              WRITE ( 14 )  'surf_v(' // dum // ')%rib                 ' 
     3135             CALL wrd_write_string( 'surf_v(' // dum // ')%rib' )
    27953136             WRITE ( 14 )  surf_v(l)%rib
    27963137          ENDIF
     3138
    27973139          IF ( ALLOCATED ( surf_v(l)%pt_surface ) )  THEN
    2798              WRITE ( 14 )  'surf_v(' // dum // ')%pt_surface          ' 
     3140             CALL wrd_write_string( 'surf_v(' // dum // ')%pt_surface' )
    27993141             WRITE ( 14 )  surf_v(l)%pt_surface
    2800           ENDIF
     3142          ENDIF
     3143
    28013144          IF ( ALLOCATED ( surf_v(l)%shf ) )  THEN
    2802              WRITE ( 14 )  'surf_v(' // dum // ')%shf                 ' 
     3145             CALL wrd_write_string( 'surf_v(' // dum // ')%shf' ) 
    28033146             WRITE ( 14 )  surf_v(l)%shf
    28043147          ENDIF
     3148
    28053149          IF ( ALLOCATED ( surf_v(l)%qsws ) )  THEN
    2806              WRITE ( 14 )  'surf_v(' // dum // ')%qsws                ' 
     3150             CALL wrd_write_string( 'surf_v(' // dum // ')%qsws' ) 
    28073151             WRITE ( 14 )  surf_v(l)%qsws
    28083152          ENDIF
     3153
    28093154          IF ( ALLOCATED ( surf_v(l)%ssws ) )  THEN
    2810              WRITE ( 14 )  'surf_v(' // dum // ')%ssws                ' 
     3155             CALL wrd_write_string( 'surf_v(' // dum // ')%ssws' ) 
    28113156             WRITE ( 14 )  surf_v(l)%ssws
    28123157          ENDIF
     3158
    28133159          IF ( ALLOCATED ( surf_v(l)%css ) )  THEN
    2814              WRITE ( 14 )  'surf_v(' // dum // ')%css                 ' 
     3160             CALL wrd_write_string( 'surf_v(' // dum // ')%css' ) 
    28153161             WRITE ( 14 )  surf_v(l)%css
    2816           ENDIF
     3162          ENDIF
     3163
    28173164          IF ( ALLOCATED ( surf_v(l)%cssws ) )  THEN
    2818              WRITE ( 14 )  'surf_v(' // dum // ')%cssws               '
     3165             CALL wrd_write_string( 'surf_v(' // dum // ')%cssws' )
    28193166             WRITE ( 14 )  surf_v(l)%cssws
    2820           ENDIF
     3167          ENDIF 
     3168
    28213169          IF ( ALLOCATED ( surf_v(l)%qcsws ) )  THEN
    2822              WRITE ( 14 )  'surf_v(' // dum // ')%qcsws               '
     3170             CALL wrd_write_string( 'surf_v(' // dum // ')%qcsws' )
    28233171             WRITE ( 14 )  surf_v(l)%qcsws
    2824           ENDIF
     3172          ENDIF 
     3173
    28253174          IF ( ALLOCATED ( surf_v(l)%ncsws ) )  THEN
    2826              WRITE ( 14 )  'surf_v(' // dum // ')%ncsws               '
     3175             CALL wrd_write_string( 'surf_v(' // dum // ')%ncsws' )
    28273176             WRITE ( 14 )  surf_v(l)%ncsws
    28283177          ENDIF
     3178
    28293179          IF ( ALLOCATED ( surf_v(l)%qrsws ) )  THEN
    2830              WRITE ( 14 )  'surf_v(' // dum // ')%qrsws               ' 
     3180             CALL wrd_write_string( 'surf_v(' // dum // ')%qrsws' ) 
    28313181             WRITE ( 14 )  surf_v(l)%qrsws
    2832           ENDIF
     3182          ENDIF 
     3183
    28333184          IF ( ALLOCATED ( surf_v(l)%nrsws ) )  THEN
    2834              WRITE ( 14 )  'surf_v(' // dum // ')%nrsws               ' 
     3185             CALL wrd_write_string( 'surf_v(' // dum // ')%nrsws' ) 
    28353186             WRITE ( 14 )  surf_v(l)%nrsws
    28363187          ENDIF
     3188
    28373189          IF ( ALLOCATED ( surf_v(l)%sasws ) )  THEN
    2838              WRITE ( 14 )  'surf_v(' // dum // ')%sasws               '
     3190             CALL wrd_write_string( 'surf_v(' // dum // ')%sasws' )
    28393191             WRITE ( 14 )  surf_v(l)%sasws
    28403192          ENDIF
     3193
    28413194          IF ( ALLOCATED ( surf_v(l)%mom_flux_uv ) )  THEN
    2842              WRITE ( 14 )  'surf_v(' // dum // ')%mom_uv              ' 
     3195             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_uv' ) 
    28433196             WRITE ( 14 )  surf_v(l)%mom_flux_uv
    28443197          ENDIF
     3198
    28453199          IF ( ALLOCATED ( surf_v(l)%mom_flux_w ) )  THEN
    2846              WRITE ( 14 )  'surf_v(' // dum // ')%mom_w               '
     3200             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_w' )
    28473201             WRITE ( 14 )  surf_v(l)%mom_flux_w
    28483202          ENDIF
     3203
    28493204          IF ( ALLOCATED ( surf_v(l)%mom_flux_tke ) )  THEN
    2850              WRITE ( 14 )  'surf_v(' // dum // ')%mom_tke             ' 
     3205             CALL wrd_write_string( 'surf_v(' // dum // ')%mom_tke' ) 
    28513206             WRITE ( 14 )  surf_v(l)%mom_flux_tke
    2852           ENDIF
     3207          ENDIF 
    28533208
    28543209       ENDDO
    28553210
    2856        WRITE ( 14 )  '*** end surf ***              '
    2857 
    2858     END SUBROUTINE surface_write_restart_data
     3211
     3212    END SUBROUTINE surface_wrd_local
    28593213
    28603214
     
    28703224!> of cyclic_fill mode.
    28713225!------------------------------------------------------------------------------!
    2872     SUBROUTINE surface_read_restart_data( ii,                                  &
    2873                                        nxlfa, nxl_on_file, nxrfa, nxr_on_file, &
    2874                                        nynfa, nyn_on_file, nysfa, nys_on_file, &
    2875                                        offset_xa, offset_ya, overlap_count )
     3226    SUBROUTINE surface_rrd_local( ii, kk, nxlf, nxlc, nxl_on_file, nxrf, nxrc, &
     3227                                  nxr_on_file, nynf, nync, nyn_on_file, nysf,  &
     3228                                  nysc, nys_on_file, found )
    28763229
    28773230       USE pegrid,                                                             &
    2878            ONLY: numprocs_previous_run
     3231           ONLY: myid, numprocs_previous_run
     3232
     3233       IMPLICIT NONE
    28793234
    28803235       CHARACTER (LEN=1)  ::  dum         !< dummy to create correct string for reading input variable
    2881        CHARACTER (LEN=30) ::  field_chr   !< input variable
    28823236
    28833237       INTEGER(iwp)       ::  i           !< running index along x-direction, refers to former domain size
     
    28863240       INTEGER(iwp)       ::  jc          !< running index along y-direction, refers to former domain size
    28873241       INTEGER(iwp)       ::  k           !< running index along z-direction
    2888        INTEGER(iwp)       ::  l           !< index variable for surface type
    28893242       INTEGER(iwp)       ::  m           !< running index for surface elements, refers to gathered array encompassing all surface types
    28903243       INTEGER(iwp)       ::  mm          !< running index for surface elements, refers to individual surface types
    2891 
    28923244       INTEGER(iwp)       ::  ii               !< running index over input files
    28933245       INTEGER(iwp)       ::  kk               !< running index over previous input files covering current local domain
     
    29043256       INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
    29053257       INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain 
    2906        INTEGER(iwp)       ::  overlap_count    !< number of overlaps
    2907  
    2908        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !<
    2909        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !<
    2910        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !<
    2911        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !<
    2912        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !<
    2913        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !<
    2914 
    2915 
    2916        LOGICAL                         ::  horizontal_surface !< flag indicating horizontal surfaces
     3258
     3259       INTEGER(iwp), SAVE  ::  l           !< index variable for surface type
     3260
    29173261       LOGICAL                         ::  surf_match_def     !< flag indicating that surface element is of default type
    29183262       LOGICAL                         ::  surf_match_lsm     !< flag indicating that surface element is of natural type
    29193263       LOGICAL                         ::  surf_match_usm     !< flag indicating that surface element is of urban type
    2920        LOGICAL                         ::  vertical_surface   !< flag indicating vertical surfaces
    2921 
    2922        TYPE(surf_type), DIMENSION(0:2) ::  surf_h             !< horizontal surface type on file
    2923        TYPE(surf_type), DIMENSION(0:3) ::  surf_v             !< vertical surface type on file
    2924 
    2925 !
    2926 !--    Read number of respective surface elements on file
    2927        READ ( 13 )  field_chr
    2928        IF ( TRIM( field_chr ) /= 'ns_h_on_file' )  THEN
    2929 !
    2930 !--       Add a proper error message
    2931        ENDIF
    2932        READ ( 13 ) ns_h_on_file
    2933 
    2934        READ ( 13 )  field_chr
    2935        IF ( TRIM( field_chr ) /= 'ns_v_on_file' )  THEN
    2936 !
    2937 !--       Add a proper error message
    2938        ENDIF
    2939        READ ( 13 ) ns_v_on_file
    2940 !
    2941 !--    Allocate memory for number of surface elements on file. Please note,
    2942 !--    these number is not necessarily the same as the final number of surface
    2943 !--    elements on local domain, which is the case if processor topology changes
    2944 !--    during restart runs.
    2945 !--    Horizontal upward facing
    2946        surf_h(0)%ns = ns_h_on_file(0)
    2947        CALL allocate_surface_attributes_h( surf_h(0),                          &
     3264
     3265       LOGICAL, INTENT(OUT) ::  found
     3266
     3267       LOGICAL, SAVE ::  horizontal_surface !< flag indicating horizontal surfaces
     3268       LOGICAL, SAVE ::  vertical_surface   !< flag indicating vertical surfaces
     3269
     3270       TYPE(surf_type), DIMENSION(0:2), SAVE ::  surf_h             !< horizontal surface type on file
     3271       TYPE(surf_type), DIMENSION(0:3), SAVE ::  surf_v             !< vertical surface type on file
     3272
     3273
     3274       found              = .TRUE.
     3275
     3276
     3277       SELECT CASE ( restart_string(1:length) )
     3278
     3279          CASE ( 'ns_h_on_file' )
     3280             IF ( kk == 1 )  THEN
     3281                READ ( 13 )  ns_h_on_file
     3282
     3283                IF ( ALLOCATED( surf_h(0)%start_index ) )                      &
     3284                   CALL deallocate_surface_attributes_h( surf_h(0) )           
     3285                IF ( ALLOCATED( surf_h(1)%start_index ) )                      &
     3286                   CALL deallocate_surface_attributes_h( surf_h(1) )           
     3287                IF ( ALLOCATED( surf_h(2)%start_index ) )                      &
     3288                   CALL deallocate_surface_attributes_h_top( surf_h(2) )       
     3289
     3290!--             Allocate memory for number of surface elements on file.
     3291!--             Please note, these number is not necessarily the same as
     3292!--             the final number of surface elements on local domain,
     3293!--             which is the case if processor topology changes during
     3294!--             restart runs. 
     3295!--             Horizontal upward facing
     3296                surf_h(0)%ns = ns_h_on_file(0)
     3297                CALL allocate_surface_attributes_h( surf_h(0),                 &
     3298                                        nys_on_file, nyn_on_file,              &
     3299                                        nxl_on_file, nxr_on_file )
     3300
     3301!--             Horizontal downward facing
     3302                surf_h(1)%ns = ns_h_on_file(1)
     3303                CALL allocate_surface_attributes_h( surf_h(1),                 &
     3304                                        nys_on_file, nyn_on_file,              &
     3305                                        nxl_on_file, nxr_on_file )
     3306
     3307!--             Model top
     3308                surf_h(2)%ns = ns_h_on_file(2)
     3309                CALL allocate_surface_attributes_h_top( surf_h(2),             &
     3310                                            nys_on_file, nyn_on_file,          &
     3311                                            nxl_on_file, nxr_on_file )
     3312
     3313!
     3314!--             Initial setting of flags for horizontal and vertical surfaces,
     3315!--             will be set after start- and end-indices are read.
     3316                horizontal_surface = .FALSE.
     3317                vertical_surface   = .FALSE.
     3318
     3319             ENDIF   
     3320
     3321          CASE ( 'ns_v_on_file' )
     3322             IF ( kk == 1 ) THEN
     3323                READ ( 13 )  ns_v_on_file
     3324
     3325                DO  l = 0, 3
     3326                   IF ( ALLOCATED( surf_v(l)%start_index ) )                   &
     3327                      CALL deallocate_surface_attributes_v( surf_v(l) )
     3328                ENDDO
     3329
     3330!--                Vertical surfaces
     3331                DO  l = 0, 3
     3332                   surf_v(l)%ns = ns_v_on_file(l)
     3333                   CALL allocate_surface_attributes_v( surf_v(l),              &
    29483334                                           nys_on_file, nyn_on_file,           &
    29493335                                           nxl_on_file, nxr_on_file )
    2950 !
    2951 !--    Horizontal downward facing
    2952        surf_h(1)%ns = ns_h_on_file(1)
    2953        CALL allocate_surface_attributes_h( surf_h(1),                          &
    2954                                            nys_on_file, nyn_on_file,           &
    2955                                            nxl_on_file, nxr_on_file )
    2956 !
    2957 !--    Model top
    2958        surf_h(2)%ns = ns_h_on_file(2)
    2959        CALL allocate_surface_attributes_h_top( surf_h(2),                      &
    2960                                                nys_on_file, nyn_on_file,       &
    2961                                                nxl_on_file, nxr_on_file )
    2962 !
    2963 !--    Vertical surfaces
    2964        DO  l = 0, 3
    2965           surf_v(l)%ns = ns_v_on_file(l)
    2966           CALL allocate_surface_attributes_v( surf_v(l),                       &
    2967                                               nys_on_file, nyn_on_file,        &
    2968                                               nxl_on_file, nxr_on_file )
    2969        ENDDO
    2970 
    2971        IF ( initializing_actions == 'read_restart_data'  .OR.                  &
    2972             initializing_actions == 'cyclic_fill' )  THEN
    2973 !
    2974 !--       Initial setting of flags for horizontal and vertical surfaces, will
    2975 !--       be set after start- and end-indices are read.
    2976           horizontal_surface = .FALSE.
    2977           vertical_surface   = .FALSE.
    2978 
    2979           READ ( 13 )  field_chr
    2980 
    2981           DO  WHILE ( TRIM( field_chr ) /= '*** end surf ***' )
    2982 !
    2983 !--          Map data on file as often as needed (data are read only for k=1)
    2984              DO  kk = 1, overlap_count
    2985 !
    2986 !--             Get the index range of the subdomain on file which overlap with the
    2987 !--             current subdomain
    2988                 nxlf = nxlfa(ii,kk)
    2989                 nxlc = nxlfa(ii,kk) + offset_xa(ii,kk)
    2990                 nxrf = nxrfa(ii,kk)
    2991                 nxrc = nxrfa(ii,kk) + offset_xa(ii,kk)
    2992                 nysf = nysfa(ii,kk)
    2993                 nysc = nysfa(ii,kk) + offset_ya(ii,kk)
    2994                 nynf = nynfa(ii,kk)
    2995                 nync = nynfa(ii,kk) + offset_ya(ii,kk)
    2996 
    2997                 SELECT CASE ( TRIM( field_chr ) )
    2998 
    2999                    CASE ( 'surf_h(0)%start_index' )
    3000                       IF ( kk == 1 )                                           &
    3001                          READ ( 13 )  surf_h(0)%start_index
    3002                       l = 0
    3003                    CASE ( 'surf_h(0)%end_index' )   
    3004                       IF ( kk == 1 )                                           &
    3005                          READ ( 13 )  surf_h(0)%end_index
    3006                       horizontal_surface = .TRUE.
    3007                       vertical_surface   = .FALSE.
    3008                    CASE ( 'surf_h(0)%us' )         
    3009                       IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )         &
    3010                          READ ( 13 )  surf_h(0)%us
    3011                    CASE ( 'surf_h(0)%ts' )         
    3012                       IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )         &
    3013                          READ ( 13 )  surf_h(0)%ts
    3014                    CASE ( 'surf_h(0)%qs' )         
    3015                       IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )         &
    3016                          READ ( 13 )  surf_h(0)%qs
    3017                    CASE ( 'surf_h(0)%ss' )         
    3018                       IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )         &
    3019                          READ ( 13 )  surf_h(0)%ss
    3020                    CASE ( 'surf_h(0)%qcs' )         
    3021                       IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )        &
    3022                          READ ( 13 )  surf_h(0)%qcs
    3023                    CASE ( 'surf_h(0)%ncs' )         
    3024                       IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )        &
    3025                          READ ( 13 )  surf_h(0)%ncs
    3026                    CASE ( 'surf_h(0)%qrs' )         
    3027                       IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )        &
    3028                          READ ( 13 )  surf_h(0)%qrs
    3029                    CASE ( 'surf_h(0)%nrs' )         
    3030                       IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )        &
    3031                          READ ( 13 )  surf_h(0)%nrs
    3032                    CASE ( 'surf_h(0)%ol' )         
    3033                       IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )         &
    3034                          READ ( 13 )  surf_h(0)%ol
    3035                    CASE ( 'surf_h(0)%rib' )         
    3036                       IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )        &
    3037                          READ ( 13 )  surf_h(0)%rib
    3038                    CASE ( 'surf_h(0)%pt_surface' )         
    3039                       IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 ) &
    3040                          READ ( 13 )  surf_h(0)%pt_surface
    3041                    CASE ( 'surf_h(0)%usws' )         
    3042                       IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )       &
    3043                          READ ( 13 )  surf_h(0)%usws
    3044                    CASE ( 'surf_h(0)%vsws' )         
    3045                       IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )       &
    3046                          READ ( 13 )  surf_h(0)%vsws
    3047                    CASE ( 'surf_h(0)%shf' )         
    3048                       IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )        &
    3049                          READ ( 13 )  surf_h(0)%shf
    3050                    CASE ( 'surf_h(0)%qsws' )         
    3051                       IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )       &
    3052                          READ ( 13 )  surf_h(0)%qsws
    3053                    CASE ( 'surf_h(0)%ssws' )         
    3054                       IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )       &
    3055                          READ ( 13 )  surf_h(0)%ssws
    3056                    CASE ( 'surf_h(0)%css' )
    3057                       IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )        &
    3058                          READ ( 13 )  surf_h(0)%css
    3059                    CASE ( 'surf_h(0)%cssws' )         
    3060                       IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )      &
    3061                          READ ( 13 )  surf_h(0)%cssws
    3062                    CASE ( 'surf_h(0)%qcsws' )         
    3063                       IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )      &
    3064                          READ ( 13 )  surf_h(0)%qcsws
    3065                    CASE ( 'surf_h(0)%ncsws' )         
    3066                       IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )      &
    3067                          READ ( 13 )  surf_h(0)%ncsws
    3068                    CASE ( 'surf_h(0)%qrsws' )         
    3069                       IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )      &
    3070                          READ ( 13 )  surf_h(0)%qrsws
    3071                    CASE ( 'surf_h(0)%nrsws' )         
    3072                       IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )      &
    3073                          READ ( 13 )  surf_h(0)%nrsws
    3074                    CASE ( 'surf_h(0)%sasws' )         
    3075                       IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )      &
    3076                          READ ( 13 )  surf_h(0)%sasws
    3077 
    3078                    CASE ( 'surf_h(1)%start_index' )   
    3079                       IF ( kk == 1 )                                           &
    3080                          READ ( 13 )  surf_h(1)%start_index
    3081                       l = 1
    3082                    CASE ( 'surf_h(1)%end_index' )   
    3083                       IF ( kk == 1 )                                           &
    3084                          READ ( 13 )  surf_h(1)%end_index
    3085                    CASE ( 'surf_h(1)%us' )         
    3086                       IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )         &
    3087                          READ ( 13 )  surf_h(1)%us
    3088                    CASE ( 'surf_h(1)%ts' )         
    3089                       IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )         &
    3090                          READ ( 13 )  surf_h(1)%ts
    3091                    CASE ( 'surf_h(1)%qs' )         
    3092                       IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )         &
    3093                          READ ( 13 )  surf_h(1)%qs
    3094                    CASE ( 'surf_h(1)%ss' )         
    3095                       IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )         &
    3096                          READ ( 13 )  surf_h(1)%ss
    3097                    CASE ( 'surf_h(1)%qcs' )         
    3098                       IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )        &
    3099                          READ ( 13 )  surf_h(1)%qcs
    3100                    CASE ( 'surf_h(1)%ncs' )         
    3101                       IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )        &
    3102                          READ ( 13 )  surf_h(1)%ncs
    3103                    CASE ( 'surf_h(1)%qrs' )         
    3104                       IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )        &
    3105                          READ ( 13 )  surf_h(1)%qrs
    3106                    CASE ( 'surf_h(1)%nrs' )         
    3107                       IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )        &
    3108                          READ ( 13 )  surf_h(1)%nrs
    3109                    CASE ( 'surf_h(1)%ol' )         
    3110                       IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )         &
    3111                          READ ( 13 )  surf_h(1)%ol
    3112                    CASE ( 'surf_h(1)%rib' )         
    3113                       IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )        &
    3114                          READ ( 13 )  surf_h(1)%rib
    3115                    CASE ( 'surf_h(1)%pt_surface' )         
    3116                       IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 ) &
    3117                          READ ( 13 )  surf_h(1)%pt_surface
    3118                    CASE ( 'surf_h(1)%usws' )         
    3119                       IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )       &
    3120                          READ ( 13 )  surf_h(1)%usws
    3121                    CASE ( 'surf_h(1)%vsws' )         
    3122                       IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )       &
    3123                          READ ( 13 )  surf_h(1)%vsws
    3124                    CASE ( 'surf_h(1)%shf' )         
    3125                       IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )        &
    3126                          READ ( 13 )  surf_h(1)%shf
    3127                    CASE ( 'surf_h(1)%qsws' )         
    3128                       IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )       &
    3129                          READ ( 13 )  surf_h(1)%qsws
    3130                    CASE ( 'surf_h(1)%ssws' )         
    3131                       IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )       &
    3132                          READ ( 13 )  surf_h(1)%ssws
    3133                    CASE ( 'surf_h(1)%css' )
    3134                       IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )        &
    3135                          READ ( 13 )  surf_h(1)%css
    3136                    CASE ( 'surf_h(1)%cssws' )         
    3137                       IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )      &
    3138                          READ ( 13 )  surf_h(1)%cssws
    3139                    CASE ( 'surf_h(1)%qcsws' )         
    3140                       IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )      &
    3141                          READ ( 13 )  surf_h(1)%qcsws
    3142                    CASE ( 'surf_h(1)%ncsws' )         
    3143                       IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )      &
    3144                          READ ( 13 )  surf_h(1)%ncsws
    3145                    CASE ( 'surf_h(1)%qrsws' )         
    3146                       IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )      &
    3147                          READ ( 13 )  surf_h(1)%qrsws
    3148                    CASE ( 'surf_h(1)%nrsws' )         
    3149                       IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )      &
    3150                          READ ( 13 )  surf_h(1)%nrsws
    3151                    CASE ( 'surf_h(1)%sasws' )         
    3152                       IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )      &
    3153                          READ ( 13 )  surf_h(1)%sasws
    3154 
    3155                    CASE ( 'surf_h(2)%start_index' )   
    3156                       IF ( kk == 1 )                                           &
    3157                          READ ( 13 )  surf_h(2)%start_index
    3158                       l = 2
    3159                    CASE ( 'surf_h(2)%end_index' )   
    3160                       IF ( kk == 1 )                                           &
    3161                          READ ( 13 )  surf_h(2)%end_index
    3162                    CASE ( 'surf_h(2)%us' )         
    3163                       IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )         &
    3164                          READ ( 13 )  surf_h(2)%us
    3165                    CASE ( 'surf_h(2)%ts' )         
    3166                       IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )         &
    3167                          READ ( 13 )  surf_h(2)%ts
    3168                    CASE ( 'surf_h(2)%qs' )       
    3169                       IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )         &
    3170                          READ ( 13 )  surf_h(2)%qs
    3171                    CASE ( 'surf_h(2)%ss' )         
    3172                       IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )         &
    3173                          READ ( 13 )  surf_h(2)%ss
    3174                    CASE ( 'surf_h(2)%qcs' )         
    3175                       IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )        &
    3176                          READ ( 13 )  surf_h(2)%qcs
    3177                    CASE ( 'surf_h(2)%ncs' )         
    3178                       IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )        &
    3179                          READ ( 13 )  surf_h(2)%ncs
    3180                    CASE ( 'surf_h(2)%qrs' )         
    3181                       IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )        &
    3182                          READ ( 13 )  surf_h(2)%qrs
    3183                    CASE ( 'surf_h(2)%nrs' )         
    3184                       IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )        &
    3185                          READ ( 13 )  surf_h(2)%nrs
    3186                    CASE ( 'surf_h(2)%ol' )         
    3187                       IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )         &
    3188                          READ ( 13 )  surf_h(2)%ol
    3189                    CASE ( 'surf_h(2)%rib' )         
    3190                       IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )        &
    3191                          READ ( 13 )  surf_h(2)%rib
    3192                    CASE ( 'surf_h(2)%usws' )         
    3193                       IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )       &
    3194                          READ ( 13 )  surf_h(2)%usws
    3195                    CASE ( 'surf_h(2)%vsws' )         
    3196                       IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )       &
    3197                          READ ( 13 )  surf_h(2)%vsws
    3198                    CASE ( 'surf_h(2)%shf' )         
    3199                       IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )        &
    3200                          READ ( 13 )  surf_h(2)%shf
    3201                    CASE ( 'surf_h(2)%qsws' )         
    3202                       IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )       &
    3203                          READ ( 13 )  surf_h(2)%qsws
    3204                    CASE ( 'surf_h(2)%ssws' )         
    3205                       IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )       &
    3206                          READ ( 13 )  surf_h(2)%ssws
    3207                    CASE ( 'surf_h(2)%css' )
    3208                       IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )        &
    3209                          READ ( 13 )  surf_h(2)%css
    3210                    CASE ( 'surf_h(2)%cssws' )         
    3211                       IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )      &
    3212                          READ ( 13 )  surf_h(2)%cssws
    3213                    CASE ( 'surf_h(2)%qcsws' )         
    3214                       IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )      &
    3215                          READ ( 13 )  surf_h(2)%qcsws
    3216                    CASE ( 'surf_h(2)%ncsws' )         
    3217                       IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )      &
    3218                          READ ( 13 )  surf_h(2)%ncsws
    3219                    CASE ( 'surf_h(2)%qrsws' )         
    3220                       IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )      &
    3221                          READ ( 13 )  surf_h(2)%qrsws
    3222                    CASE ( 'surf_h(2)%nrsws' )         
    3223                       IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )      &
    3224                          READ ( 13 )  surf_h(2)%nrsws
    3225                    CASE ( 'surf_h(2)%sasws' )         
    3226                       IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )      &
    3227                          READ ( 13 )  surf_h(2)%sasws
    3228 
    3229                    CASE ( 'surf_v(0)%start_index' )   
    3230                       IF ( kk == 1 )                                           &
    3231                          READ ( 13 )  surf_v(0)%start_index
    3232                       l = 0
    3233                       horizontal_surface = .FALSE.
    3234                       vertical_surface   = .TRUE.
    3235                    CASE ( 'surf_v(0)%end_index' )   
    3236                       IF ( kk == 1 )                                           &
    3237                          READ ( 13 )  surf_v(0)%end_index
    3238                    CASE ( 'surf_v(0)%us' )         
    3239                       IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )         &
    3240                          READ ( 13 )  surf_v(0)%us
    3241                    CASE ( 'surf_v(0)%ts' )         
    3242                       IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )         &
    3243                          READ ( 13 )  surf_v(0)%ts
    3244                    CASE ( 'surf_v(0)%qs' )         
    3245                       IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )         &
    3246                          READ ( 13 )  surf_v(0)%qs
    3247                    CASE ( 'surf_v(0)%ss' )         
    3248                       IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )         &
    3249                          READ ( 13 )  surf_v(0)%ss
    3250                    CASE ( 'surf_v(0)%qcs' )         
    3251                       IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )        &
    3252                          READ ( 13 )  surf_v(0)%qcs
    3253                    CASE ( 'surf_v(0)%ncs' )         
    3254                       IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )        &
    3255                          READ ( 13 )  surf_v(0)%ncs
    3256                    CASE ( 'surf_v(0)%qrs' )         
    3257                       IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )        &
    3258                          READ ( 13 )  surf_v(0)%qrs
    3259                    CASE ( 'surf_v(0)%nrs' )         
    3260                       IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )        &
    3261                          READ ( 13 )  surf_v(0)%nrs
    3262                    CASE ( 'surf_v(0)%ol' )         
    3263                       IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )         &
    3264                          READ ( 13 )  surf_v(0)%ol
    3265                    CASE ( 'surf_v(0)%rib' )         
    3266                       IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )        &
    3267                          READ ( 13 )  surf_v(0)%rib
    3268                    CASE ( 'surf_v(0)%pt_surface' )         
    3269                       IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 ) &
    3270                          READ ( 13 )  surf_v(0)%pt_surface
    3271                    CASE ( 'surf_v(0)%shf' )         
    3272                       IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )        &
    3273                          READ ( 13 )  surf_v(0)%shf
    3274                    CASE ( 'surf_v(0)%qsws' )         
    3275                       IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )       &
    3276                          READ ( 13 )  surf_v(0)%qsws
    3277                    CASE ( 'surf_v(0)%ssws' )         
    3278                       IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )       &
    3279                          READ ( 13 )  surf_v(0)%ssws
    3280                    CASE ( 'surf_v(0)%css' )
    3281                       IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )        &
    3282                          READ ( 13 )  surf_v(0)%css
    3283                    CASE ( 'surf_v(0)%cssws' )         
    3284                       IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )      &
    3285                          READ ( 13 )  surf_v(0)%cssws
    3286                    CASE ( 'surf_v(0)%qcsws' )         
    3287                       IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )      &
    3288                          READ ( 13 )  surf_v(0)%qcsws
    3289                    CASE ( 'surf_v(0)%ncsws' )         
    3290                       IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )      &
    3291                          READ ( 13 )  surf_v(0)%ncsws
    3292                    CASE ( 'surf_v(0)%qrsws' )         
    3293                       IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )      &
    3294                          READ ( 13 )  surf_v(0)%qrsws
    3295                    CASE ( 'surf_v(0)%nrsws' )         
    3296                       IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )      &
    3297                          READ ( 13 )  surf_v(0)%nrsws
    3298                    CASE ( 'surf_v(0)%sasws' )         
    3299                       IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )      &
    3300                          READ ( 13 )  surf_v(0)%sasws
    3301                    CASE ( 'surf_v(0)%mom_uv' )         
    3302                       IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )&
    3303                          READ ( 13 )  surf_v(0)%mom_flux_uv
    3304                    CASE ( 'surf_v(0)%mom_w' )         
    3305                       IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 ) &
    3306                          READ ( 13 )  surf_v(0)%mom_flux_w
    3307                    CASE ( 'surf_v(0)%mom_tke' )         
    3308                       IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )&
    3309                          READ ( 13 )  surf_v(0)%mom_flux_tke
    3310 
    3311                    CASE ( 'surf_v(1)%start_index' )   
    3312                       IF ( kk == 1 )                                           &
    3313                          READ ( 13 )  surf_v(1)%start_index
    3314                       l = 1
    3315                    CASE ( 'surf_v(1)%end_index' )   
    3316                       IF ( kk == 1 )                                           &
    3317                          READ ( 13 )  surf_v(1)%end_index
    3318                    CASE ( 'surf_v(1)%us' )         
    3319                       IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )         &
    3320                          READ ( 13 )  surf_v(1)%us
    3321                    CASE ( 'surf_v(1)%ts' )         
    3322                       IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )         &
    3323                          READ ( 13 )  surf_v(1)%ts
    3324                    CASE ( 'surf_v(1)%qs' )         
    3325                       IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )         &
    3326                          READ ( 13 )  surf_v(1)%qs
    3327                    CASE ( 'surf_v(1)%ss' )         
    3328                       IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )         &
    3329                          READ ( 13 )  surf_v(1)%ss
    3330                    CASE ( 'surf_v(1)%qcs' )         
    3331                       IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )        &
    3332                          READ ( 13 )  surf_v(1)%qcs
    3333                    CASE ( 'surf_v(1)%ncs' )         
    3334                       IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )        &
    3335                          READ ( 13 )  surf_v(1)%ncs
    3336                    CASE ( 'surf_v(1)%qrs' )         
    3337                       IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )        &
    3338                          READ ( 13 )  surf_v(1)%qrs
    3339                    CASE ( 'surf_v(1)%nrs' )         
    3340                       IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )        &
    3341                          READ ( 13 )  surf_v(1)%nrs
    3342                    CASE ( 'surf_v(1)%ol' )         
    3343                       IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )         &
    3344                          READ ( 13 )  surf_v(1)%ol
    3345                    CASE ( 'surf_v(1)%rib' )         
    3346                       IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )        &
    3347                          READ ( 13 )  surf_v(1)%rib
    3348                    CASE ( 'surf_v(1)%pt_surface' )         
    3349                       IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 ) &
    3350                          READ ( 13 )  surf_v(1)%pt_surface
    3351                    CASE ( 'surf_v(1)%shf' )         
    3352                       IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )        &
    3353                          READ ( 13 )  surf_v(1)%shf
    3354                    CASE ( 'surf_v(1)%qsws' )         
    3355                       IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )       &
    3356                          READ ( 13 )  surf_v(1)%qsws
    3357                    CASE ( 'surf_v(1)%ssws' )         
    3358                       IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )       &
    3359                          READ ( 13 )  surf_v(1)%ssws
    3360                    CASE ( 'surf_v(1)%css' )
    3361                       IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )        &
    3362                          READ ( 13 )  surf_v(1)%css
    3363                    CASE ( 'surf_v(1)%cssws' )         
    3364                       IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )      &
    3365                          READ ( 13 )  surf_v(1)%cssws
    3366                    CASE ( 'surf_v(1)%qcsws' )         
    3367                       IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )      &
    3368                          READ ( 13 )  surf_v(1)%qcsws
    3369                    CASE ( 'surf_v(1)%ncsws' )         
    3370                       IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )      &
    3371                          READ ( 13 )  surf_v(1)%ncsws
    3372                    CASE ( 'surf_v(1)%qrsws' )         
    3373                       IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )      &
    3374                          READ ( 13 )  surf_v(1)%qrsws
    3375                    CASE ( 'surf_v(1)%nrsws' )         
    3376                       IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )      &
    3377                          READ ( 13 )  surf_v(1)%nrsws
    3378                    CASE ( 'surf_v(1)%sasws' )         
    3379                       IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )      &
    3380                          READ ( 13 )  surf_v(1)%sasws
    3381                    CASE ( 'surf_v(1)%mom_uv' )         
    3382                       IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )&
    3383                          READ ( 13 )  surf_v(1)%mom_flux_uv
    3384                    CASE ( 'surf_v(1)%mom_w' )         
    3385                       IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 ) &
    3386                          READ ( 13 )  surf_v(1)%mom_flux_w
    3387                    CASE ( 'surf_v(1)%mom_tke' )         
    3388                       IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )&
    3389                          READ ( 13 )  surf_v(1)%mom_flux_tke
    3390 
    3391                    CASE ( 'surf_v(2)%start_index' )   
    3392                       IF ( kk == 1 )                                           &
    3393                          READ ( 13 )  surf_v(2)%start_index
    3394                       l = 2
    3395                    CASE ( 'surf_v(2)%end_index' )   
    3396                       IF ( kk == 1 )                                           &
    3397                          READ ( 13 )  surf_v(2)%end_index
    3398                    CASE ( 'surf_v(2)%us' )         
    3399                       IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )         &
    3400                          READ ( 13 )  surf_v(2)%us
    3401                    CASE ( 'surf_v(2)%ts' )         
    3402                       IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )         &
    3403                          READ ( 13 )  surf_v(2)%ts
    3404                    CASE ( 'surf_v(2)%qs' )         
    3405                       IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )         &
    3406                          READ ( 13 )  surf_v(2)%qs
    3407                    CASE ( 'surf_v(2)%ss' )         
    3408                       IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )         &
    3409                          READ ( 13 )  surf_v(2)%ss
    3410                    CASE ( 'surf_v(2)%qcs' )         
    3411                       IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )        &
    3412                          READ ( 13 )  surf_v(2)%qcs
    3413                    CASE ( 'surf_v(2)%ncs' )         
    3414                       IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )        &
    3415                          READ ( 13 )  surf_v(2)%ncs
    3416                    CASE ( 'surf_v(2)%qrs' )         
    3417                       IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )        &
    3418                          READ ( 13 )  surf_v(2)%qrs
    3419                    CASE ( 'surf_v(2)%nrs' )         
    3420                       IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )        &
    3421                          READ ( 13 )  surf_v(2)%nrs
    3422                    CASE ( 'surf_v(2)%ol' )         
    3423                       IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )         &
    3424                          READ ( 13 )  surf_v(2)%ol
    3425                    CASE ( 'surf_v(2)%rib' )         
    3426                       IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )        &
    3427                          READ ( 13 )  surf_v(2)%rib
    3428                    CASE ( 'surf_v(2)%pt_surface' )         
    3429                       IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 ) &
    3430                          READ ( 13 )  surf_v(2)%pt_surface
    3431                    CASE ( 'surf_v(2)%shf' )         
    3432                       IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )        &
    3433                          READ ( 13 )  surf_v(2)%shf
    3434                    CASE ( 'surf_v(2)%qsws' )         
    3435                       IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )       &
    3436                          READ ( 13 )  surf_v(2)%qsws
    3437                    CASE ( 'surf_v(2)%ssws' )         
    3438                       IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )       &
    3439                          READ ( 13 )  surf_v(2)%ssws
    3440                    CASE ( 'surf_v(2)%css' )
    3441                       IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )        &
    3442                          READ ( 13 )  surf_v(2)%css
    3443                    CASE ( 'surf_v(2)%cssws' )         
    3444                       IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )      &
    3445                          READ ( 13 )  surf_v(2)%cssws
    3446                    CASE ( 'surf_v(2)%qcsws' )         
    3447                       IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )      &
    3448                          READ ( 13 )  surf_v(2)%qcsws
    3449                    CASE ( 'surf_v(2)%ncsws' )         
    3450                       IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )      &
    3451                          READ ( 13 )  surf_v(2)%ncsws
    3452                    CASE ( 'surf_v(2)%qrsws' )         
    3453                       IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )      &
    3454                          READ ( 13 )  surf_v(2)%qrsws
    3455                    CASE ( 'surf_v(2)%nrsws' )         
    3456                       IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )      &
    3457                          READ ( 13 )  surf_v(2)%nrsws
    3458                    CASE ( 'surf_v(2)%sasws' )         
    3459                       IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )      &
    3460                          READ ( 13 )  surf_v(2)%sasws
    3461                    CASE ( 'surf_v(2)%mom_uv' )         
    3462                       IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )&
    3463                          READ ( 13 )  surf_v(2)%mom_flux_uv
    3464                    CASE ( 'surf_v(2)%mom_w' )