Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3253)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3254)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Additional check for surface_fractions and and checks for building_id and 
+! building_type extended.
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -37,5 +41,5 @@
 ! 
 ! 3209 2018-08-27 16:58:37Z suehring
-! Read zsoil dimension lenght only if soil variables are provided
+! Read zsoil dimension length only if soil variables are provided
 ! 
 ! 3183 2018-07-27 14:25:55Z suehring
@@ -3040,4 +3044,12 @@
        ENDIF
 !
+!--    Check for correct dimension of surface_fractions, should run from 0-2.
+       IF ( surface_fraction_f%from_file )  THEN
+          IF ( surface_fraction_f%nf-1 > 2 )  THEN
+             message_string = 'nsurface_fraction must not be larger than 3.' 
+             CALL message( 'netcdf_data_input_mod', 'PA0580', 1, 2, 0, 6, 0 )
+          ENDIF
+       ENDIF
+!
 !--    Check orography for fill-values. For the moment, give an error message.
 !--    More advanced methods, e.g. a nearest neighbor algorithm as used in GIS
@@ -3398,6 +3410,7 @@
                 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
-
+                        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 ' //   &
                                          'building is set requires a type ' // &
@@ -3411,5 +3424,7 @@
                 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
+                        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 ' //   &
                                          'building is set requires a type ' // &
@@ -3428,5 +3443,7 @@
                 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
+                        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 ' //   &
                                          'building is set requires an ID ' //  &
@@ -3437,5 +3454,7 @@
                 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
+                        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 ' //   &
                                          'building is set requires an ID ' //  &
@@ -3447,10 +3466,9 @@
              ENDIF
 !
-!--          Check if at each location where a building ID or a -type is set
-!--          also a bulding is defined.
+!--          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
+                   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
@@ -3459,6 +3477,6 @@
                    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
+                   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
Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 3253)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 3254)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Remove redundant subroutine argument
+! 
+! 3253 2018-09-17 08:39:12Z suehring
 ! Bugfix, missing deallocation of q_surface
 ! 
@@ -1815,5 +1818,5 @@
                                  topo_no_distinct
                       IF ( urban_surface  .AND.  building )  THEN
-                         CALL initialize_vertical_surfaces( 0, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(0),     &
                                                             num_usm_v(0),      &
@@ -1822,5 +1825,5 @@
                                                             .FALSE., .TRUE. ) 
                       ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( 0, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_lsm_v(0),     &
                                                             num_lsm_v(0),      &
@@ -1829,5 +1832,5 @@
                                                             .FALSE., .TRUE. ) 
                       ELSE
-                         CALL initialize_vertical_surfaces( 0, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_def_v(0),     &
                                                             num_def_v(0),      &
@@ -1847,5 +1850,5 @@
                                  topo_no_distinct
                       IF ( urban_surface  .AND.  building )  THEN
-                         CALL initialize_vertical_surfaces( 1, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(1),     &
                                                             num_usm_v(1),      &
@@ -1854,5 +1857,5 @@
                                                             .TRUE., .FALSE. )
                       ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( 1, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_lsm_v(1),     &
                                                             num_lsm_v(1),      &
@@ -1861,5 +1864,5 @@
                                                             .TRUE., .FALSE. )  
                       ELSE
-                         CALL initialize_vertical_surfaces( 1, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_def_v(1),     &
                                                             num_def_v(1),      &
@@ -1879,5 +1882,5 @@
                                  topo_no_distinct
                       IF ( urban_surface  .AND.  building )  THEN
-                         CALL initialize_vertical_surfaces( 2, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(2),     &
                                                             num_usm_v(2),      &
@@ -1886,5 +1889,5 @@
                                                             .FALSE., .FALSE. ) 
                       ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( 2, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_lsm_v(2),     &
                                                             num_lsm_v(2),      &
@@ -1893,5 +1896,5 @@
                                                             .FALSE., .FALSE. ) 
                       ELSE
-                         CALL initialize_vertical_surfaces( 2, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_def_v(2),     &
                                                             num_def_v(2),      &
@@ -1911,5 +1914,5 @@
                                  topo_no_distinct
                       IF ( urban_surface  .AND.  building )  THEN
-                         CALL initialize_vertical_surfaces( 3, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(3),     &
                                                             num_usm_v(3),      &
@@ -1918,5 +1921,5 @@
                                                            .FALSE., .FALSE. ) 
                       ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( 3, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_lsm_v(3),     &
                                                             num_lsm_v(3),      &
@@ -1925,5 +1928,5 @@
                                                            .FALSE., .FALSE. ) 
                       ELSE
-                         CALL initialize_vertical_surfaces( 3, k, j, i,        &
+                         CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_def_v(3),     &
                                                             num_def_v(3),      &
@@ -2357,8 +2360,8 @@
 !> Initialize vertical surface elements. 
 !------------------------------------------------------------------------------!
-          SUBROUTINE initialize_vertical_surfaces( l, k, j, i, surf, num_v,    &
-                                                num_v_kji, east_facing,        &
-                                                west_facing, south_facing,     &
-                                                north_facing )       
+          SUBROUTINE initialize_vertical_surfaces( k, j, i, surf, num_v,       &
+                                                   num_v_kji, east_facing,     &
+                                                   west_facing, south_facing,  &
+                                                   north_facing )       
 
              IMPLICIT NONE 
