Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 2954)
+++ palm/trunk/SOURCE/Makefile	(revision 2955)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Add log-points to measure CPU time of NetCDF data input.
+# 
+# 2938 2018-03-27 15:52:42Z suehring
 # No initialization of child domains via dynamic input file, except for soil
 # moisture and temperature
@@ -1169,4 +1172,5 @@
 	mod_kinds.o
 netcdf_data_input_mod.o: \
+	cpulog_mod.o \
 	mod_kinds.o \
 	modules.o
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 2954)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 2955)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Improve topography filter routine and add ghost-point exchange for building 
+! ID and building type. 
+! 
+! 2927 2018-03-23 15:13:00Z suehring
 ! Bugfix, setting boundary conditions for topography index array.
 ! 
@@ -1186,6 +1190,7 @@
     INTEGER(iwp) ::  num_wall   !< number of surrounding vertical walls for a single grid point
 
-    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  topo_tmp      !< temporary 3D-topography used to fill holes
-    INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  topo_3d       !< 3D-topography array merging buildings and orography
+    INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg)           ::  var_exchange_int  !< dummy array for exchanging ghost-points 
+    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE            ::  topo_tmp          !< temporary 3D-topography used to fill holes
+    INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  topo_3d           !< 3D-topography array merging buildings and orography
 !
 !-- Before checking for holes, set lateral boundary conditions for 
@@ -1201,4 +1206,14 @@
        num_hole = 0    
        CALL exchange_horiz_int( topo_3d, nys, nyn, nxl, nxr, nzt, nbgp )
+!
+!--    Exchange also building ID and type. Note, building_type is an one-byte 
+!--    variable.
+       IF ( building_id_f%from_file )                                          &
+          CALL exchange_horiz_2d_int( building_id_f%var, nys, nyn, nxl, nxr, nbgp )
+       IF ( building_type_f%from_file )  THEN
+          var_exchange_int = INT( building_type_f%var, KIND = 4 )
+          CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp )
+          building_type_f%var = INT( var_exchange_int, KIND = 1 )
+       ENDIF
 
        topo_tmp = topo_3d
@@ -1343,4 +1358,13 @@
        IF ( nxl == 0  )  topo_3d(:,:,-1)   = topo_3d(:,:,0)
        IF ( nxr == nx )  topo_3d(:,:,nx+1) = topo_3d(:,:,nx)          
+    ENDIF
+!
+!-- Exchange building ID and type. Note, building_type is an one-byte variable.
+    IF ( building_id_f%from_file )                                             &
+       CALL exchange_horiz_2d_int( building_id_f%var, nys, nyn, nxl, nxr, nbgp )
+    IF ( building_type_f%from_file )  THEN
+       var_exchange_int = INT( building_type_f%var, KIND = 4 )
+       CALL exchange_horiz_2d_int( var_exchange_int, nys, nyn, nxl, nxr, nbgp )
+       building_type_f%var = INT( var_exchange_int, KIND = 1 )
     ENDIF
 
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2954)
+++ 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 )
