Index: /palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3709)
+++ /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3710)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Check if soil-, water-, pavement- and vegetation types are set within a valid
+! range.
+! 
+! 3692 2019-01-23 14:45:49Z suehring
 ! Revise check for soil moisture higher than its saturation value
 ! 
@@ -1338,4 +1342,6 @@
     IMPLICIT NONE
 
+    INTEGER(iwp) ::  i        !< running index, x-dimension
+    INTEGER(iwp) ::  j        !< running index, y-dimension
     INTEGER(iwp) ::  k        !< running index, z-dimension
 
@@ -1374,5 +1380,104 @@
        CALL message( 'lsm_check_parameters', 'PA0400', 1, 2, 0, 6, 0 )
     ENDIF
-
+!
+!-- Check if soil types are set within a valid range.
+    IF ( TRIM( surface_type ) == 'vegetation'  .OR.                            &
+         TRIM( surface_type ) == 'pavement'    .OR.                            &
+         TRIM( surface_type ) == 'netcdf' )  THEN
+       IF ( soil_type < LBOUND( soil_pars, 2 )  .AND.                          &
+            soil_type > UBOUND( soil_pars, 2 ) )  THEN
+          WRITE( message_string, * ) 'soil_type = ', soil_type, ' is out ' //  &
+                                     'of the valid range'
+          CALL message( 'lsm_check_parameters', 'PA0452', 2, 2, 0, 6, 0 )
+       ENDIF
+       IF ( soil_type_f%from_file )  THEN
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                IF ( soil_type_f%var_2d(j,i) /= soil_type_f%fill  .AND.        &
+                     ( soil_type_f%var_2d(j,i) < LBOUND( soil_pars, 2 )  .OR.  &
+                       soil_type_f%var_2d(j,i) > UBOUND( soil_pars, 2 ) ) )  THEN
+                   WRITE( message_string, * ) 'soil_type = is out  of ' //     &
+                                        'the valid range at (j,i) = ', j, i
+                   CALL message( 'lsm_check_parameters', 'PA0452', 2, 2, 0, 6, 0 )
+                ENDIF
+             ENDDO
+          ENDDO
+       ENDIF
+    ENDIF
+!
+!-- Check if vegetation types are set within a valid range.    
+    IF ( TRIM( surface_type ) == 'vegetation'  .OR.                            &
+         TRIM( surface_type ) == 'netcdf' )  THEN
+       IF ( vegetation_type < LBOUND( vegetation_pars, 2 )  .AND.              &
+            vegetation_type > UBOUND( vegetation_pars, 2 ) )  THEN
+          WRITE( message_string, * ) 'vegetation_type = ', vegetation_type,    &
+                                     ' is out of the valid range'
+          CALL message( 'lsm_check_parameters', 'PA0526', 2, 2, 0, 6, 0 )
+       ENDIF
+       IF ( vegetation_type_f%from_file )  THEN
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                IF ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill  .AND.&
+              ( vegetation_type_f%var(j,i) < LBOUND( vegetation_pars, 2 )  .OR.&
+                vegetation_type_f%var(j,i) > UBOUND( vegetation_pars, 2 ) ) )  &
+                THEN
+                   WRITE( message_string, * ) 'vegetation_type = is out of ' //&
+                                        'the valid range at (j,i) = ', j, i
+                   CALL message( 'lsm_check_parameters', 'PA0526', 2, 2, 0, 6, 0 ) 
+                ENDIF
+             ENDDO
+          ENDDO
+       ENDIF
+    ENDIF
+!
+!-- Check if pavement types are set within a valid range.    
+    IF ( TRIM( surface_type ) == 'pavement'  .OR.                              &
+         TRIM( surface_type ) == 'netcdf' )  THEN
+       IF ( pavement_type < LBOUND( pavement_pars, 2 )  .AND.                  &
+            pavement_type > UBOUND( pavement_pars, 2 ) )  THEN
+          WRITE( message_string, * ) 'pavement_type = ', pavement_type,        &
+                                     ' is out of the valid range'
+          CALL message( 'lsm_check_parameters', 'PA0527', 2, 2, 0, 6, 0 )
+       ENDIF
+       IF ( pavement_type_f%from_file )  THEN
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                IF ( pavement_type_f%var(j,i) /= pavement_type_f%fill  .AND.   &
+              ( pavement_type_f%var(j,i) < LBOUND( pavement_pars, 2 )  .OR.    &
+                pavement_type_f%var(j,i) > UBOUND( pavement_pars, 2 ) ) )  THEN
+                   WRITE( message_string, * ) 'pavement_type = is out of ' //  &
+                                        'the valid range at (j,i) = ', j, i
+                   CALL message( 'lsm_check_parameters', 'PA0527', 2, 2, 0, 6, 0 ) 
+                ENDIF
+             ENDDO
+          ENDDO
+       ENDIF
+    ENDIF
+!
+!-- Check if water types are set within a valid range.    
+    IF ( TRIM( surface_type ) == 'water'  .OR.                                 &
+         TRIM( surface_type ) == 'netcdf' )  THEN
+       IF ( water_type < LBOUND( water_pars, 2 )  .AND.                        &
+            water_type > UBOUND( water_pars, 2 ) )  THEN
+          WRITE( message_string, * ) 'water_type = ', water_type,              &
+                                     ' is out of the valid range'
+          CALL message( 'lsm_check_parameters', 'PA0528', 2, 2, 0, 6, 0 )
+       ENDIF
+       IF ( water_type_f%from_file )  THEN
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                IF ( water_type_f%var(j,i) /= water_type_f%fill  .AND.         &
+              ( water_type_f%var(j,i) < LBOUND( water_pars, 2 )  .OR.          &
+                water_type_f%var(j,i) > UBOUND( water_pars, 2 ) ) )  THEN
+                   WRITE( message_string, * ) 'water_type = is out  of ' //    &
+                                        'the valid range at (j,i) = ', j, i
+                   CALL message( 'lsm_check_parameters', 'PA0528', 2, 2, 0, 6, 0 ) 
+                ENDIF
+             ENDDO
+          ENDDO
+       ENDIF
+    ENDIF
+!
+!-- Check further settings for consistency.
     IF ( TRIM( surface_type ) == 'vegetation' )  THEN
     
@@ -1396,5 +1501,5 @@
                               'requires setting of vegetation_coverage'//      &
                               '/= 9999999.9'
-                CALL message( 'lsm_check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
+             CALL message( 'lsm_check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
           ENDIF
 
@@ -1487,6 +1592,6 @@
           message_string = 'non-default setting of dz_soil '//                  &
                            'does not allow to use pavement_type /= 0)'
-             CALL message( 'lsm_check_parameters', 'PA0341', 1, 2, 0, 6, 0 )
-          ENDIF
+          CALL message( 'lsm_check_parameters', 'PA0341', 1, 2, 0, 6, 0 )
+       ENDIF
 
        IF ( pavement_type == 0 )  THEN  
Index: /palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 3709)
+++ /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 3710)
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! Check if building type is set within a valid range.
+! 
+! 3705 2019-01-29 19:56:39Z suehring
 ! make nzb_wall public, required for virtual-measurements
 ! 
@@ -2625,5 +2628,12 @@
            ONLY:  bc_pt_b, bc_q_b, constant_flux_layer, large_scale_forcing,   &
                   lsf_surf, topography
-
+                  
+       USE netcdf_data_input_mod,                                             &
+            ONLY:  building_type_f
+
+       IMPLICIT NONE           
+                  
+       INTEGER(iwp) ::  i        !< running index, x-dimension
+       INTEGER(iwp) ::  j        !< running index, y-dimension
 !
 !--    Dirichlet boundary conditions are required as the surface fluxes are
@@ -2659,5 +2669,5 @@
           message_string = 'topography /= "flat" is required '//               &
                            'when using the urban surface model'
-          CALL message( 'check_parameters', 'PA0592', 1, 2, 0, 6, 0 )
+          CALL message( 'usm_check_parameters', 'PA0592', 1, 2, 0, 6, 0 )
        ENDIF
 !
@@ -2667,5 +2677,27 @@
                            '"naheatlayers" can not be larger than'//           &
                            ' number of domain layers "nzt"'
-          CALL message( 'check_parameters', 'PA0593', 1, 2, 0, 6, 0 )
+          CALL message( 'usm_check_parameters', 'PA0593', 1, 2, 0, 6, 0 )
+       ENDIF
+!
+!--    Check if building types are set within a valid range.   
+       IF ( building_type < LBOUND( building_pars, 2 )  .AND.                 &
+            building_type > UBOUND( building_pars, 2 ) )  THEN
+          WRITE( message_string, * ) 'building_type = ', building_type,        &
+                                     ' is out of the valid range'
+          CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 )
+       ENDIF
+       IF ( building_type_f%from_file )  THEN
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                IF ( building_type_f%var(j,i) /= building_type_f%fill  .AND.   &
+              ( building_type_f%var(j,i) < LBOUND( building_pars, 2 )  .OR.    &
+                building_type_f%var(j,i) > UBOUND( building_pars, 2 ) ) )      &
+                THEN
+                   WRITE( message_string, * ) 'building_type = is out of ' //  &
+                                        'the valid range at (j,i) = ', j, i
+                   CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 ) 
+                ENDIF
+             ENDDO
+          ENDDO
        ENDIF
 
