Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4878)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4880)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! Minor formatting adjustments and some comments added in get_variable_surf
+!
+! 4878 2021-02-18 09:47:49Z suehring
 ! Rename resize_array into add_ghost_layers; remove number of passed indices; replace subroutine
 ! calls with interface name
@@ -4190,5 +4193,5 @@
 
     USE grid_variables,                                                                            &
-        ONLY: dx, dy
+        ONLY: ddx, ddy
 
     USE basic_constants_and_equations_mod,                                                         &
@@ -4202,5 +4205,6 @@
     CHARACTER(LEN=*)                          ::  variable_name !< variable name
 
-    INTEGER(iwp)                              ::  i, j
+    INTEGER(iwp)                              ::  i             !< grid index in x-direction
+    INTEGER(iwp)                              ::  j             !< grid index in y-direction
     INTEGER(iwp), INTENT(IN)                  ::  id            !< file id
     INTEGER(iwp)                              ::  id_azimuth    !< azimuth variable id
@@ -4215,5 +4219,5 @@
     INTEGER(iwp)                              ::  nsurf         !< total number of surfaces in file
 
-    INTEGER(iwp), DIMENSION(6)                ::  coords        !< integer coordinates of surface
+    INTEGER(iwp), DIMENSION(6)                ::  coords        !< integer coordinates of surface location
     INTEGER(iwp), DIMENSION(2)                ::  id_dim        !< dimension ids
 
@@ -4224,7 +4228,9 @@
     REAL(wp), DIMENSION(:), ALLOCATABLE       ::  azimuth       !< read buffer for azimuth(s)
     REAL(wp), DIMENSION(:), ALLOCATABLE       ::  zenith        !< read buffer for zenith(s)
-    REAL(wp), DIMENSION(:), ALLOCATABLE       ::  zs, ys, xs    !< read buffer for zs(s), ys, xs
-
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE     ::  pars_read     !< read buffer
+    REAL(wp), DIMENSION(:), ALLOCATABLE       ::  xs            !< surface coordinate array of x-dimension
+    REAL(wp), DIMENSION(:), ALLOCATABLE       ::  ys            !< surface coordinate array of y-dimension
+    REAL(wp), DIMENSION(:), ALLOCATABLE       ::  zs            !< surface coordinate array of z-dimension
+
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE     ::  pars_read     !< read buffer for the building parameters
 
     TYPE(pars_surf)                           ::  surf          !< parameters variable to be loaded
@@ -4233,5 +4239,5 @@
 #if defined( __netcdf )
 !
-!-- First, inquire variable ID
+!-- First, inquire variable ID's
     nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var )
     nc_stat = NF90_INQ_VARID( id, 'zs',                  id_zs )
@@ -4241,5 +4247,5 @@
     nc_stat = NF90_INQ_VARID( id, 'azimuth',             id_azimuth )
 !
-!-- Inquire dimension sizes
+!-- Inquire dimension sizes for the number of surfaces and parameters given
     nc_stat = NF90_INQUIRE_VARIABLE( id, id_var, DIMIDS = id_dim )
     nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim(1), LEN = nsurf )
@@ -4250,9 +4256,9 @@
               xs(nsurf_pars_read), zenith(nsurf_pars_read),                                        &
               azimuth(nsurf_pars_read),                                                            &
-              nsurf_ji(nys:nyn, nxl:nxr) )
+              nsurf_ji(nys:nyn,nxl:nxr) )
 
     nsurf_ji(:,:) = 0
 !
-!-- Scan surface coordinates, count local
+!-- Scan surface coordinates, count locally
     is0 = 1
     DO
@@ -4281,5 +4287,5 @@
                coords(3) < nxl  .OR.  coords(3) > nxr )  CYCLE
 
-          nsurf_ji(coords(2), coords(3)) = nsurf_ji(coords(2), coords(3)) + 1
+          nsurf_ji(coords(2),coords(3)) = nsurf_ji(coords(2),coords(3)) + 1
        ENDDO
        is0 = is0 + isc
@@ -4287,5 +4293,5 @@
 !
 !-- Populate reverse index from surface counts
-    ALLOCATE( surf%index_ji( 2, nys:nyn, nxl:nxr ) )
+    ALLOCATE( surf%index_ji( 2,nys:nyn,nxl:nxr ) )
     isurf = 1
     DO  j = nys, nyn
@@ -4297,6 +4303,6 @@
 
     surf%nsurf = isurf - 1
-    ALLOCATE( surf%pars( 0:surf%np-1, surf%nsurf ), &
-              surf%coords( 6, surf%nsurf ) )
+    ALLOCATE( surf%pars(0:surf%np-1,surf%nsurf),                                                   &
+              surf%coords(6,surf%nsurf) )
 !
 !-- Scan surfaces again, saving pars into allocated structures
@@ -4337,5 +4343,5 @@
 !--       Determine maximum terrain under building (base z-coordinate). Using normal vector to
 !--       locate building inner coordinates.
-          oro_max_l = buildings_f%oro_max(coords(2)-coords(5), coords(3)-coords(6))
+          oro_max_l = buildings_f%oro_max(coords(2)-coords(5),coords(3)-coords(6))
           IF ( oro_max_l == buildings_f%fill1 )  THEN
              WRITE( message_string, * ) 'Found building surface on '   //                          &
@@ -4351,9 +4357,9 @@
 !
 !--       Save surface entry
-          is = surf%index_ji(1, coords(2), coords(3)) + nsurf_ji(coords(2), coords(3))
+          is = surf%index_ji(1,coords(2),coords(3)) + nsurf_ji(coords(2),coords(3))
           surf%pars(:,is) = pars_read(isurf,:)
           surf%coords(:,is) = coords(:)
 
-          nsurf_ji(coords(2), coords(3)) = nsurf_ji(coords(2), coords(3)) + 1
+          nsurf_ji(coords(2),coords(3)) = nsurf_ji(coords(2),coords(3)) + 1
        ENDDO
 
@@ -4370,5 +4376,6 @@
 
        REAL(wp), INTENT(in) ::  azimuth  !< surface normal azimuth angle in degrees
-       REAL(wp), INTENT(in) ::  x, y     !< surface centre coordinates in metres from origin
+       REAL(wp), INTENT(in) ::  x        !< surface centre coordinate in x in metres from origin
+       REAL(wp), INTENT(in) ::  y        !< surface centre coordinate in y in metres from origin
        REAL(wp), INTENT(in) ::  zenith   !< surface normal zenith angle in degrees
 
@@ -4383,6 +4390,6 @@
 
        transform_coords(1) = -999.0_wp ! not calculated here
-       transform_coords(2) = NINT( y / dy - 0.5_wp + 0.5_wp * transform_coords(5), KIND=iwp )
-       transform_coords(3) = NINT( x / dx - 0.5_wp + 0.5_wp * transform_coords(6), KIND=iwp )
+       transform_coords(2) = NINT( y * ddy - 0.5_wp + 0.5_wp * transform_coords(5), KIND=iwp )
+       transform_coords(3) = NINT( x * ddx - 0.5_wp + 0.5_wp * transform_coords(6), KIND=iwp )
 
     END FUNCTION transform_coords
