Changeset 2894


Ignore:
Timestamp:
Mar 15, 2018 9:17:58 AM (6 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' )         
    3465                       IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 ) &
    3466                          READ ( 13 )  surf_v(2)%mom_flux_w
    3467                    CASE ( 'surf_v(2)%mom_tke' )         
    3468                       IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )&
    3469                          READ ( 13 )  surf_v(2)%mom_flux_tke
    3470 
    3471                    CASE ( 'surf_v(3)%start_index' )   
    3472                       IF ( kk == 1 )                                           &
    3473                          READ ( 13 )  surf_v(3)%start_index
    3474                       l = 3
    3475                    CASE ( 'surf_v(3)%end_index' )   
    3476                       IF ( kk == 1 )                                           &
    3477                          READ ( 13 )  surf_v(3)%end_index
    3478                    CASE ( 'surf_v(3)%us' )         
    3479                       IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )         &
    3480                          READ ( 13 )  surf_v(3)%us
    3481                    CASE ( 'surf_v(3)%ts' )         
    3482                       IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )         &
    3483                          READ ( 13 )  surf_v(3)%ts
    3484                    CASE ( 'surf_v(3)%qs' )       
    3485                       IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )         &
    3486                          READ ( 13 )  surf_v(3)%qs
    3487                    CASE ( 'surf_v(3)%ss' )         
    3488                       IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )         &
    3489                          READ ( 13 )  surf_v(3)%ss
    3490                    CASE ( 'surf_v(3)%qcs' )         
    3491                       IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )        &
    3492                          READ ( 13 )  surf_v(3)%qcs
    3493                    CASE ( 'surf_v(3)%ncs' )         
    3494                       IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )        &
    3495                          READ ( 13 )  surf_v(3)%ncs
    3496                    CASE ( 'surf_v(3)%qrs' )         
    3497                       IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )        &
    3498                          READ ( 13 )  surf_v(3)%qrs
    3499                    CASE ( 'surf_v(3)%nrs' )         
    3500                       IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )        &
    3501                          READ ( 13 )  surf_v(3)%nrs
    3502                    CASE ( 'surf_v(3)%ol' )         
    3503                       IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )         &
    3504                          READ ( 13 )  surf_v(3)%ol
    3505                    CASE ( 'surf_v(3)%rib' )         
    3506                       IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )        &
    3507                          READ ( 13 )  surf_v(3)%rib
    3508                    CASE ( 'surf_v(3)%pt_surface' )         
    3509                       IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 ) &
    3510                          READ ( 13 )  surf_v(3)%pt_surface
    3511                    CASE ( 'surf_v(3)%shf' )         
    3512                       IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )        &
    3513                          READ ( 13 )  surf_v(3)%shf
    3514                    CASE ( 'surf_v(3)%qsws' )         
    3515                       IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )       &
    3516                          READ ( 13 )  surf_v(3)%qsws
    3517                    CASE ( 'surf_v(3)%ssws' )         
    3518                       IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )       &
    3519                          READ ( 13 )  surf_v(3)%ssws
    3520                    CASE ( 'surf_v(3)%css' )
    3521                       IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )        &
    3522                          READ ( 13 )  surf_v(3)%css
    3523                    CASE ( 'surf_v(3)%cssws' )         
    3524                       IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )      &
    3525                          READ ( 13 )  surf_v(3)%cssws
    3526                    CASE ( 'surf_v(3)%qcsws' )         
    3527                       IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )      &
    3528                          READ ( 13 )  surf_v(3)%qcsws
    3529                    CASE ( 'surf_v(3)%ncsws' )         
    3530                       IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )      &
    3531                          READ ( 13 )  surf_v(3)%ncsws
    3532                    CASE ( 'surf_v(3)%qrsws' )         
    3533                       IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )      &
    3534                          READ ( 13 )  surf_v(3)%qrsws
    3535                    CASE ( 'surf_v(3)%nrsws' )         
    3536                       IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )      &
    3537                          READ ( 13 )  surf_v(3)%nrsws
    3538                    CASE ( 'surf_v(3)%sasws' )         
    3539                       IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )      &
    3540                          READ ( 13 )  surf_v(3)%sasws
    3541                    CASE ( 'surf_v(3)%mom_uv' )         
    3542                       IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )&
    3543                          READ ( 13 )  surf_v(3)%mom_flux_uv
    3544                    CASE ( 'surf_v(3)%mom_w' )         
    3545                       IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 ) &
    3546                          READ ( 13 )  surf_v(3)%mom_flux_w
    3547                    CASE ( 'surf_v(3)%mom_tke' )         
    3548                       IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )&
    3549                          READ ( 13 )  surf_v(3)%mom_flux_tke
    3550 
    3551                 END SELECT
    3552 !
    3553 !--             Redistribute surface elements on its respective type.
    3554                 IF ( horizontal_surface )  THEN
    3555                    ic = nxlc
    3556                    DO  i = nxlf, nxrf
    3557                       jc = nysc
    3558                       DO  j = nysf, nynf
    3559 
    3560                          surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=   &
    3561                                            surf_def_h(l)%start_index(jc,ic)
    3562                          surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=   &
    3563                                              surf_lsm_h%start_index(jc,ic) )   &
    3564                                      .AND.  l == 0
    3565                          surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=   &
    3566                                              surf_usm_h%start_index(jc,ic) )   &
    3567                                      .AND.  l == 0
    3568 
    3569                          IF ( surf_match_def )  THEN
    3570                             mm = surf_def_h(l)%start_index(jc,ic)
    3571                             DO  m = surf_h(l)%start_index(j,i),                &
    3572                                     surf_h(l)%end_index(j,i)
    3573                                CALL restore_surface_elements( surf_def_h(l),   &
    3574                                                               mm, surf_h(l), m )
    3575                                mm = mm + 1
    3576                             ENDDO
    3577                          ENDIF
    3578 
    3579                          IF ( surf_match_lsm )  THEN
    3580                             mm = surf_lsm_h%start_index(jc,ic)
    3581                             DO  m = surf_h(l)%start_index(j,i),                &
    3582                                     surf_h(l)%end_index(j,i)
    3583                                CALL restore_surface_elements( surf_lsm_h,      &
    3584                                                               mm, surf_h(l), m )
    3585                                mm = mm + 1
    3586                             ENDDO
    3587                          ENDIF
    3588 
    3589                          IF ( surf_match_usm )  THEN
    3590                             mm = surf_usm_h%start_index(jc,ic)
    3591                             DO  m = surf_h(l)%start_index(j,i),                &
    3592                                     surf_h(l)%end_index(j,i)
    3593                                CALL restore_surface_elements( surf_usm_h,      &
    3594                                                               mm, surf_h(l), m )
    3595                                mm = mm + 1
    3596                             ENDDO
    3597                          ENDIF
    3598 
    3599                          jc = jc + 1
    3600                       ENDDO
    3601                       ic = ic + 1
    3602                    ENDDO
    3603                 ELSEIF ( vertical_surface )  THEN
    3604                    ic = nxlc
    3605                    DO  i = nxlf, nxrf
    3606                       jc = nysc
    3607                       DO  j = nysf, nynf
    3608 
    3609                          surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=   &
    3610                                            surf_def_v(l)%start_index(jc,ic)
    3611                          surf_match_lsm  = surf_lsm_v(l)%end_index(jc,ic) >=   &
    3612                                            surf_lsm_v(l)%start_index(jc,ic)
    3613                          surf_match_usm  = surf_usm_v(l)%end_index(jc,ic) >=   &
    3614                                            surf_usm_v(l)%start_index(jc,ic)
    3615 
    3616                          IF ( surf_match_def )  THEN
    3617                             mm = surf_def_v(l)%start_index(jc,ic)
    3618                             DO  m = surf_v(l)%start_index(j,i),                &
    3619                                     surf_v(l)%end_index(j,i)
    3620                                CALL restore_surface_elements( surf_def_v(l),   &
    3621                                                               mm, surf_v(l), m )
    3622                                mm = mm + 1
    3623                             ENDDO
    3624                          ENDIF
    3625 
    3626                          IF ( surf_match_lsm )  THEN
    3627                             mm = surf_lsm_v(l)%start_index(jc,ic)
    3628                             DO  m = surf_v(l)%start_index(j,i),                &
    3629                                     surf_v(l)%end_index(j,i)
    3630                                CALL restore_surface_elements( surf_lsm_v(l),   &
    3631                                                               mm, surf_v(l), m )
    3632                                mm = mm + 1
    3633                             ENDDO
    3634                          ENDIF
    3635    
    3636                          IF ( surf_match_usm )  THEN
    3637                             mm = surf_usm_v(l)%start_index(jc,ic)
    3638                             DO  m = surf_v(l)%start_index(j,i),                &
    3639                                     surf_v(l)%end_index(j,i)
    3640                                CALL restore_surface_elements( surf_usm_v(l),   &
    3641                                                               mm, surf_v(l), m )
    3642                                mm = mm + 1
    3643                             ENDDO
    3644                          ENDIF
    3645 
    3646                          jc = jc + 1
    3647                       ENDDO
    3648                       ic = ic + 1
     3336               ENDDO
     3337
     3338             ENDIF
     3339
     3340          CASE ( 'surf_h(0)%start_index' )
     3341             IF ( kk == 1 )                                                    &
     3342                READ ( 13 )  surf_h(0)%start_index
     3343             l = 0
     3344          CASE ( 'surf_h(0)%end_index' )   
     3345             IF ( kk == 1 )                                                    &
     3346                READ ( 13 )  surf_h(0)%end_index
     3347             horizontal_surface = .TRUE.
     3348             vertical_surface   = .FALSE.
     3349          CASE ( 'surf_h(0)%us' )         
     3350             IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )                  &
     3351                READ ( 13 )  surf_h(0)%us
     3352          CASE ( 'surf_h(0)%ts' )         
     3353             IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )                  &
     3354                READ ( 13 )  surf_h(0)%ts
     3355          CASE ( 'surf_h(0)%qs' )         
     3356             IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )                  &
     3357                READ ( 13 )  surf_h(0)%qs
     3358          CASE ( 'surf_h(0)%ss' )         
     3359             IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )                  &
     3360                READ ( 13 )  surf_h(0)%ss
     3361          CASE ( 'surf_h(0)%qcs' )         
     3362             IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )                 &
     3363                READ ( 13 )  surf_h(0)%qcs
     3364          CASE ( 'surf_h(0)%ncs' )         
     3365             IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )                 &
     3366                READ ( 13 )  surf_h(0)%ncs
     3367          CASE ( 'surf_h(0)%qrs' )         
     3368             IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )                 &
     3369                READ ( 13 )  surf_h(0)%qrs
     3370          CASE ( 'surf_h(0)%nrs' )         
     3371             IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )                 &
     3372                READ ( 13 )  surf_h(0)%nrs
     3373          CASE ( 'surf_h(0)%ol' )         
     3374             IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )                  &
     3375                READ ( 13 )  surf_h(0)%ol
     3376          CASE ( 'surf_h(0)%rib' )         
     3377             IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )                 &
     3378                READ ( 13 )  surf_h(0)%rib
     3379          CASE ( 'surf_h(0)%pt_surface' )         
     3380             IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 )          &
     3381                READ ( 13 )  surf_h(0)%pt_surface
     3382          CASE ( 'surf_h(0)%usws' )         
     3383             IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )                &
     3384                READ ( 13 )  surf_h(0)%usws
     3385          CASE ( 'surf_h(0)%vsws' )         
     3386             IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )                &
     3387                READ ( 13 )  surf_h(0)%vsws
     3388          CASE ( 'surf_h(0)%shf' )         
     3389             IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )                 &
     3390                READ ( 13 )  surf_h(0)%shf
     3391          CASE ( 'surf_h(0)%qsws' )         
     3392             IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )                &
     3393                READ ( 13 )  surf_h(0)%qsws
     3394          CASE ( 'surf_h(0)%ssws' )         
     3395             IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )                &
     3396                READ ( 13 )  surf_h(0)%ssws
     3397          CASE ( 'surf_h(0)%css' )
     3398             IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )                 &
     3399                READ ( 13 )  surf_h(0)%css
     3400          CASE ( 'surf_h(0)%cssws' )         
     3401             IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )               &
     3402                READ ( 13 )  surf_h(0)%cssws
     3403          CASE ( 'surf_h(0)%qcsws' )         
     3404             IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )               &
     3405                READ ( 13 )  surf_h(0)%qcsws
     3406          CASE ( 'surf_h(0)%ncsws' )         
     3407             IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )               &
     3408                READ ( 13 )  surf_h(0)%ncsws
     3409          CASE ( 'surf_h(0)%qrsws' )         
     3410             IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )               &
     3411                READ ( 13 )  surf_h(0)%qrsws
     3412          CASE ( 'surf_h(0)%nrsws' )         
     3413             IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )               &
     3414                READ ( 13 )  surf_h(0)%nrsws
     3415          CASE ( 'surf_h(0)%sasws' )         
     3416             IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )               &
     3417                READ ( 13 )  surf_h(0)%sasws
     3418
     3419          CASE ( 'surf_h(1)%start_index' )   
     3420             IF ( kk == 1 )                                                    &
     3421                READ ( 13 )  surf_h(1)%start_index
     3422             l = 1
     3423          CASE ( 'surf_h(1)%end_index' )   
     3424             IF ( kk == 1 )                                                    &
     3425                READ ( 13 )  surf_h(1)%end_index
     3426          CASE ( 'surf_h(1)%us' )         
     3427             IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )                  &
     3428                READ ( 13 )  surf_h(1)%us
     3429          CASE ( 'surf_h(1)%ts' )         
     3430             IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )                  &
     3431                READ ( 13 )  surf_h(1)%ts
     3432          CASE ( 'surf_h(1)%qs' )         
     3433             IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )                  &
     3434                READ ( 13 )  surf_h(1)%qs
     3435          CASE ( 'surf_h(1)%ss' )         
     3436             IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )                  &
     3437                READ ( 13 )  surf_h(1)%ss
     3438          CASE ( 'surf_h(1)%qcs' )         
     3439             IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )                 &
     3440                READ ( 13 )  surf_h(1)%qcs
     3441          CASE ( 'surf_h(1)%ncs' )         
     3442             IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )                 &
     3443                READ ( 13 )  surf_h(1)%ncs
     3444          CASE ( 'surf_h(1)%qrs' )         
     3445             IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )                 &
     3446                READ ( 13 )  surf_h(1)%qrs
     3447          CASE ( 'surf_h(1)%nrs' )         
     3448             IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )                 &
     3449                READ ( 13 )  surf_h(1)%nrs
     3450          CASE ( 'surf_h(1)%ol' )         
     3451             IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )                  &
     3452                READ ( 13 )  surf_h(1)%ol
     3453          CASE ( 'surf_h(1)%rib' )         
     3454             IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )                 &
     3455                READ ( 13 )  surf_h(1)%rib
     3456          CASE ( 'surf_h(1)%pt_surface' )         
     3457             IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 )          &
     3458                READ ( 13 )  surf_h(1)%pt_surface
     3459          CASE ( 'surf_h(1)%usws' )         
     3460             IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )                &
     3461                READ ( 13 )  surf_h(1)%usws
     3462          CASE ( 'surf_h(1)%vsws' )         
     3463             IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )                &
     3464                READ ( 13 )  surf_h(1)%vsws
     3465          CASE ( 'surf_h(1)%shf' )         
     3466             IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )                 &
     3467                READ ( 13 )  surf_h(1)%shf
     3468          CASE ( 'surf_h(1)%qsws' )         
     3469             IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )                &
     3470                READ ( 13 )  surf_h(1)%qsws
     3471          CASE ( 'surf_h(1)%ssws' )         
     3472             IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )                &
     3473                READ ( 13 )  surf_h(1)%ssws
     3474          CASE ( 'surf_h(1)%css' )
     3475             IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )                 &
     3476                READ ( 13 )  surf_h(1)%css
     3477          CASE ( 'surf_h(1)%cssws' )         
     3478             IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )               &
     3479                READ ( 13 )  surf_h(1)%cssws
     3480          CASE ( 'surf_h(1)%qcsws' )         
     3481             IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )               &
     3482                READ ( 13 )  surf_h(1)%qcsws
     3483          CASE ( 'surf_h(1)%ncsws' )         
     3484             IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )               &
     3485                READ ( 13 )  surf_h(1)%ncsws
     3486          CASE ( 'surf_h(1)%qrsws' )         
     3487             IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )               &
     3488                READ ( 13 )  surf_h(1)%qrsws
     3489          CASE ( 'surf_h(1)%nrsws' )         
     3490             IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )               &
     3491                READ ( 13 )  surf_h(1)%nrsws
     3492          CASE ( 'surf_h(1)%sasws' )         
     3493             IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )               &
     3494                READ ( 13 )  surf_h(1)%sasws
     3495
     3496          CASE ( 'surf_h(2)%start_index' )   
     3497             IF ( kk == 1 )                                                    &
     3498                READ ( 13 )  surf_h(2)%start_index
     3499             l = 2
     3500          CASE ( 'surf_h(2)%end_index' )   
     3501             IF ( kk == 1 )                                                    &
     3502                READ ( 13 )  surf_h(2)%end_index
     3503          CASE ( 'surf_h(2)%us' )         
     3504             IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )                  &
     3505                READ ( 13 )  surf_h(2)%us
     3506          CASE ( 'surf_h(2)%ts' )         
     3507             IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )                  &
     3508                READ ( 13 )  surf_h(2)%ts
     3509          CASE ( 'surf_h(2)%qs' )       
     3510             IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )                  &
     3511                READ ( 13 )  surf_h(2)%qs
     3512          CASE ( 'surf_h(2)%ss' )         
     3513             IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )                  &
     3514                READ ( 13 )  surf_h(2)%ss
     3515          CASE ( 'surf_h(2)%qcs' )         
     3516             IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )                 &
     3517                READ ( 13 )  surf_h(2)%qcs
     3518          CASE ( 'surf_h(2)%ncs' )         
     3519             IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )                 &
     3520                READ ( 13 )  surf_h(2)%ncs
     3521          CASE ( 'surf_h(2)%qrs' )         
     3522             IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )                 &
     3523                READ ( 13 )  surf_h(2)%qrs
     3524          CASE ( 'surf_h(2)%nrs' )         
     3525             IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )                 &
     3526                READ ( 13 )  surf_h(2)%nrs
     3527          CASE ( 'surf_h(2)%ol' )         
     3528             IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )                  &
     3529                READ ( 13 )  surf_h(2)%ol
     3530          CASE ( 'surf_h(2)%rib' )         
     3531             IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )                 &
     3532                READ ( 13 )  surf_h(2)%rib
     3533          CASE ( 'surf_h(2)%pt_surface' )         
     3534             IF ( ALLOCATED( surf_h(2)%pt_surface )  .AND.  kk == 1 )          &
     3535                READ ( 13 )  surf_h(2)%pt_surface
     3536          CASE ( 'surf_h(2)%usws' )         
     3537             IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )                &
     3538                READ ( 13 )  surf_h(2)%usws
     3539          CASE ( 'surf_h(2)%vsws' )         
     3540             IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )                &
     3541                READ ( 13 )  surf_h(2)%vsws
     3542          CASE ( 'surf_h(2)%shf' )         
     3543             IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )                 &
     3544                READ ( 13 )  surf_h(2)%shf
     3545          CASE ( 'surf_h(2)%qsws' )         
     3546             IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )                &
     3547                READ ( 13 )  surf_h(2)%qsws
     3548          CASE ( 'surf_h(2)%ssws' )         
     3549             IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )                &
     3550                READ ( 13 )  surf_h(2)%ssws
     3551          CASE ( 'surf_h(2)%css' )
     3552             IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )                 &
     3553                READ ( 13 )  surf_h(2)%css
     3554          CASE ( 'surf_h(2)%cssws' )         
     3555             IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )               &
     3556                READ ( 13 )  surf_h(2)%cssws
     3557          CASE ( 'surf_h(2)%qcsws' )         
     3558             IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )               &
     3559                READ ( 13 )  surf_h(2)%qcsws
     3560          CASE ( 'surf_h(2)%ncsws' )         
     3561             IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )               &
     3562                READ ( 13 )  surf_h(2)%ncsws
     3563          CASE ( 'surf_h(2)%qrsws' )         
     3564             IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )               &
     3565                READ ( 13 )  surf_h(2)%qrsws
     3566          CASE ( 'surf_h(2)%nrsws' )         
     3567             IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )               &
     3568                READ ( 13 )  surf_h(2)%nrsws
     3569          CASE ( 'surf_h(2)%sasws' )         
     3570             IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )               &
     3571                READ ( 13 )  surf_h(2)%sasws
     3572
     3573          CASE ( 'surf_v(0)%start_index' )   
     3574             IF ( kk == 1 )                                                    &
     3575                READ ( 13 )  surf_v(0)%start_index
     3576             l = 0
     3577             horizontal_surface = .FALSE.
     3578             vertical_surface   = .TRUE.
     3579          CASE ( 'surf_v(0)%end_index' )   
     3580             IF ( kk == 1 )                                                    &
     3581                READ ( 13 )  surf_v(0)%end_index
     3582          CASE ( 'surf_v(0)%us' )         
     3583             IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )                  &
     3584                READ ( 13 )  surf_v(0)%us
     3585          CASE ( 'surf_v(0)%ts' )         
     3586             IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )                  &
     3587                READ ( 13 )  surf_v(0)%ts
     3588          CASE ( 'surf_v(0)%qs' )         
     3589             IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )                  &
     3590                READ ( 13 )  surf_v(0)%qs
     3591          CASE ( 'surf_v(0)%ss' )         
     3592             IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )                  &
     3593                READ ( 13 )  surf_v(0)%ss
     3594          CASE ( 'surf_v(0)%qcs' )         
     3595             IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )                 &
     3596                READ ( 13 )  surf_v(0)%qcs
     3597          CASE ( 'surf_v(0)%ncs' )         
     3598             IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )                 &
     3599                READ ( 13 )  surf_v(0)%ncs
     3600          CASE ( 'surf_v(0)%qrs' )         
     3601             IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )                 &
     3602                READ ( 13 )  surf_v(0)%qrs
     3603          CASE ( 'surf_v(0)%nrs' )         
     3604             IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )                 &
     3605                READ ( 13 )  surf_v(0)%nrs
     3606          CASE ( 'surf_v(0)%ol' )         
     3607             IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )                  &
     3608                READ ( 13 )  surf_v(0)%ol
     3609          CASE ( 'surf_v(0)%rib' )         
     3610             IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )                 &
     3611                READ ( 13 )  surf_v(0)%rib
     3612          CASE ( 'surf_v(0)%pt_surface' )         
     3613             IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 )          &
     3614                READ ( 13 )  surf_v(0)%pt_surface
     3615          CASE ( 'surf_v(0)%shf' )         
     3616             IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )                 &
     3617                READ ( 13 )  surf_v(0)%shf
     3618          CASE ( 'surf_v(0)%qsws' )         
     3619             IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )                &
     3620                READ ( 13 )  surf_v(0)%qsws
     3621          CASE ( 'surf_v(0)%ssws' )         
     3622             IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )                &
     3623                READ ( 13 )  surf_v(0)%ssws
     3624          CASE ( 'surf_v(0)%css' )
     3625             IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )                 &
     3626                READ ( 13 )  surf_v(0)%css
     3627          CASE ( 'surf_v(0)%cssws' )         
     3628             IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )               &
     3629                READ ( 13 )  surf_v(0)%cssws
     3630          CASE ( 'surf_v(0)%qcsws' )         
     3631             IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )               &
     3632                READ ( 13 )  surf_v(0)%qcsws
     3633          CASE ( 'surf_v(0)%ncsws' )         
     3634             IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )               &
     3635                READ ( 13 )  surf_v(0)%ncsws
     3636          CASE ( 'surf_v(0)%qrsws' )         
     3637             IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )               &
     3638                READ ( 13 )  surf_v(0)%qrsws
     3639          CASE ( 'surf_v(0)%nrsws' )         
     3640             IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )               &
     3641                READ ( 13 )  surf_v(0)%nrsws
     3642          CASE ( 'surf_v(0)%sasws' )         
     3643             IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )               &
     3644                READ ( 13 )  surf_v(0)%sasws
     3645          CASE ( 'surf_v(0)%mom_uv' )         
     3646             IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )         &
     3647                READ ( 13 )  surf_v(0)%mom_flux_uv
     3648          CASE ( 'surf_v(0)%mom_w' )         
     3649             IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 )          &
     3650                READ ( 13 )  surf_v(0)%mom_flux_w
     3651          CASE ( 'surf_v(0)%mom_tke' )         
     3652             IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )        &
     3653                READ ( 13 )  surf_v(0)%mom_flux_tke
     3654
     3655          CASE ( 'surf_v(1)%start_index' )   
     3656             IF ( kk == 1 )                                                    &
     3657                READ ( 13 )  surf_v(1)%start_index
     3658             l = 1
     3659          CASE ( 'surf_v(1)%end_index' )   
     3660             IF ( kk == 1 )                                                    &
     3661                READ ( 13 )  surf_v(1)%end_index
     3662          CASE ( 'surf_v(1)%us' )         
     3663             IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )                  &
     3664                READ ( 13 )  surf_v(1)%us
     3665          CASE ( 'surf_v(1)%ts' )         
     3666             IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )                  &
     3667                READ ( 13 )  surf_v(1)%ts
     3668          CASE ( 'surf_v(1)%qs' )         
     3669             IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )                  &
     3670                READ ( 13 )  surf_v(1)%qs
     3671          CASE ( 'surf_v(1)%ss' )         
     3672             IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )                  &
     3673                READ ( 13 )  surf_v(1)%ss
     3674          CASE ( 'surf_v(1)%qcs' )         
     3675             IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )                 &
     3676                READ ( 13 )  surf_v(1)%qcs
     3677          CASE ( 'surf_v(1)%ncs' )         
     3678             IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )                 &
     3679                READ ( 13 )  surf_v(1)%ncs
     3680          CASE ( 'surf_v(1)%qrs' )         
     3681             IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )                 &
     3682                READ ( 13 )  surf_v(1)%qrs
     3683          CASE ( 'surf_v(1)%nrs' )         
     3684             IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )                 &
     3685                READ ( 13 )  surf_v(1)%nrs
     3686          CASE ( 'surf_v(1)%ol' )         
     3687             IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )                  &
     3688                READ ( 13 )  surf_v(1)%ol
     3689          CASE ( 'surf_v(1)%rib' )         
     3690             IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )                 &
     3691                READ ( 13 )  surf_v(1)%rib
     3692          CASE ( 'surf_v(1)%pt_surface' )         
     3693             IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 )          &
     3694                READ ( 13 )  surf_v(1)%pt_surface
     3695          CASE ( 'surf_v(1)%shf' )         
     3696             IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )                 &
     3697                READ ( 13 )  surf_v(1)%shf
     3698          CASE ( 'surf_v(1)%qsws' )         
     3699             IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )                &
     3700                READ ( 13 )  surf_v(1)%qsws
     3701          CASE ( 'surf_v(1)%ssws' )         
     3702             IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )                &
     3703                READ ( 13 )  surf_v(1)%ssws
     3704          CASE ( 'surf_v(1)%css' )
     3705             IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )                 &
     3706                READ ( 13 )  surf_v(1)%css
     3707          CASE ( 'surf_v(1)%cssws' )         
     3708             IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )               &
     3709                READ ( 13 )  surf_v(1)%cssws
     3710          CASE ( 'surf_v(1)%qcsws' )         
     3711             IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )               &
     3712                READ ( 13 )  surf_v(1)%qcsws
     3713          CASE ( 'surf_v(1)%ncsws' )         
     3714             IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )               &
     3715                READ ( 13 )  surf_v(1)%ncsws
     3716          CASE ( 'surf_v(1)%qrsws' )         
     3717             IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )               &
     3718                READ ( 13 )  surf_v(1)%qrsws
     3719          CASE ( 'surf_v(1)%nrsws' )         
     3720             IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )               &
     3721                READ ( 13 )  surf_v(1)%nrsws
     3722          CASE ( 'surf_v(1)%sasws' )         
     3723             IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )               &
     3724                READ ( 13 )  surf_v(1)%sasws
     3725          CASE ( 'surf_v(1)%mom_uv' )         
     3726             IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )         &
     3727                READ ( 13 )  surf_v(1)%mom_flux_uv
     3728          CASE ( 'surf_v(1)%mom_w' )         
     3729             IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 )          &
     3730                READ ( 13 )  surf_v(1)%mom_flux_w
     3731          CASE ( 'surf_v(1)%mom_tke' )         
     3732             IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )        &
     3733                READ ( 13 )  surf_v(1)%mom_flux_tke
     3734
     3735          CASE ( 'surf_v(2)%start_index' )   
     3736             IF ( kk == 1 )                                                    &
     3737                READ ( 13 )  surf_v(2)%start_index
     3738             l = 2
     3739          CASE ( 'surf_v(2)%end_index' )   
     3740             IF ( kk == 1 )                                                    &
     3741                READ ( 13 )  surf_v(2)%end_index
     3742          CASE ( 'surf_v(2)%us' )         
     3743             IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )                  &
     3744                READ ( 13 )  surf_v(2)%us
     3745          CASE ( 'surf_v(2)%ts' )         
     3746             IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )                  &
     3747                READ ( 13 )  surf_v(2)%ts
     3748          CASE ( 'surf_v(2)%qs' )         
     3749             IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )                  &
     3750                READ ( 13 )  surf_v(2)%qs
     3751          CASE ( 'surf_v(2)%ss' )         
     3752             IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )                  &
     3753                READ ( 13 )  surf_v(2)%ss
     3754          CASE ( 'surf_v(2)%qcs' )         
     3755             IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )                 &
     3756                READ ( 13 )  surf_v(2)%qcs
     3757          CASE ( 'surf_v(2)%ncs' )         
     3758             IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )                 &
     3759                READ ( 13 )  surf_v(2)%ncs
     3760          CASE ( 'surf_v(2)%qrs' )         
     3761             IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )                 &
     3762                READ ( 13 )  surf_v(2)%qrs
     3763          CASE ( 'surf_v(2)%nrs' )         
     3764             IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )                 &
     3765                READ ( 13 )  surf_v(2)%nrs
     3766          CASE ( 'surf_v(2)%ol' )         
     3767             IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )                  &
     3768                READ ( 13 )  surf_v(2)%ol
     3769          CASE ( 'surf_v(2)%rib' )         
     3770             IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )                 &
     3771                READ ( 13 )  surf_v(2)%rib
     3772          CASE ( 'surf_v(2)%pt_surface' )         
     3773             IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 )          &
     3774                READ ( 13 )  surf_v(2)%pt_surface
     3775          CASE ( 'surf_v(2)%shf' )         
     3776             IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )                 &
     3777                READ ( 13 )  surf_v(2)%shf
     3778          CASE ( 'surf_v(2)%qsws' )         
     3779             IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )                &
     3780                READ ( 13 )  surf_v(2)%qsws
     3781          CASE ( 'surf_v(2)%ssws' )         
     3782             IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )                &
     3783                READ ( 13 )  surf_v(2)%ssws
     3784          CASE ( 'surf_v(2)%css' )
     3785             IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )                 &
     3786                READ ( 13 )  surf_v(2)%css
     3787          CASE ( 'surf_v(2)%cssws' )         
     3788             IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )               &
     3789                READ ( 13 )  surf_v(2)%cssws
     3790          CASE ( 'surf_v(2)%qcsws' )         
     3791             IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )               &
     3792                READ ( 13 )  surf_v(2)%qcsws
     3793          CASE ( 'surf_v(2)%ncsws' )         
     3794             IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )               &
     3795                READ ( 13 )  surf_v(2)%ncsws
     3796          CASE ( 'surf_v(2)%qrsws' )         
     3797             IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )               &
     3798                READ ( 13 )  surf_v(2)%qrsws
     3799          CASE ( 'surf_v(2)%nrsws' )         
     3800             IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )               &
     3801                READ ( 13 )  surf_v(2)%nrsws
     3802          CASE ( 'surf_v(2)%sasws' )         
     3803             IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )               &
     3804                READ ( 13 )  surf_v(2)%sasws
     3805          CASE ( 'surf_v(2)%mom_uv' )         
     3806             IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )         &
     3807                READ ( 13 )  surf_v(2)%mom_flux_uv
     3808          CASE ( 'surf_v(2)%mom_w' )         
     3809             IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 )          &
     3810                READ ( 13 )  surf_v(2)%mom_flux_w
     3811          CASE ( 'surf_v(2)%mom_tke' )         
     3812             IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )        &
     3813                READ ( 13 )  surf_v(2)%mom_flux_tke
     3814
     3815          CASE ( 'surf_v(3)%start_index' )   
     3816             IF ( kk == 1 )                                                    &
     3817                READ ( 13 )  surf_v(3)%start_index
     3818             l = 3
     3819          CASE ( 'surf_v(3)%end_index' )   
     3820             IF ( kk == 1 )                                                    &
     3821                READ ( 13 )  surf_v(3)%end_index
     3822          CASE ( 'surf_v(3)%us' )         
     3823             IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )                  &
     3824                READ ( 13 )  surf_v(3)%us
     3825          CASE ( 'surf_v(3)%ts' )         
     3826             IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )                  &
     3827                READ ( 13 )  surf_v(3)%ts
     3828          CASE ( 'surf_v(3)%qs' )       
     3829             IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )                  &
     3830                READ ( 13 )  surf_v(3)%qs
     3831          CASE ( 'surf_v(3)%ss' )         
     3832             IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )                  &
     3833                READ ( 13 )  surf_v(3)%ss
     3834          CASE ( 'surf_v(3)%qcs' )         
     3835             IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )                 &
     3836                READ ( 13 )  surf_v(3)%qcs
     3837          CASE ( 'surf_v(3)%ncs' )         
     3838             IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )                 &
     3839                READ ( 13 )  surf_v(3)%ncs
     3840          CASE ( 'surf_v(3)%qrs' )         
     3841             IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )                 &
     3842                READ ( 13 )  surf_v(3)%qrs
     3843          CASE ( 'surf_v(3)%nrs' )         
     3844             IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )                 &
     3845                READ ( 13 )  surf_v(3)%nrs
     3846          CASE ( 'surf_v(3)%ol' )         
     3847             IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )                  &
     3848                READ ( 13 )  surf_v(3)%ol
     3849          CASE ( 'surf_v(3)%rib' )         
     3850             IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )                 &
     3851                READ ( 13 )  surf_v(3)%rib
     3852          CASE ( 'surf_v(3)%pt_surface' )         
     3853             IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 )          &
     3854                READ ( 13 )  surf_v(3)%pt_surface
     3855          CASE ( 'surf_v(3)%shf' )         
     3856             IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )                 &
     3857                READ ( 13 )  surf_v(3)%shf
     3858          CASE ( 'surf_v(3)%qsws' )         
     3859             IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )                &
     3860                READ ( 13 )  surf_v(3)%qsws
     3861          CASE ( 'surf_v(3)%ssws' )         
     3862             IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )                &
     3863                READ ( 13 )  surf_v(3)%ssws
     3864          CASE ( 'surf_v(3)%css' )
     3865             IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )                 &
     3866                READ ( 13 )  surf_v(3)%css
     3867          CASE ( 'surf_v(3)%cssws' )         
     3868             IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )               &
     3869                READ ( 13 )  surf_v(3)%cssws
     3870          CASE ( 'surf_v(3)%qcsws' )         
     3871             IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )               &
     3872                READ ( 13 )  surf_v(3)%qcsws
     3873          CASE ( 'surf_v(3)%ncsws' )         
     3874             IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )               &
     3875                READ ( 13 )  surf_v(3)%ncsws
     3876          CASE ( 'surf_v(3)%qrsws' )         
     3877             IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )               &
     3878                READ ( 13 )  surf_v(3)%qrsws
     3879          CASE ( 'surf_v(3)%nrsws' )         
     3880             IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )               &
     3881                READ ( 13 )  surf_v(3)%nrsws
     3882          CASE ( 'surf_v(3)%sasws' )         
     3883             IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )               &
     3884                READ ( 13 )  surf_v(3)%sasws
     3885          CASE ( 'surf_v(3)%mom_uv' )         
     3886             IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )         &
     3887                READ ( 13 )  surf_v(3)%mom_flux_uv
     3888          CASE ( 'surf_v(3)%mom_w' )         
     3889             IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 )          &
     3890                READ ( 13 )  surf_v(3)%mom_flux_w
     3891          CASE ( 'surf_v(3)%mom_tke' )         
     3892             IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )        &
     3893                READ ( 13 )  surf_v(3)%mom_flux_tke
     3894
     3895          CASE DEFAULT
     3896
     3897                found = .FALSE.
     3898
     3899       END SELECT
     3900
     3901!
     3902!--    Redistribute surface elements on its respective type.
     3903       IF ( horizontal_surface )  THEN
     3904          ic = nxlc
     3905          DO  i = nxlf, nxrf
     3906             jc = nysc
     3907             DO  j = nysf, nynf
     3908
     3909                surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=            &
     3910                                  surf_def_h(l)%start_index(jc,ic)
     3911                surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=            &
     3912                                    surf_lsm_h%start_index(jc,ic) )            &
     3913                            .AND.  l == 0
     3914                surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=            &
     3915                                    surf_usm_h%start_index(jc,ic) )            &
     3916                            .AND.  l == 0
     3917
     3918                IF ( surf_match_def )  THEN
     3919                   mm = surf_def_h(l)%start_index(jc,ic)
     3920                   DO  m = surf_h(l)%start_index(j,i),                         &
     3921                           surf_h(l)%end_index(j,i)
     3922                      CALL restore_surface_elements( surf_def_h(l),            &
     3923                                                     mm, surf_h(l), m )
     3924                      mm = mm + 1
    36493925                   ENDDO
    36503926                ENDIF
    36513927
     3928                IF ( surf_match_lsm )  THEN
     3929                   mm = surf_lsm_h%start_index(jc,ic)
     3930                   DO  m = surf_h(l)%start_index(j,i),                         &
     3931                           surf_h(l)%end_index(j,i)
     3932                      CALL restore_surface_elements( surf_lsm_h,               &
     3933                                                     mm, surf_h(l), m )
     3934                      mm = mm + 1
     3935                   ENDDO
     3936                ENDIF
     3937
     3938                IF ( surf_match_usm )  THEN
     3939                   mm = surf_usm_h%start_index(jc,ic)
     3940                   DO  m = surf_h(l)%start_index(j,i),                         &
     3941                           surf_h(l)%end_index(j,i)
     3942                      CALL restore_surface_elements( surf_usm_h,               &
     3943                                                     mm, surf_h(l), m )
     3944                      mm = mm + 1
     3945                   ENDDO
     3946                ENDIF
     3947
     3948                jc = jc + 1
    36523949             ENDDO
    3653 
    3654              READ ( 13 )  field_chr
    3655 
     3950             ic = ic + 1
    36563951          ENDDO
    3657 
     3952       ELSEIF ( vertical_surface )  THEN
     3953          ic = nxlc
     3954          DO  i = nxlf, nxrf
     3955             jc = nysc
     3956             DO  j = nysf, nynf
     3957
     3958                surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=            &
     3959                                  surf_def_v(l)%start_index(jc,ic)
     3960                surf_match_lsm  = surf_lsm_v(l)%end_index(jc,ic) >=            &
     3961                                  surf_lsm_v(l)%start_index(jc,ic)
     3962                surf_match_usm  = surf_usm_v(l)%end_index(jc,ic) >=            &
     3963                                  surf_usm_v(l)%start_index(jc,ic)
     3964
     3965                IF ( surf_match_def )  THEN
     3966                   mm = surf_def_v(l)%start_index(jc,ic)
     3967                   DO  m = surf_v(l)%start_index(j,i),                         &
     3968                           surf_v(l)%end_index(j,i)
     3969                      CALL restore_surface_elements( surf_def_v(l),            &
     3970                                                     mm, surf_v(l), m )
     3971                      mm = mm + 1
     3972                   ENDDO
     3973                ENDIF
     3974
     3975                IF ( surf_match_lsm )  THEN
     3976                   mm = surf_lsm_v(l)%start_index(jc,ic)
     3977                   DO  m = surf_v(l)%start_index(j,i),                         &
     3978                           surf_v(l)%end_index(j,i)
     3979                      CALL restore_surface_elements( surf_lsm_v(l),            &
     3980                                                     mm, surf_v(l), m )
     3981                      mm = mm + 1
     3982                   ENDDO
     3983                ENDIF
     3984
     3985                IF ( surf_match_usm )  THEN
     3986                   mm = surf_usm_v(l)%start_index(jc,ic)
     3987                   DO  m = surf_v(l)%start_index(j,i),                         &
     3988                           surf_v(l)%end_index(j,i)
     3989                      CALL restore_surface_elements( surf_usm_v(l),            &
     3990                                                     mm, surf_v(l), m )
     3991                      mm = mm + 1
     3992                   ENDDO
     3993                ENDIF
     3994
     3995                jc = jc + 1
     3996             ENDDO
     3997             ic = ic + 1
     3998          ENDDO
    36583999       ENDIF
    36594000
    3660        CONTAINS
     4001
     4002    CONTAINS
    36614003!------------------------------------------------------------------------------!
    36624004! Description:
     
    36764018             TYPE( surf_type ) ::  surf_file   !< surface type on file
    36774019
    3678              IF ( INDEX( TRIM( field_chr ), '%us' ) /= 0 )  THEN
     4020             IF ( INDEX( restart_string(1:length), '%us' ) /= 0 )  THEN
    36794021                IF ( ALLOCATED( surf_target%us )  .AND.                        &
    36804022                     ALLOCATED( surf_file%us   ) )                             &
     
    36824024             ENDIF
    36834025
    3684              IF ( INDEX( TRIM( field_chr ), '%ol' ) /= 0 )  THEN
     4026             IF ( INDEX( restart_string(1:length), '%ol' ) /= 0 )  THEN
    36854027                IF ( ALLOCATED( surf_target%ol )  .AND.                        &
    36864028                     ALLOCATED( surf_file%ol   ) )                             &
     
    36884030             ENDIF
    36894031
    3690              IF ( INDEX( TRIM( field_chr ), '%pt_surface' ) /= 0 )  THEN
     4032             IF ( INDEX( restart_string(1:length), '%pt_surface' ) /= 0 )  THEN
    36914033                IF ( ALLOCATED( surf_target%pt_surface )  .AND.                &
    36924034                     ALLOCATED( surf_file%pt_surface   ) )                     &
     
    36944036             ENDIF
    36954037
    3696              IF ( INDEX( TRIM( field_chr ), '%usws' ) /= 0 )  THEN
     4038             IF ( INDEX( restart_string(1:length), '%usws' ) /= 0 )  THEN
    36974039                IF ( ALLOCATED( surf_target%usws )  .AND.                      &
    36984040                     ALLOCATED( surf_file%usws   ) )                           &
     
    37004042             ENDIF
    37014043
    3702              IF ( INDEX( TRIM( field_chr ), '%vsws' ) /= 0 )  THEN
     4044             IF ( INDEX( restart_string(1:length), '%vsws' ) /= 0 )  THEN
    37034045                IF ( ALLOCATED( surf_target%vsws )  .AND.                      &
    37044046                     ALLOCATED( surf_file%vsws   ) )                           &
     
    37064048             ENDIF
    37074049
    3708              IF ( INDEX( TRIM( field_chr ), '%ts' ) /= 0 )  THEN
     4050             IF ( INDEX( restart_string(1:length), '%ts' ) /= 0 )  THEN
    37094051                IF ( ALLOCATED( surf_target%ts )  .AND.                        &
    37104052                     ALLOCATED( surf_file%ts   ) )                             &
     
    37124054             ENDIF
    37134055
    3714              IF ( INDEX( TRIM( field_chr ), '%shf' ) /= 0 )  THEN
     4056             IF ( INDEX( restart_string(1:length), '%shf' ) /= 0 )  THEN
    37154057                IF ( ALLOCATED( surf_target%shf )  .AND.                       &
    37164058                     ALLOCATED( surf_file%shf   ) )                            &
     
    37184060             ENDIF
    37194061
    3720              IF ( INDEX( TRIM( field_chr ), '%qs' ) /= 0 )  THEN
     4062             IF ( INDEX( restart_string(1:length), '%qs' ) /= 0 )  THEN
    37214063                IF ( ALLOCATED( surf_target%qs )  .AND.                        &
    37224064                     ALLOCATED( surf_file%qs   ) )                             &
     
    37244066             ENDIF
    37254067
    3726              IF ( INDEX( TRIM( field_chr ), '%qsws' ) /= 0 )  THEN
     4068             IF ( INDEX( restart_string(1:length), '%qsws' ) /= 0 )  THEN
    37274069                IF ( ALLOCATED( surf_target%qsws )  .AND.                      &
    37284070                     ALLOCATED( surf_file%qsws   ) )                           &
     
    37304072             ENDIF
    37314073
    3732              IF ( INDEX( TRIM( field_chr ), '%ss' ) /= 0 )  THEN
     4074             IF ( INDEX( restart_string(1:length), '%ss' ) /= 0 )  THEN
    37334075                IF ( ALLOCATED( surf_target%ss )  .AND.                        &
    37344076                     ALLOCATED( surf_file%ss   ) )                             &
     
    37364078             ENDIF
    37374079
    3738              IF ( INDEX( TRIM( field_chr ), '%ssws' ) /= 0 )  THEN
     4080             IF ( INDEX( restart_string(1:length), '%ssws' ) /= 0 )  THEN
    37394081                IF ( ALLOCATED( surf_target%ssws )  .AND.                      &
    37404082                     ALLOCATED( surf_file%ssws   ) )                           &
     
    37424084             ENDIF
    37434085
    3744              IF ( INDEX( TRIM( field_chr ), '%css' ) /= 0 )  THEN
     4086             IF ( INDEX( restart_string(1:length), '%css' ) /= 0 )  THEN
    37454087                IF ( ALLOCATED( surf_target%css )  .AND.                     &
    37464088                     ALLOCATED( surf_file%css   ) )  THEN                 
     
    37504092                ENDIF
    37514093             ENDIF
    3752              IF ( INDEX( TRIM( field_chr ), '%cssws' ) /= 0 )  THEN
     4094             IF ( INDEX( restart_string(1:length), '%cssws' ) /= 0 )  THEN
    37534095                IF ( ALLOCATED( surf_target%cssws )  .AND.                     &
    37544096                     ALLOCATED( surf_file%cssws   ) )  THEN                 
     
    37594101             ENDIF
    37604102
    3761              IF ( INDEX( TRIM( field_chr ), '%qcs' ) /= 0 )  THEN
     4103             IF ( INDEX( restart_string(1:length), '%qcs' ) /= 0 )  THEN
    37624104                IF ( ALLOCATED( surf_target%qcs )  .AND.                       &
    37634105                     ALLOCATED( surf_file%qcs   ) )                            &
     
    37654107             ENDIF
    37664108
    3767              IF ( INDEX( TRIM( field_chr ), '%qcsws' ) /= 0 )  THEN
     4109             IF ( INDEX( restart_string(1:length), '%qcsws' ) /= 0 )  THEN
    37684110                IF ( ALLOCATED( surf_target%qcsws )  .AND.                     &
    37694111                     ALLOCATED( surf_file%qcsws   ) )                          &
     
    37714113             ENDIF
    37724114
    3773              IF ( INDEX( TRIM( field_chr ), '%ncs' ) /= 0 )  THEN
     4115             IF ( INDEX( restart_string(1:length), '%ncs' ) /= 0 )  THEN
    37744116                IF ( ALLOCATED( surf_target%ncs )  .AND.                       &
    37754117                     ALLOCATED( surf_file%ncs   ) )                            &
     
    37774119             ENDIF
    37784120
    3779              IF ( INDEX( TRIM( field_chr ), '%ncsws' ) /= 0 )  THEN
     4121             IF ( INDEX( restart_string(1:length), '%ncsws' ) /= 0 )  THEN
    37804122                IF ( ALLOCATED( surf_target%ncsws )  .AND.                     &
    37814123                     ALLOCATED( surf_file%ncsws   ) )                          &
     
    37834125             ENDIF
    37844126
    3785              IF ( INDEX( TRIM( field_chr ), '%qrs' ) /= 0 )  THEN
     4127             IF ( INDEX( restart_string(1:length), '%qrs' ) /= 0 )  THEN
    37864128                IF ( ALLOCATED( surf_target%qrs )  .AND.                       &
    37874129                     ALLOCATED( surf_file%qrs   ) )                            &
     
    37894131             ENDIF
    37904132
    3791              IF ( INDEX( TRIM( field_chr ), '%qrsws' ) /= 0 )  THEN
     4133             IF ( INDEX( restart_string(1:length), '%qrsws' ) /= 0 )  THEN
    37924134                IF ( ALLOCATED( surf_target%qrsws )  .AND.                     &
    37934135                     ALLOCATED( surf_file%qrsws   ) )                          &
     
    37954137             ENDIF
    37964138
    3797              IF ( INDEX( TRIM( field_chr ), '%nrs' ) /= 0 )  THEN
     4139             IF ( INDEX( restart_string(1:length), '%nrs' ) /= 0 )  THEN
    37984140                IF ( ALLOCATED( surf_target%nrs )  .AND.                       &
    37994141                     ALLOCATED( surf_file%nrs   ) )                            &
     
    38014143             ENDIF
    38024144
    3803              IF ( INDEX( TRIM( field_chr ), '%nrsws' ) /= 0 )  THEN
     4145             IF ( INDEX( restart_string(1:length), '%nrsws' ) /= 0 )  THEN
    38044146                IF ( ALLOCATED( surf_target%nrsws )  .AND.                     &
    38054147                     ALLOCATED( surf_file%nrsws   ) )                          &
     
    38074149             ENDIF
    38084150
    3809              IF ( INDEX( TRIM( field_chr ), '%sasws' ) /= 0 )  THEN
     4151             IF ( INDEX( restart_string(1:length), '%sasws' ) /= 0 )  THEN
    38104152                IF ( ALLOCATED( surf_target%sasws )  .AND.                     &
    38114153                     ALLOCATED( surf_file%sasws   ) )                          &
     
    38134155             ENDIF
    38144156
    3815              IF ( INDEX( TRIM( field_chr ), '%mom_uv' ) /= 0 )  THEN
     4157             IF ( INDEX( restart_string(1:length), '%mom_uv' ) /= 0 )  THEN
    38164158                IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.               &
    38174159                     ALLOCATED( surf_file%mom_flux_uv   ) )                    &
     
    38204162             ENDIF
    38214163
    3822              IF ( INDEX( TRIM( field_chr ), '%mom_w' ) /= 0 )  THEN
     4164             IF ( INDEX( restart_string(1:length), '%mom_w' ) /= 0 )  THEN
    38234165                IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.                &
    38244166                     ALLOCATED( surf_file%mom_flux_w   ) )                     &
     
    38274169             ENDIF
    38284170
    3829              IF ( INDEX( TRIM( field_chr ), '%mom_tke' ) /= 0 )  THEN
     4171             IF ( INDEX( restart_string(1:length), '%mom_tke' ) /= 0 )  THEN
    38304172                IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.              &
    38314173                     ALLOCATED( surf_file%mom_flux_tke   ) )                   &
     
    38344176             ENDIF
    38354177
     4178
    38364179          END SUBROUTINE restore_surface_elements
    38374180
    3838     END SUBROUTINE surface_read_restart_data
     4181
     4182    END SUBROUTINE surface_rrd_local
    38394183
    38404184 
     
    39034247       REAL(wp), DIMENSION(:) ::  surf_target !< target surface type
    39044248       REAL(wp), DIMENSION(:) ::  surf_file   !< surface type on file
    3905        
     4249
    39064250       ic = nxlc
    39074251       DO  i = nxlf, nxrf
  • palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90

    r2841 r2894  
    2525! -----------------
    2626! $Id$
     27! variable named found has been introduced for checking if restart data was found,
     28! reading of restart strings has been moved completely to read_restart_data_mod,
     29! redundant skipping function has been removed, stg_read/write_restart_data
     30! have been renamed to stg_r/wrd_global, stg_rrd_global is called in
     31! read_restart_data_mod now, flag syn_turb_gen_prerun and marker *** end stg
     32! *** have been removed (Giersch), strings and their respective lengths are
     33! written out and read now in case of restart runs to get rid of prescribed
     34! character lengths (Giersch), CASE DEFAULT was added if restart data is read
     35!
     36! 2841 2018-02-27 15:02:57Z suehring
    2737! Bugfix: wrong placement of include 'mpif.h' corrected
    2838!
     
    4454!
    4555! 2576 2017-10-24 13:49:46Z Giersch
    46 ! Definition of a new function called stg_skip_var_list to skip module
     56! Definition of a new function called stg_skip_global to skip module
    4757! parameters during reading restart data
    4858!
     
    92102    USE control_parameters,                                                    &
    93103        ONLY:  initializing_actions, message_string,                           &
    94                syn_turb_gen, syn_turb_gen_prerun
     104               syn_turb_gen
    95105
    96106    USE cpulog,                                                                &
     
    208218
    209219!
    210 !-- Skipping of parameters for restart runs
    211     INTERFACE stg_skip_var_list
    212        MODULE PROCEDURE stg_skip_var_list
    213     END INTERFACE stg_skip_var_list
    214 
    215 !
    216220!-- Reading of parameters for restart runs
    217     INTERFACE stg_read_restart_data
    218        MODULE PROCEDURE stg_read_restart_data
    219     END INTERFACE stg_read_restart_data
     221    INTERFACE stg_rrd_global
     222       MODULE PROCEDURE stg_rrd_global
     223    END INTERFACE stg_rrd_global
    220224
    221225!
    222226!-- Writing of binary output for restart runs
    223     INTERFACE stg_write_restart_data
    224        MODULE PROCEDURE stg_write_restart_data
    225     END INTERFACE stg_write_restart_data
     227    INTERFACE stg_wrd_global
     228       MODULE PROCEDURE stg_wrd_global
     229    END INTERFACE stg_wrd_global
    226230
    227231    SAVE
     
    232236!-- Public interfaces
    233237    PUBLIC  stg_check_parameters, stg_header, stg_init, stg_main, stg_parin,   &
    234             stg_write_restart_data, stg_skip_var_list
     238            stg_wrd_global, stg_rrd_global
    235239
    236240!
     
    702706    syn_turb_gen = .TRUE.
    703707
    704     IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
    705        CALL stg_read_restart_data
    706     ENDIF
    707708
    708709 10 CONTINUE
    709710
    710711 END SUBROUTINE stg_parin
    711 
    712 
    713 !------------------------------------------------------------------------------!
    714 ! Description:
    715 ! ------------
    716 !> Skipping the stg variables from restart-file (binary format).
    717 !------------------------------------------------------------------------------!
    718    SUBROUTINE stg_skip_var_list
    719        
    720       IMPLICIT NONE
    721            
    722       CHARACTER (LEN=1)  ::  cdum
    723       CHARACTER (LEN=30) ::  variable_chr
    724            
    725       READ ( 13 )  variable_chr
    726 
    727       DO  WHILE ( TRIM( variable_chr ) /= '*** end stg module ***' )
    728 
    729          READ ( 13 )  cdum
    730          READ ( 13 )  variable_chr
    731 
    732       ENDDO   
    733            
    734    END SUBROUTINE stg_skip_var_list
    735712
    736713
     
    740717!> This routine reads the respective restart data.
    741718!------------------------------------------------------------------------------!
    742  SUBROUTINE stg_read_restart_data
     719 SUBROUTINE stg_rrd_global( found )
     720
     721
     722    USE control_parameters,                                                    &
     723        ONLY: length, restart_string
    743724
    744725
    745726    IMPLICIT NONE
    746727
    747     CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
    748 
    749 
    750     READ ( 13 )  variable_chr
    751     DO  WHILE ( TRIM( variable_chr ) /= '*** end stg module ***' )
    752 
    753        SELECT CASE ( TRIM( variable_chr ) )
    754 
    755           CASE ( 'use_syn_turb_gen' )
    756              READ ( 13 )  use_syn_turb_gen
    757           CASE ( 'mc_factor' )
    758              READ ( 13 )  mc_factor
    759           CASE ( 'syn_turb_gen_prerun' )
    760              READ ( 13 )  syn_turb_gen_prerun
    761 
    762        END SELECT
    763 
    764        READ ( 13 )  variable_chr
    765 
    766     ENDDO
    767 
    768  END SUBROUTINE stg_read_restart_data
     728    LOGICAL, INTENT(OUT)  ::  found
     729
     730
     731    found = .TRUE.
     732 
     733
     734    SELECT CASE ( restart_string(1:length) )
     735
     736       CASE ( 'mc_factor' )
     737          READ ( 13 )  mc_factor
     738       CASE ( 'use_syn_turb_gen' )
     739          READ ( 13 )  use_syn_turb_gen
     740
     741       CASE DEFAULT
     742
     743          found = .FALSE.   
     744
     745    END SELECT
     746
     747
     748 END SUBROUTINE stg_rrd_global
    769749
    770750
     
    774754!> This routine writes the respective restart data.
    775755!------------------------------------------------------------------------------!
    776  SUBROUTINE stg_write_restart_data
     756 SUBROUTINE stg_wrd_global
    777757
    778758
    779759    IMPLICIT NONE
    780760
    781     syn_turb_gen_prerun = .TRUE.
    782 
    783     WRITE ( 14 )  'use_syn_turb_gen              '
     761
     762    CALL wrd_write_string( 'mc_factor' )
     763    WRITE ( 14 )  mc_factor
     764
     765    CALL wrd_write_string( 'use_syn_turb_gen' )
    784766    WRITE ( 14 )  use_syn_turb_gen
    785     WRITE ( 14 )  'mc_factor                     '
    786     WRITE ( 14 )  mc_factor
    787     WRITE ( 14 )  'syn_turb_gen_prerun           '
    788     WRITE ( 14 )  syn_turb_gen_prerun
    789 
    790     WRITE ( 14 )  '*** end stg module ***        '
    791 
    792 END SUBROUTINE stg_write_restart_data
     767
     768
     769 END SUBROUTINE stg_wrd_global
    793770
    794771
  • palm/trunk/SOURCE/urban_surface_mod.f90

    r2805 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! usm_read/write_restart_data have been renamed to usm_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, usm_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 usm
     37! *** 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
     40!
     41! 2805 2018-02-14 17:00:09Z suehring
    2842! Initialization of resistances.
    2943!
     
    711725    END INTERFACE usm_temperature_near_surface
    712726
    713     INTERFACE usm_read_restart_data
    714        MODULE PROCEDURE usm_read_restart_data
    715     END INTERFACE usm_read_restart_data
     727    INTERFACE usm_rrd_local
     728       MODULE PROCEDURE usm_rrd_local
     729    END INTERFACE usm_rrd_local
    716730
    717731    INTERFACE usm_surface_energy_balance
     
    723737    END INTERFACE usm_swap_timelevel
    724738       
    725     INTERFACE usm_write_restart_data
    726        MODULE PROCEDURE usm_write_restart_data
    727     END INTERFACE usm_write_restart_data
     739    INTERFACE usm_wrd_local
     740       MODULE PROCEDURE usm_wrd_local
     741    END INTERFACE usm_wrd_local
    728742
    729743    INTERFACE usm_allocate_surface
     
    742756!-- Public functions
    743757    PUBLIC usm_boundary_condition, usm_check_parameters, usm_init_urban_surface,&
    744            usm_read_restart_data,                                               &
     758           usm_rrd_local,                                                       &
    745759           usm_surface_energy_balance, usm_material_heat_model,                 &
    746760           usm_swap_timelevel, usm_check_data_output, usm_average_3d_data,      &
    747761           usm_data_output_3d, usm_define_netcdf_grid, usm_parin,               &
    748            usm_write_restart_data, usm_allocate_surface
     762           usm_wrd_local, usm_allocate_surface
    749763
    750764!-- Public parameters, constants and initial values
     
    51965210! Description:
    51975211! ------------
    5198 !> Soubroutine reads t_surf and t_wall data from restart files
     5212!> Soubroutine reads t_surf and t_wall data from restart file(s)
    51995213!kanani: Renamed this routine according to corresponging routines in PALM
    5200 !kanani: Modified the routine to match read_var_list, from where usm_read_restart_data
     5214!kanani: Modified the routine to match rrd_global, from where usm_rrd_local
    52015215!        shall be called in the future. This part has not been tested yet. (see virtual_flight_mod)
    52025216!        Also, I had some trouble with the allocation of t_surf, since this is a pointer.
    52035217!        So, I added some directives here.
    52045218!------------------------------------------------------------------------------!
    5205     SUBROUTINE usm_read_restart_data( ii,                                      &
    5206                                       nxlfa, nxl_on_file, nxrfa, nxr_on_file,  &
    5207                                       nynfa, nyn_on_file, nysfa, nys_on_file,  &
    5208                                       offset_xa, offset_ya, overlap_count )
    5209 
    5210 
    5211        USE pegrid,                                                             &
    5212            ONLY: numprocs_previous_run
     5219    SUBROUTINE usm_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,       &
     5220                              nxr_on_file, nynf, nync, nyn_on_file, nysf, nysc,&
     5221                              nys_on_file, found )
     5222
     5223
     5224       USE control_parameters,                                                 &
     5225           ONLY: length, restart_string
    52135226           
    52145227       IMPLICIT NONE
    52155228
    52165229       CHARACTER (LEN=1)  ::  dum              !< dummy to create correct string for reading input variable
    5217        CHARACTER (LEN=30) ::  field_chr        !< input variable
    52185230
    52195231       INTEGER(iwp)       ::  l                !< index variable for surface type
    5220        INTEGER(iwp)       ::  ii               !< running index over input files
    5221        INTEGER(iwp)       ::  kk               !< running index over previous input files covering current local domain
     5232       INTEGER(iwp)       ::  i                !< running index over input files
     5233       INTEGER(iwp)       ::  k                !< running index over previous input files covering current local domain
    52225234       INTEGER(iwp)       ::  ns_h_on_file_usm !< number of horizontal surface elements (urban type) on file
    52235235       INTEGER(iwp)       ::  nxlc             !< index of left boundary on current subdomain
     
    52265238       INTEGER(iwp)       ::  nxrc             !< index of right boundary on current subdomain
    52275239       INTEGER(iwp)       ::  nxrf             !< index of right boundary on former subdomain
    5228        INTEGER(iwp)       ::  nxr_on_file      !< index of right boundary on former local domain  
     5240       INTEGER(iwp)       ::  nxr_on_file      !< index of right boundary on former local domain
    52295241       INTEGER(iwp)       ::  nync             !< index of north boundary on current subdomain
    52305242       INTEGER(iwp)       ::  nynf             !< index of north boundary on former subdomain
    5231        INTEGER(iwp)       ::  nyn_on_file      !< index of norht boundary on former local domain
     5243       INTEGER(iwp)       ::  nyn_on_file      !< index of north boundary on former local domain
    52325244       INTEGER(iwp)       ::  nysc             !< index of south boundary on current subdomain
    52335245       INTEGER(iwp)       ::  nysf             !< index of south boundary on former subdomain
    5234        INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain 
    5235        INTEGER(iwp)       ::  overlap_count    !< number of overlaps
     5246       INTEGER(iwp)       ::  nys_on_file      !< index of south boundary on former local domain
    52365247       
    52375248       INTEGER(iwp)       ::  ns_v_on_file_usm(0:3) !< number of vertical surface elements (urban type) on file
     5249       
     5250       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  start_index_on_file
     5251       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  end_index_on_file
     5252
     5253       LOGICAL, INTENT(OUT)  ::  found
     5254       
     5255       REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_h, tmp_surf_window_h, tmp_surf_green_h
     5256       REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  tmp_wall_h, tmp_window_h, tmp_green_h
     5257       
     5258       TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_v, tmp_surf_window_v, tmp_surf_green_v
     5259       TYPE( t_wall_vertical ), DIMENSION(0:3), SAVE ::  tmp_wall_v, tmp_window_v, tmp_green_v
     5260
     5261
     5262       found = .TRUE.
     5263
     5264
     5265          SELECT CASE ( restart_string(1:length) )
     5266
     5267             CASE ( 'ns_h_on_file_usm')
     5268                IF ( k == 1 )  THEN
     5269                   READ ( 13 ) ns_h_on_file_usm
     5270               
     5271                   IF ( ALLOCATED( tmp_surf_h ) ) DEALLOCATE( tmp_surf_h )
     5272                   IF ( ALLOCATED( tmp_wall_h ) ) DEALLOCATE( tmp_wall_h )
     5273                   IF ( ALLOCATED( tmp_surf_window_h ) )                       &
     5274                      DEALLOCATE( tmp_surf_window_h )
     5275                   IF ( ALLOCATED( tmp_window_h) ) DEALLOCATE( tmp_window_h )
     5276                   IF ( ALLOCATED( tmp_surf_green_h) )                         &
     5277                      DEALLOCATE( tmp_surf_green_h )
     5278                   IF ( ALLOCATED( tmp_green_h) ) DEALLOCATE( tmp_green_h )
    52385279 
    5239        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxlfa       !<
    5240        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nxrfa       !<
    5241        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nynfa       !<
    5242        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  nysfa       !<
    5243        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_xa   !<
    5244        INTEGER(iwp), DIMENSION(numprocs_previous_run,1000) ::  offset_ya   !<
     5280!
     5281!--                Allocate temporary arrays for reading data on file. Note,
     5282!--                the size of allocated surface elements do not necessarily
     5283!--                need  to match the size of present surface elements on
     5284!--                current processor, as the number of processors between
     5285!--                restarts can change.
     5286                   ALLOCATE( tmp_surf_h(1:ns_h_on_file_usm) )
     5287                   ALLOCATE( tmp_wall_h(nzb_wall:nzt_wall+1,                   &
     5288                                        1:ns_h_on_file_usm) )
     5289                   ALLOCATE( tmp_surf_window_h(1:ns_h_on_file_usm) )
     5290                   ALLOCATE( tmp_window_h(nzb_wall:nzt_wall+1,                 &
     5291                                          1:ns_h_on_file_usm) )
     5292                   ALLOCATE( tmp_surf_green_h(1:ns_h_on_file_usm) )
     5293                   ALLOCATE( tmp_green_h(nzb_wall:nzt_wall+1,                  &
     5294                                         1:ns_h_on_file_usm) )
     5295
     5296                ENDIF
     5297
     5298             CASE ( 'ns_v_on_file_usm')
     5299                IF ( k == 1 )  THEN
     5300                   READ ( 13 ) ns_v_on_file_usm
     5301
     5302                   DO  l = 0, 3
     5303                      IF ( ALLOCATED( tmp_surf_v(l)%t ) )                      &
     5304                         DEALLOCATE( tmp_surf_v(l)%t )
     5305                      IF ( ALLOCATED( tmp_wall_v(l)%t ) )                      &
     5306                         DEALLOCATE( tmp_wall_v(l)%t )
     5307                      IF ( ALLOCATED( tmp_surf_window_v(l)%t ) )               &
     5308                         DEALLOCATE( tmp_surf_window_v(l)%t )
     5309                      IF ( ALLOCATED( tmp_window_v(l)%t ) )                    &
     5310                         DEALLOCATE( tmp_window_v(l)%t )
     5311                      IF ( ALLOCATED( tmp_surf_green_v(l)%t ) )                &
     5312                         DEALLOCATE( tmp_surf_green_v(l)%t )
     5313                      IF ( ALLOCATED( tmp_green_v(l)%t ) )                     &
     5314                         DEALLOCATE( tmp_green_v(l)%t )
     5315                   ENDDO
     5316
     5317!
     5318!--                Allocate temporary arrays for reading data on file. Note,
     5319!--                the size of allocated surface elements do not necessarily
     5320!--                need to match the size of present surface elements on
     5321!--                current processor, as the number of processors between
     5322!--                restarts can change.
     5323                   DO  l = 0, 3
     5324                      ALLOCATE( tmp_surf_v(l)%t(1:ns_v_on_file_usm(l)) )
     5325                      ALLOCATE( tmp_wall_v(l)%t(nzb_wall:nzt_wall+1,           &
     5326                                                1:ns_v_on_file_usm(l) ) )
     5327                      ALLOCATE( tmp_surf_window_v(l)%t(1:ns_v_on_file_usm(l)) )
     5328                      ALLOCATE( tmp_window_v(l)%t(nzb_wall:nzt_wall+1,         &
     5329                                                  1:ns_v_on_file_usm(l) ) )
     5330                      ALLOCATE( tmp_surf_green_v(l)%t(1:ns_v_on_file_usm(l)) )
     5331                      ALLOCATE( tmp_green_v(l)%t(nzb_wall:nzt_wall+1,          &
     5332                                                 1:ns_v_on_file_usm(l) ) )
     5333                   ENDDO
     5334
     5335                ENDIF   
     5336         
     5337             CASE ( 'usm_start_index_h', 'usm_start_index_v'  )   
     5338                IF ( k == 1 )  THEN
     5339
     5340                   IF ( ALLOCATED( start_index_on_file ) )                     &
     5341                      DEALLOCATE( start_index_on_file )
     5342
     5343                   ALLOCATE ( start_index_on_file(nys_on_file:nyn_on_file,     &
     5344                                                  nxl_on_file:nxr_on_file) )
     5345
     5346                   READ ( 13 )  start_index_on_file
     5347
     5348                ENDIF
     5349               
     5350             CASE ( 'usm_end_index_h', 'usm_end_index_v' )   
     5351                IF ( k == 1 )  THEN
     5352
     5353                   IF ( ALLOCATED( end_index_on_file ) )                       &
     5354                      DEALLOCATE( end_index_on_file )
     5355
     5356                   ALLOCATE ( end_index_on_file(nys_on_file:nyn_on_file,       &
     5357                                                nxl_on_file:nxr_on_file) )
     5358
     5359                   READ ( 13 )  end_index_on_file
     5360
     5361                ENDIF
     5362         
     5363             CASE ( 't_surf_h' )
     5364#if defined( __nopointer )                   
     5365                IF ( k == 1 )  THEN
     5366                   IF ( .NOT.  ALLOCATED( t_surf_h ) )                         &
     5367                      ALLOCATE( t_surf_h(1:surf_usm_h%ns) )
     5368                   READ ( 13 )  tmp_surf_h
     5369                ENDIF
     5370                CALL surface_restore_elements(                                 &
     5371                                        t_surf_h, tmp_surf_h,                  &
     5372                                        surf_usm_h%start_index,                & 
     5373                                        start_index_on_file,                   &
     5374                                        end_index_on_file,                     &
     5375                                        nxlc, nysc,                            &
     5376                                        nxlf, nxrf, nysf, nynf,                &
     5377                                        nys_on_file, nyn_on_file,              &
     5378                                        nxl_on_file,nxr_on_file )
     5379#else                 
     5380                IF ( k == 1 )  THEN
     5381                   IF ( .NOT.  ALLOCATED( t_surf_h_1 ) )                       &
     5382                      ALLOCATE( t_surf_h_1(1:surf_usm_h%ns) )
     5383                   READ ( 13 )  tmp_surf_h
     5384                ENDIF             
     5385                CALL surface_restore_elements(                                 &
     5386                                        t_surf_h_1, tmp_surf_h,                &
     5387                                        surf_usm_h%start_index,                &
     5388                                        start_index_on_file,                   &
     5389                                        end_index_on_file,                     &
     5390                                        nxlc, nysc,                            &
     5391                                        nxlf, nxrf, nysf, nynf,                &
     5392                                        nys_on_file, nyn_on_file,              &
     5393                                        nxl_on_file,nxr_on_file )
     5394#endif
     5395
     5396             CASE ( 't_surf_v(0)' )
     5397#if defined( __nopointer )           
     5398                IF ( k == 1 )  THEN
     5399                   IF ( .NOT.  ALLOCATED( t_surf_v(0)%t ) )                    &
     5400                      ALLOCATE( t_surf_v(0)%t(1:surf_usm_v(0)%ns) )
     5401                   READ ( 13 )  tmp_surf_v(0)%t
     5402                ENDIF
     5403                CALL surface_restore_elements(                                 &
     5404                                        t_surf_v(0)%t, tmp_surf_v(0)%t,        &
     5405                                        surf_usm_v(0)%start_index,             &
     5406                                        start_index_on_file,                   &
     5407                                        end_index_on_file,                     &
     5408                                        nxlc, nysc,                            &
     5409                                        nxlf, nxrf, nysf, nynf,                &
     5410                                        nys_on_file, nyn_on_file,              &
     5411                                        nxl_on_file,nxr_on_file )
     5412#else                     
     5413                IF ( k == 1 )  THEN
     5414                   IF ( .NOT.  ALLOCATED( t_surf_v_1(0)%t ) )                  &
     5415                      ALLOCATE( t_surf_v_1(0)%t(1:surf_usm_v(0)%ns) )
     5416                   READ ( 13 )  tmp_surf_v(0)%t
     5417                ENDIF
     5418                CALL surface_restore_elements(                                 &
     5419                                        t_surf_v_1(0)%t, tmp_surf_v(0)%t,      &
     5420                                        surf_usm_v(0)%start_index,             &
     5421                                        start_index_on_file,                   &
     5422                                        end_index_on_file,                     &
     5423                                        nxlc, nysc,                            &
     5424                                        nxlf, nxrf, nysf, nynf,                &
     5425                                        nys_on_file, nyn_on_file,              &
     5426                                        nxl_on_file,nxr_on_file )
     5427#endif
     5428                     
     5429             CASE ( 't_surf_v(1)' )
     5430#if defined( __nopointer )       
     5431                IF ( k == 1 )  THEN
     5432                   IF ( .NOT.  ALLOCATED( t_surf_v(1)%t ) )                    &
     5433                      ALLOCATE( t_surf_v(1)%t(1:surf_usm_v(1)%ns) )
     5434                   READ ( 13 )  tmp_surf_v(1)%t
     5435                ENDIF
     5436                CALL surface_restore_elements(                                 &
     5437                                        t_surf_v(1)%t, tmp_surf_v(1)%t,        &
     5438                                        surf_usm_v(1)%start_index,             &
     5439                                        start_index_on_file,                   &
     5440                                        end_index_on_file,                     &
     5441                                        nxlc, nysc,                            &
     5442                                        nxlf, nxrf, nysf, nynf,                &
     5443                                        nys_on_file, nyn_on_file,              &
     5444                                        nxl_on_file,nxr_on_file )                 
     5445#else                     
     5446                IF ( k == 1 )  THEN
     5447                   IF ( .NOT.  ALLOCATED( t_surf_v_1(1)%t ) )                  &
     5448                      ALLOCATE( t_surf_v_1(1)%t(1:surf_usm_v(1)%ns) )
     5449                   READ ( 13 )  tmp_surf_v(1)%t
     5450                ENDIF
     5451                CALL surface_restore_elements(                                 &
     5452                                        t_surf_v_1(1)%t, tmp_surf_v(1)%t,      &
     5453                                        surf_usm_v(1)%start_index,             &
     5454                                        start_index_on_file,                   &
     5455                                        end_index_on_file,                     &
     5456                                        nxlc, nysc,                            &
     5457                                        nxlf, nxrf, nysf, nynf,                &
     5458                                        nys_on_file, nyn_on_file,              &
     5459                                        nxl_on_file,nxr_on_file )
     5460#endif
     5461
     5462             CASE ( 't_surf_v(2)' )
     5463#if defined( __nopointer )         
     5464                IF ( k == 1 )  THEN
     5465                   IF ( .NOT.  ALLOCATED( t_surf_v(2)%t ) )                    &
     5466                      ALLOCATE( t_surf_v(2)%t(1:surf_usm_v(2)%ns) )
     5467                   READ ( 13 )  tmp_surf_v(2)%t
     5468                ENDIF
     5469                CALL surface_restore_elements(                                 &
     5470                                        t_surf_v(2)%t, tmp_surf_v(2)%t,        &
     5471                                        surf_usm_v(2)%start_index,             &
     5472                                        start_index_on_file,                   &
     5473                                        end_index_on_file,                     &
     5474                                        nxlc, nysc,                            &
     5475                                        nxlf, nxrf, nysf, nynf,                &
     5476                                        nys_on_file, nyn_on_file,              &
     5477                                        nxl_on_file,nxr_on_file )
     5478#else                     
     5479                IF ( k == 1 )  THEN
     5480                   IF ( .NOT.  ALLOCATED( t_surf_v_1(2)%t ) )                  &
     5481                      ALLOCATE( t_surf_v_1(2)%t(1:surf_usm_v(2)%ns) )
     5482                   READ ( 13 )  tmp_surf_v(2)%t
     5483                ENDIF
     5484                CALL surface_restore_elements(                                 &
     5485                                        t_surf_v_1(2)%t, tmp_surf_v(2)%t,      &
     5486                                        surf_usm_v(2)%start_index,             & 
     5487                                        start_index_on_file,                   &
     5488                                        end_index_on_file,                     &
     5489                                        nxlc, nysc,                            &
     5490                                        nxlf, nxrf, nysf, nynf,                &
     5491                                        nys_on_file, nyn_on_file,              &
     5492                                        nxl_on_file,nxr_on_file )
     5493#endif
     5494                     
     5495             CASE ( 't_surf_v(3)' )
     5496#if defined( __nopointer )   
     5497                IF ( k == 1 )  THEN
     5498                   IF ( .NOT.  ALLOCATED( t_surf_v(3)%t ) )                    &
     5499                      ALLOCATE( t_surf_v(3)%t(1:surf_usm_v(3)%ns) )
     5500                   READ ( 13 )  tmp_surf_v(3)%t
     5501                ENDIF
     5502                CALL surface_restore_elements(                                 &
     5503                                        t_surf_v(3)%t, tmp_surf_v(3)%t,        &
     5504                                        surf_usm_v(3)%start_index,             &
     5505                                        start_index_on_file,                   &
     5506                                        end_index_on_file,                     &
     5507                                        nxlc, nysc,                            &
     5508                                        nxlf, nxrf, nysf, nynf,                &
     5509                                        nys_on_file, nyn_on_file,              &
     5510                                        nxl_on_file,nxr_on_file )
     5511#else                     
     5512                IF ( k == 1 )  THEN
     5513                   IF ( .NOT.  ALLOCATED( t_surf_v_1(3)%t ) )                  &
     5514                      ALLOCATE( t_surf_v_1(3)%t(1:surf_usm_v(3)%ns) )
     5515                   READ ( 13 )  tmp_surf_v(3)%t
     5516                ENDIF
     5517                CALL surface_restore_elements(                                 &
     5518                                        t_surf_v_1(3)%t, tmp_surf_v(3)%t,      &
     5519                                        surf_usm_v(3)%start_index,             &
     5520                                        start_index_on_file,                   &
     5521                                        end_index_on_file,                     &
     5522                                        nxlc, nysc,                            &
     5523                                        nxlf, nxrf, nysf, nynf,                &
     5524                                        nys_on_file, nyn_on_file,              &
     5525                                        nxl_on_file,nxr_on_file )
     5526#endif
     5527             CASE ( 't_surf_green_h' )
     5528#if defined( __nopointer )                   
     5529                IF ( k == 1 )  THEN
     5530                   IF ( .NOT.  ALLOCATED( t_surf_green_h ) )                   &
     5531                      ALLOCATE( t_surf_green_h(1:surf_usm_h%ns) )
     5532                   READ ( 13 )  tmp_surf_green_h
     5533                ENDIF
     5534                CALL surface_restore_elements(                                 &
     5535                                        t_surf_green_h, tmp_surf_green_h,      &
     5536                                        surf_usm_h%start_index,                &
     5537                                        start_index_on_file,                   &
     5538                                        end_index_on_file,                     &
     5539                                        nxlc, nysc,                            &
     5540                                        nxlf, nxrf, nysf, nynf,                &
     5541                                        nys_on_file, nyn_on_file,              &
     5542                                        nxl_on_file,nxr_on_file )
     5543#else                     
     5544                IF ( k == 1 )  THEN
     5545                   IF ( .NOT.  ALLOCATED( t_surf_green_h_1 ) )                 &
     5546                      ALLOCATE( t_surf_green_h_1(1:surf_usm_h%ns) )
     5547                   READ ( 13 )  tmp_surf_green_h
     5548                ENDIF
     5549                CALL surface_restore_elements(                                 &
     5550                                        t_surf_green_h_1, tmp_surf_green_h,    &
     5551                                        surf_usm_h%start_index,                & 
     5552                                        start_index_on_file,                   &
     5553                                        end_index_on_file,                     &
     5554                                        nxlc, nysc,                            &
     5555                                        nxlf, nxrf, nysf, nynf,                &
     5556                                        nys_on_file, nyn_on_file,              &
     5557                                        nxl_on_file,nxr_on_file )
     5558#endif
     5559
     5560             CASE ( 't_surf_green_v(0)' )
     5561#if defined( __nopointer )           
     5562                IF ( k == 1 )  THEN
     5563                   IF ( .NOT.  ALLOCATED( t_surf_green_v(0)%t ) )              &
     5564                      ALLOCATE( t_surf_green_v(0)%t(1:surf_usm_v(0)%ns) )
     5565                   READ ( 13 )  tmp_surf_green_v(0)%t
     5566                ENDIF
     5567                CALL surface_restore_elements(                                 &
     5568                                        t_surf_green_v(0)%t,                   &
     5569                                        tmp_surf_green_v(0)%t,                 &
     5570                                        surf_usm_v(0)%start_index,             &
     5571                                        start_index_on_file,                   &
     5572                                        end_index_on_file,                     &
     5573                                        nxlc, nysc,                            &
     5574                                        nxlf, nxrf, nysf, nynf,                &
     5575                                        nys_on_file, nyn_on_file,              &
     5576                                        nxl_on_file,nxr_on_file )
     5577#else                     
     5578                IF ( k == 1 )  THEN
     5579                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(0)%t ) )            &
     5580                      ALLOCATE( t_surf_green_v_1(0)%t(1:surf_usm_v(0)%ns) )
     5581                   READ ( 13 )  tmp_surf_green_v(0)%t
     5582                ENDIF
     5583                CALL surface_restore_elements(                                 &
     5584                                        t_surf_green_v_1(0)%t,                 &
     5585                                        tmp_surf_green_v(0)%t,                 &
     5586                                        surf_usm_v(0)%start_index,             &
     5587                                        start_index_on_file,                   &
     5588                                        end_index_on_file,                     &
     5589                                        nxlc, nysc,                            &
     5590                                        nxlf, nxrf, nysf, nynf,                &
     5591                                        nys_on_file, nyn_on_file,              &
     5592                                        nxl_on_file,nxr_on_file )
     5593#endif
     5594                   
     5595             CASE ( 't_surf_green_v(1)' )
     5596#if defined( __nopointer )       
     5597                IF ( k == 1 )  THEN
     5598                   IF ( .NOT.  ALLOCATED( t_surf_green_v(1)%t ) )              &
     5599                      ALLOCATE( t_surf_green_v(1)%t(1:surf_usm_v(1)%ns) )
     5600                   READ ( 13 )  tmp_surf_green_v(1)%t
     5601                ENDIF
     5602                CALL surface_restore_elements(                                 &
     5603                                        t_surf_green_v(1)%t,                   &
     5604                                        tmp_surf_green_v(1)%t,                 &
     5605                                        surf_usm_v(1)%start_index,             &
     5606                                        start_index_on_file,                   &
     5607                                        end_index_on_file,                     &
     5608                                        nxlc, nysc,                            &
     5609                                        nxlf, nxrf, nysf, nynf,                &
     5610                                        nys_on_file, nyn_on_file,              &
     5611                                        nxl_on_file,nxr_on_file )                 
     5612#else                     
     5613                IF ( k == 1 )  THEN
     5614                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(1)%t ) )            &
     5615                      ALLOCATE( t_surf_green_v_1(1)%t(1:surf_usm_v(1)%ns) )
     5616                   READ ( 13 )  tmp_surf_green_v(1)%t
     5617                ENDIF
     5618                CALL surface_restore_elements(                                 &
     5619                                        t_surf_green_v_1(1)%t,                 &
     5620                                        tmp_surf_green_v(1)%t,                 &
     5621                                        surf_usm_v(1)%start_index,             & 
     5622                                        start_index_on_file,                   &
     5623                                        end_index_on_file,                     &
     5624                                        nxlc, nysc,                            &
     5625                                        nxlf, nxrf, nysf, nynf,                &
     5626                                        nys_on_file, nyn_on_file,              &
     5627                                        nxl_on_file,nxr_on_file )
     5628#endif
     5629
     5630             CASE ( 't_surf_green_v(2)' )
     5631#if defined( __nopointer )         
     5632                IF ( k == 1 )  THEN
     5633                   IF ( .NOT.  ALLOCATED( t_surf_green_v(2)%t ) )              &
     5634                      ALLOCATE( t_surf_green_v(2)%t(1:surf_usm_v(2)%ns) )
     5635                   READ ( 13 )  tmp_surf_green_v(2)%t
     5636                ENDIF
     5637                CALL surface_restore_elements(                                 &
     5638                                        t_surf_green_v(2)%t,                   &
     5639                                        tmp_surf_green_v(2)%t,                 &
     5640                                        surf_usm_v(2)%start_index,             &
     5641                                        start_index_on_file,                   &
     5642                                        end_index_on_file,                     &
     5643                                        nxlc, nysc,                            &
     5644                                        nxlf, nxrf, nysf, nynf,                &
     5645                                        nys_on_file, nyn_on_file,              &
     5646                                        nxl_on_file,nxr_on_file )
     5647#else                     
     5648                IF ( k == 1 )  THEN
     5649                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(2)%t ) )            &
     5650                      ALLOCATE( t_surf_green_v_1(2)%t(1:surf_usm_v(2)%ns) )
     5651                   READ ( 13 )  tmp_surf_green_v(2)%t
     5652                ENDIF
     5653                CALL surface_restore_elements(                                 &
     5654                                        t_surf_green_v_1(2)%t,                 &
     5655                                        tmp_surf_green_v(2)%t,                 &
     5656                                        surf_usm_v(2)%start_index,             & 
     5657                                        start_index_on_file,                   &
     5658                                        end_index_on_file,                     &
     5659                                        nxlc, nysc,                            &
     5660                                        nxlf, nxrf, nysf, nynf,                &
     5661                                        nys_on_file, nyn_on_file,              &
     5662                                        nxl_on_file,nxr_on_file )
     5663#endif
     5664                   
     5665             CASE ( 't_surf_green_v(3)' )
     5666#if defined( __nopointer )   
     5667                IF ( k == 1 )  THEN
     5668                   IF ( .NOT.  ALLOCATED( t_surf_green_v(3)%t ) )              &
     5669                      ALLOCATE( t_surf_green_v(3)%t(1:surf_usm_v(3)%ns) )
     5670                   READ ( 13 )  tmp_surf_green_v(3)%t
     5671                ENDIF
     5672                CALL surface_restore_elements(                                 &
     5673                                        t_surf_green_v(3)%t,                   &
     5674                                        tmp_surf_green_v(3)%t,                 &
     5675                                        surf_usm_v(3)%start_index,             &
     5676                                        start_index_on_file,                   &
     5677                                        end_index_on_file,                     &
     5678                                        nxlc, nysc,                            &
     5679                                        nxlf, nxrf, nysf, nynf,                &
     5680                                        nys_on_file, nyn_on_file,              &
     5681                                        nxl_on_file,nxr_on_file )
     5682#else                     
     5683                IF ( k == 1 )  THEN
     5684                   IF ( .NOT.  ALLOCATED( t_surf_green_v_1(3)%t ) )            &
     5685                      ALLOCATE( t_surf_green_v_1(3)%t(1:surf_usm_v(3)%ns) )
     5686                   READ ( 13 )  tmp_surf_green_v(3)%t
     5687                ENDIF
     5688                CALL surface_restore_elements(                                 &
     5689                                        t_surf_green_v_1(3)%t,                 &
     5690                                        tmp_surf_green_v(3)%t,                 &
     5691                                        surf_usm_v(3)%start_index,             &
     5692                                        start_index_on_file,                   &
     5693                                        end_index_on_file,                     &
     5694                                        nxlc, nysc,                            &
     5695                                        nxlf, nxrf, nysf, nynf,                &
     5696                                        nys_on_file, nyn_on_file,              &
     5697                                        nxl_on_file,nxr_on_file )
     5698#endif
     5699             CASE ( 't_surf_window_h' )
     5700#if defined( __nopointer )                   
     5701                IF ( k == 1 )  THEN
     5702                   IF ( .NOT.  ALLOCATED( t_surf_window_h ) )                  &
     5703                      ALLOCATE( t_surf_window_h(1:surf_usm_h%ns) )
     5704                   READ ( 13 )  tmp_surf_window_h
     5705                ENDIF
     5706                CALL surface_restore_elements(                                 &
     5707                                        t_surf_window_h, tmp_surf_window_h,    &
     5708                                        surf_usm_h%start_index,                &
     5709                                        start_index_on_file,                   &
     5710                                        end_index_on_file,                     &
     5711                                        nxlc, nysc,                            &
     5712                                        nxlf, nxrf, nysf, nynf,                &
     5713                                        nys_on_file, nyn_on_file,              &
     5714                                        nxl_on_file,nxr_on_file )
     5715#else                     
     5716                IF ( k == 1 )  THEN
     5717                   IF ( .NOT.  ALLOCATED( t_surf_window_h_1 ) )                &
     5718                      ALLOCATE( t_surf_window_h_1(1:surf_usm_h%ns) )
     5719                   READ ( 13 )  tmp_surf_window_h
     5720                ENDIF
     5721                CALL surface_restore_elements(                                 &
     5722                                        t_surf_window_h_1,                     &
     5723                                        tmp_surf_window_h,                     &
     5724                                        surf_usm_h%start_index,                &
     5725                                        start_index_on_file,                   &
     5726                                        end_index_on_file,                     &
     5727                                        nxlc, nysc,                            &
     5728                                        nxlf, nxrf, nysf, nynf,                &
     5729                                        nys_on_file, nyn_on_file,              &
     5730                                        nxl_on_file,nxr_on_file )
     5731#endif
     5732
     5733             CASE ( 't_surf_window_v(0)' )
     5734#if defined( __nopointer )           
     5735                IF ( k == 1 )  THEN
     5736                   IF ( .NOT.  ALLOCATED( t_surf_window_v(0)%t ) )             &
     5737                      ALLOCATE( t_surf_window_v(0)%t(1:surf_usm_v(0)%ns) )
     5738                   READ ( 13 )  tmp_surf_window_v(0)%t
     5739                ENDIF
     5740                CALL surface_restore_elements(                                 &
     5741                                        t_surf_window_v(0)%t,                  &
     5742                                        tmp_surf_window_v(0)%t,                &
     5743                                        surf_usm_v(0)%start_index,             &
     5744                                        start_index_on_file,                   &
     5745                                        end_index_on_file,                     &
     5746                                        nxlc, nysc,                            &
     5747                                        nxlf, nxrf, nysf, nynf,                &
     5748                                        nys_on_file, nyn_on_file,              &
     5749                                        nxl_on_file,nxr_on_file )
     5750#else                     
     5751                IF ( k == 1 )  THEN
     5752                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(0)%t ) )           &
     5753                      ALLOCATE( t_surf_window_v_1(0)%t(1:surf_usm_v(0)%ns) )
     5754                   READ ( 13 )  tmp_surf_window_v(0)%t
     5755                ENDIF
     5756                CALL surface_restore_elements(                                 &
     5757                                        t_surf_window_v_1(0)%t,                &
     5758                                        tmp_surf_window_v(0)%t,                &
     5759                                        surf_usm_v(0)%start_index,             &
     5760                                        start_index_on_file,                   &
     5761                                        end_index_on_file,                     &
     5762                                        nxlc, nysc,                            &
     5763                                        nxlf, nxrf, nysf, nynf,                &
     5764                                        nys_on_file, nyn_on_file,              &
     5765                                        nxl_on_file,nxr_on_file )
     5766#endif
     5767                   
     5768             CASE ( 't_surf_window_v(1)' )
     5769#if defined( __nopointer )       
     5770                IF ( k == 1 )  THEN
     5771                   IF ( .NOT.  ALLOCATED( t_surf_window_v(1)%t ) )             &
     5772                      ALLOCATE( t_surf_window_v(1)%t(1:surf_usm_v(1)%ns) )
     5773                   READ ( 13 )  tmp_surf_window_v(1)%t
     5774                ENDIF
     5775                CALL surface_restore_elements(                                 &
     5776                                        t_surf_window_v(1)%t,                  &
     5777                                        tmp_surf_window_v(1)%t,                &
     5778                                        surf_usm_v(1)%start_index,             &
     5779                                        start_index_on_file,                   &
     5780                                        end_index_on_file,                     &
     5781                                        nxlc, nysc,                            &
     5782                                        nxlf, nxrf, nysf, nynf,                &
     5783                                        nys_on_file, nyn_on_file,              &
     5784                                        nxl_on_file,nxr_on_file )                 
     5785#else                     
     5786                IF ( k == 1 )  THEN
     5787                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(1)%t ) )           &
     5788                      ALLOCATE( t_surf_window_v_1(1)%t(1:surf_usm_v(1)%ns) )
     5789                   READ ( 13 )  tmp_surf_window_v(1)%t
     5790                ENDIF
     5791                CALL surface_restore_elements(                                 &
     5792                                        t_surf_window_v_1(1)%t,                &
     5793                                        tmp_surf_window_v(1)%t,                &
     5794                                        surf_usm_v(1)%start_index,             &
     5795                                        start_index_on_file,                   &
     5796                                        end_index_on_file,                     &
     5797                                        nxlc, nysc,                            &
     5798                                        nxlf, nxrf, nysf, nynf,                &
     5799                                        nys_on_file, nyn_on_file,              &
     5800                                        nxl_on_file,nxr_on_file )
     5801#endif
     5802
     5803             CASE ( 't_surf_window_v(2)' )
     5804#if defined( __nopointer )         
     5805                IF ( k == 1 )  THEN
     5806                   IF ( .NOT.  ALLOCATED( t_surf_window_v(2)%t ) )             &
     5807                      ALLOCATE( t_surf_window_v(2)%t(1:surf_usm_v(2)%ns) )
     5808                   READ ( 13 )  tmp_surf_window_v(2)%t
     5809                ENDIF
     5810                CALL surface_restore_elements(                                 &
     5811                                        t_surf_window_v(2)%t,                  &
     5812                                        tmp_surf_window_v(2)%t,                &
     5813                                        surf_usm_v(2)%start_index,             &   
     5814                                        start_index_on_file,                   &
     5815                                        end_index_on_file,                     &
     5816                                        nxlc, nysc,                            &
     5817                                        nxlf, nxrf, nysf, nynf,                &
     5818                                        nys_on_file, nyn_on_file,              &
     5819                                        nxl_on_file,nxr_on_file )
     5820#else                     
     5821                IF ( k == 1 )  THEN
     5822                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(2)%t ) )           &
     5823                      ALLOCATE( t_surf_window_v_1(2)%t(1:surf_usm_v(2)%ns) )
     5824                   READ ( 13 )  tmp_surf_window_v(2)%t
     5825                ENDIF
     5826                CALL surface_restore_elements(                                 &
     5827                                        t_surf_window_v_1(2)%t,                &
     5828                                        tmp_surf_window_v(2)%t,                &
     5829                                        surf_usm_v(2)%start_index,             &
     5830                                        start_index_on_file,                   &
     5831                                        end_index_on_file,                     &
     5832                                        nxlc, nysc,                            &
     5833                                        nxlf, nxrf, nysf, nynf,                &
     5834                                        nys_on_file, nyn_on_file,              &
     5835                                        nxl_on_file,nxr_on_file )
     5836#endif
     5837                   
     5838             CASE ( 't_surf_window_v(3)' )
     5839#if defined( __nopointer )   
     5840                IF ( k == 1 )  THEN
     5841                   IF ( .NOT.  ALLOCATED( t_surf_window_v(3)%t ) )             &
     5842                      ALLOCATE( t_surf_window_v(3)%t(1:surf_usm_v(3)%ns) )
     5843                   READ ( 13 )  tmp_surf_window_v(3)%t
     5844                ENDIF
     5845                CALL surface_restore_elements(                                 &
     5846                                        t_surf_window_v(3)%t,                  &
     5847                                        tmp_surf_window_v(3)%t,                &
     5848                                        surf_usm_v(3)%start_index,             &
     5849                                        start_index_on_file,                   &
     5850                                        end_index_on_file,                     &
     5851                                        nxlc, nysc,                            &
     5852                                        nxlf, nxrf, nysf, nynf,                &
     5853                                        nys_on_file, nyn_on_file,              &
     5854                                        nxl_on_file,nxr_on_file )
     5855#else                     
     5856                IF ( k == 1 )  THEN
     5857                   IF ( .NOT.  ALLOCATED( t_surf_window_v_1(3)%t ) )           &
     5858                      ALLOCATE( t_surf_window_v_1(3)%t(1:surf_usm_v(3)%ns) )
     5859                   READ ( 13 )  tmp_surf_window_v(3)%t
     5860                ENDIF
     5861                CALL surface_restore_elements(                                 &
     5862                                        t_surf_window_v_1(3)%t,                & 
     5863                                        tmp_surf_window_v(3)%t,                &
     5864                                        surf_usm_v(3)%start_index,             &
     5865                                        start_index_on_file,                   &
     5866                                        end_index_on_file,                     &
     5867                                        nxlc, nysc,                            &
     5868                                        nxlf, nxrf, nysf, nynf,                &
     5869                                        nys_on_file, nyn_on_file,              &
     5870                                        nxl_on_file,nxr_on_file )
     5871#endif
     5872             CASE ( 't_wall_h' )
     5873#if defined( __nopointer )
     5874                IF ( k == 1 )  THEN
     5875                   IF ( .NOT.  ALLOCATED( t_wall_h ) )                         &
     5876                      ALLOCATE( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
     5877                   READ ( 13 )  tmp_wall_h
     5878                ENDIF
     5879                CALL surface_restore_elements(                                 &
     5880                                        t_wall_h, tmp_wall_h,                  &
     5881                                        surf_usm_h%start_index,                &
     5882                                        start_index_on_file,                   &
     5883                                        end_index_on_file,                     &
     5884                                        nxlc, nysc,                            &
     5885                                        nxlf, nxrf, nysf, nynf,                &
     5886                                        nys_on_file, nyn_on_file,              &
     5887                                        nxl_on_file,nxr_on_file )
     5888#else
     5889                IF ( k == 1 )  THEN
     5890                   IF ( .NOT.  ALLOCATED( t_wall_h_1 ) )                       &
     5891                      ALLOCATE( t_wall_h_1(nzb_wall:nzt_wall+1,                &
     5892                                           1:surf_usm_h%ns) )
     5893                   READ ( 13 )  tmp_wall_h
     5894                ENDIF
     5895                CALL surface_restore_elements(                                 &
     5896                                        t_wall_h_1, tmp_wall_h,                &
     5897                                        surf_usm_h%start_index,                &
     5898                                        start_index_on_file,                   &
     5899                                        end_index_on_file,                     &
     5900                                        nxlc, nysc,                            &
     5901                                        nxlf, nxrf, nysf, nynf,                &
     5902                                        nys_on_file, nyn_on_file,              &
     5903                                        nxl_on_file,nxr_on_file )
     5904#endif
     5905             CASE ( 't_wall_v(0)' )
     5906#if defined( __nopointer )
     5907                IF ( k == 1 )  THEN
     5908                   IF ( .NOT.  ALLOCATED( t_wall_v(0)%t ) )                    &
     5909                      ALLOCATE( t_wall_v(0)%t(nzb_wall:nzt_wall+1,             &
     5910                                              1:surf_usm_v(0)%ns) )
     5911                   READ ( 13 )  tmp_wall_v(0)%t
     5912                ENDIF
     5913                CALL surface_restore_elements(                                 &
     5914                                        t_wall_v(0)%t, tmp_wall_v(0)%t,        &
     5915                                        surf_usm_v(0)%start_index,             &   
     5916                                        start_index_on_file,                   &
     5917                                        end_index_on_file,                     &
     5918                                        nxlc, nysc,                            &
     5919                                        nxlf, nxrf, nysf, nynf,                &
     5920                                        nys_on_file, nyn_on_file,              &
     5921                                        nxl_on_file,nxr_on_file )
     5922#else
     5923                IF ( k == 1 )  THEN
     5924                   IF ( .NOT.  ALLOCATED( t_wall_v_1(0)%t ) )                  &
     5925                      ALLOCATE( t_wall_v_1(0)%t(nzb_wall:nzt_wall+1,           &
     5926                                                1:surf_usm_v(0)%ns) )
     5927                   READ ( 13 )  tmp_wall_v(0)%t
     5928                ENDIF
     5929                CALL surface_restore_elements(                                 &
     5930                                        t_wall_v_1(0)%t, tmp_wall_v(0)%t,      &
     5931                                        surf_usm_v(0)%start_index,             & 
     5932                                        start_index_on_file,                   &
     5933                                        end_index_on_file,                     &
     5934                                        nxlc, nysc,                            &
     5935                                        nxlf, nxrf, nysf, nynf,                &
     5936                                        nys_on_file, nyn_on_file,              &
     5937                                        nxl_on_file,nxr_on_file )
     5938#endif
     5939             CASE ( 't_wall_v(1)' )
     5940#if defined( __nopointer )
     5941                IF ( k == 1 )  THEN
     5942                   IF ( .NOT.  ALLOCATED( t_wall_v(1)%t ) )                    &
     5943                      ALLOCATE( t_wall_v(1)%t(nzb_wall:nzt_wall+1,             &
     5944                                              1:surf_usm_v(1)%ns) )
     5945                   READ ( 13 )  tmp_wall_v(1)%t
     5946                ENDIF
     5947                CALL surface_restore_elements(                                 &
     5948                                        t_wall_v(1)%t, tmp_wall_v(1)%t,        &
     5949                                        surf_usm_v(1)%start_index,             &
     5950                                        start_index_on_file,                   &
     5951                                        end_index_on_file ,                    &
     5952                                        nxlc, nysc,                            &
     5953                                        nys_on_file, nyn_on_file,              &
     5954                                        nxl_on_file, nxr_on_file )
     5955#else
     5956                IF ( k == 1 )  THEN
     5957                   IF ( .NOT.  ALLOCATED( t_wall_v_1(1)%t ) )                  &
     5958                      ALLOCATE( t_wall_v_1(1)%t(nzb_wall:nzt_wall+1,           &
     5959                                                1:surf_usm_v(1)%ns) )
     5960                   READ ( 13 )  tmp_wall_v(1)%t
     5961                ENDIF
     5962                CALL surface_restore_elements(                                 &
     5963                                        t_wall_v_1(1)%t, tmp_wall_v(1)%t,      &
     5964                                        surf_usm_v(1)%start_index,             & 
     5965                                        start_index_on_file,                   &
     5966                                        end_index_on_file,                     &
     5967                                        nxlc, nysc,                            &
     5968                                        nxlf, nxrf, nysf, nynf,                &
     5969                                        nys_on_file, nyn_on_file,              &
     5970                                        nxl_on_file,nxr_on_file )
     5971#endif
     5972             CASE ( 't_wall_v(2)' )
     5973#if defined( __nopointer )
     5974                IF ( k == 1 )  THEN
     5975                   IF ( .NOT.  ALLOCATED( t_wall_v(2)%t ) )                    &
     5976                      ALLOCATE( t_wall_v(2)%t(nzb_wall:nzt_wall+1,             &
     5977                                              1:surf_usm_v(2)%ns) )
     5978                   READ ( 13 )  tmp_wall_v(2)%t
     5979                ENDIF
     5980                CALL surface_restore_elements(                                 &
     5981                                        t_wall_v(2)%t, tmp_wall_v(2)%t,        &
     5982                                        surf_usm_v(2)%start_index,             & 
     5983                                        start_index_on_file,                   &
     5984                                        end_index_on_file,                     &
     5985                                        nxlc, nysc,                            &
     5986                                        nxlf, nxrf, nysf, nynf,                &
     5987                                        nys_on_file, nyn_on_file,              &
     5988                                        nxl_on_file,nxr_on_file )
     5989#else
     5990                IF ( k == 1 )  THEN
     5991                   IF ( .NOT.  ALLOCATED( t_wall_v_1(2)%t ) )                  &
     5992                      ALLOCATE( t_wall_v_1(2)%t(nzb_wall:nzt_wall+1,           &
     5993                                                1:surf_usm_v(2)%ns) )
     5994                   READ ( 13 )  tmp_wall_v(2)%t
     5995                ENDIF
     5996                CALL surface_restore_elements(                                 &
     5997                                        t_wall_v_1(2)%t, tmp_wall_v(2)%t,      &
     5998                                        surf_usm_v(2)%start_index,             &
     5999                                        start_index_on_file,                   &
     6000                                        end_index_on_file ,                    &
     6001                                        nxlc, nysc,                            &
     6002                                        nxlf, nxrf, nysf, nynf,                &
     6003                                        nys_on_file, nyn_on_file,              &
     6004                                        nxl_on_file,nxr_on_file )
     6005#endif
     6006             CASE ( 't_wall_v(3)' )
     6007#if defined( __nopointer )
     6008                IF ( k == 1 )  THEN
     6009                   IF ( .NOT.  ALLOCATED( t_wall_v(3)%t ) )                    &
     6010                      ALLOCATE( t_wall_v(3)%t(nzb_wall:nzt_wall+1,             &
     6011                                              1:surf_usm_v(3)%ns) )
     6012                   READ ( 13 )  tmp_wall_v(3)%t
     6013                ENDIF
     6014                CALL surface_restore_elements(                                 &
     6015                                        t_wall_v(3)%t, tmp_wall_v(3)%t,        &
     6016                                        surf_usm_v(3)%start_index,             &   
     6017                                        start_index_on_file,                   &
     6018                                        end_index_on_file,                     &
     6019                                        nxlc, nysc,                            &
     6020                                        nxlf, nxrf, nysf, nynf,                &
     6021                                        nys_on_file, nyn_on_file,              &
     6022                                        nxl_on_file,nxr_on_file )
     6023#else
     6024                IF ( k == 1 )  THEN
     6025                   IF ( .NOT.  ALLOCATED( t_wall_v_1(3)%t ) )                  &
     6026                      ALLOCATE( t_wall_v_1(3)%t(nzb_wall:nzt_wall+1,           &
     6027                                                1:surf_usm_v(3)%ns) )
     6028                   READ ( 13 )  tmp_wall_v(3)%t
     6029                ENDIF
     6030                CALL surface_restore_elements(                                 &
     6031                                        t_wall_v_1(3)%t, tmp_wall_v(3)%t,      &
     6032                                        surf_usm_v(3)%start_index,             &   
     6033                                        start_index_on_file,                   &
     6034                                        end_index_on_file,                     &
     6035                                        nxlc, nysc,                            &
     6036                                        nxlf, nxrf, nysf, nynf,                &
     6037                                        nys_on_file, nyn_on_file,              &
     6038                                        nxl_on_file,nxr_on_file )
     6039#endif
     6040             CASE ( 't_green_h' )
     6041#if defined( __nopointer )
     6042                IF ( k == 1 )  THEN
     6043                   IF ( .NOT.  ALLOCATED( t_green_h ) )                        &
     6044                      ALLOCATE( t_green_h(nzb_wall:nzt_wall+1,                 &
     6045                                          1:surf_usm_h%ns) )
     6046                   READ ( 13 )  tmp_green_h
     6047                ENDIF
     6048                CALL surface_restore_elements(                                 &
     6049                                        t_green_h, tmp_green_h,                &
     6050                                        surf_usm_h%start_index,                &
     6051                                        start_index_on_file,                   &
     6052                                        end_index_on_file,                     &
     6053                                        nxlc, nysc,                            &
     6054                                        nxlf, nxrf, nysf, nynf,                &
     6055                                        nys_on_file, nyn_on_file,              &
     6056                                        nxl_on_file,nxr_on_file )
     6057#else
     6058                IF ( k == 1 )  THEN
     6059                   IF ( .NOT.  ALLOCATED( t_green_h_1 ) )                      &
     6060                      ALLOCATE( t_green_h_1(nzb_wall:nzt_wall+1,               &
     6061                                            1:surf_usm_h%ns) )
     6062                   READ ( 13 )  tmp_green_h
     6063                ENDIF
     6064                CALL surface_restore_elements(                                 &
     6065                                        t_green_h_1, tmp_green_h,              &
     6066                                        surf_usm_h%start_index,                &
     6067                                        start_index_on_file,                   &
     6068                                        end_index_on_file,                     &
     6069                                        nxlc, nysc,                            &
     6070                                        nxlf, nxrf, nysf, nynf,                &
     6071                                        nys_on_file, nyn_on_file,              &
     6072                                        nxl_on_file,nxr_on_file )
     6073#endif
     6074             CASE ( 't_green_v(0)' )
     6075#if defined( __nopointer )
     6076                IF ( k == 1 )  THEN
     6077                   IF ( .NOT.  ALLOCATED( t_green_v(0)%t ) )                   &
     6078                      ALLOCATE( t_green_v(0)%t(nzb_wall:nzt_wall+1,            &
     6079                                               1:surf_usm_v(0)%ns) )
     6080                   READ ( 13 )  tmp_green_v(0)%t
     6081                ENDIF
     6082                CALL surface_restore_elements(                                 &
     6083                                        t_green_v(0)%t, tmp_green_v(0)%t,      &
     6084                                        surf_usm_v(0)%start_index,             &
     6085                                        start_index_on_file,                   &
     6086                                        end_index_on_file,                     &
     6087                                        nxlc, nysc,                            &
     6088                                        nxlf, nxrf, nysf, nynf,                &
     6089                                        nys_on_file, nyn_on_file,              &
     6090                                        nxl_on_file,nxr_on_file )
     6091#else
     6092                IF ( k == 1 )  THEN
     6093                   IF ( .NOT.  ALLOCATED( t_green_v_1(0)%t ) )                 &
     6094                      ALLOCATE( t_green_v_1(0)%t(nzb_wall:nzt_wall+1,          &
     6095                                                 1:surf_usm_v(0)%ns) )
     6096                   READ ( 13 )  tmp_green_v(0)%t
     6097                ENDIF
     6098                CALL surface_restore_elements(                                 &
     6099                                        t_green_v_1(0)%t, tmp_green_v(0)%t,    &
     6100                                        surf_usm_v(0)%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#endif
     6108             CASE ( 't_green_v(1)' )
     6109#if defined( __nopointer )
     6110                IF ( k == 1 )  THEN
     6111                   IF ( .NOT.  ALLOCATED( t_green_v(1)%t ) )                   &
     6112                      ALLOCATE( t_green_v(1)%t(nzb_wall:nzt_wall+1,            &
     6113                                               1:surf_usm_v(1)%ns) )
     6114                   READ ( 13 )  tmp_green_v(1)%t
     6115                ENDIF
     6116                CALL surface_restore_elements(                                 &
     6117                                        t_green_v(1)%t, tmp_green_v(1)%t,      &
     6118                                        surf_usm_v(1)%start_index,             &
     6119                                        start_index_on_file,                   &
     6120                                        end_index_on_file ,                    &
     6121                                        nxlc, nysc,                            &
     6122                                        nys_on_file, nyn_on_file,              &
     6123                                        nxl_on_file,nxr_on_file )
     6124#else
     6125                IF ( k == 1 )  THEN
     6126                   IF ( .NOT.  ALLOCATED( t_green_v_1(1)%t ) )                 &
     6127                      ALLOCATE( t_green_v_1(1)%t(nzb_wall:nzt_wall+1,          &
     6128                                                 1:surf_usm_v(1)%ns) )
     6129                   READ ( 13 )  tmp_green_v(1)%t
     6130                ENDIF
     6131                CALL surface_restore_elements(                                 &
     6132                                        t_green_v_1(1)%t, tmp_green_v(1)%t,    &
     6133                                        surf_usm_v(1)%start_index,             &
     6134                                        start_index_on_file,                   &
     6135                                        end_index_on_file,                     &
     6136                                        nxlc, nysc,                            &
     6137                                        nxlf, nxrf, nysf, nynf,                &
     6138                                        nys_on_file, nyn_on_file,              &
     6139                                        nxl_on_file,nxr_on_file )
     6140#endif
     6141             CASE ( 't_green_v(2)' )
     6142#if defined( __nopointer )
     6143                IF ( k == 1 )  THEN
     6144                   IF ( .NOT.  ALLOCATED( t_green_v(2)%t ) )                   &
     6145                      ALLOCATE( t_green_v(2)%t(nzb_wall:nzt_wall+1,            &
     6146                                               1:surf_usm_v(2)%ns) )
     6147                   READ ( 13 )  tmp_green_v(2)%t
     6148                ENDIF
     6149                CALL surface_restore_elements(                                 &
     6150                                        t_green_v(2)%t, tmp_green_v(2)%t,      &
     6151                                        surf_usm_v(2)%start_index,             &
     6152                                        start_index_on_file,                   &
     6153                                        end_index_on_file,                     &
     6154                                        nxlc, nysc,                            &
     6155                                        nxlf, nxrf, nysf, nynf,                &
     6156                                        nys_on_file, nyn_on_file,              &
     6157                                        nxl_on_file,nxr_on_file )
     6158#else
     6159                IF ( k == 1 )  THEN
     6160                   IF ( .NOT.  ALLOCATED( t_green_v_1(2)%t ) )                 &
     6161                      ALLOCATE( t_green_v_1(2)%t(nzb_wall:nzt_wall+1,          &
     6162                                                 1:surf_usm_v(2)%ns) )
     6163                   READ ( 13 )  tmp_green_v(2)%t
     6164                ENDIF
     6165                CALL surface_restore_elements(                                 &
     6166                                        t_green_v_1(2)%t, tmp_green_v(2)%t,    &
     6167                                        surf_usm_v(2)%start_index,             &
     6168                                        start_index_on_file,                   &
     6169                                        end_index_on_file ,                    &
     6170                                        nxlc, nysc,                            &
     6171                                        nxlf, nxrf, nysf, nynf,                &
     6172                                        nys_on_file, nyn_on_file,              &
     6173                                        nxl_on_file,nxr_on_file )
     6174#endif
     6175             CASE ( 't_green_v(3)' )
     6176#if defined( __nopointer )
     6177                IF ( k == 1 )  THEN
     6178                   IF ( .NOT.  ALLOCATED( t_green_v(3)%t ) )                   &
     6179                      ALLOCATE( t_green_v(3)%t(nzb_wall:nzt_wall+1,            &
     6180                                               1:surf_usm_v(3)%ns) )
     6181                   READ ( 13 )  tmp_green_v(3)%t
     6182                ENDIF
     6183                CALL surface_restore_elements(                                 &
     6184                                        t_green_v(3)%t, tmp_green_v(3)%t,      &
     6185                                        surf_usm_v(3)%start_index,             & 
     6186                                        start_index_on_file,                   &
     6187                                        end_index_on_file,                     &
     6188                                        nxlc, nysc,                            &
     6189                                        nxlf, nxrf, nysf, nynf,                &
     6190                                        nys_on_file, nyn_on_file,              &
     6191                                        nxl_on_file,nxr_on_file )
     6192#else
     6193                IF ( k == 1 )  THEN
     6194                   IF ( .NOT.  ALLOCATED( t_green_v_1(3)%t ) )                 &
     6195                      ALLOCATE( t_green_v_1(3)%t(nzb_wall:nzt_wall+1,          &
     6196                                                 1:surf_usm_v(3)%ns) )
     6197                   READ ( 13 )  tmp_green_v(3)%t
     6198                ENDIF
     6199                CALL surface_restore_elements(                                 &
     6200                                        t_green_v_1(3)%t, tmp_green_v(3)%t,    &
     6201                                        surf_usm_v(3)%start_index,             & 
     6202                                        start_index_on_file,                   &
     6203                                        end_index_on_file,                     &
     6204                                        nxlc, nysc,                            &
     6205                                        nxlf, nxrf, nysf, nynf,                &
     6206                                        nys_on_file, nyn_on_file,              &
     6207                                        nxl_on_file,nxr_on_file )
     6208#endif
     6209             CASE ( 't_window_h' )
     6210#if defined( __nopointer )
     6211                IF ( k == 1 )  THEN
     6212                   IF ( .NOT.  ALLOCATED( t_window_h ) )                       &
     6213                      ALLOCATE( t_window_h(nzb_wall:nzt_wall+1,                &
     6214                                           1:surf_usm_h%ns) )
     6215                   READ ( 13 )  tmp_window_h
     6216                ENDIF
     6217                CALL surface_restore_elements(                                 &
     6218                                        t_window_h, tmp_window_h,              &
     6219                                        surf_usm_h%start_index,                &
     6220                                        start_index_on_file,                   &
     6221                                        end_index_on_file,                     &
     6222                                        nxlc, nysc,                            &
     6223                                        nxlf, nxrf, nysf, nynf,                &
     6224                                        nys_on_file, nyn_on_file,              &
     6225                                        nxl_on_file,nxr_on_file )
     6226#else
     6227                IF ( k == 1 )  THEN
     6228                   IF ( .NOT.  ALLOCATED( t_window_h_1 ) )                     &
     6229                      ALLOCATE( t_window_h_1(nzb_wall:nzt_wall+1,              &
     6230                                             1:surf_usm_h%ns) )
     6231                   READ ( 13 )  tmp_window_h
     6232                ENDIF
     6233                CALL surface_restore_elements(                                 &
     6234                                        t_window_h_1, tmp_window_h,            &
     6235                                        surf_usm_h%start_index,                &
     6236                                        start_index_on_file,                   &
     6237                                        end_index_on_file,                     &
     6238                                        nxlc, nysc,                            &
     6239                                        nxlf, nxrf, nysf, nynf,                &
     6240                                        nys_on_file, nyn_on_file,              &
     6241                                        nxl_on_file, nxr_on_file )
     6242#endif
     6243             CASE ( 't_window_v(0)' )
     6244#if defined( __nopointer )
     6245                IF ( k == 1 )  THEN
     6246                   IF ( .NOT.  ALLOCATED( t_window_v(0)%t ) )                  &
     6247                      ALLOCATE( t_window_v(0)%t(nzb_wall:nzt_wall+1,           &
     6248                                                1:surf_usm_v(0)%ns) )
     6249                   READ ( 13 )  tmp_window_v(0)%t
     6250                ENDIF
     6251                CALL surface_restore_elements(                                 &
     6252                                        t_window_v(0)%t, tmp_window_v(0)%t,    &
     6253                                        surf_usm_v(0)%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#else
     6261                IF ( k == 1 )  THEN
     6262                   IF ( .NOT.  ALLOCATED( t_window_v_1(0)%t ) )                &
     6263                      ALLOCATE( t_window_v_1(0)%t(nzb_wall:nzt_wall+1,         &
     6264                                                  1:surf_usm_v(0)%ns) )
     6265                   READ ( 13 )  tmp_window_v(0)%t
     6266                ENDIF
     6267                CALL surface_restore_elements(                                 &
     6268                                        t_window_v_1(0)%t,                     &
     6269                                        tmp_window_v(0)%t,                     &
     6270                                        surf_usm_v(0)%start_index,             &
     6271                                        start_index_on_file,                   &
     6272                                        end_index_on_file,                     &
     6273                                        nxlc, nysc,                            &
     6274                                        nxlf, nxrf, nysf, nynf,                &
     6275                                        nys_on_file, nyn_on_file,              &
     6276                                        nxl_on_file,nxr_on_file )
     6277#endif
     6278             CASE ( 't_window_v(1)' )
     6279#if defined( __nopointer )
     6280                IF ( k == 1 )  THEN
     6281                   IF ( .NOT.  ALLOCATED( t_window_v(1)%t ) )                  &
     6282                      ALLOCATE( t_window_v(1)%t(nzb_wall:nzt_wall+1,           &
     6283                                                1:surf_usm_v(1)%ns) )
     6284                   READ ( 13 )  tmp_window_v(1)%t
     6285                ENDIF
     6286                CALL surface_restore_elements(                                 &
     6287                                        t_window_v(1)%t, tmp_window_v(1)%t,    &
     6288                                        surf_usm_v(1)%start_index,             &
     6289                                        start_index_on_file,                   &
     6290                                        end_index_on_file ,                    &
     6291                                        nxlc, nysc,                            &
     6292                                        nys_on_file, nyn_on_file,              &
     6293                                        nxl_on_file, nxr_on_file )
     6294#else
     6295                IF ( k == 1 )  THEN
     6296                   IF ( .NOT.  ALLOCATED( t_window_v_1(1)%t ) )                &
     6297                      ALLOCATE( t_window_v_1(1)%t(nzb_wall:nzt_wall+1,         &
     6298                                                  1:surf_usm_v(1)%ns) )
     6299                   READ ( 13 )  tmp_window_v(1)%t
     6300                ENDIF
     6301                CALL surface_restore_elements(                                 &
     6302                                        t_window_v_1(1)%t,                     &
     6303                                        tmp_window_v(1)%t,                     &
     6304                                        surf_usm_v(1)%start_index,             &
     6305                                        start_index_on_file,                   &
     6306                                        end_index_on_file,                     &
     6307                                        nxlc, nysc,                            &
     6308                                        nxlf, nxrf, nysf, nynf,                &
     6309                                        nys_on_file, nyn_on_file,              &
     6310                                        nxl_on_file,nxr_on_file )
     6311#endif
     6312             CASE ( 't_window_v(2)' )
     6313#if defined( __nopointer )
     6314                IF ( k == 1 )  THEN
     6315                   IF ( .NOT.  ALLOCATED( t_window_v(2)%t ) )                  &
     6316                      ALLOCATE( t_window_v(2)%t(nzb_wall:nzt_wall+1,           &
     6317                                                1:surf_usm_v(2)%ns) )
     6318                   READ ( 13 )  tmp_window_v(2)%t
     6319                ENDIF
     6320                CALL surface_restore_elements(                                 &
     6321                                        t_window_v(2)%t, tmp_window_v(2)%t,    &
     6322                                        surf_usm_v(2)%start_index,             &
     6323                                        start_index_on_file,                   &
     6324                                        end_index_on_file,                     &
     6325                                        nxlc, nysc,                            &
     6326                                        nxlf, nxrf, nysf, nynf,                &
     6327                                        nys_on_file, nyn_on_file,              &
     6328                                        nxl_on_file,nxr_on_file )
     6329#else
     6330                IF ( k == 1 )  THEN
     6331                   IF ( .NOT.  ALLOCATED( t_window_v_1(2)%t ) )                &
     6332                      ALLOCATE( t_window_v_1(2)%t(nzb_wall:nzt_wall+1,         &
     6333                                                  1:surf_usm_v(2)%ns) )
     6334                   READ ( 13 )  tmp_window_v(2)%t
     6335                ENDIF
     6336                CALL surface_restore_elements(                                 &
     6337                                        t_window_v_1(2)%t,                     &
     6338                                        tmp_window_v(2)%t,                     &
     6339                                        surf_usm_v(2)%start_index,             & 
     6340                                        start_index_on_file,                   &
     6341                                        end_index_on_file ,                    &
     6342                                        nxlc, nysc,                            &
     6343                                        nxlf, nxrf, nysf, nynf,                &
     6344                                        nys_on_file, nyn_on_file,              &
     6345                                        nxl_on_file,nxr_on_file )
     6346#endif
     6347             CASE ( 't_window_v(3)' )
     6348#if defined( __nopointer )
     6349                IF ( k == 1 )  THEN
     6350                   IF ( .NOT.  ALLOCATED( t_window_v(3)%t ) )                  &
     6351                      ALLOCATE( t_window_v(3)%t(nzb_wall:nzt_wall+1,           &
     6352                                                1:surf_usm_v(3)%ns) )
     6353                   READ ( 13 )  tmp_window_v(3)%t
     6354                ENDIF
     6355                CALL surface_restore_elements(                                 &
     6356                                        t_window_v(3)%t, tmp_window_v(3)%t,    &
     6357                                        surf_usm_v(3)%start_index,             &
     6358                                        start_index_on_file,                   &
     6359                                        end_index_on_file,                     &
     6360                                        nxlc, nysc,                            &
     6361                                        nxlf, nxrf, nysf, nynf,                &
     6362                                        nys_on_file, nyn_on_file,              &
     6363                                        nxl_on_file,nxr_on_file )
     6364#else
     6365                IF ( k == 1 )  THEN
     6366                   IF ( .NOT.  ALLOCATED( t_window_v_1(3)%t ) )                &
     6367                      ALLOCATE( t_window_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
     6368                   READ ( 13 )  tmp_window_v(3)%t
     6369                ENDIF
     6370                CALL surface_restore_elements(                                 &
     6371                                        t_window_v_1(3)%t,                     &
     6372                                        tmp_window_v(3)%t,                     &
     6373                                        surf_usm_v(3)%start_index,             &
     6374                                        start_index_on_file,                   &
     6375                                        end_index_on_file,                     &
     6376                                        nxlc, nysc,                            &
     6377                                        nxlf, nxrf, nysf, nynf,                &
     6378                                        nys_on_file, nyn_on_file,              &
     6379                                        nxl_on_file,nxr_on_file )
     6380#endif
     6381             CASE DEFAULT
     6382
     6383                   found = .FALSE.
     6384
     6385          END SELECT
     6386
    52456387       
    5246        INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  start_index_on_file
    5247        INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) ::  end_index_on_file
    5248        
    5249        REAL(wp), DIMENSION(:), ALLOCATABLE   ::  tmp_surf_h, tmp_surf_window_h, tmp_surf_green_h
    5250        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tmp_wall_h, tmp_window_h, tmp_green_h
    5251        
    5252        TYPE( t_surf_vertical ), DIMENSION(0:3) ::  tmp_surf_v, tmp_surf_window_v, tmp_surf_green_v
    5253        TYPE( t_wall_vertical ), DIMENSION(0:3) ::  tmp_wall_v, tmp_window_v, tmp_green_v
    5254 
    5255        
    5256        IF ( initializing_actions == 'read_restart_data'  .OR.                  &
    5257             initializing_actions == 'cyclic_fill' )  THEN
    5258          
    5259 !
    5260 !--       Read number of respective surface elements on file
    5261           READ ( 13 ) field_chr
    5262           IF ( TRIM( field_chr ) /= 'ns_h_on_file_usm' )  THEN
    5263 !
    5264 !--          Add a proper error message
    5265           ENDIF
    5266           READ ( 13 ) ns_h_on_file_usm
    5267 
    5268           READ ( 13 )  field_chr
    5269           IF ( TRIM( field_chr ) /= 'ns_v_on_file_usm' )  THEN
    5270 !
    5271 !--          Add a proper error message
    5272           ENDIF
    5273           READ ( 13 ) ns_v_on_file_usm
    5274 !
    5275 !--       Allocate temporary arrays for reading data on file. Note, the
    5276 !--       size of allocated surface elements do not necessarily need to match
    5277 !--       the size of present surface elements on current processor, as the
    5278 !--       number of processors between restarts can change.
    5279           ALLOCATE( tmp_surf_h(1:ns_h_on_file_usm) )
    5280           ALLOCATE( tmp_wall_h(nzb_wall:nzt_wall+1,1:ns_h_on_file_usm) )
    5281           ALLOCATE( tmp_surf_window_h(1:ns_h_on_file_usm) )
    5282           ALLOCATE( tmp_window_h(nzb_wall:nzt_wall+1,1:ns_h_on_file_usm) )
    5283           ALLOCATE( tmp_surf_green_h(1:ns_h_on_file_usm) )
    5284           ALLOCATE( tmp_green_h(nzb_wall:nzt_wall+1,1:ns_h_on_file_usm) )
    5285          
    5286           DO  l = 0, 3
    5287              ALLOCATE( tmp_surf_v(l)%t(1:ns_v_on_file_usm(l)) )
    5288              ALLOCATE( tmp_wall_v(l)%t(nzb_wall:nzt_wall+1,1:ns_v_on_file_usm(l) ) )
    5289              ALLOCATE( tmp_surf_window_v(l)%t(1:ns_v_on_file_usm(l)) )
    5290              ALLOCATE( tmp_window_v(l)%t(nzb_wall:nzt_wall+1,1:ns_v_on_file_usm(l) ) )
    5291              ALLOCATE( tmp_surf_green_v(l)%t(1:ns_v_on_file_usm(l)) )
    5292              ALLOCATE( tmp_green_v(l)%t(nzb_wall:nzt_wall+1,1:ns_v_on_file_usm(l) ) )
    5293           ENDDO
    5294          
    5295        
    5296           READ ( 13 )  field_chr
    5297 
    5298           DO  WHILE ( TRIM( field_chr ) /= '*** end usm ***' )
    5299 !
    5300 !--          Map data on file as often as needed (data are read only for k=1)
    5301              DO  kk = 1, overlap_count
    5302 !
    5303 !--             Get the index range of the subdomain on file which overlap with the
    5304 !--             current subdomain
    5305                 nxlf = nxlfa(ii,kk)
    5306                 nxlc = nxlfa(ii,kk) + offset_xa(ii,kk)
    5307                 nxrf = nxrfa(ii,kk)
    5308                 nxrc = nxrfa(ii,kk) + offset_xa(ii,kk)
    5309                 nysf = nysfa(ii,kk)
    5310                 nysc = nysfa(ii,kk) + offset_ya(ii,kk)
    5311                 nynf = nynfa(ii,kk)
    5312                 nync = nynfa(ii,kk) + offset_ya(ii,kk)
    5313 
    5314                 SELECT CASE ( TRIM( field_chr ) )     
    5315                
    5316                    CASE ( 'usm_start_index_h', 'usm_start_index_v'  )   
    5317                       IF ( kk == 1 )                                           &
    5318                          READ ( 13 )  start_index_on_file
    5319                      
    5320                    CASE ( 'usm_end_index_h', 'usm_end_index_v' )   
    5321                       IF ( kk == 1 )                                           &
    5322                          READ ( 13 )  end_index_on_file
    5323                
    5324                    CASE ( 't_surf_h' )
    5325 #if defined( __nopointer )                   
    5326                       IF ( kk == 1 )  THEN
    5327                          IF ( .NOT.  ALLOCATED( t_surf_h ) )                   &
    5328                             ALLOCATE( t_surf_h(1:surf_usm_h%ns) )
    5329                          READ ( 13 )  tmp_surf_h
    5330                       ENDIF
    5331                       CALL surface_restore_elements(                           &
    5332                                               t_surf_h, tmp_surf_h,            &
    5333                                               surf_usm_h%start_index,          &
    5334                                               start_index_on_file,             &
    5335                                               end_index_on_file,               &
    5336                                               nxlc, nysc,                      &
    5337                                               nxlf, nxrf, nysf, nynf,          &
    5338                                               nys_on_file, nyn_on_file,        &
    5339                                               nxl_on_file,nxr_on_file )
    5340 #else                     
    5341                       IF ( kk == 1 )  THEN
    5342                          IF ( .NOT.  ALLOCATED( t_surf_h_1 ) )                 &
    5343                             ALLOCATE( t_surf_h_1(1:surf_usm_h%ns) )
    5344                          READ ( 13 )  tmp_surf_h
    5345                       ENDIF
    5346                       CALL surface_restore_elements(                           &
    5347                                               t_surf_h_1, tmp_surf_h,          &
    5348                                               surf_usm_h%start_index,          &
    5349                                               start_index_on_file,             &
    5350                                               end_index_on_file,               &
    5351                                               nxlc, nysc,                      &
    5352                                               nxlf, nxrf, nysf, nynf,          &
    5353                                               nys_on_file, nyn_on_file,        &
    5354                                               nxl_on_file,nxr_on_file )
    5355 #endif
    5356 
    5357                    CASE ( 't_surf_v(0)' )
    5358 #if defined( __nopointer )           
    5359                       IF ( kk == 1 )  THEN
    5360                          IF ( .NOT.  ALLOCATED( t_surf_v(0)%t ) )              &
    5361                             ALLOCATE( t_surf_v(0)%t(1:surf_usm_v(0)%ns) )
    5362                          READ ( 13 )  tmp_surf_v(0)%t
    5363                       ENDIF
    5364                       CALL surface_restore_elements(                           &
    5365                                               t_surf_v(0)%t, tmp_surf_v(0)%t,  &
    5366                                               surf_usm_v(0)%start_index,       &
    5367                                               start_index_on_file,             &
    5368                                               end_index_on_file,               &
    5369                                               nxlc, nysc,                      &
    5370                                               nxlf, nxrf, nysf, nynf,          &
    5371                                               nys_on_file, nyn_on_file,        &
    5372                                               nxl_on_file,nxr_on_file )
    5373 #else                     
    5374                       IF ( kk == 1 )  THEN
    5375                          IF ( .NOT.  ALLOCATED( t_surf_v_1(0)%t ) )            &
    5376                             ALLOCATE( t_surf_v_1(0)%t(1:surf_usm_v(0)%ns) )
    5377                          READ ( 13 )  tmp_surf_v(0)%t
    5378                       ENDIF
    5379                       CALL surface_restore_elements(                           &
    5380                                               t_surf_v_1(0)%t, tmp_surf_v(0)%t,&
    5381                                               surf_usm_v(0)%start_index,       &
    5382                                               start_index_on_file,             &
    5383                                               end_index_on_file,               &
    5384                                               nxlc, nysc,                      &
    5385                                               nxlf, nxrf, nysf, nynf,          &
    5386                                               nys_on_file, nyn_on_file,        &
    5387                                               nxl_on_file,nxr_on_file )
    5388 #endif
    5389                          
    5390                    CASE ( 't_surf_v(1)' )
    5391 #if defined( __nopointer )       
    5392                       IF ( kk == 1 )  THEN
    5393                          IF ( .NOT.  ALLOCATED( t_surf_v(1)%t ) )              &
    5394                             ALLOCATE( t_surf_v(1)%t(1:surf_usm_v(1)%ns) )
    5395                          READ ( 13 )  tmp_surf_v(1)%t
    5396                       ENDIF
    5397                       CALL surface_restore_elements(                           &
    5398                                               t_surf_v(1)%t, tmp_surf_v(1)%t,  &
    5399                                               surf_usm_v(1)%start_index,       &
    5400                                               start_index_on_file,             &
    5401                                               end_index_on_file,               &
    5402                                               nxlc, nysc,                      &
    5403                                               nxlf, nxrf, nysf, nynf,          &
    5404                                               nys_on_file, nyn_on_file,        &
    5405                                               nxl_on_file,nxr_on_file )                 
    5406 #else                     
    5407                       IF ( kk == 1 )  THEN
    5408                          IF ( .NOT.  ALLOCATED( t_surf_v_1(1)%t ) )            &
    5409                             ALLOCATE( t_surf_v_1(1)%t(1:surf_usm_v(1)%ns) )
    5410                          READ ( 13 )  tmp_surf_v(1)%t
    5411                       ENDIF
    5412                       CALL surface_restore_elements(                           &
    5413                                               t_surf_v_1(1)%t, tmp_surf_v(1)%t,&
    5414                                               surf_usm_v(1)%start_index,       &
    5415                                               start_index_on_file,             &
    5416                                               end_index_on_file,               &
    5417                                               nxlc, nysc,                      &
    5418                                               nxlf, nxrf, nysf, nynf,          &
    5419                                               nys_on_file, nyn_on_file,        &
    5420                                               nxl_on_file,nxr_on_file )
    5421 #endif
    5422 
    5423                    CASE ( 't_surf_v(2)' )
    5424 #if defined( __nopointer )         
    5425                       IF ( kk == 1 )  THEN
    5426                          IF ( .NOT.  ALLOCATED( t_surf_v(2)%t ) )              &
    5427                             ALLOCATE( t_surf_v(2)%t(1:surf_usm_v(2)%ns) )
    5428                          READ ( 13 )  tmp_surf_v(2)%t
    5429                       ENDIF
    5430                       CALL surface_restore_elements(                           &
    5431                                               t_surf_v(2)%t, tmp_surf_v(2)%t,  &
    5432                                               surf_usm_v(2)%start_index,       &
    5433                                               start_index_on_file,             &
    5434                                               end_index_on_file,               &
    5435                                               nxlc, nysc,                      &
    5436                                               nxlf, nxrf, nysf, nynf,          &
    5437                                               nys_on_file, nyn_on_file,        &
    5438                                               nxl_on_file,nxr_on_file )
    5439 #else                     
    5440                       IF ( kk == 1 )  THEN
    5441                          IF ( .NOT.  ALLOCATED( t_surf_v_1(2)%t ) )            &
    5442                             ALLOCATE( t_surf_v_1(2)%t(1:surf_usm_v(2)%ns) )
    5443                          READ ( 13 )  tmp_surf_v(2)%t
    5444                       ENDIF
    5445                       CALL surface_restore_elements(                           &
    5446                                               t_surf_v_1(2)%t, tmp_surf_v(2)%t,&
    5447                                               surf_usm_v(2)%start_index,       &
    5448                                               start_index_on_file,             &
    5449                                               end_index_on_file,               &
    5450                                               nxlc, nysc,                      &
    5451                                               nxlf, nxrf, nysf, nynf,          &
    5452                                               nys_on_file, nyn_on_file,        &
    5453                                               nxl_on_file,nxr_on_file )
    5454 #endif
    5455                          
    5456                    CASE ( 't_surf_v(3)' )
    5457 #if defined( __nopointer )   
    5458                       IF ( kk == 1 )  THEN
    5459                          IF ( .NOT.  ALLOCATED( t_surf_v(3)%t ) )              &
    5460                             ALLOCATE( t_surf_v(3)%t(1:surf_usm_v(3)%ns) )
    5461                          READ ( 13 )  tmp_surf_v(3)%t
    5462                       ENDIF
    5463                       CALL surface_restore_elements(                           &
    5464                                               t_surf_v(3)%t, tmp_surf_v(3)%t,  &
    5465                                               surf_usm_v(3)%start_index,       &
    5466                                               start_index_on_file,             &
    5467                                               end_index_on_file,               &
    5468                                               nxlc, nysc,                      &
    5469                                               nxlf, nxrf, nysf, nynf,          &
    5470                                               nys_on_file, nyn_on_file,        &
    5471                                               nxl_on_file,nxr_on_file )
    5472 #else                     
    5473                       IF ( kk == 1 )  THEN
    5474                          IF ( .NOT.  ALLOCATED( t_surf_v_1(3)%t ) )            &
    5475                             ALLOCATE( t_surf_v_1(3)%t(1:surf_usm_v(3)%ns) )
    5476                          READ ( 13 )  tmp_surf_v(3)%t
    5477                       ENDIF
    5478                       CALL surface_restore_elements(                           &
    5479                                               t_surf_v_1(3)%t, tmp_surf_v(3)%t,&
    5480                                               surf_usm_v(3)%start_index,       &
    5481                                               start_index_on_file,             &
    5482                                               end_index_on_file,               &
    5483                                               nxlc, nysc,                      &
    5484                                               nxlf, nxrf, nysf, nynf,          &
    5485                                               nys_on_file, nyn_on_file,        &
    5486                                               nxl_on_file,nxr_on_file )
    5487 #endif
    5488                    CASE ( 't_surf_green_h' )
    5489 #if defined( __nopointer )                   
    5490                       IF ( kk == 1 )  THEN
    5491                          IF ( .NOT.  ALLOCATED( t_surf_green_h ) )                   &
    5492                             ALLOCATE( t_surf_green_h(1:surf_usm_h%ns) )
    5493                          READ ( 13 )  tmp_surf_green_h
    5494                       ENDIF
    5495                       CALL surface_restore_elements(                           &
    5496                                               t_surf_green_h, tmp_surf_green_h, &
    5497                                               surf_usm_h%start_index,          &
    5498                                               start_index_on_file,             &
    5499                                               end_index_on_file,               &
    5500                                               nxlc, nysc,                      &
    5501                                               nxlf, nxrf, nysf, nynf,          &
    5502                                               nys_on_file, nyn_on_file,        &
    5503                                               nxl_on_file,nxr_on_file )
    5504 #else                     
    5505                       IF ( kk == 1 )  THEN
    5506                          IF ( .NOT.  ALLOCATED( t_surf_green_h_1 ) )                 &
    5507                             ALLOCATE( t_surf_green_h_1(1:surf_usm_h%ns) )
    5508                          READ ( 13 )  tmp_surf_green_h
    5509                       ENDIF
    5510                       CALL surface_restore_elements(                           &
    5511                                               t_surf_green_h_1, tmp_surf_green_h, &
    5512                                               surf_usm_h%start_index,          &
    5513                                               start_index_on_file,             &
    5514                                               end_index_on_file,               &
    5515                                               nxlc, nysc,                      &
    5516                                               nxlf, nxrf, nysf, nynf,          &
    5517                                               nys_on_file, nyn_on_file,        &
    5518                                               nxl_on_file,nxr_on_file )
    5519 #endif
    5520 
    5521                    CASE ( 't_surf_green_v(0)' )
    5522 #if defined( __nopointer )           
    5523                       IF ( kk == 1 )  THEN
    5524                          IF ( .NOT.  ALLOCATED( t_surf_green_v(0)%t ) )              &
    5525                             ALLOCATE( t_surf_green_v(0)%t(1:surf_usm_v(0)%ns) )
    5526                          READ ( 13 )  tmp_surf_green_v(0)%t
    5527                       ENDIF
    5528                       CALL surface_restore_elements(                           &
    5529                                               t_surf_green_v(0)%t, tmp_surf_green_v(0)%t,  &
    5530                                               surf_usm_v(0)%start_index,       &
    5531                                               start_index_on_file,             &
    5532                                               end_index_on_file,               &
    5533                                               nxlc, nysc,                      &
    5534                                               nxlf, nxrf, nysf, nynf,          &
    5535                                               nys_on_file, nyn_on_file,        &
    5536                                               nxl_on_file,nxr_on_file )
    5537 #else                     
    5538                       IF ( kk == 1 )  THEN
    5539                          IF ( .NOT.  ALLOCATED( t_surf_green_v_1(0)%t ) )            &
    5540                             ALLOCATE( t_surf_green_v_1(0)%t(1:surf_usm_v(0)%ns) )
    5541                          READ ( 13 )  tmp_surf_green_v(0)%t
    5542                       ENDIF
    5543                       CALL surface_restore_elements(                           &
    5544                                               t_surf_green_v_1(0)%t, tmp_surf_green_v(0)%t,&
    5545                                               surf_usm_v(0)%start_index,       &
    5546                                               start_index_on_file,             &
    5547                                               end_index_on_file,               &
    5548                                               nxlc, nysc,                      &
    5549                                               nxlf, nxrf, nysf, nynf,          &
    5550                                               nys_on_file, nyn_on_file,        &
    5551                                               nxl_on_file,nxr_on_file )
    5552 #endif
    5553                          
    5554                    CASE ( 't_surf_green_v(1)' )
    5555 #if defined( __nopointer )       
    5556                       IF ( kk == 1 )  THEN
    5557                          IF ( .NOT.  ALLOCATED( t_surf_green_v(1)%t ) )              &
    5558                             ALLOCATE( t_surf_green_v(1)%t(1:surf_usm_v(1)%ns) )
    5559                          READ ( 13 )  tmp_surf_green_v(1)%t
    5560                       ENDIF
    5561                       CALL surface_restore_elements(                           &
    5562                                               t_surf_green_v(1)%t, tmp_surf_green_v(1)%t,  &
    5563                                               surf_usm_v(1)%start_index,       &
    5564                                               start_index_on_file,             &
    5565                                               end_index_on_file,               &
    5566                                               nxlc, nysc,                      &
    5567                                               nxlf, nxrf, nysf, nynf,          &
    5568                                               nys_on_file, nyn_on_file,        &
    5569                                               nxl_on_file,nxr_on_file )                 
    5570 #else                     
    5571                       IF ( kk == 1 )  THEN
    5572                          IF ( .NOT.  ALLOCATED( t_surf_green_v_1(1)%t ) )            &
    5573                             ALLOCATE( t_surf_green_v_1(1)%t(1:surf_usm_v(1)%ns) )
    5574                          READ ( 13 )  tmp_surf_green_v(1)%t
    5575                       ENDIF
    5576                       CALL surface_restore_elements(                           &
    5577                                               t_surf_green_v_1(1)%t, tmp_surf_green_v(1)%t,&
    5578                                               surf_usm_v(1)%start_index,       &
    5579                                               start_index_on_file,             &
    5580                                               end_index_on_file,               &
    5581                                               nxlc, nysc,                      &
    5582                                               nxlf, nxrf, nysf, nynf,          &
    5583                                               nys_on_file, nyn_on_file,        &
    5584                                               nxl_on_file,nxr_on_file )
    5585 #endif
    5586 
    5587                    CASE ( 't_surf_green_v(2)' )
    5588 #if defined( __nopointer )         
    5589                       IF ( kk == 1 )  THEN
    5590                          IF ( .NOT.  ALLOCATED( t_surf_green_v(2)%t ) )              &
    5591                             ALLOCATE( t_surf_green_v(2)%t(1:surf_usm_v(2)%ns) )
    5592                          READ ( 13 )  tmp_surf_green_v(2)%t
    5593                       ENDIF
    5594                       CALL surface_restore_elements(                           &
    5595                                               t_surf_green_v(2)%t, tmp_surf_green_v(2)%t,  &
    5596                                               surf_usm_v(2)%start_index,       &
    5597                                               start_index_on_file,             &
    5598                                               end_index_on_file,               &
    5599                                               nxlc, nysc,                      &
    5600                                               nxlf, nxrf, nysf, nynf,          &
    5601                                               nys_on_file, nyn_on_file,        &
    5602                                               nxl_on_file,nxr_on_file )
    5603 #else                     
    5604                       IF ( kk == 1 )  THEN
    5605                          IF ( .NOT.  ALLOCATED( t_surf_green_v_1(2)%t ) )            &
    5606                             ALLOCATE( t_surf_green_v_1(2)%t(1:surf_usm_v(2)%ns) )
    5607                          READ ( 13 )  tmp_surf_green_v(2)%t
    5608                       ENDIF
    5609                       CALL surface_restore_elements(                           &
    5610                                               t_surf_green_v_1(2)%t, tmp_surf_green_v(2)%t,&
    5611                                               surf_usm_v(2)%start_index,       &
    5612                                               start_index_on_file,             &
    5613                                               end_index_on_file,               &
    5614                                               nxlc, nysc,                      &
    5615                                               nxlf, nxrf, nysf, nynf,          &
    5616                                               nys_on_file, nyn_on_file,        &
    5617                                               nxl_on_file,nxr_on_file )
    5618 #endif
    5619                          
    5620                    CASE ( 't_surf_green_v(3)' )
    5621 #if defined( __nopointer )   
    5622                       IF ( kk == 1 )  THEN
    5623                          IF ( .NOT.  ALLOCATED( t_surf_green_v(3)%t ) )              &
    5624                             ALLOCATE( t_surf_green_v(3)%t(1:surf_usm_v(3)%ns) )
    5625                          READ ( 13 )  tmp_surf_green_v(3)%t
    5626                       ENDIF
    5627                       CALL surface_restore_elements(                           &
    5628                                               t_surf_green_v(3)%t, tmp_surf_green_v(3)%t,  &
    5629                                               surf_usm_v(3)%start_index,       &
    5630                                               start_index_on_file,             &
    5631                                               end_index_on_file,               &
    5632                                               nxlc, nysc,                      &
    5633                                               nxlf, nxrf, nysf, nynf,          &
    5634                                               nys_on_file, nyn_on_file,        &
    5635                                               nxl_on_file,nxr_on_file )
    5636 #else                     
    5637                       IF ( kk == 1 )  THEN
    5638                          IF ( .NOT.  ALLOCATED( t_surf_green_v_1(3)%t ) )            &
    5639                             ALLOCATE( t_surf_green_v_1(3)%t(1:surf_usm_v(3)%ns) )
    5640                          READ ( 13 )  tmp_surf_green_v(3)%t
    5641                       ENDIF
    5642                       CALL surface_restore_elements(                           &
    5643                                               t_surf_green_v_1(3)%t, tmp_surf_green_v(3)%t,&
    5644                                               surf_usm_v(3)%start_index,       &
    5645                                               start_index_on_file,             &
    5646                                               end_index_on_file,               &
    5647                                               nxlc, nysc,                      &
    5648                                               nxlf, nxrf, nysf, nynf,          &
    5649                                               nys_on_file, nyn_on_file,        &
    5650                                               nxl_on_file,nxr_on_file )
    5651 #endif
    5652                    CASE ( 't_surf_window_h' )
    5653 #if defined( __nopointer )                   
    5654                       IF ( kk == 1 )  THEN
    5655                          IF ( .NOT.  ALLOCATED( t_surf_window_h ) )                   &
    5656                             ALLOCATE( t_surf_window_h(1:surf_usm_h%ns) )
    5657                          READ ( 13 )  tmp_surf_window_h
    5658                       ENDIF
    5659                       CALL surface_restore_elements(                           &
    5660                                               t_surf_window_h, tmp_surf_window_h,            &
    5661                                               surf_usm_h%start_index,          &
    5662                                               start_index_on_file,             &
    5663                                               end_index_on_file,               &
    5664                                               nxlc, nysc,                      &
    5665                                               nxlf, nxrf, nysf, nynf,          &
    5666                                               nys_on_file, nyn_on_file,        &
    5667                                               nxl_on_file,nxr_on_file )
    5668 #else                     
    5669                       IF ( kk == 1 )  THEN
    5670                          IF ( .NOT.  ALLOCATED( t_surf_window_h_1 ) )                 &
    5671                             ALLOCATE( t_surf_window_h_1(1:surf_usm_h%ns) )
    5672                          READ ( 13 )  tmp_surf_window_h
    5673                       ENDIF
    5674                       CALL surface_restore_elements(                           &
    5675                                               t_surf_window_h_1, tmp_surf_window_h,          &
    5676                                               surf_usm_h%start_index,          &
    5677                                               start_index_on_file,             &
    5678                                               end_index_on_file,               &
    5679                                               nxlc, nysc,                      &
    5680                                               nxlf, nxrf, nysf, nynf,          &
    5681                                               nys_on_file, nyn_on_file,        &
    5682                                               nxl_on_file,nxr_on_file )
    5683 #endif
    5684 
    5685                    CASE ( 't_surf_window_v(0)' )
    5686 #if defined( __nopointer )           
    5687                       IF ( kk == 1 )  THEN
    5688                          IF ( .NOT.  ALLOCATED( t_surf_window_v(0)%t ) )              &
    5689                             ALLOCATE( t_surf_window_v(0)%t(1:surf_usm_v(0)%ns) )
    5690                          READ ( 13 )  tmp_surf_window_v(0)%t
    5691                       ENDIF
    5692                       CALL surface_restore_elements(                           &
    5693                                               t_surf_window_v(0)%t, tmp_surf_window_v(0)%t,  &
    5694                                               surf_usm_v(0)%start_index,       &
    5695                                               start_index_on_file,             &
    5696                                               end_index_on_file,               &
    5697                                               nxlc, nysc,                      &
    5698                                               nxlf, nxrf, nysf, nynf,          &
    5699                                               nys_on_file, nyn_on_file,        &
    5700                                               nxl_on_file,nxr_on_file )
    5701 #else                     
    5702                       IF ( kk == 1 )  THEN
    5703                          IF ( .NOT.  ALLOCATED( t_surf_window_v_1(0)%t ) )            &
    5704                             ALLOCATE( t_surf_window_v_1(0)%t(1:surf_usm_v(0)%ns) )
    5705                          READ ( 13 )  tmp_surf_window_v(0)%t
    5706                       ENDIF
    5707                       CALL surface_restore_elements(                           &
    5708                                               t_surf_window_v_1(0)%t, tmp_surf_window_v(0)%t,&
    5709                                               surf_usm_v(0)%start_index,       &
    5710                                               start_index_on_file,             &
    5711                                               end_index_on_file,               &
    5712                                               nxlc, nysc,                      &
    5713                                               nxlf, nxrf, nysf, nynf,          &
    5714                                               nys_on_file, nyn_on_file,        &
    5715                                               nxl_on_file,nxr_on_file )
    5716 #endif
    5717                          
    5718                    CASE ( 't_surf_window_v(1)' )
    5719 #if defined( __nopointer )       
    5720                       IF ( kk == 1 )  THEN
    5721                          IF ( .NOT.  ALLOCATED( t_surf_window_v(1)%t ) )              &
    5722                             ALLOCATE( t_surf_window_v(1)%t(1:surf_usm_v(1)%ns) )
    5723                          READ ( 13 )  tmp_surf_window_v(1)%t
    5724                       ENDIF
    5725                       CALL surface_restore_elements(                           &
    5726                                               t_surf_window_v(1)%t, tmp_surf_window_v(1)%t,  &
    5727                                               surf_usm_v(1)%start_index,       &
    5728                                               start_index_on_file,             &
    5729                                               end_index_on_file,               &
    5730                                               nxlc, nysc,                      &
    5731                                               nxlf, nxrf, nysf, nynf,          &
    5732                                               nys_on_file, nyn_on_file,        &
    5733                                               nxl_on_file,nxr_on_file )                 
    5734 #else                     
    5735                       IF ( kk == 1 )  THEN
    5736                          IF ( .NOT.  ALLOCATED( t_surf_window_v_1(1)%t ) )            &
    5737                             ALLOCATE( t_surf_window_v_1(1)%t(1:surf_usm_v(1)%ns) )
    5738                          READ ( 13 )  tmp_surf_window_v(1)%t
    5739                       ENDIF
    5740                       CALL surface_restore_elements(                           &
    5741                                               t_surf_window_v_1(1)%t, tmp_surf_window_v(1)%t,&
    5742                                               surf_usm_v(1)%start_index,       &
    5743                                               start_index_on_file,             &
    5744                                               end_index_on_file,               &
    5745                                               nxlc, nysc,                      &
    5746                                               nxlf, nxrf, nysf, nynf,          &
    5747                                               nys_on_file, nyn_on_file,        &
    5748                                               nxl_on_file,nxr_on_file )
    5749 #endif
    5750 
    5751                    CASE ( 't_surf_window_v(2)' )
    5752 #if defined( __nopointer )         
    5753                       IF ( kk == 1 )  THEN
    5754                          IF ( .NOT.  ALLOCATED( t_surf_window_v(2)%t ) )              &
    5755                             ALLOCATE( t_surf_window_v(2)%t(1:surf_usm_v(2)%ns) )
    5756                          READ ( 13 )  tmp_surf_window_v(2)%t
    5757                       ENDIF
    5758                       CALL surface_restore_elements(                           &
    5759                                               t_surf_window_v(2)%t, tmp_surf_window_v(2)%t,  &
    5760                                               surf_usm_v(2)%start_index,       &
    5761                                               start_index_on_file,             &
    5762                                               end_index_on_file,               &
    5763                                               nxlc, nysc,                      &
    5764                                               nxlf, nxrf, nysf, nynf,          &
    5765                                               nys_on_file, nyn_on_file,        &
    5766                                               nxl_on_file,nxr_on_file )
    5767 #else                     
    5768                       IF ( kk == 1 )  THEN
    5769                          IF ( .NOT.  ALLOCATED( t_surf_window_v_1(2)%t ) )            &
    5770                             ALLOCATE( t_surf_window_v_1(2)%t(1:surf_usm_v(2)%ns) )
    5771                          READ ( 13 )  tmp_surf_window_v(2)%t
    5772                       ENDIF
    5773                       CALL surface_restore_elements(                           &
    5774                                               t_surf_window_v_1(2)%t, tmp_surf_window_v(2)%t,&
    5775                                               surf_usm_v(2)%start_index,       &
    5776                                               start_index_on_file,             &
    5777                                               end_index_on_file,               &
    5778                                               nxlc, nysc,                      &
    5779                                               nxlf, nxrf, nysf, nynf,          &
    5780                                               nys_on_file, nyn_on_file,        &
    5781                                               nxl_on_file,nxr_on_file )
    5782 #endif
    5783                          
    5784                    CASE ( 't_surf_window_v(3)' )
    5785 #if defined( __nopointer )   
    5786                       IF ( kk == 1 )  THEN
    5787                          IF ( .NOT.  ALLOCATED( t_surf_window_v(3)%t ) )              &
    5788                             ALLOCATE( t_surf_window_v(3)%t(1:surf_usm_v(3)%ns) )
    5789                          READ ( 13 )  tmp_surf_window_v(3)%t
    5790                       ENDIF
    5791                       CALL surface_restore_elements(                           &
    5792                                               t_surf_window_v(3)%t, tmp_surf_window_v(3)%t,  &
    5793                                               surf_usm_v(3)%start_index,       &
    5794                                               start_index_on_file,             &
    5795                                               end_index_on_file,               &
    5796                                               nxlc, nysc,                      &
    5797                                               nxlf, nxrf, nysf, nynf,          &
    5798                                               nys_on_file, nyn_on_file,        &
    5799                                               nxl_on_file,nxr_on_file )
    5800 #else                     
    5801                       IF ( kk == 1 )  THEN
    5802                          IF ( .NOT.  ALLOCATED( t_surf_window_v_1(3)%t ) )            &
    5803                             ALLOCATE( t_surf_window_v_1(3)%t(1:surf_usm_v(3)%ns) )
    5804                          READ ( 13 )  tmp_surf_window_v(3)%t
    5805                       ENDIF
    5806                       CALL surface_restore_elements(                           &
    5807                                               t_surf_window_v_1(3)%t, tmp_surf_window_v(3)%t,&
    5808                                               surf_usm_v(3)%start_index,       &
    5809                                               start_index_on_file,             &
    5810                                               end_index_on_file,               &
    5811                                               nxlc, nysc,                      &
    5812                                               nxlf, nxrf, nysf, nynf,          &
    5813                                               nys_on_file, nyn_on_file,        &
    5814                                               nxl_on_file,nxr_on_file )
    5815 #endif
    5816                    CASE ( 't_wall_h' )
    5817 #if defined( __nopointer )
    5818                       IF ( kk == 1 )  THEN
    5819                          IF ( .NOT.  ALLOCATED( t_wall_h ) )                   &
    5820                             ALLOCATE( t_wall_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    5821                          READ ( 13 )  tmp_wall_h
    5822                       ENDIF
    5823                       CALL surface_restore_elements(                           &
    5824                                               t_wall_h, tmp_wall_h,            &
    5825                                               surf_usm_h%start_index,          &
    5826                                               start_index_on_file,             &
    5827                                               end_index_on_file,               &
    5828                                               nxlc, nysc,                      &
    5829                                               nxlf, nxrf, nysf, nynf,          &
    5830                                               nys_on_file, nyn_on_file,        &
    5831                                               nxl_on_file,nxr_on_file )
    5832 #else
    5833                       IF ( kk == 1 )  THEN
    5834                          IF ( .NOT.  ALLOCATED( t_wall_h_1 ) )                 &
    5835                             ALLOCATE( t_wall_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    5836                          READ ( 13 )  tmp_wall_h
    5837                       ENDIF
    5838                       CALL surface_restore_elements(                           &
    5839                                               t_wall_h_1, tmp_wall_h,          &
    5840                                               surf_usm_h%start_index,          &
    5841                                               start_index_on_file,             &
    5842                                               end_index_on_file,               &
    5843                                               nxlc, nysc,                      &
    5844                                               nxlf, nxrf, nysf, nynf,          &
    5845                                               nys_on_file, nyn_on_file,        &
    5846                                               nxl_on_file,nxr_on_file )
    5847 #endif
    5848                    CASE ( 't_wall_v(0)' )
    5849 #if defined( __nopointer )
    5850                       IF ( kk == 1 )  THEN
    5851                          IF ( .NOT.  ALLOCATED( t_wall_v(0)%t ) )              &
    5852                             ALLOCATE( t_wall_v(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
    5853                          READ ( 13 )  tmp_wall_v(0)%t
    5854                       ENDIF
    5855                       CALL surface_restore_elements(                           &
    5856                                               t_wall_v(0)%t, tmp_wall_v(0)%t,  &
    5857                                               surf_usm_v(0)%start_index,       &
    5858                                               start_index_on_file,             &
    5859                                               end_index_on_file,               &
    5860                                               nxlc, nysc,                      &
    5861                                               nxlf, nxrf, nysf, nynf,          &
    5862                                               nys_on_file, nyn_on_file,        &
    5863                                               nxl_on_file,nxr_on_file )
    5864 #else
    5865                       IF ( kk == 1 )  THEN
    5866                          IF ( .NOT.  ALLOCATED( t_wall_v_1(0)%t ) )            &
    5867                             ALLOCATE( t_wall_v_1(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
    5868                          READ ( 13 )  tmp_wall_v(0)%t
    5869                       ENDIF
    5870                       CALL surface_restore_elements(                           &
    5871                                               t_wall_v_1(0)%t, tmp_wall_v(0)%t,&
    5872                                               surf_usm_v(0)%start_index,       &
    5873                                               start_index_on_file,             &
    5874                                               end_index_on_file,               &
    5875                                               nxlc, nysc,                      &
    5876                                               nxlf, nxrf, nysf, nynf,          &
    5877                                               nys_on_file, nyn_on_file,        &
    5878                                               nxl_on_file,nxr_on_file )
    5879 #endif
    5880                    CASE ( 't_wall_v(1)' )
    5881 #if defined( __nopointer )
    5882                       IF ( kk == 1 )  THEN
    5883                          IF ( .NOT.  ALLOCATED( t_wall_v(1)%t ) )              &
    5884                             ALLOCATE( t_wall_v(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
    5885                          READ ( 13 )  tmp_wall_v(1)%t
    5886                       ENDIF
    5887                       CALL surface_restore_elements(                           &
    5888                                               t_wall_v(1)%t, tmp_wall_v(1)%t,  &
    5889                                               surf_usm_v(1)%start_index,       &
    5890                                               start_index_on_file,             &
    5891                                               end_index_on_file ,              &
    5892                                               nxlc, nysc,                      &
    5893                                               nys_on_file, nyn_on_file,        &
    5894                                               nxl_on_file, nxr_on_file )
    5895 #else
    5896                       IF ( kk == 1 )  THEN
    5897                          IF ( .NOT.  ALLOCATED( t_wall_v_1(1)%t ) )            &
    5898                             ALLOCATE( t_wall_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
    5899                          READ ( 13 )  tmp_wall_v(1)%t
    5900                       ENDIF
    5901                       CALL surface_restore_elements(                           &
    5902                                               t_wall_v_1(1)%t, tmp_wall_v(1)%t,&
    5903                                               surf_usm_v(1)%start_index,       &
    5904                                               start_index_on_file,             &
    5905                                               end_index_on_file,               &
    5906                                               nxlc, nysc,                      &
    5907                                               nxlf, nxrf, nysf, nynf,          &
    5908                                               nys_on_file, nyn_on_file,        &
    5909                                               nxl_on_file,nxr_on_file )
    5910 #endif
    5911                    CASE ( 't_wall_v(2)' )
    5912 #if defined( __nopointer )
    5913                       IF ( kk == 1 )  THEN
    5914                          IF ( .NOT.  ALLOCATED( t_wall_v(2)%t ) )              &
    5915                             ALLOCATE( t_wall_v(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
    5916                          READ ( 13 )  tmp_wall_v(2)%t
    5917                       ENDIF
    5918                       CALL surface_restore_elements(                           &
    5919                                               t_wall_v(2)%t, tmp_wall_v(2)%t,  &
    5920                                               surf_usm_v(2)%start_index,       &
    5921                                               start_index_on_file,             &
    5922                                               end_index_on_file,               &
    5923                                               nxlc, nysc,                      &
    5924                                               nxlf, nxrf, nysf, nynf,          &
    5925                                               nys_on_file, nyn_on_file,        &
    5926                                               nxl_on_file,nxr_on_file )
    5927 #else
    5928                       IF ( kk == 1 )  THEN
    5929                          IF ( .NOT.  ALLOCATED( t_wall_v_1(2)%t ) )            &
    5930                             ALLOCATE( t_wall_v_1(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
    5931                          READ ( 13 )  tmp_wall_v(2)%t
    5932                       ENDIF
    5933                       CALL surface_restore_elements(                           &
    5934                                               t_wall_v_1(2)%t, tmp_wall_v(2)%t,&
    5935                                               surf_usm_v(2)%start_index,       &
    5936                                               start_index_on_file,             &
    5937                                               end_index_on_file ,               &
    5938                                               nxlc, nysc,                      &
    5939                                               nxlf, nxrf, nysf, nynf,          &
    5940                                               nys_on_file, nyn_on_file,        &
    5941                                               nxl_on_file,nxr_on_file )
    5942 #endif
    5943                    CASE ( 't_wall_v(3)' )
    5944 #if defined( __nopointer )
    5945                       IF ( kk == 1 )  THEN
    5946                          IF ( .NOT.  ALLOCATED( t_wall_v(3)%t ) )              &
    5947                             ALLOCATE( t_wall_v(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
    5948                          READ ( 13 )  tmp_wall_v(3)%t
    5949                       ENDIF
    5950                       CALL surface_restore_elements(                           &
    5951                                               t_wall_v(3)%t, tmp_wall_v(3)%t,  &
    5952                                               surf_usm_v(3)%start_index,       &
    5953                                               start_index_on_file,             &
    5954                                               end_index_on_file,               &
    5955                                               nxlc, nysc,                      &
    5956                                               nxlf, nxrf, nysf, nynf,          &
    5957                                               nys_on_file, nyn_on_file,        &
    5958                                               nxl_on_file,nxr_on_file )
    5959 #else
    5960                       IF ( kk == 1 )  THEN
    5961                          IF ( .NOT.  ALLOCATED( t_wall_v_1(3)%t ) )            &
    5962                             ALLOCATE( t_wall_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
    5963                          READ ( 13 )  tmp_wall_v(3)%t
    5964                       ENDIF
    5965                       CALL surface_restore_elements(                           &
    5966                                               t_wall_v_1(3)%t, tmp_wall_v(3)%t,&
    5967                                               surf_usm_v(3)%start_index,       &
    5968                                               start_index_on_file,             &
    5969                                               end_index_on_file,               &
    5970                                               nxlc, nysc,                      &
    5971                                               nxlf, nxrf, nysf, nynf,          &
    5972                                               nys_on_file, nyn_on_file,        &
    5973                                               nxl_on_file,nxr_on_file )
    5974 #endif
    5975                    CASE ( 't_green_h' )
    5976 #if defined( __nopointer )
    5977                       IF ( kk == 1 )  THEN
    5978                          IF ( .NOT.  ALLOCATED( t_green_h ) )                   &
    5979                             ALLOCATE( t_green_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    5980                          READ ( 13 )  tmp_green_h
    5981                       ENDIF
    5982                       CALL surface_restore_elements(                           &
    5983                                               t_green_h, tmp_green_h,            &
    5984                                               surf_usm_h%start_index,          &
    5985                                               start_index_on_file,             &
    5986                                               end_index_on_file,               &
    5987                                               nxlc, nysc,                      &
    5988                                               nxlf, nxrf, nysf, nynf,          &
    5989                                               nys_on_file, nyn_on_file,        &
    5990                                               nxl_on_file,nxr_on_file )
    5991 #else
    5992                       IF ( kk == 1 )  THEN
    5993                          IF ( .NOT.  ALLOCATED( t_green_h_1 ) )                 &
    5994                             ALLOCATE( t_green_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    5995                          READ ( 13 )  tmp_green_h
    5996                       ENDIF
    5997                       CALL surface_restore_elements(                           &
    5998                                               t_green_h_1, tmp_green_h,          &
    5999                                               surf_usm_h%start_index,          &
    6000                                               start_index_on_file,             &
    6001                                               end_index_on_file,               &
    6002                                               nxlc, nysc,                      &
    6003                                               nxlf, nxrf, nysf, nynf,          &
    6004                                               nys_on_file, nyn_on_file,        &
    6005                                               nxl_on_file,nxr_on_file )
    6006 #endif
    6007                    CASE ( 't_green_v(0)' )
    6008 #if defined( __nopointer )
    6009                       IF ( kk == 1 )  THEN
    6010                          IF ( .NOT.  ALLOCATED( t_green_v(0)%t ) )              &
    6011                             ALLOCATE( t_green_v(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
    6012                          READ ( 13 )  tmp_green_v(0)%t
    6013                       ENDIF
    6014                       CALL surface_restore_elements(                           &
    6015                                               t_green_v(0)%t, tmp_green_v(0)%t,  &
    6016                                               surf_usm_v(0)%start_index,       &
    6017                                               start_index_on_file,             &
    6018                                               end_index_on_file,               &
    6019                                               nxlc, nysc,                      &
    6020                                               nxlf, nxrf, nysf, nynf,          &
    6021                                               nys_on_file, nyn_on_file,        &
    6022                                               nxl_on_file,nxr_on_file )
    6023 #else
    6024                       IF ( kk == 1 )  THEN
    6025                          IF ( .NOT.  ALLOCATED( t_green_v_1(0)%t ) )            &
    6026                             ALLOCATE( t_green_v_1(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
    6027                          READ ( 13 )  tmp_green_v(0)%t
    6028                       ENDIF
    6029                       CALL surface_restore_elements(                           &
    6030                                               t_green_v_1(0)%t, tmp_green_v(0)%t,&
    6031                                               surf_usm_v(0)%start_index,       &
    6032                                               start_index_on_file,             &
    6033                                               end_index_on_file,               &
    6034                                               nxlc, nysc,                      &
    6035                                               nxlf, nxrf, nysf, nynf,          &
    6036                                               nys_on_file, nyn_on_file,        &
    6037                                               nxl_on_file,nxr_on_file )
    6038 #endif
    6039                    CASE ( 't_green_v(1)' )
    6040 #if defined( __nopointer )
    6041                       IF ( kk == 1 )  THEN
    6042                          IF ( .NOT.  ALLOCATED( t_green_v(1)%t ) )              &
    6043                             ALLOCATE( t_green_v(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
    6044                          READ ( 13 )  tmp_green_v(1)%t
    6045                       ENDIF
    6046                       CALL surface_restore_elements(                           &
    6047                                               t_green_v(1)%t, tmp_green_v(1)%t,  &
    6048                                               surf_usm_v(1)%start_index,       &
    6049                                               start_index_on_file,             &
    6050                                               end_index_on_file ,              &
    6051                                               nxlc, nysc,                      &
    6052                                               nys_on_file, nyn_on_file,        &
    6053                                               nxl_on_file,nxr_on_file )
    6054 #else
    6055                       IF ( kk == 1 )  THEN
    6056                          IF ( .NOT.  ALLOCATED( t_green_v_1(1)%t ) )            &
    6057                             ALLOCATE( t_green_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
    6058                          READ ( 13 )  tmp_green_v(1)%t
    6059                       ENDIF
    6060                       CALL surface_restore_elements(                           &
    6061                                               t_green_v_1(1)%t, tmp_green_v(1)%t,&
    6062                                               surf_usm_v(1)%start_index,       &
    6063                                               start_index_on_file,             &
    6064                                               end_index_on_file,               &
    6065                                               nxlc, nysc,                      &
    6066                                               nxlf, nxrf, nysf, nynf,          &
    6067                                               nys_on_file, nyn_on_file,        &
    6068                                               nxl_on_file,nxr_on_file )
    6069 #endif
    6070                    CASE ( 't_green_v(2)' )
    6071 #if defined( __nopointer )
    6072                       IF ( kk == 1 )  THEN
    6073                          IF ( .NOT.  ALLOCATED( t_green_v(2)%t ) )              &
    6074                             ALLOCATE( t_green_v(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
    6075                          READ ( 13 )  tmp_green_v(2)%t
    6076                       ENDIF
    6077                       CALL surface_restore_elements(                           &
    6078                                               t_green_v(2)%t, tmp_green_v(2)%t,  &
    6079                                               surf_usm_v(2)%start_index,       &
    6080                                               start_index_on_file,             &
    6081                                               end_index_on_file,               &
    6082                                               nxlc, nysc,                      &
    6083                                               nxlf, nxrf, nysf, nynf,          &
    6084                                               nys_on_file, nyn_on_file,        &
    6085                                               nxl_on_file,nxr_on_file )
    6086 #else
    6087                       IF ( kk == 1 )  THEN
    6088                          IF ( .NOT.  ALLOCATED( t_green_v_1(2)%t ) )            &
    6089                             ALLOCATE( t_green_v_1(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
    6090                          READ ( 13 )  tmp_green_v(2)%t
    6091                       ENDIF
    6092                       CALL surface_restore_elements(                           &
    6093                                               t_green_v_1(2)%t, tmp_green_v(2)%t,&
    6094                                               surf_usm_v(2)%start_index,       &
    6095                                               start_index_on_file,             &
    6096                                               end_index_on_file ,               &
    6097                                               nxlc, nysc,                      &
    6098                                               nxlf, nxrf, nysf, nynf,          &
    6099                                               nys_on_file, nyn_on_file,        &
    6100                                               nxl_on_file,nxr_on_file )
    6101 #endif
    6102                    CASE ( 't_green_v(3)' )
    6103 #if defined( __nopointer )
    6104                       IF ( kk == 1 )  THEN
    6105                          IF ( .NOT.  ALLOCATED( t_green_v(3)%t ) )              &
    6106                             ALLOCATE( t_green_v(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
    6107                          READ ( 13 )  tmp_green_v(3)%t
    6108                       ENDIF
    6109                       CALL surface_restore_elements(                           &
    6110                                               t_green_v(3)%t, tmp_green_v(3)%t,  &
    6111                                               surf_usm_v(3)%start_index,       &
    6112                                               start_index_on_file,             &
    6113                                               end_index_on_file,               &
    6114                                               nxlc, nysc,                      &
    6115                                               nxlf, nxrf, nysf, nynf,          &
    6116                                               nys_on_file, nyn_on_file,        &
    6117                                               nxl_on_file,nxr_on_file )
    6118 #else
    6119                       IF ( kk == 1 )  THEN
    6120                          IF ( .NOT.  ALLOCATED( t_green_v_1(3)%t ) )            &
    6121                             ALLOCATE( t_green_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
    6122                          READ ( 13 )  tmp_green_v(3)%t
    6123                       ENDIF
    6124                       CALL surface_restore_elements(                           &
    6125                                               t_green_v_1(3)%t, tmp_green_v(3)%t,&
    6126                                               surf_usm_v(3)%start_index,       &
    6127                                               start_index_on_file,             &
    6128                                               end_index_on_file,               &
    6129                                               nxlc, nysc,                      &
    6130                                               nxlf, nxrf, nysf, nynf,          &
    6131                                               nys_on_file, nyn_on_file,        &
    6132                                               nxl_on_file,nxr_on_file )
    6133 #endif
    6134                    CASE ( 't_window_h' )
    6135 #if defined( __nopointer )
    6136                       IF ( kk == 1 )  THEN
    6137                          IF ( .NOT.  ALLOCATED( t_window_h ) )                   &
    6138                             ALLOCATE( t_window_h(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    6139                          READ ( 13 )  tmp_window_h
    6140                       ENDIF
    6141                       CALL surface_restore_elements(                           &
    6142                                               t_window_h, tmp_window_h,            &
    6143                                               surf_usm_h%start_index,          &
    6144                                               start_index_on_file,             &
    6145                                               end_index_on_file,               &
    6146                                               nxlc, nysc,                      &
    6147                                               nxlf, nxrf, nysf, nynf,          &
    6148                                               nys_on_file, nyn_on_file,        &
    6149                                               nxl_on_file,nxr_on_file )
    6150 #else
    6151                       IF ( kk == 1 )  THEN
    6152                          IF ( .NOT.  ALLOCATED( t_window_h_1 ) )                 &
    6153                             ALLOCATE( t_window_h_1(nzb_wall:nzt_wall+1,1:surf_usm_h%ns) )
    6154                          READ ( 13 )  tmp_window_h
    6155                       ENDIF
    6156                       CALL surface_restore_elements(                           &
    6157                                               t_window_h_1, tmp_window_h,          &
    6158                                               surf_usm_h%start_index,          &
    6159                                               start_index_on_file,             &
    6160                                               end_index_on_file,               &
    6161                                               nxlc, nysc,                      &
    6162                                               nxlf, nxrf, nysf, nynf,          &
    6163                                               nys_on_file, nyn_on_file,        &
    6164                                               nxl_on_file, nxr_on_file )
    6165 #endif
    6166                    CASE ( 't_window_v(0)' )
    6167 #if defined( __nopointer )
    6168                       IF ( kk == 1 )  THEN
    6169                          IF ( .NOT.  ALLOCATED( t_window_v(0)%t ) )              &
    6170                             ALLOCATE( t_window_v(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
    6171                          READ ( 13 )  tmp_window_v(0)%t
    6172                       ENDIF
    6173                       CALL surface_restore_elements(                           &
    6174                                               t_window_v(0)%t, tmp_window_v(0)%t,  &
    6175                                               surf_usm_v(0)%start_index,       &
    6176                                               start_index_on_file,             &
    6177                                               end_index_on_file,               &
    6178                                               nxlc, nysc,                      &
    6179                                               nxlf, nxrf, nysf, nynf,          &
    6180                                               nys_on_file, nyn_on_file,        &
    6181                                               nxl_on_file, nxr_on_file )
    6182 #else
    6183                       IF ( kk == 1 )  THEN
    6184                          IF ( .NOT.  ALLOCATED( t_window_v_1(0)%t ) )            &
    6185                             ALLOCATE( t_window_v_1(0)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(0)%ns) )
    6186                          READ ( 13 )  tmp_window_v(0)%t
    6187                       ENDIF
    6188                       CALL surface_restore_elements(                           &
    6189                                               t_window_v_1(0)%t, tmp_window_v(0)%t,&
    6190                                               surf_usm_v(0)%start_index,       &
    6191                                               start_index_on_file,             &
    6192                                               end_index_on_file,               &
    6193                                               nxlc, nysc,                      &
    6194                                               nxlf, nxrf, nysf, nynf,          &
    6195                                               nys_on_file, nyn_on_file,        &
    6196                                               nxl_on_file,nxr_on_file )
    6197 #endif
    6198                    CASE ( 't_window_v(1)' )
    6199 #if defined( __nopointer )
    6200                       IF ( kk == 1 )  THEN
    6201                          IF ( .NOT.  ALLOCATED( t_window_v(1)%t ) )              &
    6202                             ALLOCATE( t_window_v(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
    6203                          READ ( 13 )  tmp_window_v(1)%t
    6204                       ENDIF
    6205                       CALL surface_restore_elements(                           &
    6206                                               t_window_v(1)%t, tmp_window_v(1)%t,  &
    6207                                               surf_usm_v(1)%start_index,       &
    6208                                               start_index_on_file,             &
    6209                                               end_index_on_file ,              &
    6210                                               nxlc, nysc,                      &
    6211                                               nys_on_file, nyn_on_file,        &
    6212                                               nxl_on_file, nxr_on_file )
    6213 #else
    6214                       IF ( kk == 1 )  THEN
    6215                          IF ( .NOT.  ALLOCATED( t_window_v_1(1)%t ) )            &
    6216                             ALLOCATE( t_window_v_1(1)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(1)%ns) )
    6217                          READ ( 13 )  tmp_window_v(1)%t
    6218                       ENDIF
    6219                       CALL surface_restore_elements(                           &
    6220                                               t_window_v_1(1)%t, tmp_window_v(1)%t,&
    6221                                               surf_usm_v(1)%start_index,       &
    6222                                               start_index_on_file,             &
    6223                                               end_index_on_file,               &
    6224                                               nxlc, nysc,                      &
    6225                                               nxlf, nxrf, nysf, nynf,          &
    6226                                               nys_on_file, nyn_on_file,        &
    6227                                               nxl_on_file,nxr_on_file )
    6228 #endif
    6229                    CASE ( 't_window_v(2)' )
    6230 #if defined( __nopointer )
    6231                       IF ( kk == 1 )  THEN
    6232                          IF ( .NOT.  ALLOCATED( t_window_v(2)%t ) )              &
    6233                             ALLOCATE( t_window_v(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
    6234                          READ ( 13 )  tmp_window_v(2)%t
    6235                       ENDIF
    6236                       CALL surface_restore_elements(                           &
    6237                                               t_window_v(2)%t, tmp_window_v(2)%t,  &
    6238                                               surf_usm_v(2)%start_index,       &
    6239                                               start_index_on_file,             &
    6240                                               end_index_on_file,               &
    6241                                               nxlc, nysc,                      &
    6242                                               nxlf, nxrf, nysf, nynf,          &
    6243                                               nys_on_file, nyn_on_file,        &
    6244                                               nxl_on_file,nxr_on_file )
    6245 #else
    6246                       IF ( kk == 1 )  THEN
    6247                          IF ( .NOT.  ALLOCATED( t_window_v_1(2)%t ) )            &
    6248                             ALLOCATE( t_window_v_1(2)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(2)%ns) )
    6249                          READ ( 13 )  tmp_window_v(2)%t
    6250                       ENDIF
    6251                       CALL surface_restore_elements(                           &
    6252                                               t_window_v_1(2)%t, tmp_window_v(2)%t,&
    6253                                               surf_usm_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 #endif
    6261                    CASE ( 't_window_v(3)' )
    6262 #if defined( __nopointer )
    6263                       IF ( kk == 1 )  THEN
    6264                          IF ( .NOT.  ALLOCATED( t_window_v(3)%t ) )              &
    6265                             ALLOCATE( t_window_v(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
    6266                          READ ( 13 )  tmp_window_v(3)%t
    6267                       ENDIF
    6268                       CALL surface_restore_elements(                           &
    6269                                               t_window_v(3)%t, tmp_window_v(3)%t,  &
    6270                                               surf_usm_v(3)%start_index,       &
    6271                                               start_index_on_file,             &
    6272                                               end_index_on_file,               &
    6273                                               nxlc, nysc,                      &
    6274                                               nxlf, nxrf, nysf, nynf,          &
    6275                                               nys_on_file, nyn_on_file,        &
    6276                                               nxl_on_file,nxr_on_file )
    6277 #else
    6278                       IF ( kk == 1 )  THEN
    6279                          IF ( .NOT.  ALLOCATED( t_window_v_1(3)%t ) )            &
    6280                             ALLOCATE( t_window_v_1(3)%t(nzb_wall:nzt_wall+1,1:surf_usm_v(3)%ns) )
    6281                          READ ( 13 )  tmp_window_v(3)%t
    6282                       ENDIF
    6283                       CALL surface_restore_elements(                           &
    6284                                               t_window_v_1(3)%t, tmp_window_v(3)%t,&
    6285                                               surf_usm_v(3)%start_index,       &
    6286                                               start_index_on_file,             &
    6287                                               end_index_on_file,               &
    6288                                               nxlc, nysc,                      &
    6289                                               nxlf, nxrf, nysf, nynf,          &
    6290                                               nys_on_file, nyn_on_file,        &
    6291                                               nxl_on_file,nxr_on_file )
    6292 #endif
    6293                    CASE DEFAULT
    6294                       WRITE ( message_string, * )  'unknown variable named "', &
    6295                                         TRIM( field_chr ), '" found in',       &
    6296                                         '&data from prior run on PE ', myid
    6297                       CALL message( 'user_read_restart_data', 'UI0012', 1, 2, 0, 6, 0 )
    6298 
    6299                 END SELECT
    6300 
    6301              ENDDO
    6302 
    6303              READ ( 13 )  field_chr
    6304 
    6305           ENDDO
    6306 
    6307        ENDIF
    6308        
    6309     END SUBROUTINE usm_read_restart_data
     6388    END SUBROUTINE usm_rrd_local
    63106389   
    63116390
     
    73567435! Description:
    73577436! ------------
    7358 !> Subroutine writes t_surf and t_wall data into restart files
     7437!> Subroutine writes t_surf and t_wall data into restart files. It is necessary
     7438!> to write start_index and end_index several times
    73597439!kanani: Renamed this routine according to corresponging routines in PALM
    7360 !kanani: Modified the routine to match write_var_list, from where usm_write_restart_data
     7440!kanani: Modified the routine to match wrd_global, from where usm_wrd_local
    73617441!        shall be called in the future. This part has not been tested yet. (see virtual_flight_mod)
    73627442!        Also, I had some trouble with the allocation of t_surf, since this is a pointer.
    73637443!        So, I added some directives here.
    73647444!------------------------------------------------------------------------------!
    7365     SUBROUTINE usm_write_restart_data
     7445    SUBROUTINE usm_wrd_local
     7446
    73667447   
    73677448       IMPLICIT NONE
     
    73697450       CHARACTER(LEN=1) ::  dum     !< dummy string to create output-variable name 
    73707451       INTEGER(iwp)     ::  l       !< index surface type orientation
     7452
     7453       CALL wrd_write_string( 'ns_h_on_file_usm' )
     7454       WRITE ( 14 )  surf_usm_h%ns
     7455
     7456       CALL wrd_write_string( 'ns_v_on_file_usm' )
     7457       WRITE ( 14 )  surf_usm_v(0:3)%ns
     7458
     7459       CALL wrd_write_string( 'usm_start_index_h' )
     7460       WRITE ( 14 )  surf_usm_h%start_index
     7461
     7462       CALL wrd_write_string( 'usm_end_index_h' )
     7463       WRITE ( 14 )  surf_usm_h%end_index
     7464
     7465       CALL wrd_write_string( 't_surf_h' )
     7466       WRITE ( 14 )  t_surf_h
     7467
     7468       CALL wrd_write_string( 't_surf_window_h' )
     7469       WRITE ( 14 )  t_surf_window_h
     7470
     7471       CALL wrd_write_string( 't_surf_green_h' )
     7472       WRITE ( 14 )  t_surf_green_h
     7473
     7474       DO  l = 0, 3
     7475
     7476          CALL wrd_write_string( 'usm_start_index_v' )
     7477          WRITE ( 14 )  surf_usm_v(l)%start_index
     7478
     7479          CALL wrd_write_string( 'usm_end_index_v' )
     7480          WRITE ( 14 )  surf_usm_v(l)%end_index
     7481
     7482          WRITE( dum, '(I1)')  l         
     7483
     7484          CALL wrd_write_string( 't_surf_v(' // dum // ')' )
     7485          WRITE ( 14 )  t_surf_v(l)%t
     7486
     7487          CALL wrd_write_string( 't_surf_window_v(' // dum // ')' )
     7488          WRITE ( 14 ) t_surf_window_v(l)%t     
     7489
     7490          CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
     7491          WRITE ( 14 ) t_surf_green_v(l)%t   
     7492         
     7493       ENDDO
     7494
     7495       CALL wrd_write_string( 'usm_start_index_h' )
     7496       WRITE ( 14 )  surf_usm_h%start_index
     7497
     7498       CALL wrd_write_string( 'usm_end_index_h' )
     7499       WRITE ( 14 )  surf_usm_h%end_index
     7500
     7501       CALL wrd_write_string( 't_wall_h' )
     7502       WRITE ( 14 )  t_wall_h
     7503
     7504       CALL wrd_write_string( 't_window_h' )
     7505       WRITE ( 14 )  t_window_h
     7506
     7507       CALL wrd_write_string( 't_green_h' )
     7508       WRITE ( 14 )  t_green_h
     7509
     7510       DO  l = 0, 3
     7511
     7512          CALL wrd_write_string( 'usm_start_index_v' )
     7513          WRITE ( 14 )  surf_usm_v(l)%start_index
     7514
     7515          CALL wrd_write_string( 'usm_end_index_v' )
     7516          WRITE ( 14 )  surf_usm_v(l)%end_index
     7517
     7518          WRITE( dum, '(I1)')  l     
     7519
     7520          CALL wrd_write_string( 't_wall_v(' // dum // ')' )
     7521          WRITE ( 14 )  t_wall_v(l)%t
     7522
     7523          CALL wrd_write_string( 't_window_v(' // dum // ')' )
     7524          WRITE ( 14 )  t_window_v(l)%t
     7525
     7526          CALL wrd_write_string( 't_green_v(' // dum // ')' )
     7527          WRITE ( 14 )  t_green_v(l)%t
    73717528       
    7372        WRITE ( 14 ) 'ns_h_on_file_usm              '
    7373        WRITE ( 14 ) surf_usm_h%ns
    7374        WRITE ( 14 ) 'ns_v_on_file_usm              '
    7375        WRITE ( 14 ) surf_usm_v(0:3)%ns
     7529       ENDDO
     7530
    73767531       
    7377        WRITE ( 14 ) 'usm_start_index_h             '
    7378        WRITE ( 14 ) surf_usm_h%start_index
    7379        WRITE ( 14 ) 'usm_end_index_h               '
    7380        WRITE ( 14 ) surf_usm_h%end_index
    7381        WRITE ( 14 ) 't_surf_h                      '
    7382        WRITE ( 14 ) t_surf_h
    7383        WRITE ( 14 ) 't_surf_window_h               '
    7384        WRITE ( 14 ) t_surf_window_h
    7385        WRITE ( 14 ) 't_surf_green_h                '
    7386        WRITE ( 14 ) t_surf_green_h
    7387        
    7388        DO  l = 0, 3
    7389           WRITE ( 14 ) 'usm_start_index_v             '
    7390           WRITE ( 14 ) surf_usm_v(l)%start_index
    7391           WRITE ( 14 ) 'usm_end_index_v               '
    7392           WRITE ( 14 ) surf_usm_v(l)%end_index
    7393           WRITE( dum, '(I1)')  l         
    7394           WRITE ( 14 ) 't_surf_v(' // dum // ')                   '
    7395           WRITE ( 14 ) t_surf_v(l)%t         
    7396           WRITE ( 14 ) 't_surf_window_v(' // dum // ')            '
    7397           WRITE ( 14 ) t_surf_window_v(l)%t         
    7398           WRITE ( 14 ) 't_surf_green_v(' // dum // ')             '
    7399           WRITE ( 14 ) t_surf_green_v(l)%t         
    7400        ENDDO
    7401 
    7402        WRITE ( 14 ) 'usm_start_index_h             '
    7403        WRITE ( 14 ) surf_usm_h%start_index
    7404        WRITE ( 14 ) 'usm_end_index_h               '
    7405        WRITE ( 14 ) surf_usm_h%end_index
    7406        WRITE ( 14 ) 't_wall_h                      '
    7407        WRITE ( 14 ) t_wall_h
    7408        WRITE ( 14 ) 't_window_h                    '
    7409        WRITE ( 14 ) t_window_h
    7410        WRITE ( 14 ) 't_green_h                     '
    7411        WRITE ( 14 ) t_green_h
    7412        DO  l = 0, 3
    7413           WRITE ( 14 ) 'usm_start_index_v             '
    7414           WRITE ( 14 ) surf_usm_v(l)%start_index
    7415           WRITE ( 14 ) 'usm_end_index_v               '
    7416           WRITE ( 14 ) surf_usm_v(l)%end_index
    7417           WRITE( dum, '(I1)')  l         
    7418           WRITE ( 14 )  't_wall_v(' // dum // ')                   '
    7419           WRITE ( 14 )  t_wall_v(l)%t         
    7420           WRITE ( 14 )  't_window_v(' // dum // ')                 '
    7421           WRITE ( 14 )  t_window_v(l)%t         
    7422           WRITE ( 14 )  't_green_v(' // dum // ')                  '
    7423           WRITE ( 14 )  t_green_v(l)%t         
    7424        ENDDO
    7425 
    7426        WRITE ( 14 )  '*** end usm ***               '
    7427        
    7428     END SUBROUTINE usm_write_restart_data
     7532    END SUBROUTINE usm_wrd_local
    74297533
    74307534!
  • palm/trunk/SOURCE/user_last_actions.f90

    r2718 r2894  
    2525! -----------------
    2626! $Id$
     27! Writing of user-defined restart data will be done in an own module called
     28! user_write_restart_data_mod
     29!
     30! 2718 2018-01-02 08:49:38Z suehring
    2731! Corrected "Former revisions" section
    2832!
     
    6670
    6771!
    68 !-- Here the user-defined actions at the end of a job follow.
    69 !-- Sample for user-defined output:
    70     IF ( write_binary )  THEN
    71 !       IF ( ALLOCATED( u2_av ) )  THEN
    72 !          WRITE ( 14 )  'u2_av               ';  WRITE ( 14 )  u2_av
    73 !       ENDIF
     72!-- Here the user-defined actions at the end of a job might follow.
    7473
    75        WRITE ( 14 )  '*** end user ***    '
    76 
    77     ENDIF
    7874
    7975 END SUBROUTINE user_last_actions
  • palm/trunk/SOURCE/user_module.f90

    r2718 r2894  
    2525! -----------------
    2626! $Id$
     27! An example for a user defined global variable has been added (Giersch)
     28!
     29! 2718 2018-01-02 08:49:38Z suehring
    2730! Corrected "Former revisions" section
    2831!
     
    8285!
    8386!-- Sample for user-defined output
     87!    REAL(wp) :: global_parameter !< user defined global parameter
     88!
    8489!    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u2       !< user defined array
    8590!    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u2_av    !< user defined array
  • palm/trunk/SOURCE/uv_exposure_model_mod.f90

    r2718 r2894  
    2525! -----------------
    2626! $Id$
     27! Routine for skipping global restart data has been removed, uvem_last_actions
     28! has been renamed to uvem_wrd_global and uvem_read_restart_data has been
     29! renamed to uvem_rrd_global, variable named found has been introduced for
     30! checking if restart data was found, reading of restart strings has been moved
     31! completely to read_restart_data_mod, marker *** end new module *** has been
     32! removed, strings and their respective lengths are written out and read now
     33! in case of restart runs to get rid of prescribed character lengths, CASE
     34! DEFAULT was added if restart data is read
     35!
     36! 2848 2018-03-05 10:11:18Z Giersch
    2737! Initial revision
    2838!
     
    199209! !
    200210! !-- Writing of binary output for restart runs  !!! renaming?!
    201 !     INTERFACE uvem_last_actions
    202 !        MODULE PROCEDURE uvem_last_actions
    203 !     END INTERFACE uvem_last_actions
     211!     INTERFACE uvem_wrd_global
     212!        MODULE PROCEDURE uvem_wrd_global
     213!     END INTERFACE uvem_wrd_global
    204214!     
    205215!
     
    211221! !
    212222! !-- Reading of parameters for restart runs
    213 !     INTERFACE uvem_read_restart_data
    214 !        MODULE PROCEDURE uvem_read_restart_data
    215 !     END INTERFACE uvem_read_restart_data
    216 !
    217 ! !
    218 ! !-- Writing of parameters for restart runs !!! renaming?!
    219 !     INTERFACE uvem_skip_var_list
    220 !        MODULE PROCEDURE uvem_skip_var_list
    221 !     END INTERFACE uvem_skip_var_list
     223!     INTERFACE uvem_rrd_global
     224!        MODULE PROCEDURE uvem_rrd_global
     225!     END INTERFACE uvem_rrd_global
    222226!
    223227! !
     
    860864! ! Description:
    861865! ! ------------
    862 ! !> This routine reads the respective restart data.
     866! !> This routine reads the global restart data.
    863867! !------------------------------------------------------------------------------!
    864 !  SUBROUTINE uvem_read_restart_data 
    865 !
    866 !     
     868!  SUBROUTINE uvem_rrd_global
     869!
     870!
     871!     USE control_parameters,                                                    &
     872!         ONLY: length, restart_string
     873!
     874!
    867875!     IMPLICIT NONE
    868 !       
    869 !     CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
     876!
     877!     LOGICAL, INTENT(OUT)  ::  found
     878!
     879!
     880!     found = .TRUE.
    870881!       
    871882!       
    872 !     READ ( 13 )  variable_chr
    873 !     DO  WHILE ( TRIM( variable_chr ) /= '*** end new module ***' )
    874 !
    875 !        SELECT CASE ( TRIM( variable_chr ) )
    876 !           
    877 ! !           CASE ( 'param1' )
    878 ! !              IF ( .NOT. ALLOCATED( param1 ) )  ALLOCATE( param1(...) )
    879 ! !              READ ( 13 )  param1   
    880 !           
    881 !        END SELECT
    882 !           
    883 !        READ ( 13 )  variable_chr
    884 !           
    885 !     ENDDO
    886 !
    887 !  END SUBROUTINE uvem_read_restart_data 
     883!     SELECT CASE ( restart_string(1:length) )
     884!
     885!       CASE ( 'param1' )
     886!          READ ( 13 )  param1
     887!
     888!        CASE DEFAULT
     889!
     890!          found = .FALSE.   
     891!
     892!     END SELECT
     893!
     894!  END SUBROUTINE uvem_rrd_global 
    888895   
    889896
     
    891898! ! Description:
    892899! ! ------------
    893 ! !> This routine writes the respective restart data.
     900! !> This routine writes the global restart data.
    894901! !------------------------------------------------------------------------------!
    895 !  SUBROUTINE uvem_last_actions
    896 !
     902!  SUBROUTINE uvem_wrd_global
     903!
     904!
    897905!     IMPLICIT NONE
     906!
     907!
     908!     CALL wrd_write_string( 'param1' )
     909!     WRITE ( 14 )  param1         
     910!
    898911!       
    899 ! !      WRITE ( 14 )  'param1                            '
    900 ! !      WRITE ( 14 )  param1       
    901 !
    902912!       
    903 !     WRITE ( 14 )  '*** end new module ***            '
    904 !       
    905 !  END SUBROUTINE uvem_last_actions   
    906 
    907 
    908 ! !------------------------------------------------------------------------------!
    909 ! ! Description:
    910 ! ! ------------
    911 ! !> Skipping of parameters from restart file (binary format).
    912 ! !------------------------------------------------------------------------------!
    913 !  SUBROUTINE uvem_skip_var_list 
    914 !           
    915 !     IMPLICIT NONE
    916 !       
    917 !     CHARACTER (LEN=1)  ::  param2         !<
    918 !     CHARACTER (LEN=30) ::  variable_chr   !<
    919 !       
    920 !     READ ( 13 )  variable_chr
    921 !     DO  WHILE ( TRIM( variable_chr ) /= '*** end new module ***' )
    922 !        READ ( 13 )  param2
    923 !     ENDDO   
    924 !       
    925 !  END SUBROUTINE uvem_skip_var_list
     913!  END SUBROUTINE uvem_wrd_global   
    926914
    927915
  • palm/trunk/SOURCE/virtual_flight_mod.f90

    r2776 r2894  
    2525! -----------------
    2626! $Id$
     27! variable named found has been introduced for checking if restart data was
     28! found, reading of restart strings has been moved completely to
     29! read_restart_data_mod, virtual_flight_prerun flag has been removed, redundant
     30! skipping function has been removed, flight_read/write_restart_data
     31! have been renamed to flight_r/wrd_global, flight_rrd_global is called in
     32! read_restart_data_mod now, marker *** end flight *** was removed, strings and
     33! their respective lengths are written out and read now in case of restart runs
     34! to get rid of prescribed character lengths, CASE DEFAULT was added if restart
     35! data is read
     36!
     37! 2872 2018-03-12 10:05:47Z Giersch
    2738! virutal_flight_prerun flag is used to define if module
    2839! related parameters were outputted as restart data
     
    6677 
    6778    USE control_parameters,                                                    &
    68         ONLY:  fl_max, num_leg, num_var_fl, num_var_fl_user, virtual_flight,   &
    69                virtual_flight_prerun
     79        ONLY:  fl_max, num_leg, num_var_fl, num_var_fl_user, virtual_flight
    7080 
    7181    USE kinds
     
    134144       MODULE PROCEDURE flight_measurement
    135145    END INTERFACE flight_measurement
    136 
    137     INTERFACE flight_skip_var_list
    138        MODULE PROCEDURE flight_skip_var_list
    139     END INTERFACE flight_skip_var_list
    140    
    141     INTERFACE flight_read_restart_data
    142        MODULE PROCEDURE flight_read_restart_data
    143     END INTERFACE flight_read_restart_data
    144    
    145     INTERFACE flight_write_restart_data
    146        MODULE PROCEDURE flight_write_restart_data
    147     END INTERFACE flight_write_restart_data
     146   
     147    INTERFACE flight_rrd_global
     148       MODULE PROCEDURE flight_rrd_global
     149    END INTERFACE flight_rrd_global
     150   
     151    INTERFACE flight_wrd_global
     152       MODULE PROCEDURE flight_wrd_global
     153    END INTERFACE flight_wrd_global
    148154
    149155!
     
    153159!-- Public interfaces
    154160    PUBLIC flight_init, flight_header, flight_parin, flight_measurement,       &
    155            flight_write_restart_data, flight_skip_var_list                    
     161           flight_wrd_global, flight_rrd_global                   
    156162!
    157163!-- Public variables
     
    238244       virtual_flight = .TRUE.
    239245
    240        IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
    241           CALL flight_read_restart_data
    242        ENDIF
    243246
    244247 10    CONTINUE
     
    879882
    880883    END SUBROUTINE flight_check_parameters
    881 
    882 !------------------------------------------------------------------------------!
    883 ! Description:
    884 ! ------------
    885 !> Skipping the flight-module variables from restart-file (binary format).
    886 !------------------------------------------------------------------------------!
    887    SUBROUTINE flight_skip_var_list
    888884       
    889       IMPLICIT NONE
    890            
    891       CHARACTER (LEN=1)  ::  cdum
    892       CHARACTER (LEN=30) ::  variable_chr
    893            
    894       READ ( 13 )  variable_chr
    895 
    896       DO  WHILE ( TRIM( variable_chr ) /= '*** end flight ***' )
    897 
    898          READ ( 13 )  cdum
    899          READ ( 13 )  variable_chr
    900 
    901       ENDDO   
    902            
    903    END SUBROUTINE flight_skip_var_list
    904        
    905    
     885
    906886!------------------------------------------------------------------------------!
    907887! Description:
     
    909889!> This routine reads the respective restart data.
    910890!------------------------------------------------------------------------------!
    911     SUBROUTINE flight_read_restart_data 
     891    SUBROUTINE flight_rrd_global( found ) 
     892
     893
     894       USE control_parameters,                                                 &
     895           ONLY: length, restart_string
    912896
    913897   
    914898       IMPLICIT NONE
    915899       
    916        CHARACTER (LEN=30) ::  variable_chr !< dummy variable to read string
    917        
    918        
    919        READ ( 13 )  variable_chr
    920        DO  WHILE ( TRIM( variable_chr ) /= '*** end flight ***' )
    921 
    922           SELECT CASE ( TRIM( variable_chr ) )
     900       LOGICAL, INTENT(OUT)  ::  found
     901
     902
     903       found = .TRUE.
     904
     905
     906       SELECT CASE ( restart_string(1:length) )
    923907         
    924              CASE ( 'u_agl' )
    925                 IF ( .NOT. ALLOCATED( u_agl ) )  ALLOCATE( u_agl(1:num_leg) )
    926                 READ ( 13 )  u_agl   
    927              CASE ( 'v_agl' )
    928                 IF ( .NOT. ALLOCATED( v_agl ) )  ALLOCATE( v_agl(1:num_leg) )
    929                 READ ( 13 )  v_agl
    930              CASE ( 'w_agl' )
    931                 IF ( .NOT. ALLOCATED( w_agl ) )  ALLOCATE( w_agl(1:num_leg) )
    932                 READ ( 13 )  w_agl
    933              CASE ( 'x_pos' )
    934                 IF ( .NOT. ALLOCATED( x_pos ) )  ALLOCATE( x_pos(1:num_leg) )
    935                 READ ( 13 )  x_pos
    936              CASE ( 'y_pos' )
    937                 IF ( .NOT. ALLOCATED( y_pos ) )  ALLOCATE( y_pos(1:num_leg) )
    938                 READ ( 13 )  y_pos
    939              CASE ( 'z_pos' )
    940                 IF ( .NOT. ALLOCATED( z_pos ) )  ALLOCATE( z_pos(1:num_leg) )
    941                 READ ( 13 )  z_pos
    942              CASE ( 'virtual_flight_prerun' )
    943                 READ ( 13 )  virtual_flight_prerun
     908          CASE ( 'u_agl' )
     909             IF ( .NOT. ALLOCATED( u_agl ) )  ALLOCATE( u_agl(1:num_leg) )
     910             READ ( 13 )  u_agl   
     911          CASE ( 'v_agl' )
     912             IF ( .NOT. ALLOCATED( v_agl ) )  ALLOCATE( v_agl(1:num_leg) )
     913             READ ( 13 )  v_agl
     914          CASE ( 'w_agl' )
     915             IF ( .NOT. ALLOCATED( w_agl ) )  ALLOCATE( w_agl(1:num_leg) )
     916             READ ( 13 )  w_agl
     917          CASE ( 'x_pos' )
     918             IF ( .NOT. ALLOCATED( x_pos ) )  ALLOCATE( x_pos(1:num_leg) )
     919             READ ( 13 )  x_pos
     920          CASE ( 'y_pos' )
     921             IF ( .NOT. ALLOCATED( y_pos ) )  ALLOCATE( y_pos(1:num_leg) )
     922             READ ( 13 )  y_pos
     923          CASE ( 'z_pos' )
     924             IF ( .NOT. ALLOCATED( z_pos ) )  ALLOCATE( z_pos(1:num_leg) )
     925             READ ( 13 )  z_pos
     926
     927          CASE DEFAULT
     928
     929             found = .FALSE.
    944930         
    945           END SELECT
    946          
    947           READ ( 13 )  variable_chr
    948          
    949        ENDDO
    950 
    951     END SUBROUTINE flight_read_restart_data 
     931       END SELECT
     932
     933
     934    END SUBROUTINE flight_rrd_global 
    952935   
    953936!------------------------------------------------------------------------------!
     
    956939!> This routine writes the respective restart data.
    957940!------------------------------------------------------------------------------!
    958     SUBROUTINE flight_write_restart_data 
     941    SUBROUTINE flight_wrd_global 
     942
    959943
    960944       IMPLICIT NONE
    961945
    962        virtual_flight_prerun = .TRUE.
    963        
    964        WRITE ( 14 )  'u_agl                         '
    965        WRITE ( 14 )  u_agl       
    966        WRITE ( 14 )  'v_agl                         '
     946 
     947       CALL wrd_write_string( 'u_agl' )
     948       WRITE ( 14 )  u_agl
     949
     950       CALL wrd_write_string( 'v_agl' )
    967951       WRITE ( 14 )  v_agl
    968        WRITE ( 14 )  'w_agl                         '
     952
     953       CALL wrd_write_string( 'w_agl' )
    969954       WRITE ( 14 )  w_agl
    970        WRITE ( 14 )  'x_pos                         '
     955
     956       CALL wrd_write_string( 'x_pos' )
    971957       WRITE ( 14 )  x_pos
    972        WRITE ( 14 )  'y_pos                         '
     958
     959       CALL wrd_write_string( 'y_pos' )
    973960       WRITE ( 14 )  y_pos
    974        WRITE ( 14 )  'z_pos                         '
     961
     962       CALL wrd_write_string( 'z_pos' )
    975963       WRITE ( 14 )  z_pos
    976        WRITE ( 14 )  'virtual_flight_prerun         '
    977        WRITE ( 14 )  virtual_flight_prerun
    978        
    979        WRITE ( 14 )  '*** end flight ***            '
    980        
    981     END SUBROUTINE flight_write_restart_data   
     964
     965       
     966    END SUBROUTINE flight_wrd_global   
    982967   
    983968
  • palm/trunk/SOURCE/wind_turbine_model_mod.f90

    r2836 r2894  
    2626! -----------------
    2727! $Id$
     28! variable named found has been introduced for checking if restart data was
     29! found, reading of restart strings has been moved completely to
     30! read_restart_data_mod, wind_turbine_prerun flag has been removed, redundant
     31! skipping function has been removed, wtm_read/write_restart_data have been
     32! renamed to wtm_r/wrd_global, wtm_rrd_global is called in
     33! read_restart_data_mod now, marker *** end wtm *** was removed, strings and
     34! their respective lengths are written out and read now in case of restart
     35! runs to get rid of prescribed character lengths, CASE DEFAULT was added if
     36! restart data is read
     37!
     38! 2885 2018-03-14 11:02:46Z Giersch
    2839! Bugfix in interpolation of lift and drag coefficients on fine grid of radius
    2940! segments and angles of attack, speed-up of the initialization of the wind
     
    4960!
    5061! 2576 2017-10-24 13:49:46Z Giersch
    51 ! Definition of a new function called wtm_skip_var_list to skip module
     62! Definition of a new function called wtm_skip_global to skip module
    5263! parameters during reading restart data
    5364!
     
    137148    USE control_parameters,                                                    &
    138149        ONLY:  coupling_char, dt_3d, dz, message_string, simulated_time,       &
    139                wind_turbine, wind_turbine_prerun, initializing_actions
     150               wind_turbine, initializing_actions
    140151
    141152    USE cpulog,                                                                &
     
    404415    END INTERFACE wtm_parin
    405416
    406     INTERFACE wtm_skip_var_list
    407        MODULE PROCEDURE wtm_skip_var_list
    408     END INTERFACE wtm_skip_var_list
    409 
    410     INTERFACE wtm_write_restart_data
    411        MODULE PROCEDURE wtm_write_restart_data
    412     END INTERFACE wtm_write_restart_data
    413 
    414     INTERFACE wtm_read_restart_data
    415        MODULE PROCEDURE wtm_read_restart_data
    416     END INTERFACE wtm_read_restart_data
     417    INTERFACE wtm_wrd_global
     418       MODULE PROCEDURE wtm_wrd_global
     419    END INTERFACE wtm_wrd_global
     420
     421    INTERFACE wtm_rrd_global
     422       MODULE PROCEDURE wtm_rrd_global
     423    END INTERFACE wtm_rrd_global
    417424   
    418425    INTERFACE wtm_check_parameters
     
    456463   
    457464    PUBLIC wtm_check_parameters, wtm_forces, wtm_init, wtm_init_arrays,        &
    458            wtm_parin, wtm_write_restart_data, wtm_tendencies, wtm_skip_var_list
     465           wtm_parin, wtm_wrd_global, wtm_rrd_global, wtm_tendencies
    459466
    460467
     
    514521       wind_turbine = .TRUE.
    515522
    516        IF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN
    517           CALL wtm_read_restart_data
    518        ENDIF
    519523
    520524 10    CONTINUE   ! TBD Change from continue, mit ierrn machen
     
    522526
    523527    END SUBROUTINE wtm_parin
    524 
    525 
    526 !------------------------------------------------------------------------------!
    527 ! Description:
    528 ! ------------
    529 !> Skipping the wind turbine module variables from restart-file (binary format).
    530 !------------------------------------------------------------------------------!
    531    SUBROUTINE wtm_skip_var_list
    532        
    533       IMPLICIT NONE
    534            
    535       CHARACTER (LEN=1)  ::  cdum
    536       CHARACTER (LEN=30) ::  variable_chr
    537            
    538       READ ( 13 )  variable_chr
    539 
    540       DO  WHILE ( TRIM( variable_chr ) /= '*** end wtm ***' )
    541 
    542          READ ( 13 )  cdum
    543          READ ( 13 )  variable_chr
    544 
    545       ENDDO   
    546            
    547    END SUBROUTINE wtm_skip_var_list
    548528
    549529
     
    553533!> This routine writes the respective restart data.
    554534!------------------------------------------------------------------------------!
    555     SUBROUTINE wtm_write_restart_data 
     535    SUBROUTINE wtm_wrd_global 
     536
    556537
    557538       IMPLICIT NONE
    558539
    559        wind_turbine_prerun = .TRUE.
    560        
    561        WRITE ( 14 )  'omega_gen                     '
     540       
     541       CALL wrd_write_string( 'omega_gen' )
    562542       WRITE ( 14 )  omega_gen
    563        WRITE ( 14 )  'omega_gen_f                   '
     543
     544       CALL wrd_write_string( 'omega_gen_f' )
    564545       WRITE ( 14 )  omega_gen_f
    565        WRITE ( 14 )  'omega_gen_f_old               '
     546
     547       CALL wrd_write_string( 'omega_gen_f_old' )
    566548       WRITE ( 14 )  omega_gen_f_old
    567        WRITE ( 14 )  'omega_gen_old                 '
     549
     550       CALL wrd_write_string( 'omega_gen_old' )
    568551       WRITE ( 14 )  omega_gen_old
    569        WRITE ( 14 )  'omega_rot                     '
     552
     553       CALL wrd_write_string( 'omega_rot' )
    570554       WRITE ( 14 )  omega_rot
    571        WRITE ( 14 )  'phi_yaw                       '
    572        WRITE ( 14 )  phi_yaw(:)
    573        WRITE ( 14 )  'pitch_add                     '
     555
     556       CALL wrd_write_string( 'phi_yaw' )
     557       WRITE ( 14 )  phi_yaw
     558
     559       CALL wrd_write_string( 'pitch_add' )
    574560       WRITE ( 14 )  pitch_add
    575        WRITE ( 14 )  'pitch_add_old                 '
     561
     562       CALL wrd_write_string( 'pitch_add_old' )
    576563       WRITE ( 14 )  pitch_add_old
    577        WRITE ( 14 )  'torque_gen                    '
     564
     565       CALL wrd_write_string( 'torque_gen' )
    578566       WRITE ( 14 )  torque_gen
    579        WRITE ( 14 )  'torque_gen_old                '
     567
     568       CALL wrd_write_string( 'torque_gen_old' )
    580569       WRITE ( 14 )  torque_gen_old
    581        WRITE ( 14 )  'wind_turbine_prerun           '
    582        WRITE ( 14 )  wind_turbine_prerun
    583      
    584        WRITE ( 14 )  '*** end wtm ***               '
    585        
    586     END SUBROUTINE wtm_write_restart_data   
     570
     571       
     572    END SUBROUTINE wtm_wrd_global   
    587573
    588574
     
    592578!> This routine reads the respective restart data.
    593579!------------------------------------------------------------------------------!
    594  SUBROUTINE wtm_read_restart_data
     580 SUBROUTINE wtm_rrd_global( found )
     581
     582
     583    USE control_parameters,                                                    &
     584        ONLY: length, restart_string
    595585
    596586
    597587    IMPLICIT NONE
    598588
    599     CHARACTER (LEN=30) ::  variable_chr  !< dummy variable to read string
    600 
    601 
    602     READ ( 13 )  variable_chr
    603     DO  WHILE ( TRIM( variable_chr ) /= '*** end wtm ***' )
    604 
    605        SELECT CASE ( TRIM( variable_chr ) )
    606 
    607           CASE ( 'omega_gen' )
    608              READ ( 13 )  omega_gen
    609           CASE ( 'omega_gen_f' )
    610              READ ( 13 )  omega_gen_f
    611           CASE ( 'omega_gen_f_old' )
    612              READ ( 13 )  omega_gen_f_old
    613           CASE ( 'omega_gen_old' )
    614              READ ( 13 )  omega_gen_old
    615           CASE ( 'omega_rot' )
    616              READ ( 13 )  omega_rot
    617           CASE ( 'phi_yaw' )
    618              READ ( 13 )  phi_yaw
    619           CASE ( 'pitch_add' )
    620              READ ( 13 )  pitch_add
    621           CASE ( 'pitch_add_old' )
    622              READ ( 13 )  pitch_add_old
    623           CASE ( 'torque_gen' )
    624              READ ( 13 )  torque_gen
    625           CASE ( 'torque_gen_old' )
    626              READ ( 13 )  torque_gen_old
    627           CASE ( 'wind_turbine_prerun' )
    628              READ ( 13 )  wind_turbine_prerun
    629 
    630        END SELECT
    631        
    632        READ ( 13 )  variable_chr
    633 
    634     ENDDO
    635 
    636  END SUBROUTINE wtm_read_restart_data
     589    LOGICAL, INTENT(OUT)  ::  found
     590
     591
     592    found = .TRUE.
     593
     594
     595    SELECT CASE ( restart_string(1:length) )
     596
     597       CASE ( 'omega_gen' )
     598          READ ( 13 )  omega_gen
     599       CASE ( 'omega_gen_f' )
     600          READ ( 13 )  omega_gen_f
     601       CASE ( 'omega_gen_f_old' )
     602          READ ( 13 )  omega_gen_f_old
     603       CASE ( 'omega_gen_old' )
     604          READ ( 13 )  omega_gen_old
     605       CASE ( 'omega_rot' )
     606          READ ( 13 )  omega_rot
     607       CASE ( 'phi_yaw' )
     608          READ ( 13 )  phi_yaw
     609       CASE ( 'pitch_add' )
     610          READ ( 13 )  pitch_add
     611       CASE ( 'pitch_add_old' )
     612          READ ( 13 )  pitch_add_old
     613       CASE ( 'torque_gen' )
     614          READ ( 13 )  torque_gen
     615       CASE ( 'torque_gen_old' )
     616          READ ( 13 )  torque_gen_old
     617
     618       CASE DEFAULT
     619
     620          found = .FALSE.
     621
     622    END SELECT
     623   
     624
     625 END SUBROUTINE wtm_rrd_global
    637626
    638627
     
    20662055                     turb_cl(rseg)  = tl_factor * turb_cl(rseg)                                 
    20672056                                 
    2068                    END IF               
     2057                   ENDIF               
    20692058!
    20702059!--                !-----------------------------------------------------!
     
    23712360             ENDDO ! End of loop over turbines
    23722361                           
    2373           END IF  ! end of yaw control
     2362          ENDIF  ! end of yaw control
    23742363         
    23752364          IF ( speed_control )  THEN
Note: See TracChangeset for help on using the changeset viewer.