Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3960)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3961)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Revise checks for building IDs and types
+! 
+! 3943 2019-05-02 09:50:41Z maronga
 ! Temporarily disabled some (faulty) checks for static driver.
 ! 
@@ -3844,5 +3847,5 @@
 
        USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nys
+           ONLY:  nxl, nxr, nyn, nys, wall_flags_0
 
        IMPLICIT NONE
@@ -4258,82 +4261,47 @@
              ENDIF
 !
-!--          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  .OR. &
-!                         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 location where a ' //   &
-!                                       '2D 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', 'PA0573',         &
-!                                      2, 2, myid, 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  .OR. &
-!                   .NOT. 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 ' //   &
-!                                       '3D 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', 'PA0573',         &
-!                                      2, 2, myid, 6, 0 )
-!                    ENDIF
-!                 ENDIF
-!              ENDIF
+!--          Check if building_type is set at each building and vice versa. 
+!--          Please note, buildings are already processed and filtered.
+!--          For this reason, consistency checks are based on wall_flags_0 
+!--          rather than buildings_f (buildings are represented by bit 6 in 
+!--          wall_flags_0). 
+             IF ( building_type_f%from_file  .AND.  buildings_f%from_file )  THEN
+                IF ( ANY( BTEST ( wall_flags_0(:,j,i), 6 ) )  .AND.            &
+                     building_type_f%var(j,i) == building_type_f%fill  .OR.    &
+               .NOT. ANY( BTEST ( wall_flags_0(:,j,i), 6 ) )  .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', 'PA0573',            &
+                                  2, 2, myid, 6, 0 )
+                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  .OR.    &
-!                         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 ' //   &
-!                                       '2D building is set requires an ID ' //  &
-!                                       '( and vice versa ). i, j = ', i, j
-!                       CALL message( 'netcdf_data_input_mod', 'PA0574',         &
-!                                      2, 2, myid, 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  .OR.     &
-!                   .NOT. 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 ' //   &
-!                                       '3D building is set requires an ID ' //  &
-!                                       '( and vice versa ). i, j = ', i, j
-!                       CALL message( 'netcdf_data_input_mod', 'PA0574',         &
-!                                      2, 2, myid, 6, 0 )
-!                    ENDIF
-!                 ENDIF
-!              ENDIF
+             IF ( buildings_f%from_file )  THEN
+                IF ( ANY( BTEST ( wall_flags_0(:,j,i), 6 ) )  .AND.           &
+                     building_id_f%var(j,i) == building_id_f%fill  .OR.       &
+               .NOT. ANY( BTEST ( wall_flags_0(:,j,i), 6 ) )  .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', 'PA0574',           &
+                                  2, 2, myid, 6, 0 )
+                ENDIF
+             ENDIF
 !
 !--          Check if building ID is set where 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', 'PA0575',         &
-                                     2, 2, myid, 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 building grid point '// &
-                                                 'requires an ID.', i, j
-                      CALL message( 'netcdf_data_input_mod', 'PA0575',         &
-                                     2, 2, myid, 6, 0 )
-                   ENDIF
+                IF ( ANY( BTEST ( wall_flags_0(:,j,i), 6 ) )  .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', 'PA0575',           &
+                                  2, 2, myid, 6, 0 )
                 ENDIF
              ENDIF
