Index: palm/trunk/UTIL/inifor/src/inifor_io.f90
===================================================================
--- palm/trunk/UTIL/inifor/src/io.f90	(revision 3395)
+++ palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 3447)
@@ -1,3 +1,3 @@
-!> @file src/io.f90
+!> @file src/inifor_io.f90
 !------------------------------------------------------------------------------!
 ! This file is part of the PALM model system.
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! Removed INCLUDE statement for get_netcdf_variable()
+! Renamed source files for compatibilty with PALM build system
+! 
+! 
+! 3395 2018-10-22 17:32:49Z eckhard
 ! Added command-line options for configuring the computation of geostrophic
 !     winds (--averagin-mode, --averaging-angle)
@@ -91,5 +96,32 @@
        INTEGER(hp), ALLOCATABLE, INTENT(INOUT) ::  buffer(:,:,:)
 
-       INCLUDE 'get_netcdf_variable.inc'
+       INTEGER               ::  ncid
+       INTEGER, DIMENSION(3) ::  start, count
+
+       IF ( nf90_open( TRIM(in_file), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. &
+            nf90_inq_varid( ncid, in_var % name, in_var % varid ) .EQ. NF90_NOERR )  THEN
+
+          CALL get_input_dimensions(in_var, ncid)
+
+          CALL get_netcdf_start_and_count(in_var, start, count)
+ CALL run_control('time', 'read')
+
+          ALLOCATE( buffer( count(1), count(2), count(3) ) )
+ CALL run_control('time', 'alloc')
+
+          CALL check(nf90_get_var( ncid, in_var % varid, buffer,                  &
+                                   start = start,                                 &
+                                   count = count ))
+
+       ELSE
+
+          message = "Failed to read '" // TRIM(in_var % name) // &
+             "' from file '" // TRIM(in_file) // "'."
+          CALL abort('get_netcdf_variable', message)
+
+       END IF
+
+       CALL check(nf90_close(ncid))
+ CALL run_control('time', 'read')
 
     END SUBROUTINE get_netcdf_variable_int
@@ -102,7 +134,97 @@
        REAL(dp), ALLOCATABLE, INTENT(INOUT) ::  buffer(:,:,:)
 
-       INCLUDE 'get_netcdf_variable.inc'
+       INTEGER               ::  ncid
+       INTEGER, DIMENSION(3) ::  start, count
+
+       IF ( nf90_open( TRIM(in_file), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. &
+            nf90_inq_varid( ncid, in_var % name, in_var % varid ) .EQ. NF90_NOERR )  THEN
+
+          CALL get_input_dimensions(in_var, ncid)
+
+          CALL get_netcdf_start_and_count(in_var, start, count)
+ CALL run_control('time', 'read')
+
+          ALLOCATE( buffer( count(1), count(2), count(3) ) )
+ CALL run_control('time', 'alloc')
+
+          CALL check(nf90_get_var( ncid, in_var % varid, buffer,                  &
+                                   start = start,                                 &
+                                   count = count ))
+
+       ELSE
+
+          message = "Failed to read '" // TRIM(in_var % name) // &
+             "' from file '" // TRIM(in_file) // "'."
+          CALL abort('get_netcdf_variable', message)
+
+       END IF
+
+       CALL check(nf90_close(ncid))
+ CALL run_control('time', 'read')
 
     END SUBROUTINE get_netcdf_variable_real
+
+
+    SUBROUTINE get_input_dimensions(in_var, ncid)
+
+       TYPE(nc_var), INTENT(INOUT)     ::  in_var
+       INTEGER, INTENT(OUT)            ::  ncid
+
+       INTEGER ::  i
+
+       CALL check(nf90_get_att( ncid, in_var % varid, "long_name",             &
+                                in_var % long_name))
+
+       CALL check(nf90_get_att( ncid, in_var % varid, "units",                 &
+                                in_var % units ))
+
+       CALL check(nf90_inquire_variable( ncid, in_var % varid,                 &
+                                         ndims  = in_var % ndim,               &
+                                         dimids = in_var % dimids ))
+
+       DO i = 1, in_var % ndim
+          CALL check(nf90_inquire_dimension( ncid, in_var % dimids(i),         &
+                                             name = in_var % dimname(i),       &
+                                             len  = in_var % dimlen(i) ))
+       END DO
+
+    END SUBROUTINE get_input_dimensions
+
+
+    SUBROUTINE get_netcdf_start_and_count(in_var, start, count)
+
+       TYPE(nc_var), INTENT(INOUT)        ::  in_var
+       INTEGER, DIMENSION(3), INTENT(OUT) ::  start, count
+
+       INTEGER ::  ndim
+
+       IF ( in_var % ndim .LT. 2  .OR.  in_var % ndim .GT. 4 )  THEN
+
+          message = "Failed reading NetCDF variable " //                       &
+             TRIM(in_var % name) // " with " // TRIM(str(in_var%ndim)) //      &
+             " dimensions because only two- and and three-dimensional" //      &
+             " variables are supported."
+          CALL abort('get_netcdf_start_and_count', message)
+
+       END IF
+
+       start = (/ 1, 1, 1 /)
+       IF ( TRIM(in_var % name) .EQ. 'T_SO' )  THEN
+          ! Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8
+          in_var % dimlen(3) = in_var % dimlen(3) - 1
+
+          ! Start reading from second level, e.g. depth = 0.005 instead of 0.0
+          start(3) = 2
+       END IF
+
+       IF (in_var % ndim .EQ. 2)  THEN
+          in_var % dimlen(3) = 1
+       ENDIF
+
+       ndim = MIN(in_var % ndim, 3)
+       count = (/ 1, 1, 1 /)
+       count(1:ndim) = in_var % dimlen(1:ndim)
+
+    END SUBROUTINE get_netcdf_start_and_count
 
 
