Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4877)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4878)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! Rename resize_array into add_ghost_layers; remove number of passed indices; replace subroutine
+! calls with interface name
+!
+! 4877 2021-02-17 16:17:35Z suehring
 ! Add interface for resize_array and add subroutine to resize 2d-real arrays
 !
@@ -242,5 +246,9 @@
 
     USE indices,                                                                                   &
-        ONLY:  nbgp
+        ONLY:  nbgp,                                                                               &
+               nxl,                                                                                &
+               nxr,                                                                                &
+               nys,                                                                                &
+               nyn
 
     USE kinds
@@ -790,12 +798,12 @@
     END INTERFACE get_attribute
 
-    INTERFACE resize_array
-       MODULE PROCEDURE resize_array_2d_int8
-       MODULE PROCEDURE resize_array_2d_int32
-       MODULE PROCEDURE resize_array_2d_real
-       MODULE PROCEDURE resize_array_3d_int8
-       MODULE PROCEDURE resize_array_3d_real
-       MODULE PROCEDURE resize_array_4d_real
-    END INTERFACE resize_array
+    INTERFACE add_ghost_layers
+       MODULE PROCEDURE add_ghost_layers_2d_int8
+       MODULE PROCEDURE add_ghost_layers_2d_int32
+       MODULE PROCEDURE add_ghost_layers_2d_real
+       MODULE PROCEDURE add_ghost_layers_3d_int8
+       MODULE PROCEDURE add_ghost_layers_3d_real
+       MODULE PROCEDURE add_ghost_layers_4d_real
+    END INTERFACE add_ghost_layers
 
 !
@@ -862,5 +870,6 @@
 !
 !-- Public subroutines
-    PUBLIC check_existence,                                                                        &
+    PUBLIC add_ghost_layers,                                                                       &
+           check_existence,                                                                        &
            close_input_file,                                                                       &
            get_attribute,                                                                          &
@@ -879,6 +888,5 @@
            netcdf_data_input_surface_data,                                                         &
            netcdf_data_input_topo,                                                                 &
-           open_read_file,                                                                         &
-           resize_array
+           open_read_file
 
 
@@ -1913,21 +1921,21 @@
 !-- Exchange ghost points for surface variables. Therefore, resize variables.
     IF ( albedo_type_f%from_file )  THEN
-       CALL resize_array_2d_int8( albedo_type_f%var, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( albedo_type_f%var )
        CALL exchange_horiz_2d_byte( albedo_type_f%var, nys, nyn, nxl, nxr, nbgp )
     ENDIF
     IF ( pavement_type_f%from_file )  THEN
-       CALL resize_array_2d_int8( pavement_type_f%var, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( pavement_type_f%var )
        CALL exchange_horiz_2d_byte( pavement_type_f%var, nys, nyn, nxl, nxr, nbgp )
     ENDIF
     IF ( soil_type_f%from_file  .AND.  ALLOCATED( soil_type_f%var_2d ) )  THEN
-       CALL resize_array_2d_int8( soil_type_f%var_2d, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( soil_type_f%var_2d )
        CALL exchange_horiz_2d_byte( soil_type_f%var_2d, nys, nyn, nxl, nxr, nbgp )
     ENDIF
     IF ( vegetation_type_f%from_file )  THEN
-       CALL resize_array_2d_int8( vegetation_type_f%var, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( vegetation_type_f%var )
        CALL exchange_horiz_2d_byte( vegetation_type_f%var, nys, nyn, nxl, nxr, nbgp )
     ENDIF
     IF ( water_type_f%from_file )  THEN
-       CALL resize_array_2d_int8( water_type_f%var, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( water_type_f%var )
        CALL exchange_horiz_2d_byte( water_type_f%var, nys, nyn, nxl, nxr, nbgp )
     ENDIF
@@ -1938,5 +1946,5 @@
 !-- introduced just for 2 variables.
     IF ( soil_type_f%from_file  .AND.  ALLOCATED( soil_type_f%var_3d ) )  THEN
-       CALL resize_array_3d_int8( soil_type_f%var_3d, 0, nz_soil, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( soil_type_f%var_3d, 0, nz_soil )
        DO  k = 0, nz_soil
           CALL exchange_horiz_2d_byte( soil_type_f%var_3d(k,:,:), nys, nyn, nxl, nxr, nbgp )
@@ -1945,6 +1953,5 @@
 
     IF ( surface_fraction_f%from_file )  THEN
-       CALL resize_array_3d_real( surface_fraction_f%frac, 0, surface_fraction_f%nf-1, nys, nyn,   &
-                                  nxl, nxr )
+       CALL add_ghost_layers( surface_fraction_f%frac, 0, surface_fraction_f%nf-1 )
        DO  k = 0, surface_fraction_f%nf-1
           CALL exchange_horiz_2d( surface_fraction_f%frac(k,:,:) )
@@ -1953,6 +1960,5 @@
 
     IF ( building_pars_f%from_file )  THEN
-       CALL resize_array_3d_real( building_pars_f%pars_xy, 0, building_pars_f%np-1, nys, nyn, nxl, &
-                                  nxr )
+       CALL add_ghost_layers( building_pars_f%pars_xy, 0, building_pars_f%np-1 )
        DO  k = 0, building_pars_f%np-1
           CALL exchange_horiz_2d( building_pars_f%pars_xy(k,:,:) )
@@ -1961,5 +1967,5 @@
 
     IF ( albedo_pars_f%from_file )  THEN
-       CALL resize_array_3d_real( albedo_pars_f%pars_xy, 0, albedo_pars_f%np-1, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( albedo_pars_f%pars_xy, 0, albedo_pars_f%np-1 )
        DO  k = 0, albedo_pars_f%np-1
           CALL exchange_horiz_2d( albedo_pars_f%pars_xy(k,:,:) )
@@ -1968,6 +1974,5 @@
 
     IF ( pavement_pars_f%from_file )  THEN
-       CALL resize_array_3d_real( pavement_pars_f%pars_xy, 0, pavement_pars_f%np-1, nys, nyn, nxl, &
-                                  nxr )
+       CALL add_ghost_layers( pavement_pars_f%pars_xy, 0, pavement_pars_f%np-1 )
        DO  k = 0, pavement_pars_f%np-1
           CALL exchange_horiz_2d( pavement_pars_f%pars_xy(k,:,:) )
@@ -1976,6 +1981,5 @@
 
     IF ( vegetation_pars_f%from_file )  THEN
-       CALL resize_array_3d_real( vegetation_pars_f%pars_xy, 0, vegetation_pars_f%np-1, nys, nyn,  &
-                                  nxl, nxr )
+       CALL add_ghost_layers( vegetation_pars_f%pars_xy, 0, vegetation_pars_f%np-1 )
        DO  k = 0, vegetation_pars_f%np-1
           CALL exchange_horiz_2d( vegetation_pars_f%pars_xy(k,:,:) )
@@ -1984,5 +1988,5 @@
 
     IF ( water_pars_f%from_file )  THEN
-       CALL resize_array_3d_real( water_pars_f%pars_xy, 0, water_pars_f%np-1, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( water_pars_f%pars_xy, 0, water_pars_f%np-1 )
        DO  k = 0, water_pars_f%np-1
           CALL exchange_horiz_2d( water_pars_f%pars_xy(k,:,:) )
@@ -1991,6 +1995,5 @@
 
     IF ( root_area_density_lsm_f%from_file )  THEN
-       CALL resize_array_3d_real( root_area_density_lsm_f%var, 0, root_area_density_lsm_f%nz-1,    &
-                                  nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( root_area_density_lsm_f%var, 0, root_area_density_lsm_f%nz-1 )
        DO  k = 0, root_area_density_lsm_f%nz-1
           CALL exchange_horiz_2d( root_area_density_lsm_f%var(k,:,:) )
@@ -2000,5 +2003,5 @@
     IF ( soil_pars_f%from_file )  THEN
        IF ( soil_pars_f%lod == 1 )  THEN
-          CALL resize_array_3d_real( soil_pars_f%pars_xy, 0, soil_pars_f%np-1, nys, nyn, nxl, nxr )
+          CALL add_ghost_layers( soil_pars_f%pars_xy, 0, soil_pars_f%np-1 )
           DO  k = 0, soil_pars_f%np-1
              CALL exchange_horiz_2d( soil_pars_f%pars_xy(k,:,:) )
@@ -2006,6 +2009,5 @@
 
        ELSEIF ( soil_pars_f%lod == 2 )  THEN
-          CALL resize_array_4d_real( soil_pars_f%pars_xyz, 0, soil_pars_f%np-1,                    &
-                                     0, soil_pars_f%nz-1, nys, nyn, nxl, nxr )
+          CALL add_ghost_layers( soil_pars_f%pars_xyz, 0, soil_pars_f%np-1, 0, soil_pars_f%nz-1 )
 
           DO  k2 = 0, soil_pars_f%nz-1
@@ -2018,7 +2020,7 @@
 
     IF ( pavement_subsurface_pars_f%from_file )  THEN
-       CALL resize_array_4d_real( pavement_subsurface_pars_f%pars_xyz,                             &
-                                  0, pavement_subsurface_pars_f%np-1,                              &
-                                  0, pavement_subsurface_pars_f%nz-1, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( pavement_subsurface_pars_f%pars_xyz,                                 &
+                              0, pavement_subsurface_pars_f%np-1,                                  &
+                              0, pavement_subsurface_pars_f%nz-1 )
 
        DO  k2 = 0, pavement_subsurface_pars_f%nz-1
@@ -2407,10 +2409,10 @@
 !-- In case of non-cyclic boundary conditions set Neumann conditions at the lateral boundaries.
     IF ( building_id_f%from_file )  THEN
-       CALL resize_array_2d_int32( building_id_f%var, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( building_id_f%var )
        CALL exchange_horiz_2d_int( building_id_f%var, nys, nyn, nxl, nxr, nbgp )
     ENDIF
 
     IF ( building_type_f%from_file )  THEN
-       CALL resize_array_2d_int8( building_type_f%var, nys, nyn, nxl, nxr )
+       CALL add_ghost_layers( building_type_f%var )
        CALL exchange_horiz_2d_byte( building_type_f%var, nys, nyn, nxl, nxr, nbgp )
     ENDIF
@@ -3381,12 +3383,7 @@
 !> Resize 8-bit 2D Integer array: (nys:nyn,nxl:nxr) -> (nysg:nyng,nxlg:nxrg)
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE resize_array_2d_int8( var, js, je, is, ie )
+ SUBROUTINE add_ghost_layers_2d_int8( var )
 
     IMPLICIT NONE
-
-    INTEGER(iwp) ::  ie  !< upper index bound along x direction
-    INTEGER(iwp) ::  is  !< lower index bound along x direction
-    INTEGER(iwp) ::  je  !< upper index bound along y direction
-    INTEGER(iwp) ::  js  !< lower index bound along y direction
 
     INTEGER(KIND=1), DIMENSION(:,:), ALLOCATABLE ::  var     !< treated variable
@@ -3394,17 +3391,17 @@
 !
 !-- Allocate temporary variable
-    ALLOCATE( var_tmp(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var_tmp(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Temporary copy of the variable
-    var_tmp(js:je,is:ie) = var(js:je,is:ie)
+    var_tmp(nys:nyn,nxl:nxr) = var(nys:nyn,nxl:nxr)
 !
 !-- Resize the array
     DEALLOCATE( var )
-    ALLOCATE( var(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Transfer temporary copy back to original array
-    var(js:je,is:ie) = var_tmp(js:je,is:ie)
-
- END SUBROUTINE resize_array_2d_int8
+    var(nys:nyn,nxl:nxr) = var_tmp(nys:nyn,nxl:nxr)
+
+ END SUBROUTINE add_ghost_layers_2d_int8
 
 
@@ -3414,12 +3411,7 @@
 !> Resize 32-bit 2D Integer array: (nys:nyn,nxl:nxr) -> (nysg:nyng,nxlg:nxrg)
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE resize_array_2d_int32( var, js, je, is, ie )
+ SUBROUTINE add_ghost_layers_2d_int32( var )
 
     IMPLICIT NONE
-
-    INTEGER(iwp) ::  ie  !< upper index bound along x direction
-    INTEGER(iwp) ::  is  !< lower index bound along x direction
-    INTEGER(iwp) ::  je  !< upper index bound along y direction
-    INTEGER(iwp) ::  js  !< lower index bound along y direction
 
     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  var     !< treated variable
@@ -3427,17 +3419,17 @@
 !
 !-- Allocate temporary variable
-    ALLOCATE( var_tmp(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var_tmp(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Temporary copy of the variable
-    var_tmp(js:je,is:ie) = var(js:je,is:ie)
+    var_tmp(nys:nyn,nxl:nxr) = var(nys:nyn,nxl:nxr)
 !
 !-- Resize the array
     DEALLOCATE( var )
-    ALLOCATE( var(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Transfer temporary copy back to original array
-    var(js:je,is:ie) = var_tmp(js:je,is:ie)
-
- END SUBROUTINE resize_array_2d_int32
+    var(nys:nyn,nxl:nxr) = var_tmp(nys:nyn,nxl:nxr)
+
+ END SUBROUTINE add_ghost_layers_2d_int32
 
 !--------------------------------------------------------------------------------------------------!
@@ -3446,12 +3438,7 @@
 !> Resize 2D float array: (nys:nyn,nxl:nxr) -> (nysg:nyng,nxlg:nxrg)
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE resize_array_2d_real( var, js, je, is, ie )
+ SUBROUTINE add_ghost_layers_2d_real( var )
 
     IMPLICIT NONE
-
-    INTEGER(iwp) ::  ie  !< upper index bound along x direction
-    INTEGER(iwp) ::  is  !< lower index bound along x direction
-    INTEGER(iwp) ::  je  !< upper index bound along y direction
-    INTEGER(iwp) ::  js  !< lower index bound along y direction
 
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  var     !< treated variable
@@ -3459,17 +3446,17 @@
 !
 !-- Allocate temporary variable
-    ALLOCATE( var_tmp(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var_tmp(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Temporary copy of the variable
-    var_tmp(js:je,is:ie) = var(js:je,is:ie)
+    var_tmp(nys:nyn,nxl:nxr) = var(nys:nyn,nxl:nxr)
 !
 !-- Resize the array
     DEALLOCATE( var )
-    ALLOCATE( var(js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Transfer temporary copy back to original array
-    var(js:je,is:ie) = var_tmp(js:je,is:ie)
-
- END SUBROUTINE resize_array_2d_real
+    var(nys:nyn,nxl:nxr) = var_tmp(nys:nyn,nxl:nxr)
+
+ END SUBROUTINE add_ghost_layers_2d_real
 
 
@@ -3479,12 +3466,8 @@
 !> Resize 8-bit 3D Integer array: (:,nys:nyn,nxl:nxr) -> (:,nysg:nyng,nxlg:nxrg)
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE resize_array_3d_int8( var, ks, ke, js, je, is, ie )
+ SUBROUTINE add_ghost_layers_3d_int8( var, ks, ke )
 
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  ie  !< upper index bound along x direction
-    INTEGER(iwp) ::  is  !< lower index bound along x direction
-    INTEGER(iwp) ::  je  !< upper index bound along y direction
-    INTEGER(iwp) ::  js  !< lower index bound along y direction
     INTEGER(iwp) ::  ke  !< upper bound of treated array in z-direction
     INTEGER(iwp) ::  ks  !< lower bound of treated array in z-direction
@@ -3494,17 +3477,17 @@
 !
 !-- Allocate temporary variable
-    ALLOCATE( var_tmp(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var_tmp(ks:ke,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Temporary copy of the variable
-    var_tmp(ks:ke,js:je,is:ie) = var(ks:ke,js:je,is:ie)
+    var_tmp(ks:ke,nys:nyn,nxl:nxr) = var(ks:ke,nys:nyn,nxl:nxr)
 !
 !-- Resize the array
     DEALLOCATE( var )
-    ALLOCATE( var(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var(ks:ke,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Transfer temporary copy back to original array
-    var(ks:ke,js:je,is:ie) = var_tmp(ks:ke,js:je,is:ie)
-
- END SUBROUTINE resize_array_3d_int8
+    var(ks:ke,nys:nyn,nxl:nxr) = var_tmp(ks:ke,nys:nyn,nxl:nxr)
+
+ END SUBROUTINE add_ghost_layers_3d_int8
 
 
@@ -3514,12 +3497,8 @@
 !> Resize 3D Real array: (:,nys:nyn,nxl:nxr) -> (:,nysg:nyng,nxlg:nxrg)
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE resize_array_3d_real( var, ks, ke, js, je, is, ie )
+ SUBROUTINE add_ghost_layers_3d_real( var, ks, ke )
 
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  ie  !< upper index bound along x direction
-    INTEGER(iwp) ::  is  !< lower index bound along x direction
-    INTEGER(iwp) ::  je  !< upper index bound along y direction
-    INTEGER(iwp) ::  js  !< lower index bound along y direction
     INTEGER(iwp) ::  ke  !< upper bound of treated array in z-direction
     INTEGER(iwp) ::  ks  !< lower bound of treated array in z-direction
@@ -3529,17 +3508,17 @@
 !
 !-- Allocate temporary variable
-    ALLOCATE( var_tmp(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var_tmp(ks:ke,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Temporary copy of the variable
-    var_tmp(ks:ke,js:je,is:ie) = var(ks:ke,js:je,is:ie)
+    var_tmp(ks:ke,nys:nyn,nxl:nxr) = var(ks:ke,nys:nyn,nxl:nxr)
 !
 !-- Resize the array
     DEALLOCATE( var )
-    ALLOCATE( var(ks:ke,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var(ks:ke,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Transfer temporary copy back to original array
-    var(ks:ke,js:je,is:ie) = var_tmp(ks:ke,js:je,is:ie)
-
- END SUBROUTINE resize_array_3d_real
+    var(ks:ke,nys:nyn,nxl:nxr) = var_tmp(ks:ke,nys:nyn,nxl:nxr)
+
+ END SUBROUTINE add_ghost_layers_3d_real
 
 
@@ -3549,12 +3528,8 @@
 !> Resize 4D Real array: (:,:,nys:nyn,nxl:nxr) -> (:,nysg:nyng,nxlg:nxrg)
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE resize_array_4d_real( var, k1s, k1e, k2s, k2e, js, je, is, ie )
+ SUBROUTINE add_ghost_layers_4d_real( var, k1s, k1e, k2s, k2e )
 
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  ie   !< upper index bound along x direction
-    INTEGER(iwp) ::  is   !< lower index bound along x direction
-    INTEGER(iwp) ::  je   !< upper index bound along y direction
-    INTEGER(iwp) ::  js   !< lower index bound along y direction
     INTEGER(iwp) ::  k1e  !< upper bound of treated array in z-direction
     INTEGER(iwp) ::  k1s  !< lower bound of treated array in z-direction
@@ -3566,17 +3541,17 @@
 !
 !-- Allocate temporary variable
-    ALLOCATE( var_tmp(k1s:k1e,k2s:k2e,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var_tmp(k1s:k1e,k2s:k2e,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Temporary copy of the variable
-    var_tmp(k1s:k1e,k2s:k2e,js:je,is:ie) = var(k1s:k1e,k2s:k2e,js:je,is:ie)
+    var_tmp(k1s:k1e,k2s:k2e,nys:nyn,nxl:nxr) = var(k1s:k1e,k2s:k2e,nys:nyn,nxl:nxr)
 !
 !-- Resize the array
     DEALLOCATE( var )
-    ALLOCATE( var(k1s:k1e,k2s:k2e,js-nbgp:je+nbgp,is-nbgp:ie+nbgp) )
+    ALLOCATE( var(k1s:k1e,k2s:k2e,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) )
 !
 !-- Transfer temporary copy back to original array
-    var(k1s:k1e,k2s:k2e,js:je,is:ie) = var_tmp(k1s:k1e,k2s:k2e,js:je,is:ie)
-
- END SUBROUTINE resize_array_4d_real
+    var(k1s:k1e,k2s:k2e,nys:nyn,nxl:nxr) = var_tmp(k1s:k1e,k2s:k2e,nys:nyn,nxl:nxr)
+
+ END SUBROUTINE add_ghost_layers_4d_real
 
 
