Index: palm/trunk/UTIL/inifor/src/inifor_defs.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 4537)
+++ palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 4538)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Bumped version number
+! 
+! 
+! 4523 2020-05-07 15:58:16Z eckhard
 ! Updated copyright notice, bumped version number
 ! 
@@ -188,5 +192,5 @@
     ACHAR( 10 ) // ' Copyright 2017-2020 Deutscher Wetterdienst Offenbach' !< Copyright notice
  CHARACTER(LEN=*), PARAMETER ::  LOG_FILE_NAME = 'inifor.log' !< Name of INIFOR's log file
- CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.13'           !< INIFOR version number
+ CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.14'           !< INIFOR version number
  
  END MODULE inifor_defs
Index: palm/trunk/UTIL/inifor/src/inifor_grid.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 4537)
+++ palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 4538)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Modularize setup of PALM origin
+! 
+! 
+! 4523 2020-05-07 15:58:16Z eckhard
 ! respect integer working precision (iwp) specified in inifor_defs.f90
 ! 
@@ -166,7 +170,7 @@
                PIDS_ORIGIN_Z
     USE inifor_io,                                                             &
-        ONLY:  get_cosmo_grid, get_netcdf_attribute, get_netcdf_dim_vector,    &
-               get_netcdf_variable, parse_command_line_arguments,              &
-               get_input_file_list, validate_config
+        ONLY:  get_cosmo_grid, get_input_file_list, get_netcdf_attribute,      &
+               get_netcdf_dim_vector, get_netcdf_variable, set_palm_origin,    &
+               parse_command_line_arguments, validate_config
     USE inifor_transform,                                                      &
         ONLY:  average_2d, rotate_to_cosmo, find_horizontal_neighbours,        &
@@ -561,41 +565,5 @@
     CALL get_netcdf_variable(cfg%soiltyp_file, cosmo_var, soiltyp)
 
-    message = 'Reading PALM-4U origin from'
-    IF (TRIM(cfg%static_driver_file) .NE. '')  THEN
-
-       origin_lon = get_netcdf_attribute(cfg%static_driver_file, TRIM( PIDS_ORIGIN_LON ) )
-       origin_lat = get_netcdf_attribute(cfg%static_driver_file, TRIM( PIDS_ORIGIN_LAT ) )
-       z0         = get_netcdf_attribute(cfg%static_driver_file, TRIM( PIDS_ORIGIN_Z ) )
-
-
-       message = TRIM(message) // " static driver file '"                   &
-                               // TRIM(cfg%static_driver_file) // "'"
-
-
-    ELSE
-
-       origin_lon = longitude
-       origin_lat = latitude
-
-       message = TRIM(message) // " namlist file '"                         &
-                               // TRIM(cfg%namelist_file) // "'"
-
-    ENDIF
-    origin_lon = origin_lon * TO_RADIANS
-    origin_lat = origin_lat * TO_RADIANS
-
-    CALL report('setup_parameters', message)
-
-    IF ( cfg%z0_is_set .AND. TRIM( cfg%static_driver_file ) .NE. '' )  THEN
-
-       message = 'You specified both --static-driver/-t and --elevation/-z0. ' // &
-                 'Using the command line value (' // TRIM( real_to_str_f( cfg%z0 ) ) // &
-                 ') instead of static driver value (' // TRIM( real_to_str_f( z0 ) ) // ').'
-       CALL warn('setup_parameters', message)
-
-       z0 = cfg%z0
-
-    END IF
-
+    CALL set_palm_origin(cfg, longitude, latitude, origin_lon, origin_lat, z0)
     p0 = cfg%p0
 
@@ -3980,4 +3948,5 @@
              CASE DEFAULT
                 message = "Invalid averaging period '" // TRIM(str(dt)) // " hours"
+                message = "Invalid averaging period '" // TRIM(str(dt)) // " hours"
                 CALL inifor_abort('preprocess', message)
 
Index: palm/trunk/UTIL/inifor/src/inifor_io.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 4537)
+++ palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 4538)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Make setting the vertical PALM origin mandatory
+! 
+! 
+! 4523 2020-05-07 15:58:16Z eckhard
 ! respect integer working precision (iwp) specified in inifor_defs.f90
 ! 
@@ -139,5 +143,6 @@
                NC_DEPTH_NAME, NC_HHL_NAME, NC_RLAT_NAME, NC_RLON_NAME,         &
                NC_ROTATED_POLE_NAME, NC_POLE_LATITUDE_NAME,                    &
-               NC_POLE_LONGITUDE_NAME, RHO_L, iwp, wp
+               NC_POLE_LONGITUDE_NAME, RHO_L, iwp, wp,                         &
+               PIDS_ORIGIN_LON, PIDS_ORIGIN_LAT, PIDS_ORIGIN_Z
     USE inifor_types
     USE inifor_util,                                                           &
@@ -431,4 +436,5 @@
     cfg%soil_prefix_is_set = .FALSE.
     cfg%soilmoisture_prefix_is_set = .FALSE.
+    cfg%static_driver_is_set = .FALSE.
     cfg%ug_defined_by_user = .FALSE.
     cfg%vg_defined_by_user = .FALSE.
@@ -503,4 +509,5 @@
 
              CASE( '-static', '-t', '--static-driver' )
+                cfg%static_driver_is_set = .TRUE.
                 CALL get_option_argument( i, arg )
                 cfg%static_driver_file = TRIM(arg)
@@ -762,4 +769,14 @@
        message = "You specified only one component of the geostrophic " // &
                  "wind. Please specify either both or none."
+       CALL inifor_abort( 'validate_config', message )
+    ENDIF
+
+    IF ( .NOT. cfg%static_driver_is_set .AND. .NOT. cfg%z0_is_set )  THEN
+       message =                                                               &
+          "The vertical origin of the PALM grid has not been defined. " // NEW_LINE(" ") // &
+          "Please specify the right value for your setup by either " // NEW_LINE(" ") // &
+          "  - using the command-line option --elevation <height above sea level>, or by" // NEW_LINE(" ") // &
+          "  - specifying a static driver file using --static <filename> in order to use " // NEW_LINE(" ") // &
+          "    use the value of origin_z (and origin_lon and origin_lat) specifed therein."
        CALL inifor_abort( 'validate_config', message )
     ENDIF
@@ -1512,4 +1529,55 @@
  END SUBROUTINE check
 
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Setup the origin of the PALM coordinate system based on what is given in the
+!> INIFOR namelist file and via an optional static driver.
+!------------------------------------------------------------------------------!
+ SUBROUTINE set_palm_origin( cfg, namelist_longitude, namelist_latitude,       &
+                             origin_lon, origin_lat, z0 )
+
+    TYPE(inifor_config), INTENT(IN) ::  cfg
+    REAL(wp), INTENT(IN)            ::  namelist_longitude, namelist_latitude
+    REAL(wp), INTENT(OUT)           ::  origin_lon, origin_lat, z0
+
+    message = 'Reading PALM-4U origin from'
+    IF ( TRIM( cfg%static_driver_file ) .NE. '' )  THEN
+
+       origin_lon = get_netcdf_attribute( cfg%static_driver_file, TRIM( PIDS_ORIGIN_LON ) )
+       origin_lat = get_netcdf_attribute( cfg%static_driver_file, TRIM( PIDS_ORIGIN_LAT ) )
+       z0         = get_netcdf_attribute( cfg%static_driver_file, TRIM( PIDS_ORIGIN_Z ) )
+
+       message = TRIM(message) // " static driver file '"                      &
+                               // TRIM( cfg%static_driver_file ) // "'"
+
+
+    ELSE
+
+       origin_lon = namelist_longitude
+       origin_lat = namelist_latitude
+
+       message = TRIM( message ) // " namlist file '"                          &
+                                 // TRIM( cfg%namelist_file ) // "'"
+
+    ENDIF
+    origin_lon = origin_lon * TO_RADIANS
+    origin_lat = origin_lat * TO_RADIANS
+
+    CALL report('set_palm_origin', message)
+
+    IF ( cfg%z0_is_set )  THEN
+       z0 = cfg%z0
+       IF ( TRIM( cfg%static_driver_file ) .NE. '' )  THEN
+          message = 'You specified both --static-driver/-t and --elevation/-z0. ' // &
+                    'Using the command line value (' // TRIM( real_to_str_f( cfg%z0 ) ) // &
+                    ') instead of static driver value (' // TRIM( real_to_str_f( z0 ) ) // ').'
+          CALL warn( 'set_palm_origin', message )
+       ENDIF
+    ENDIF
+
+ END SUBROUTINE set_palm_origin
+
  END MODULE inifor_io
 #endif
Index: palm/trunk/UTIL/inifor/src/inifor_types.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_types.f90	(revision 4537)
+++ palm/trunk/UTIL/inifor/src/inifor_types.f90	(revision 4538)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Added boolean indicator for --static-driver option invocation
+! 
+! 
+! 4523 2020-05-07 15:58:16Z eckhard
 ! respect integer working precision (iwp) specified in inifor_defs.f90
 ! 
@@ -131,4 +135,5 @@
     LOGICAL              ::  soil_prefix_is_set          !< indicates whether the soil prefix was set manually
     LOGICAL              ::  soilmoisture_prefix_is_set  !< indicates whether the soilmoisture prefix was set manually
+    LOGICAL              ::  static_driver_is_set        !< indicates whether a static driver was given
     LOGICAL              ::  ug_defined_by_user          !< indicates whether ug was set manually
     LOGICAL              ::  vg_defined_by_user          !< indicates whether vg was set manually
