Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 2895)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 2897)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Relax restrictions for topography input, terrain and building heights can be
+! input separately and are not mandatory any more. 
+! 
+! 2893 2018-03-14 16:20:52Z suehring
 ! Revise informative message concerning filtered topography (1 grid-point 
 ! holes). 
@@ -896,18 +900,21 @@
 !-- and terrain height can be made. Moreover, this is also not necessary if
 !-- urban-surface and land-surface model are used at the same time. 
-    IF ( input_pids_static )  THEN 
-       num_buildings_l = 0
-       num_buildings   = 0
-!
-!--    Allocate at least one element for building ids, 
-       ALLOCATE( build_ids_l(1) )
-       DO  i = nxl, nxr
-          DO  j = nys, nyn
-             IF ( building_id_f%var(j,i) /= building_id_f%fill )  THEN
-                IF ( num_buildings_l(myid) > 0 )  THEN
-                   IF ( ANY( building_id_f%var(j,i) .EQ.  build_ids_l ) )  THEN
-                      CYCLE
-                   ELSE
-                      num_buildings_l(myid) = num_buildings_l(myid) + 1
+    IF ( input_pids_static )  THEN
+
+       IF ( buildings_f%from_file )  THEN 
+          num_buildings_l = 0
+          num_buildings   = 0
+!
+!--       Allocate at least one element for building ids, 
+          ALLOCATE( build_ids_l(1) )
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                IF ( building_id_f%var(j,i) /= building_id_f%fill )  THEN
+                   IF ( num_buildings_l(myid) > 0 )  THEN
+                      IF ( ANY( building_id_f%var(j,i) .EQ.  build_ids_l ) )   &
+                      THEN
+                         CYCLE
+                      ELSE
+                         num_buildings_l(myid) = num_buildings_l(myid) + 1
 !
 !--                   Resize array with different local building ids
@@ -922,104 +929,105 @@
                    ENDIF
 !
-!--             First occuring building id on PE 
-                ELSE 
-                   num_buildings_l(myid) = num_buildings_l(myid) + 1
-                   build_ids_l(1) = building_id_f%var(j,i)
+!--                First occuring building id on PE 
+                   ELSE 
+                      num_buildings_l(myid) = num_buildings_l(myid) + 1
+                      build_ids_l(1) = building_id_f%var(j,i)
+                   ENDIF
                 ENDIF
-             ENDIF
-          ENDDO
-       ENDDO
-!
-!--    Determine number of different building ids for the entire domain 
+             ENDDO
+          ENDDO
+!
+!--       Determine number of different building ids for the entire domain 
 #if defined( __parallel ) 
-       CALL MPI_ALLREDUCE( num_buildings_l, num_buildings, numprocs,              &
-                           MPI_INTEGER, MPI_SUM, comm2d, ierr ) 
+          CALL MPI_ALLREDUCE( num_buildings_l, num_buildings, numprocs,              &
+                              MPI_INTEGER, MPI_SUM, comm2d, ierr ) 
 #else
-       num_buildings = num_buildings_l
+          num_buildings = num_buildings_l
 #endif
 !
-!--    Gather all buildings ids on each PEs. 
-!--    First, allocate array encompassing all building ids in model domain.  
-       ALLOCATE( build_ids(1:SUM(num_buildings)) )
+!--       Gather all buildings ids on each PEs. 
+!--       First, allocate array encompassing all building ids in model domain.  
+          ALLOCATE( build_ids(1:SUM(num_buildings)) )
 #if defined( __parallel ) 
 !
-!--    Allocate array for displacements. 
-!--    As each PE may has a different number of buildings, so that
-!--    the block sizes send by each PE may not be equal. Hence, 
-!--    information about the respective displacement is required, indicating 
-!--    the respective adress where each MPI-task writes into the receive 
-!--    buffer array  
-       ALLOCATE( displace_dum(0:numprocs-1) )
-       displace_dum(0) = 0
-       DO i = 1, numprocs-1
-          displace_dum(i) = displace_dum(i-1) + num_buildings(i-1)
-       ENDDO
-
-       CALL MPI_ALLGATHERV( build_ids_l(1:num_buildings_l(myid)),                 &
-                            num_buildings(myid),                                  &
-                            MPI_INTEGER,                                          &
-                            build_ids,                                            &
-                            num_buildings,                                        &
-                            displace_dum,                                         & 
-                            MPI_INTEGER,                                          &
-                            comm2d, ierr )   
-
-       DEALLOCATE( displace_dum )
+!--       Allocate array for displacements. 
+!--       As each PE may has a different number of buildings, so that
+!--       the block sizes send by each PE may not be equal. Hence, 
+!--       information about the respective displacement is required, indicating 
+!--       the respective adress where each MPI-task writes into the receive 
+!--       buffer array  
+          ALLOCATE( displace_dum(0:numprocs-1) )
+          displace_dum(0) = 0
+          DO i = 1, numprocs-1
+             displace_dum(i) = displace_dum(i-1) + num_buildings(i-1)
+          ENDDO
+
+          CALL MPI_ALLGATHERV( build_ids_l(1:num_buildings_l(myid)),                 &
+                               num_buildings(myid),                                  &
+                               MPI_INTEGER,                                          &
+                               build_ids,                                            &
+                               num_buildings,                                        &
+                               displace_dum,                                         & 
+                               MPI_INTEGER,                                          &
+                               comm2d, ierr )   
+
+          DEALLOCATE( displace_dum )
 
 #else
-       build_ids = build_ids_l
+          build_ids = build_ids_l
 #endif
 
 !
-!--    Note, in parallel mode building ids can occure mutliple times, as 
-!--    each PE has send its own ids. Therefore, sort out building ids which 
-!--    appear more than one time. 
-       num_build = 0
-       DO  nr = 1, SIZE(build_ids)
-
-          IF ( ALLOCATED(build_ids_final) )  THEN
-             IF ( ANY( build_ids(nr) .EQ. build_ids_final ) )  THEN
-                CYCLE
+!--       Note, in parallel mode building ids can occure mutliple times, as 
+!--       each PE has send its own ids. Therefore, sort out building ids which 
+!--       appear more than one time. 
+          num_build = 0
+          DO  nr = 1, SIZE(build_ids)
+
+             IF ( ALLOCATED(build_ids_final) )  THEN
+                IF ( ANY( build_ids(nr) .EQ. build_ids_final ) )  THEN
+                   CYCLE
+                ELSE
+                   num_build = num_build + 1
+!
+!--                Resize
+                   ALLOCATE( build_ids_final_tmp(1:num_build) )
+                   build_ids_final_tmp(1:num_build-1) = build_ids_final(1:num_build-1)
+                   DEALLOCATE( build_ids_final )
+                   ALLOCATE( build_ids_final(1:num_build) )
+                   build_ids_final(1:num_build-1) = build_ids_final_tmp(1:num_build-1)
+                   build_ids_final(num_build) = build_ids(nr)
+                   DEALLOCATE( build_ids_final_tmp )
+                ENDIF             
              ELSE
                 num_build = num_build + 1
-!
-!--             Resize
-                ALLOCATE( build_ids_final_tmp(1:num_build) )
-                build_ids_final_tmp(1:num_build-1) = build_ids_final(1:num_build-1)
-                DEALLOCATE( build_ids_final )
                 ALLOCATE( build_ids_final(1:num_build) )
-                build_ids_final(1:num_build-1) = build_ids_final_tmp(1:num_build-1)
                 build_ids_final(num_build) = build_ids(nr)
-                DEALLOCATE( build_ids_final_tmp )
-             ENDIF             
-          ELSE
-             num_build = num_build + 1
-             ALLOCATE( build_ids_final(1:num_build) )
-             build_ids_final(num_build) = build_ids(nr)
-          ENDIF
-       ENDDO
-
-!
-!--    Finally, determine maximumum terrain height occupied by the 
-!--    respective building. 
-       ALLOCATE( oro_max_l(1:SIZE(build_ids_final)) )
-       ALLOCATE( oro_max(1:SIZE(build_ids_final))   )
-       oro_max_l = 0.0_wp
-
-       DO  nr = 1, SIZE(build_ids_final)
-          oro_max_l(nr) = MAXVAL(                                              &
-                           MERGE( terrain_height_f%var, 0.0_wp,                &
-                                  building_id_f%var(nys:nyn,nxl:nxr) .EQ.      &
-                                  build_ids_final(nr) ) )
-       ENDDO
+             ENDIF
+          ENDDO
+
+!
+!--       Finally, determine maximumum terrain height occupied by the 
+!--       respective building. 
+          ALLOCATE( oro_max_l(1:SIZE(build_ids_final)) )
+          ALLOCATE( oro_max(1:SIZE(build_ids_final))   )
+          oro_max_l = 0.0_wp
+
+          DO  nr = 1, SIZE(build_ids_final)
+             oro_max_l(nr) = MAXVAL(                                              &
+                              MERGE( terrain_height_f%var, 0.0_wp,                &
+                                     building_id_f%var(nys:nyn,nxl:nxr) .EQ.      &
+                                     build_ids_final(nr) ) )
+          ENDDO
    
 #if defined( __parallel )    
-       IF ( SIZE(build_ids_final) >= 1 ) THEN
-          CALL MPI_ALLREDUCE( oro_max_l, oro_max, SIZE( oro_max ), MPI_REAL,   &
-                              MPI_MAX, comm2d, ierr ) 
+          IF ( SIZE(build_ids_final) >= 1 ) THEN
+             CALL MPI_ALLREDUCE( oro_max_l, oro_max, SIZE( oro_max ), MPI_REAL,   &
+                                 MPI_MAX, comm2d, ierr ) 
+          ENDIF
+#else
+          oro_max = oro_max_l
+#endif
        ENDIF
-#else
-       oro_max = oro_max_l
-#endif
 !
 !--    Map orography as well as buildings onto grid. 
@@ -1047,5 +1055,5 @@
 !--             Set building grid points. Here, only consider 2D buildings. 
 !--             3D buildings require separate treatment. 
-                IF ( buildings_f%lod == 1 )  THEN
+                IF ( buildings_f%from_file  .AND.  buildings_f%lod == 1 )  THEN
                    IF ( building_id_f%var(j,i) /= building_id_f%fill )  THEN
 !
@@ -1071,5 +1079,5 @@
 !--          height covered by the building. In other words, extend 
 !--          building down to the respective local terrain-surface height. 
-             IF ( buildings_f%lod == 2 )  THEN
+             IF ( buildings_f%from_file  .AND.  buildings_f%lod == 2 )  THEN
                 IF ( building_id_f%var(j,i) /= building_id_f%fill )  THEN
 !
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2895)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2897)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Relax restrictions for topography input, terrain and building heights can be
+! input separately and are not mandatory any more. 
+! 
+! 2874 2018-03-13 10:55:42Z knoop
 ! Bugfix: wrong placement of netcdf cpp-macros fixed
 ! 
@@ -1825,17 +1829,23 @@
        ENDDO
 !
-!--    Check for minimum requirement of topography data in case
-!--    static input file is used. Note, doing this check in check_parameters 
+!--    Check for minimum requirement to setup building topography. If buildings
+!--    are provided, also an ID and a type are required. 
+!--    Note, doing this check in check_parameters 
 !--    will be too late (data will be used for grid inititialization before).
        IF ( input_pids_static )  THEN
-          IF ( .NOT. terrain_height_f%from_file  .OR.                          &
-               .NOT. building_id_f%from_file     .OR.                          &
-               .NOT. buildings_f%from_file )  THEN                        
-             message_string = 'Minimum requirement for topography input ' //   &
-                              'is not fulfilled. ' //                          &
-                              'Orography, buildings, as well as building ' //  &
-                              'IDs are required.'
+          IF ( buildings_f%from_file  .AND.                                    &
+               .NOT. building_id_f%from_file )  THEN                        
+             message_string = 'If building heigths are prescribed in ' //      &
+                              'static input file, also an ID is required.'
              CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
           ENDIF
+       ENDIF
+!
+!--    In case no terrain height is provided by static input file, allocate 
+!--    array nevertheless and set terrain height to 0, which simplifies 
+!--    topography initialization.
+       IF ( .NOT. terrain_height_f%from_file )  THEN
+          ALLOCATE ( terrain_height_f%var(nys:nyn,nxl:nxr) )
+          terrain_height_f%var = 0.0_wp
        ENDIF
 !
