Index: /palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2897)
+++ /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2898)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Check if each building has a type. Further, check if dimensions in static 
+! input file match the model dimensions. 
+! 
+! 2897 2018-03-15 11:47:16Z suehring
 ! Relax restrictions for topography input, terrain and building heights can be
 ! input separately and are not mandatory any more. 
@@ -85,5 +89,12 @@
 
     USE pegrid
-
+!
+!-- Define type for dimensions. 
+    TYPE dims_xy
+       INTEGER(iwp) :: nx                             !< dimension length in x
+       INTEGER(iwp) :: ny                             !< dimension length in y
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: x       !< dimension array in x
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: y       !< dimension array in y
+    END TYPE dims_xy
 !
 !-- Define data type for nesting in larger-scale models like COSMO.
@@ -287,6 +298,9 @@
        REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  pars_xyz          !< respective parameters, level of detail = 2
     END TYPE pars
-
-    TYPE(force_type) ::  force !< input variable for lateral and top boundaries derived from large-scale model  
+!
+!-- Define variables
+    TYPE(dims_xy)    ::  dim_static !< data structure for x, y-dimension in static input file
+
+    TYPE(force_type) ::  force     !< data structure for data input at lateral and top boundaries (provided by Inifor)  
 
     TYPE(init_type) ::  init_3d    !< data structure for the initialization of the 3D flow and soil fields
@@ -1660,4 +1674,12 @@
                 ALLOCATE( var_names(1:num_vars) )
                 CALL inquire_variable_names( id_topo, var_names )
+!
+!--             Read x, y - dimensions
+                CALL get_dimension_length( id_topo, dim_static%nx, 'x' )
+                CALL get_dimension_length( id_topo, dim_static%ny, 'y' )
+                ALLOCATE( dim_static%x(0:dim_static%nx-1) )
+                ALLOCATE( dim_static%y(0:dim_static%ny-1) )
+                CALL get_variable( id_topo, 'x', dim_static%x )
+                CALL get_variable( id_topo, 'y', dim_static%y )
 !
 !--             Terrain height. First, get variable-related _FillValue attribute
@@ -2747,6 +2769,9 @@
            ONLY:  land_surface, message_string, urban_surface
 
+       USE grid_variables,                                                     &
+           ONLY:  dx, dy
+
        USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nys
+           ONLY:  nx, nxl, nxr, ny, nyn, nys
 
        IMPLICIT NONE
@@ -2760,5 +2785,23 @@
 !
 !--    Return if no static input file is available
-       IF ( .NOT. input_pids_static )  RETURN  
+       IF ( .NOT. input_pids_static )  RETURN
+!
+!--    Check whether dimension size in input file matches the model dimensions
+       IF ( dim_static%nx-1 /= nx  .OR.  dim_static%ny-1 /= ny )  THEN
+          message_string = 'Static input file: horizontal dimension in ' //    &
+                           'x- and/or y-direction ' //                         &
+                           'do not match the respective model dimension'
+          CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+       ENDIF
+!
+!--    Check if grid spacing of provided input data matches the respective 
+!--    grid spacing in the model. 
+       IF ( dim_static%x(1) - dim_static%x(0) /= dx  .OR.                      &
+            dim_static%y(1) - dim_static%y(0) /= dy )  THEN
+          message_string = 'Static input file: horizontal grid spacing ' //    &
+                           'in x- and/or y-direction ' //                      &
+                           'do not match the respective model grid spacing.'
+          CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+       ENDIF
 !
 !--    Check orography for fill-values. For the moment, give an error message.
@@ -3041,13 +3084,28 @@
 !
 !--          Check if building_type is set at each building
-!              IF ( building_type_f%from_file  .AND.  buildings_f%from_file )  THEN
-!                 IF ( buildings_f%var_2d(j,i) /= buildings_f%fill1  .AND.       &
-!                      building_type_f%var(j,i) == building_type_f%fill )  THEN
-!                       WRITE( message_string, * ) 'Each building requires ' //  &
-!                                        ' a type. i, j = ', i, j
-!                       CALL message( 'netcdf_data_input_mod', 'PA0999',         &
-!                                      2, 2, 0, 6, 0 )
-!                 ENDIF
-!              ENDIF
+             IF ( building_type_f%from_file  .AND.  buildings_f%from_file )  THEN
+                IF ( buildings_f%lod == 1 )  THEN
+                   IF ( buildings_f%var_2d(j,i)  /= buildings_f%fill1  .AND.   &
+                        building_type_f%var(j,i) == building_type_f%fill )  THEN
+                      WRITE( message_string, * ) 'Each building requires ' //  &
+                                                 'a type in case the ' //      &
+                                                 'urban-surface model is ' //  &
+                                                 'applied. i, j = ', i, j
+                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                                     2, 2, 0, 6, 0 )
+                   ENDIF
+                ENDIF
+                IF ( buildings_f%lod == 2 )  THEN
+                   IF ( ANY( buildings_f%var_3d(:,j,i) == 1 )                  &
+                  .AND. building_type_f%var(j,i) == building_type_f%fill )  THEN
+                      WRITE( message_string, * ) 'Each building requires ' //  &
+                                                 'a type in case the ' //      &
+                                                 'urban-surface model is ' //  &
+                                                 'applied. i, j = ', i, j
+                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                                     2, 2, 0, 6, 0 )
+                   ENDIF
+                ENDIF
+             ENDIF
 !
 !--          Check albedo parameters. If albedo_type is 0, all parameters  
