Index: /palm/trunk/UTIL/inifor/src/inifor_defs.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 4552)
+++ /palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 4553)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Bumped version number
+! 
+! 
+! 4538 2020-05-18 13:45:35Z eckhard
 ! Bumped version number
 ! 
@@ -192,5 +196,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.14'           !< INIFOR version number
+ CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.4.15'           !< 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 4552)
+++ /palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 4553)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! Fixed domain extent check
+! Added and fixed code documentation
+! 
+! 
+! 4538 2020-05-18 13:45:35Z eckhard
 ! Modularize setup of PALM origin
 ! 
@@ -687,21 +692,4 @@
     averaging_width_ns = averaging_angle * EARTH_RADIUS
 
-    lonmin_tot = MIN(lam_centre - averaging_angle, lonmin_palm)
-    lonmax_tot = MAX(lam_centre + averaging_angle, lonmax_palm)
-    latmin_tot = MIN(phi_centre - averaging_angle, latmin_palm)
-    latmax_tot = MAX(phi_centre + averaging_angle, latmax_palm)
-
-    palm_domain_outside_cosmo = ANY(                                           &
-       (/ lonmin_tot,   -lonmax_tot,   latmin_tot,   -latmax_tot/) .LT.        &
-       (/ lonmin_cosmo, -lonmax_cosmo, latmin_cosmo, -latmax_cosmo/)           &
-    )
-
-    IF ( palm_domain_outside_cosmo )  THEN
-       message = 'PALM domain or geostrophic averaging domains extend ' //     &
-                 'outside COSMO domain.'
-       CALL inifor_abort( 'setup_parameters', message )
-    ENDIF
-
-
 !
 !-- Coriolis parameter
@@ -1077,4 +1065,21 @@
     latmax_palm = MAXVAL(palm_intermediate%clat)
 
+    lonmin_tot = MIN(lam_centre - averaging_angle, lonmin_palm)
+    lonmax_tot = MAX(lam_centre + averaging_angle, lonmax_palm)
+    latmin_tot = MIN(phi_centre - averaging_angle, latmin_palm)
+    latmax_tot = MAX(phi_centre + averaging_angle, latmax_palm)
+
+    palm_domain_outside_cosmo = ANY(                                           &
+       (/ lonmin_tot,   -lonmax_tot,   latmin_tot,   -latmax_tot/) .LT.        &
+       (/ lonmin_cosmo, -lonmax_cosmo, latmin_cosmo, -latmax_cosmo/)           &
+    )
+
+    IF ( palm_domain_outside_cosmo )  THEN
+       message = 'PALM domain or geostrophic averaging domains extend ' //     &
+                 'outside COSMO domain.'
+       CALL inifor_abort( 'setup_grids', message )
+    ENDIF
+
+
     CALL init_averaging_grid(averaged_initial_scalar_profile, cosmo_grid,   &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
@@ -1268,13 +1273,13 @@
 
     IF (setup_volumetric)  THEN
-       ALLOCATE( intermediate_grid%h(0:intermediate_grid%nx,            &
-                                     0:intermediate_grid%ny,            &
-                                     0:intermediate_grid%nz) ) 
-       intermediate_grid%h(:,:,:) = - EARTH_RADIUS
+       ALLOCATE( intermediate_grid%intermediate_h(0:intermediate_grid%nx,      &
+                                                  0:intermediate_grid%ny,      &
+                                                  0:intermediate_grid%nz) ) 
+       intermediate_grid%intermediate_h(:,:,:) = - EARTH_RADIUS
 
 !
 !--    For w points, use hhl, for scalars use hfl
 !--    compute the full heights for the intermediate grids
-       CALL interpolate_2d(cosmo_h, intermediate_grid%h, intermediate_grid)
+       CALL interpolate_2d(cosmo_h, intermediate_grid%intermediate_h, intermediate_grid)
        CALL find_vertical_neighbours_and_weights_interp(grid, intermediate_grid)
     ENDIF
@@ -1550,5 +1555,5 @@
 !> kind : kind of quantity to be averaged using this averaging grid.
 !>    Destinguishes COSMO-DE scalar and w-velocity levels. Note that finding the
-!>    parent/COSMO columns for the region in get_cosmo_averaging_region() is
+!>    parent/COSMO columns for the region in get_latlon_averaging_region() is
 !>    independent of 'kind' b/ecause INIFOR uses column-centred u and v velocity
 !>    components, which are computed in the preprocessing step.
@@ -1595,5 +1600,5 @@
 !-- Find and store COSMO columns that fall into the coordinate range
 !-- given by avg_grid%clon, %clat
-    CALL get_cosmo_averaging_region(avg_grid, cosmo_grid)
+    CALL get_latlon_averaging_region(avg_grid, cosmo_grid)
 
     ALLOCATE (avg_grid%kkk(avg_grid%n_columns, avg_grid%nz, 2) )
@@ -1612,15 +1617,15 @@
           message = "Averaging grid kind '" // TRIM(avg_grid%kind) // &
                     "' is not supported. Use 'scalar', 'u', or 'v'."
-          CALL inifor_abort('get_cosmo_averaging_region', message)
+          CALL inifor_abort('get_latlon_averaging_region', message)
 
     END SELECT
 
 !
-!-- For level-besed averaging, compute average heights
+!-- For level-based averaging, compute average heights
     level_based_averaging = ( TRIM(cfg%averaging_mode) == 'level' )
     IF (level_based_averaging)  THEN
-       ALLOCATE(avg_grid%h(1,1,SIZE(avg_grid%cosmo_h, 3)) )
+       ALLOCATE(avg_grid%intermediate_h(1,1,SIZE(avg_grid%cosmo_h, 3)) )
  
-       CALL average_2d(avg_grid%cosmo_h, avg_grid%h(1,1,:),             &
+       CALL average_2d(avg_grid%cosmo_h, avg_grid%intermediate_h(1,1,:),       &
                        avg_grid%iii, avg_grid%jjj)
 
@@ -1636,5 +1641,14 @@
 
 
- SUBROUTINE get_cosmo_averaging_region(avg_grid, cosmo_grid)
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> get_latlon_averaging_region() finds all mesocsale columns within the
+!> latitude-longitude reactagle given by the four values in avg_grid%lon(1:2)
+!> and %lat(1:2). The total number of all found columns is stored in
+!> avg_grid%n_columns, and their indices are stored in the sequential lists
+!> avg_grid%iii(:) and %jjj(:).
+!------------------------------------------------------------------------------!
+ SUBROUTINE get_latlon_averaging_region(avg_grid, cosmo_grid)
     TYPE(grid_definition), INTENT(INOUT)         ::  avg_grid
     TYPE(grid_definition), TARGET, INTENT(IN)    ::  cosmo_grid
@@ -1663,10 +1677,8 @@
           message = "Averaging grid kind '" // TRIM(avg_grid%kind) // &
                     "' is not supported. Use 'scalar', 'u', or 'v'."
-          CALL inifor_abort('get_cosmo_averaging_region', message)
+          CALL inifor_abort('get_latlon_averaging_region', message)
 
     END SELECT
 
-!
-!-- FIXME: make dlon, dlat parameters of the grid_defintion type
     dlon = cosmo_lon(1) - cosmo_lon(0)
     dlat = cosmo_lat(1) - cosmo_lat(0)
@@ -1682,5 +1694,5 @@
               " and " //                                                    &
               TRIM(str(jmin)) // " <= j <= " // TRIM(str(jmax))
-    CALL report( 'get_cosmo_averaging_region', message )
+    CALL report( 'get_latlon_averaging_region', message )
 
     nx = imax - imin + 1
@@ -1700,5 +1712,5 @@
     ENDDO
 
- END SUBROUTINE get_cosmo_averaging_region
+ END SUBROUTINE get_latlon_averaging_region
 
 
Index: /palm/trunk/UTIL/inifor/src/inifor_io.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 4552)
+++ /palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 4553)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! Option --help now points the user to INIFOR's wiki page
+! Remove deprecated command-line options -clon and -clat
+!
+! 
+! 4538 2020-05-18 13:45:35Z eckhard
 ! Make setting the vertical PALM origin mandatory
 ! 
@@ -444,10 +449,4 @@
     IF (arg_count .GT. 0)  THEN
 
-       message = "The -clon and -clat command line options are depricated. " // &
-          "Please remove them form your inifor command and specify the " // &
-          "location of the PALM-4U origin either" // NEW_LINE(' ') // &
-          "   - by setting the namelist parameters 'longitude' and 'latitude', or" // NEW_LINE(' ') // &
-          "   - by providing a static driver netCDF file via the -static command-line option."
-
        i = 1
        DO  WHILE (i .LE. arg_count)
@@ -487,7 +486,4 @@
                 CALL get_option_argument( i, arg )
                 READ(arg, *) cfg%vg
-
-             CASE( '-clon', '-clat' )
-                CALL inifor_abort('parse_command_line_arguments', message)
 
              CASE( '-path', '-p', '--path' )
@@ -560,5 +556,7 @@
                 CALL print_version
                 PRINT *, ""
-                PRINT *, "For a list of command-line options have a look at the README file."
+                PRINT *, &
+                   "For documentation and a list of available command-line options " // NEW_LINE(" ") // &
+                   " please visit https://palm.muk.uni-hannover.de/trac/wiki/doc/app/iofiles/inifor."
                 STOP
 
Index: /palm/trunk/UTIL/inifor/src/inifor_transform.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_transform.f90	(revision 4552)
+++ /palm/trunk/UTIL/inifor/src/inifor_transform.f90	(revision 4553)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Improved code readability and documentation
+! 
+! 
+! 4523 2020-05-07 15:58:16Z eckhard
 ! bugfix: pressure extrapolation
 ! respect integer working precision (iwp) specified in inifor_defs.f90
@@ -1037,6 +1041,6 @@
        k_intermediate = 0
 
-       column_base = palm_intermediate%h(i,j,0)
-       column_top  = palm_intermediate%h(i,j,nlev)
+       column_base = palm_intermediate%intermediate_h(i,j,0)
+       column_top  = palm_intermediate%intermediate_h(i,j,nlev)
 
 !
@@ -1051,6 +1055,6 @@
 !--       current height within it
           current_height = palm_grid%z(k) + palm_grid%z0
-          h_top    = palm_intermediate%h(i,j,k_intermediate+1)
-          h_bottom = palm_intermediate%h(i,j,k_intermediate)
+          h_top    = palm_intermediate%intermediate_h(i,j,k_intermediate+1)
+          h_bottom = palm_intermediate%intermediate_h(i,j,k_intermediate)
 
           point_is_above_grid = (current_height > column_top) !22000m, very unlikely
@@ -1086,6 +1090,6 @@
                 k_intermediate = k_intermediate + 1
 
-                h_top    = palm_intermediate%h(i,j,k_intermediate+1)
-                h_bottom = palm_intermediate%h(i,j,k_intermediate)
+                h_top    = palm_intermediate%intermediate_h(i,j,k_intermediate+1)
+                h_bottom = palm_intermediate%intermediate_h(i,j,k_intermediate)
                 point_is_in_current_cell = (                                &
                    current_height >= h_bottom .AND.                         &
@@ -1127,5 +1131,5 @@
 !> are adressed. While the _interp variant loops over all PALM grid columns
 !> given by combinations of all index indices (i,j), this routine loops over a
-!> subset of COSMO columns, which are sequantlially stored in the index lists
+!> subset of COSMO columns, which are sequentially stored in the index lists
 !> iii(:) and jjj(:).
 !------------------------------------------------------------------------------!
@@ -1149,6 +1153,9 @@
     nlev = SIZE(avg_grid%cosmo_h, 3)
 
+!
+!-- For level-based averaging, use the profile of averaged vertical mesoscale
+!-- levels computed in init_averaging_grid().
     IF (level_based_averaging)  THEN
-       cosmo_h => avg_grid%h
+       cosmo_h => avg_grid%intermediate_h
     ELSE
        cosmo_h => avg_grid%cosmo_h
@@ -1159,4 +1166,8 @@
     DO  l = 1, avg_grid%n_columns
 
+!--    The profile of averaged vertical mesoscale levels stored in
+!--    intermediate_h only contains one column. By using the same column -- and
+!--    consequently the same vertical interpolation neighbours and weights --
+!--    
        IF (level_based_averaging)  THEN
           i = 1
@@ -1171,9 +1182,9 @@
 
 !
-!--    scan through avg_grid column until and set neighbour indices in
+!--    Scan through avg_grid column until and set neighbour indices in
 !--    case current_height is either below column_base, in the current
 !--    cell, or above column_top. Keep increasing current cell index until
 !--    the current cell overlaps with the current_height.
-       k_intermediate = 1 !avg_grid%cosmo_h is indezed 1-based.
+       k_intermediate = 1 !avg_grid%cosmo_h is indexed 1-based.
        DO  k_palm = 1, avg_grid%nz
 
Index: /palm/trunk/UTIL/inifor/src/inifor_types.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_types.f90	(revision 4552)
+++ /palm/trunk/UTIL/inifor/src/inifor_types.f90	(revision 4553)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Minor code readability improvements
+! 
+! 
+! 4538 2020-05-18 13:45:35Z eckhard
 ! Added boolean indicator for --static-driver option invocation
 ! 
@@ -171,5 +175,5 @@
     REAL(wp), ALLOCATABLE ::  y(:)          !< coordinates of cell centers in y direction [m]
     REAL(wp), POINTER     ::  z(:)          !< coordinates of cell centers in z direction [m]
-    REAL(wp), ALLOCATABLE ::  h(:,:,:)      !< heights grid point for intermediate grids [m]
+    REAL(wp), ALLOCATABLE ::  intermediate_h(:,:,:) !< heights grid point for intermediate grids [m]
     REAL(wp), POINTER     ::  cosmo_h(:,:,:)!< pointer to appropriate COSMO level heights (scalar/w) [m]
     REAL(wp), POINTER     ::  hhl(:,:,:)    !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from 
