Index: palm/trunk/UTIL/inifor/README
===================================================================
--- palm/trunk/UTIL/inifor/README	(revision 3618)
+++ palm/trunk/UTIL/inifor/README	(revision 3678)
@@ -1,3 +1,3 @@
-# INIFOR - Mesoscale Interface for Initializing and Forcing PALM-4U (v1.4.3)
+# INIFOR - Mesoscale Interface for Initializing and Forcing PALM-4U (v1.4.4)
 
 INIFOR provides the meteorological fields required to initialize and drive the
Index: palm/trunk/UTIL/inifor/src/inifor_control.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_control.f90	(revision 3618)
+++ palm/trunk/UTIL/inifor/src/inifor_control.f90	(revision 3678)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Added message buffer for displaying tips to rectify encountered errors
+! 
+! 
+! 3618 2018-12-10 13:25:22Z eckhard
 ! Prefixed all INIFOR modules with inifor_
 ! 
@@ -73,4 +77,5 @@
 
     CHARACTER (LEN=5000) ::  message = '' !< log message buffer
+    CHARACTER (LEN=5000) ::  tip     = '' !< optional log message buffer for tips on how to rectify encountered errors
 
  CONTAINS
Index: palm/trunk/UTIL/inifor/src/inifor_defs.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 3618)
+++ palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 3678)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Bumped version number
+! 
+! 
+! 3618 2018-12-10 13:25:22Z eckhard
 ! Prefixed module with inifor_
 ! 
@@ -127,5 +131,5 @@
  INTEGER, PARAMETER          ::  FORCING_STEP = 1             !< Number of hours between forcing time steps [h]
  REAL(dp), PARAMETER         ::  NUDGING_TAU = 21600.0_dp     !< Nudging relaxation time scale [s]
- CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.3'            !< INIFOR version number
+ CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.4'            !< INIFOR version number
  CHARACTER(LEN=*), PARAMETER ::  COPYRIGHT = 'Copyright 2017-2018 Leibniz Universitaet Hannover' // &
      ACHAR( 10 ) // ' Copyright 2017-2018 Deutscher Wetterdienst Offenbach' !< Copyright notice
Index: palm/trunk/UTIL/inifor/src/inifor_grid.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 3618)
+++ palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 3678)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! bugfix: Avoid empty averaging regions for small PALM domains
+! change: moved get_input_file_list() to io module
+! 
+! 
+! 3618 2018-12-10 13:25:22Z eckhard
 ! Prefixed all INIFOR modules with inifor_, removed unused variables
 ! 
@@ -112,5 +117,5 @@
         ONLY:  get_netcdf_attribute, get_netcdf_dim_vector,                    &
                get_netcdf_variable, parse_command_line_arguments,              &
-               validate_config
+               get_input_file_list, validate_config
     USE inifor_transform,                                                      &
         ONLY:  average_2d, rotate_to_cosmo, find_horizontal_neighbours,&
@@ -1625,9 +1630,9 @@
        dlat = cosmo_lat(1) - cosmo_lat(0)
 
-       imin = CEILING( (avg_grid % lon(1) - cosmo_lon(0)) / dlon )
-       imax = FLOOR  ( (avg_grid % lon(2) - cosmo_lon(0)) / dlon )
-
-       jmin = CEILING( (avg_grid % lat(1) - cosmo_lat(0)) / dlat )
-       jmax = FLOOR  ( (avg_grid % lat(2) - cosmo_lat(0)) / dlat )
+       imin = FLOOR  ( (avg_grid % lon(1) - cosmo_lon(0)) / dlon )
+       imax = CEILING( (avg_grid % lon(2) - cosmo_lon(0)) / dlon )
+
+       jmin = FLOOR  ( (avg_grid % lat(1) - cosmo_lat(0)) / dlat )
+       jmax = CEILING( (avg_grid % lat(2) - cosmo_lat(0)) / dlat )
        
        message = "Averaging '" // TRIM(avg_grid % kind) // "' over "//         &
@@ -3641,31 +3646,4 @@
 
 
-    SUBROUTINE get_input_file_list(start_date_string, start_hour, end_hour,        &
-                                   step_hour, path, prefix, suffix, file_list)
-
-       CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
-       CHARACTER (LEN=*),    INTENT(IN) ::  prefix, suffix, path
-       INTEGER,              INTENT(IN) ::  start_hour, end_hour, step_hour
-       CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
-
-       INTEGER             ::  number_of_intervals, hour, i
-       CHARACTER(LEN=DATE) ::  date_string
-
-       number_of_intervals = CEILING( REAL(end_hour - start_hour) / step_hour )
-       ALLOCATE( file_list(number_of_intervals + 1) )
-
-       DO i = 0, number_of_intervals
-          hour = start_hour + i * step_hour
-          date_string = add_hours_to(start_date_string, hour)
-
-          file_list(i+1) = TRIM(path) // TRIM(prefix) // TRIM(date_string) //    &
-                           TRIM(suffix) // '.nc'
-          message = "Set up input file name '" // TRIM(file_list(i+1)) //"'"
-          CALL report('input_file_list', message)
-       END DO
-
-    END SUBROUTINE get_input_file_list
-
-
 !------------------------------------------------------------------------------!
 ! Description:
Index: palm/trunk/UTIL/inifor/src/inifor_io.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 3618)
+++ palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 3678)
@@ -26,4 +26,11 @@
 ! -----------------
 ! $Id$
+! Moved get_input_file_list() here from grid module, added check for presence of
+!    input files
+!
+! 
+! 
+! 
+! 3618 2018-12-10 13:25:22Z eckhard
 ! Prefixed all INIFOR modules with inifor_
 ! 
@@ -98,5 +105,5 @@
     USE inifor_types
     USE inifor_util,                                                           &
-        ONLY:  reverse, str, real_to_str
+        ONLY:  add_hours_to, reverse, str, real_to_str
     USE netcdf
 
@@ -529,4 +536,102 @@
 
    
+
+   SUBROUTINE get_datetime_file_list( start_date_string, start_hour, end_hour, &
+                                      step_hour, input_path, prefix, suffix,   &
+                                      file_list )
+
+      CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
+      CHARACTER (LEN=*),    INTENT(IN) ::  prefix, suffix, input_path
+      INTEGER,              INTENT(IN) ::  start_hour, end_hour, step_hour
+      CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
+
+      INTEGER             ::  number_of_intervals, hour, i
+      CHARACTER(LEN=DATE) ::  date_string
+
+      number_of_intervals = CEILING( REAL(end_hour - start_hour) / step_hour )
+      ALLOCATE( file_list(number_of_intervals + 1) )
+
+      DO i = 0, number_of_intervals
+
+         hour = start_hour + i * step_hour
+         date_string = add_hours_to(start_date_string, hour)
+
+         file_list(i+1) = TRIM(input_path) // TRIM(prefix) //                  &
+                          TRIM(date_string) // TRIM(suffix) // '.nc'
+
+         message = "Set up input file name '" // TRIM(file_list(i+1)) // "'"
+         CALL report('input_file_list', message)
+
+      END DO
+
+   END SUBROUTINE get_datetime_file_list
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Establish a list of files based on the given start and end times and file
+!> prefixes and suffixes.
+!------------------------------------------------------------------------------!
+   SUBROUTINE get_input_file_list( start_date_string, start_hour, end_hour,    &
+                                   step_hour, input_path, prefix, suffix,      &
+                                   file_list )
+
+      CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
+      CHARACTER (LEN=*),    INTENT(IN) ::  prefix, suffix, input_path
+      INTEGER,              INTENT(IN) ::  start_hour, end_hour, step_hour
+      CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
+
+      INTEGER             ::  number_of_intervals, hour, i
+      CHARACTER(LEN=DATE) ::  date_string
+      CHARACTER(LEN=PATH) ::  file_name
+
+      CALL get_datetime_file_list( start_date_string, start_hour, end_hour,    &
+                                   step_hour, input_path, prefix, suffix,      &
+                                   file_list )
+
+      tip = "Please check if you specified the correct file prefix " //        &
+            "using the options --input-prefix, --flow-prefix, etc."
+
+      DO i = 1, SIZE(file_list)
+          CALL verify_file(file_list(i), 'input', tip)
+      END DO
+
+   END SUBROUTINE get_input_file_list
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Abort INIFOR if the given file is not present.
+!------------------------------------------------------------------------------!
+   SUBROUTINE verify_file(file_name, file_kind, tip)
+
+      CHARACTER(LEN=*), INTENT(IN)           ::  file_name, file_kind
+      CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  tip
+
+      IF (.NOT. file_present(file_name))  THEN
+
+         IF (LEN(TRIM(file_name)) == 0)  THEN
+
+            message = "No name was given for the " // TRIM(file_kind) // " file."
+
+         ELSE
+
+            message = "The " // TRIM(file_kind) // " file '" //                &
+                      TRIM(file_name) // "' was not found."
+
+            IF (PRESENT(tip))  THEN
+               message = TRIM(message) // " " // TRIM(tip)
+            END IF
+
+         END IF
+
+         CALL inifor_abort('verify_file', message)
+
+      END IF
+
+   END SUBROUTINE verify_file
+
+
 !------------------------------------------------------------------------------!
 ! Description:
@@ -552,23 +657,15 @@
    SUBROUTINE validate_config(cfg)
       TYPE(inifor_config), INTENT(IN) ::  cfg
-      LOGICAL                         ::  all_files_present
-
-      all_files_present = .TRUE.
-      all_files_present = all_files_present .AND. file_present(cfg % hhl_file, 'HHL')
-      all_files_present = all_files_present .AND. file_present(cfg % namelist_file, 'NAMELIST')
-      all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file, 'SOILTYP')
+
+      CALL verify_file(cfg % hhl_file, 'HHL')
+      CALL verify_file(cfg % namelist_file, 'NAMELIST')
+      CALL verify_file(cfg % soiltyp_file, 'SOILTYP')
 
 !
 !--   Only check optional static driver file name, if it has been given.
       IF (TRIM(cfg % static_driver_file) .NE. '')  THEN
-         all_files_present = all_files_present .AND. file_present(cfg % static_driver_file, 'static driver')
+         CALL verify_file(cfg % static_driver_file, 'static driver')
       END IF
 
-      IF (.NOT. all_files_present)  THEN
-         message = "INIFOR configuration invalid; some input files are missing."
-         CALL inifor_abort( 'validate_config', message )
-      END IF
-      
-      
       SELECT CASE( TRIM(cfg % ic_mode) )
       CASE( 'profile', 'volume')
@@ -619,25 +716,8 @@
 !> Check whether the given file is present on the filesystem.
 !------------------------------------------------------------------------------!
-   LOGICAL FUNCTION file_present(filename, kind)
+   LOGICAL FUNCTION file_present(filename)
       CHARACTER(LEN=PATH), INTENT(IN) ::  filename
-      CHARACTER(LEN=*), INTENT(IN)    ::  kind
-
-      IF (LEN(TRIM(filename))==0)  THEN
-
-         file_present = .FALSE.
-         message = "No name was given for the " // TRIM(kind) // " file."
-         CALL report('file_present', message)
-
-      ELSE
-
-         INQUIRE(FILE=filename, EXIST=file_present)
-
-         IF (.NOT. file_present)  THEN
-            message = "The given " // TRIM(kind) // " file '" //               &
-                      TRIM(filename) // "' does not exist."
-            CALL report('file_present', message)
-         END IF
-
-      END IF
+
+      INQUIRE(FILE=filename, EXIST=file_present)
 
    END FUNCTION file_present
Index: palm/trunk/UTIL/inifor/src/inifor_transform.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/inifor_transform.f90	(revision 3618)
+++ palm/trunk/UTIL/inifor/src/inifor_transform.f90	(revision 3678)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Check if set of averaging columns is empty
+! 
+! 
+! 3618 2018-12-10 13:25:22Z eckhard
 ! Prefixed all INIFOR modules with inifor_, removed unused variables
 ! 
@@ -226,8 +230,14 @@
        REAL(dp) ::  ni
 
-       IF (SIZE(ii) .NE. SIZE(jj))  THEN
+       IF (SIZE(ii) /= SIZE(jj))  THEN
           message = "Length of 'ii' and 'jj' index lists do not match." //     &
              NEW_LINE(' ') // "ii has " // str(SIZE(ii)) // " elements, " //   &
              NEW_LINE(' ') // "jj has " // str(SIZE(jj)) // "."
+          CALL inifor_abort('average_2d', message)
+       END IF
+
+       IF (SIZE(ii) == 0)  THEN
+          message = "No columns to average over; " //                          &
+                    "size of index lists 'ii' and 'jj' is zero."
           CALL inifor_abort('average_2d', message)
        END IF
Index: palm/trunk/UTIL/inifor/tests/test-input-files.f90
===================================================================
--- palm/trunk/UTIL/inifor/tests/test-input-files.f90	(revision 3618)
+++ palm/trunk/UTIL/inifor/tests/test-input-files.f90	(revision 3678)
@@ -21,4 +21,5 @@
 ! Current revisions:
 ! -----------------
+! Switched to get_datetime_file_list()
 ! 
 ! 
@@ -51,6 +52,6 @@
     USE inifor_defs,                                                           &
         ONLY :  PATH
-    USE inifor_grid,                                                           &
-        ONLY :  get_input_file_list
+    USE inifor_io,                                                             &
+        ONLY :  get_datetime_file_list
     USE test_utils
     
@@ -78,8 +79,8 @@
 
     ! Act
-    CALL get_input_file_list(start_date_string='2017102823',                   &
-                             start_hour=0, end_hour=5, step_hour=1,            &
-                             path='./', prefix="laf", suffix='-test',          &
-                             file_list=file_list)
+    CALL get_datetime_file_list(start_date_string='2017102823',                &
+                                start_hour=0, end_hour=5, step_hour=1,         &
+                                input_path='./', prefix="laf", suffix='-test', &
+                                file_list=file_list)
 
     ! Assert
@@ -103,8 +104,8 @@
 
     ! Act
-    CALL get_input_file_list(start_date_string='2016022823',                   &
-                             start_hour=0, end_hour=1, step_hour=1,            &
-                             path='./', prefix="laf", suffix='-test',          &
-                             file_list=file_list)
+    CALL get_datetime_file_list(start_date_string='2016022823',                &
+                                start_hour=0, end_hour=1, step_hour=1,         &
+                                input_path='./', prefix="laf", suffix='-test', &
+                                file_list=file_list)
 
     ! Assert
@@ -131,8 +132,8 @@
 
     ! Act
-    CALL get_input_file_list(start_date_string='2017102901',                   &
-                             start_hour=-2, end_hour=3, step_hour=2,           &
-                             path='./', prefix="laf", suffix='-test',          &
-                             file_list=file_list)
+    CALL get_datetime_file_list(start_date_string='2017102901',                &
+                                start_hour=-2, end_hour=3, step_hour=2,        &
+                                input_path='./', prefix="laf", suffix='-test', &
+                                file_list=file_list)
 
     PRINT *, file_list
