Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2953)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2955)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Extend checks for consistent setting of buildings, its ID and type. 
+! Add log-points to measure CPU time of NetCDF data input.
+! 
+! 2953 2018-04-09 11:26:02Z suehring
 ! Bugfix in checks for initialization data
 ! 
@@ -108,4 +112,7 @@
         ONLY:  coupling_char, io_blocks, io_group
 
+    USE cpulog,                                                                &
+        ONLY:  cpu_log, log_point_s
+
     USE kinds
 
@@ -595,4 +602,7 @@
 !--    If not static input file is available, skip this routine
        IF ( .NOT. input_pids_static )  RETURN
+!
+!--    Measure CPU time
+       CALL cpu_log( log_point_s(82), 'NetCDF input', 'start' )
 !
 !--    Read plant canopy variables.
@@ -1215,4 +1225,7 @@
 #endif
        ENDDO
+!
+!--    End of CPU measurement
+       CALL cpu_log( log_point_s(82), 'NetCDF input', 'stop' )
 !
 !--    Exchange 1 ghost points for surface variables. Please note, ghost point
@@ -1689,5 +1702,7 @@
 
        REAL(wp) ::  dum           !< dummy variable to skip columns while reading topography file   
-
+!
+!--    CPU measurement
+       CALL cpu_log( log_point_s(83), 'NetCDF/ASCII input topo', 'start' )
 
        DO  ii = 0, io_blocks-1
@@ -1890,4 +1905,7 @@
        ENDDO
 !
+!--    End of CPU measurement
+       CALL cpu_log( log_point_s(83), 'NetCDF/ASCII input topo', 'stop' )
+!
 !--    Check for minimum requirement to setup building topography. If buildings
 !--    are provided, also an ID and a type are required. 
@@ -2002,4 +2020,8 @@
        IF ( bc_lr_cyc  .AND.  nxl == 0 )  nxlu = 1  
        IF ( bc_ns_cyc  .AND.  nys == 0 )  nysv = 1
+
+!
+!--    CPU measurement
+       CALL cpu_log( log_point_s(85), 'NetCDF input init', 'start' )
 
        DO  ii = 0, io_blocks-1
@@ -2348,4 +2370,7 @@
 #endif
        ENDDO
+!
+!--    End of CPU measurement
+       CALL cpu_log( log_point_s(85), 'NetCDF input init', 'stop' )
 !
 !--    Finally, check if the input data has any fill values. Please note, 
@@ -2471,4 +2496,8 @@
 !--    Skip input if no forcing from larger-scale models is applied.
        IF ( .NOT. forcing )  RETURN
+
+!
+!--    CPU measurement
+       CALL cpu_log( log_point_s(86), 'NetCDF input forcing', 'start' )
 
        DO  ii = 0, io_blocks-1
@@ -2837,4 +2866,8 @@
 
 !
+!--    End of CPU measurement
+       CALL cpu_log( log_point_s(86), 'NetCDF input forcing', 'stop' )
+
+!
 !--    Finally, after data input set control flag indicating that vertical 
 !--    inter- and/or extrapolation is required. 
@@ -3250,13 +3283,15 @@
              ENDIF
 !
-!--          Check if building_type is set at each building
+!--          Check if building_type is set at each building and vice versa.
              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
+
+                      WRITE( message_string, * ) 'Each location where a ' //   &
+                                         'building is set requires a type ' // &
+                                         '( and vice versa ) in case the ' //  &
+                                         'urban-surface model is applied. ' // &
+                                         'i, j = ', i, j
                       CALL message( 'netcdf_data_input_mod', 'NDI035',         &
                                      2, 2, 0, 6, 0 )
@@ -3264,10 +3299,57 @@
                 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 location where a ' //   &
+                                         'building is set requires a type ' // &
+                                         '( and vice versa ) in case the ' //  &
+                                         'urban-surface model is applied. ' // &
+                                         'i, j = ', i, j
+                      CALL message( 'netcdf_data_input_mod', 'NDI035',         &
+                                     2, 2, 0, 6, 0 )
+                   ENDIF
+                ENDIF
+             ENDIF
+!
+!--          Check if at each location where a building is present also an ID
+!--          is set and vice versa. 
+             IF ( buildings_f%from_file )  THEN
+                IF ( buildings_f%lod == 1 )  THEN
+                   IF ( buildings_f%var_2d(j,i) /= buildings_f%fill1  .AND.    &
+                        building_id_f%var(j,i)  == building_id_f%fill )  THEN
+                      WRITE( message_string, * ) 'Each location where a ' //   &
+                                         'building is set requires an ID ' //  &
+                                         '( and vice versa ). i, j = ', i, j
+                      CALL message( 'netcdf_data_input_mod', 'NDI036',         &
+                                     2, 2, 0, 6, 0 )
+                   ENDIF
+                ELSEIF ( buildings_f%lod == 2 )  THEN
+                   IF ( ANY( buildings_f%var_3d(:,j,i) == 1 )  .AND.           &
+                        building_id_f%var(j,i) == building_id_f%fill )  THEN
+                      WRITE( message_string, * ) 'Each location where a ' //   &
+                                         'building is set requires an ID ' //  &
+                                         '( and vice versa ). i, j = ', i, j
+                      CALL message( 'netcdf_data_input_mod', 'NDI036',         &
+                                     2, 2, 0, 6, 0 )
+                   ENDIF
+                ENDIF
+             ENDIF
+!
+!--          Check if at each location where a building ID or a -type is set
+!--          also a bulding is defined. 
+             IF ( buildings_f%from_file )  THEN
+                IF ( buildings_f%lod == 1 )  THEN
+                   IF ( buildings_f%var_2d(j,i)  /= buildings_f%fill1  .AND.   &
+                        building_id_f%var(j,i) == building_id_f%fill )  THEN
+                      WRITE( message_string, * ) 'Each building grid point '// &
+                                                 'requires an ID.', i, j
+                      CALL message( 'netcdf_data_input_mod', 'NDI036',         &
+                                     2, 2, 0, 6, 0 )
+                   ENDIF
+                ELSEIF ( 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
+                  .AND. building_id_f%var(j,i) == building_id_f%fill )  THEN
+                      WRITE( message_string, * ) 'Each building grid point '// &
+                                                 'requires an ID.', i, j
                       CALL message( 'netcdf_data_input_mod', 'NDI036',         &
                                      2, 2, 0, 6, 0 )
