Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 4506)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 4507)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! update origin_z with shifting height of orography (oro_min)
+! 
+! 4457 2020-03-11 14:20:43Z raasch
 ! use statement for exchange horiz added,
 ! bugfix for call of exchange horiz 2d
@@ -936,5 +939,5 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, message_string, ocean_mode
+        ONLY:  bc_lr_cyc, bc_ns_cyc, ocean_mode
 
     USE exchange_horiz_mod,                                                    &
@@ -946,5 +949,7 @@
 
     USE netcdf_data_input_mod,                                                 &
-        ONLY:  buildings_f, building_id_f, building_type_f, input_pids_static, &
+        ONLY:  buildings_f, building_id_f, building_type_f,                    &
+               init_model,                                                     &
+               input_pids_static,                                              &
                terrain_height_f
 
@@ -983,10 +988,10 @@
 
 !
-!-- Reference lowest terrain height to zero. In case the minimum terrain height
-!-- is non-zero, all grid points of the lower vertical grid levels might be 
-!-- entirely below the surface, meaning a waste of computational resources.
-!-- In order to avoid this, remove the lowest terrain height. Please note,
-!-- in case of a nested run, the global minimum from all parent and childs 
-!-- need to be remove to avoid steep edges at the child-domain boundaries.
+!-- Reference lowest terrain height to zero. This ensures that first, 
+!-- non-required gird levels (those which lie entirely below the minimum 
+!-- orography) are avoided, and second, that also negative orography can be used
+!-- within the input file.
+!-- Please note, in case of a nested run, the global minimum from all parent and 
+!-- childs need to be remove to avoid steep edges at the child-domain boundaries.
     IF ( input_pids_static )  THEN
     
@@ -998,12 +1003,8 @@
 #endif
        terrain_height_f%var = terrain_height_f%var - oro_min
-!                           
-!--    Give an informative message that terrain height is referenced to zero    
-       IF ( oro_min > 0.0_wp )  THEN
-          WRITE( message_string, * ) 'Terrain height was internally shifted '//&
-                          'downwards by ', oro_min, 'meter(s) to save ' //     &
-                          'computational resources.'
-          CALL message( 'init_grid', 'PA0505', 0, 0, 0, 6, 0 )
-       ENDIF
+!
+!--    Update reference height used within output files
+       init_model%origin_z = init_model%origin_z + oro_min
+
     ENDIF    
     
@@ -2604,6 +2605,2 @@
 
  END SUBROUTINE set_topo_flags
-
-
-
-
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4506)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4507)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! - bugfix: check terrain height for fill values directly after reading
+! - changes: 
+!   - remove check for negative zt
+!   - add reference height from input file upon PALM reference height (origin_z)
+! 
+! 4457 2020-03-11 14:20:43Z raasch
 ! use statement for exchange horiz added,
 ! bugfixes for calls of exchange horiz 2d
@@ -988,4 +994,7 @@
 !
 !--    Copy latitude, longitude, origin_z, rotation angle on init type
+!--    NOTE: A shifting height might have already been saved to orgin_z in
+!--    init_grid; therefore, do not override but add the reference height from
+!--    the input file.
        init_model%latitude        = input_file_atts%origin_lat
        init_model%longitude       = input_file_atts%origin_lon
@@ -993,5 +1002,5 @@
        init_model%origin_x        = input_file_atts%origin_x
        init_model%origin_y        = input_file_atts%origin_y
-       init_model%origin_z        = input_file_atts%origin_z  
+       init_model%origin_z        = init_model%origin_z + input_file_atts%origin_z
        init_model%rotation_angle  = input_file_atts%rotation_angle  
 
@@ -2553,9 +2562,23 @@
           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
+
+       IF ( terrain_height_f%from_file )  THEN
+!
+!--       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 systems might be implemented
+!--       later.
+!--       NOTE: This check must be placed here as terrain_height_f is altered
+!--       within init_grid which is called before netcdf_data_input_check_static
+          IF ( ANY( terrain_height_f%var == terrain_height_f%fill ) )  THEN
+             message_string = 'NetCDF variable zt is not ' //                  &
+                              'allowed to have missing data'
+             CALL message( 'netcdf_data_input_mod', 'PA0550', 2, 2, myid, 6, 0 )
+          ENDIF
+       ELSE
+!
+!--       In case no terrain height is provided by static input file, allocate
+!--       array nevertheless and set terrain height to 0, which simplifies
+!--       topography initialization.
           ALLOCATE ( terrain_height_f%var(nys:nyn,nxl:nxr) )
           terrain_height_f%var = 0.0_wp
@@ -3161,21 +3184,4 @@
              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
-!--    systems might be implemented later.
-!--    Please note, if no terrain height is provided, it is set to 0.
-       IF ( ANY( terrain_height_f%var == terrain_height_f%fill ) )  THEN
-          message_string = 'NetCDF variable zt is not ' //                     &
-                           'allowed to have missing data'
-          CALL message( 'netcdf_data_input_mod', 'PA0550', 2, 2, myid, 6, 0 )
-       ENDIF
-!
-!--    Check for negative terrain heights
-       IF ( ANY( terrain_height_f%var < 0.0_wp ) )  THEN
-          message_string = 'NetCDF variable zt is not ' //                     &
-                           'allowed to have negative values'
-          CALL message( 'netcdf_data_input_mod', 'PA0551', 2, 2, myid, 6, 0 )
        ENDIF
 !
