Index: /palm/trunk/SOURCE/message.f90
===================================================================
--- /palm/trunk/SOURCE/message.f90	(revision 3018)
+++ /palm/trunk/SOURCE/message.f90	(revision 3019)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Temporaraly deactivate MPI_BARRIER as long as nested systems freeze due to
+! asynchronous calls of location_message.
+! 
+! 2961 2018-04-12 10:13:48Z suehring
 ! Synchronize location message between parent and child. Message will be not 
 ! flushed before all models finished their respective task.  
@@ -267,5 +271,5 @@
 
 #if defined( __parallel )
-    IF ( nested_run )  CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
+!    IF ( nested_run )  CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
 #endif
 !
Index: /palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3018)
+++ /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3019)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Improved reading speed of large NetCDF files
+! 
+! 2963 2018-04-12 14:47:44Z suehring
 ! - Revise checks for static input variables.
 ! - Introduce index for vegetation/wall, pavement/green-wall and water/window 
@@ -415,4 +418,6 @@
     LOGICAL ::  input_pids_dynamic = .FALSE.   !< Flag indicating whether Palm-input-data-standard file containing dynamic information exists
 
+    LOGICAL ::  collective_read = .FALSE.      !< Enable NetCDF collective read
+
     SAVE
 
@@ -466,4 +471,5 @@
        MODULE PROCEDURE get_variable_3d_int8
        MODULE PROCEDURE get_variable_3d_real
+       MODULE PROCEDURE get_variable_3d_real_v
        MODULE PROCEDURE get_variable_4d_real
     END INTERFACE get_variable
@@ -666,11 +672,8 @@
                                                    nys:nyn,nxl:nxr) )
 
-                   DO  i = nxl, nxr
-                      DO  j = nys, nyn
-                         CALL get_variable( id_surf, 'leaf_area_density',      &
-                                            i, j,                              &
-                                            leaf_area_density_f%var(:,j,i) ) 
-                      ENDDO
-                   ENDDO
+                   CALL get_variable( id_surf, 'leaf_area_density',      &
+                                      nxl, nxr, nys, nyn,                &
+                                      leaf_area_density_f%var(:,nys:nyn, nxl:nxr) )
+
                 ELSE
                    leaf_area_density_f%from_file = .FALSE. 
@@ -695,11 +698,7 @@
                                                   nys:nyn,nxl:nxr) )
 
-                   DO  i = nxl, nxr
-                      DO  j = nys, nyn
-                         CALL get_variable( id_surf, 'basal_area_density',     &
-                                            i, j,                              &
-                                            basal_area_density_f%var(:,j,i) ) 
-                      ENDDO
-                   ENDDO
+                   CALL get_variable( id_surf, 'basal_area_density',     &
+                                      nxl, nxr, nys, nyn,                &
+                                      basal_area_density_f%var(:,nys:nyn, nxl:nxr) )
                 ELSE
                    basal_area_density_f%from_file = .FALSE. 
@@ -724,11 +723,7 @@
                                                 nys:nyn,nxl:nxr) )
 
-                   DO  i = nxl, nxr
-                      DO  j = nys, nyn
-                         CALL get_variable( id_surf, 'root_area_density_lad',  &
-                                            i, j,                              &
-                                            root_area_density_lad_f%var(:,j,i) ) 
-                      ENDDO
-                   ENDDO
+                   CALL get_variable( id_surf, 'root_area_density_lad',  &
+                                      nxl, nxr, nys, nyn,                              &
+                                      root_area_density_lad_f%var(:,nys:nyn, nxl:nxr) )
                 ELSE
                    root_area_density_lad_f%from_file = .FALSE. 
@@ -890,10 +885,7 @@
 !
 !--             Read surface fractions
-                DO  i = nxl, nxr
-                   DO  j = nys, nyn
-                      CALL get_variable( id_surf, 'surface_fraction', i, j,    &
-                                         surface_fraction_f%frac(:,j,i) ) 
-                   ENDDO
-                ENDDO
+                CALL get_variable( id_surf, 'surface_fraction',     &
+                                   nxl, nxr, nys, nyn,              &
+                                   surface_fraction_f%frac(:,nys:nyn, nxl:nxr))
              ELSE
                 surface_fraction_f%from_file = .FALSE. 
@@ -922,10 +914,7 @@
 !
 !--             Read building_pars
-                DO  i = nxl, nxr
-                   DO  j = nys, nyn
-                      CALL get_variable( id_surf, 'building_pars', i, j,       &
-                                         building_pars_f%pars_xy(:,j,i) )   
-                   ENDDO
-                ENDDO
+                CALL get_variable( id_surf, 'building_pars',                   &
+                                   nxl, nxr, nys, nyn,                         &
+                                   building_pars_f%pars_xy(:,nys:nyn, nxl:nxr) )
              ELSE
                 building_pars_f%from_file = .FALSE. 
@@ -1075,10 +1064,7 @@
                                    vegetation_pars_f%pars )
 
-                DO  i = nxl, nxr
-                   DO  j = nys, nyn
-                      CALL get_variable( id_surf, 'vegetation_pars', i, j,     &
-                                         vegetation_pars_f%pars_xy(:,j,i) ) 
-                   ENDDO
-                ENDDO
+                CALL get_variable( id_surf, 'vegetation_pars',                 &
+                                   nxl, nxr, nys, nyn,                         &
+                                   vegetation_pars_f%pars_xy(:,nys:nyn,nxl:nxr ) )
              ELSE
                 vegetation_pars_f%from_file = .FALSE. 
@@ -3796,5 +3782,20 @@
        LOGICAL                       ::  file_open = .FALSE.
 
+#if defined( __netcdf4_parallel )
+!      if __netcdf4_parallel is defined, parrallel NetCDF will be used unconditionally
+       nc_stat = NF90_OPEN( filename, IOR( NF90_WRITE, NF90_MPIIO ), id,  &
+                            COMM = comm2d, INFO = MPI_INFO_NULL )
+       IF(nc_stat /= NF90_NOERR )  THEN                                       !possible NetCDF 3 file
+           nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id )
+           collective_read = .FALSE.
+           write(9,*) 'open ',TRIM(filename),' as serial NetCDF file on every PE'
+       ELSE
+           collective_read = .TRUE.
+           write(9,*) 'open ',TRIM(filename),' using parallel NetCDF'
+       END IF
+#else
+!      All MPI processes open und read
        nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id )
+#endif
 
        CALL handle_error( 'open_read_file', 536 )
@@ -4285,6 +4286,82 @@
 
        CALL handle_error( 'get_variable_3d_real', 532 )
+
 #endif
     END SUBROUTINE get_variable_3d_real
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Reads a 3D float array from file.
+!------------------------------------------------------------------------------!
+    SUBROUTINE get_variable_3d_real_v( id, variable_name, is, ie, js, je, var )
+
+       USE indices
+       USE pegrid
+
+       IMPLICIT NONE
+
+       CHARACTER(LEN=*)              ::  variable_name   !< variable name
+
+       INTEGER(iwp), INTENT(IN)      ::  is,ie           !< index range along x direction
+       INTEGER(iwp), INTENT(IN)      ::  id              !< file id
+       INTEGER(iwp)                  ::  id_var          !< variable id
+       INTEGER(iwp), INTENT(IN)      ::  js,je           !< index range along y direction
+       INTEGER(iwp)                  ::  n3              !< number of data-points along 3rd dimension
+
+       INTEGER(iwp)                  ::  i,j,k
+       INTEGER(iwp), DIMENSION(3)    ::  id_dim
+
+       REAL(wp), DIMENSION(:,:,:), INTENT(INOUT) ::  var         !< variable to be read
+#if defined( __netcdf )
+!
+!--    Inside the ...static NetCDF files, the array is stored as float.
+!--    Therefore single precision is sufficiant for the temporary array
+
+       REAL(sp), DIMENSION(:,:,:), ALLOCATABLE   ::  tmp_var     !< temporary array to read NetCDF data in i,j,k direction
+
+!kk    Please check, if it is time consuming to do the inquire every time
+!
+!--    Inquire variable id
+       nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var )
+!
+!--    Get length of first dimension, required for the count parameter.
+!--    Therefore, first inquired dimension ids
+       nc_stat = NF90_INQUIRE_VARIABLE( id, id_var, DIMIDS = id_dim )
+       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim(3), LEN = n3 )
+
+       IF(collective_read)  THEN
+          nc_stat = NF90_VAR_PAR_ACCESS (id, id_var, NF90_COLLECTIVE)
+       ENDIF
+
+!
+!--    Allocate temporary array ro read NetCDF data in i,j,k direction
+
+       ALLOCATE(tmp_var(is:ie,js:je,n3))
+!
+!--    Get variable
+!--    Read complete local 3-D array in oone call
+
+       nc_stat = NF90_GET_VAR( id, id_var, tmp_var,                              &
+                               start = (/ is+1, js+1, 1 /),                      &
+                               count = (/ ie-is+1, je-js+1, n3 /) )
+
+       CALL handle_error( 'get_variable_3d_real', 532 )
+
+!
+!--    Resort data in k,j,i direction
+
+       DO i=is,ie
+          DO j=js,je
+             DO K=1,n3
+                var (k,j-js+1,i-is+1) = tmp_var(i,j,k)
+             END DO
+          END DO
+       END DO
+
+       DEALLOCATE(tmp_var)
+
+#endif
+    END SUBROUTINE get_variable_3d_real_v
 
 
