Index: /palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4204)
+++ /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4205)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! Missing working precision + bugfix in calculation of wind speed
+! 
+! 4188 2019-08-26 14:15:47Z suehring
 ! Minor adjustment in error number
 ! 
@@ -235,21 +238,21 @@
      IMPLICIT NONE
 !--  input parameters
-     INTEGER(iwp), INTENT(IN)          :: i, j, k, kk        !< indices of the pc gridbox
-     REAL(wp), INTENT(IN)              :: pcbsw              !< sw radiation in gridbox (W)
-     REAL(wp), INTENT(IN)              :: pcblw              !< lw radiation in gridbox (W)
-     REAL(wp), INTENT(OUT)             :: pcbtr              !< transpiration rate dq/dt (kg/kg/s)
-     REAL(wp), INTENT(OUT)             :: pcblh              !< latent heat from transpiration dT/dt (K/s)
+     INTEGER(iwp), INTENT(IN) ::  i, j, k, kk        !< indices of the pc gridbox
+     REAL(wp), INTENT(IN)     ::  pcbsw              !< sw radiation in gridbox (W)
+     REAL(wp), INTENT(IN)     ::  pcblw              !< lw radiation in gridbox (W)
+     REAL(wp), INTENT(OUT)    ::  pcbtr              !< transpiration rate dq/dt (kg/kg/s)
+     REAL(wp), INTENT(OUT)    ::  pcblh              !< latent heat from transpiration dT/dt (K/s)
 
 !--  variables and parameters for calculation of transpiration rate
-     REAL(wp)                          :: sat_press, sat_press_d, temp, v_lad
-     REAL(wp)                          :: d_fact, g_b, g_s, wind_speed, evapor_rate
-     REAL(wp)                          :: f1, f2, f3, f4, vpd, rswc, e_eq, e_imp, rad
-     REAL(wp), PARAMETER               :: gama_psychr = 66   !< psychrometric constant (Pa/K)
-     REAL(wp), PARAMETER               :: g_s_max = 0.01     !< maximum stomatal conductivity (m/s)
-     REAL(wp), PARAMETER               :: m_soil = 0.4_wp    !< soil water content (needs to adjust or take from LSM)
-     REAL(wp), PARAMETER               :: m_wilt = 0.01_wp   !< wilting point soil water content (needs to adjust or take from LSM)
-     REAL(wp), PARAMETER               :: m_sat = 0.51_wp    !< saturation soil water content (needs to adjust or take from LSM)
-     REAL(wp), PARAMETER               :: t2_min = 0.0_wp    !< minimal temperature for calculation of f2
-     REAL(wp), PARAMETER               :: t2_max = 40.0_wp   !< maximal temperature for calculation of f2
+     REAL(wp)             ::  sat_press, sat_press_d, temp, v_lad
+     REAL(wp)             ::  d_fact, g_b, g_s, wind_speed, evapor_rate
+     REAL(wp)             ::  f1, f2, f3, f4, vpd, rswc, e_eq, e_imp, rad
+     REAL(wp), PARAMETER  ::  gama_psychr = 66.0_wp !< psychrometric constant (Pa/K)
+     REAL(wp), PARAMETER  ::  g_s_max = 0.01        !< maximum stomatal conductivity (m/s)
+     REAL(wp), PARAMETER  ::  m_soil = 0.4_wp       !< soil water content (needs to adjust or take from LSM)
+     REAL(wp), PARAMETER  ::  m_wilt = 0.01_wp      !< wilting point soil water content (needs to adjust or take from LSM)
+     REAL(wp), PARAMETER  ::  m_sat = 0.51_wp       !< saturation soil water content (needs to adjust or take from LSM)
+     REAL(wp), PARAMETER  ::  t2_min = 0.0_wp       !< minimal temperature for calculation of f2
+     REAL(wp), PARAMETER  ::  t2_max = 40.0_wp      !< maximal temperature for calculation of f2
 
 
@@ -257,5 +260,5 @@
      temp = pt(k,j,i) * exner(k) - degc_to_k
 !--  Coefficient for conversion of radiation to grid to radiation to unit leaves surface
-     v_lad = 1.0_wp / ( MAX( lad_s(kk,j,i), 1.0e-10_wp ) * dx * dy * dz(1) )
+     v_lad = 1.0_wp / ( MAX( lad_s(kk,j,i), 1.0E-10_wp ) * dx * dy * dz(1) )
 !--  Magnus formula for the saturation pressure (see Ngao, Adam and Saudreau (2017) eq. 1)
 !--  There are updated formulas available, kept consistent with the rest of the parametrization
@@ -265,6 +268,6 @@
 !--  Wind speed
      wind_speed = SQRT( ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 +            &
-                        ( 0.5_wp * ( v(k,j,i) + v(k,j,i+1) ) )**2 +            &
-                        ( 0.5_wp * ( w(k,j,i) + w(k,j,i+1) ) )**2 )
+                        ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) )**2 +            &
+                        ( 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) )**2 )
 !--  Aerodynamic conductivity (Daudet et al. (1999) eq. 14
      g_b = 0.01_wp * wind_speed + 0.0071_wp
@@ -273,5 +276,5 @@
 !--  First function for calculation of stomatal conductivity (radiation dependency)
 !--  Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 17
-     f1 = rad * (1000._wp+42.1_wp) / 1000._wp / (rad+42.1_wp)
+     f1 = rad * (1000.0_wp+42.1_wp) / 1000.0_wp / (rad+42.1_wp)
 !--  Second function for calculation of stomatal conductivity (temperature dependency)
 !--  Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 21
@@ -286,5 +289,5 @@
 !--  than the coefficients from Stewart (1988) which correspond to conifer trees.
      vpd = MIN(MAX(vpd,770.0_wp),3820.0_wp)
-     f3 = -2e-4_wp * vpd + 1.154_wp
+     f3 = -2E-4_wp * vpd + 1.154_wp
 !--  Fourth function for calculation of stomatal conductivity (soil moisture dependency)
 !--  Residual soil water content
@@ -293,13 +296,13 @@
      rswc = ( m_sat - m_soil ) / ( m_sat - m_wilt )
 !--  van Wijk et al. (1998; Tree Physiology 20) eq. 5-6 (it is a reformulation of eq. 22-23 of Stewart(1988))
-     f4 = MAX(0._wp, MIN(1.0_wp - 0.041_wp * EXP(3.2_wp * rswc), 1.0_wp - 0.041_wp))
+     f4 = MAX(0.0_wp, MIN(1.0_wp - 0.041_wp * EXP(3.2_wp * rswc), 1.0_wp - 0.041_wp))
 !--  Stomatal conductivity
 !--  Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 12
 !--  (notation according to Ngao, Adam and Saudreau (2017) and others)
-     g_s = g_s_max * f1 * f2 * f3 * f4 + 1.0e-10_wp
+     g_s = g_s_max * f1 * f2 * f3 * f4 + 1.0E-10_wp
 !--  Decoupling factor
 !--  Daudet et al. (1999) eq. 6
-     d_fact = (sat_press_d / gama_psychr + 2._wp ) /                        &
-              (sat_press_d / gama_psychr + 2._wp + 2 * g_b / g_s )
+     d_fact = (sat_press_d / gama_psychr + 2.0_wp ) /                        &
+              (sat_press_d / gama_psychr + 2.0_wp + 2.0_wp * g_b / g_s )
 !--  Equilibrium evaporation rate
 !--  Daudet et al. (1999) eq. 4
Index: /palm/trunk/SOURCE/surface_data_output_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 4204)
+++ /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 4205)
@@ -25,4 +25,11 @@
 ! -----------------
 ! $Id$
+! - Correct x,y-coordinates of vertical surfaces in netcdf output
+! - Change definition of azimuth angle, reference is north 0 degree
+! - zenith angle is always defined, also for vertical surfaces where it is 
+!   90 degree, while azimuth angle is only defined for vertical surfaces, not
+!   for horizontal ones
+! 
+! 4182 2019-08-22 15:20:23Z scharf
 ! Corrected "Former revisions" section
 ! 
@@ -1068,22 +1075,23 @@
 !
 !--       For vertical surfaces, zenith angles are not defined (fill value).
-!--       Azimuth angle: eastward (0), westward (180), northward (270),
-!--       southward (90).
+!--       Azimuth angle: northward (0), eastward (90), southward (180), 
+!--       westward (270). 
+!--       Note, for vertical surfaces, zenith angles are 90.0_wp. 
           DO  l = 0, 3
              IF ( l == 0 )  THEN
-                az    = 270.0_wp
+                az    = 0.0_wp
                 off_x = 0.5_wp
                 off_y = 0.0_wp
              ELSEIF ( l == 1 )  THEN
+                az    = 180.0_wp
+                off_x = 0.5_wp
+                off_y = 1.0_wp
+             ELSEIF ( l == 2 )  THEN
                 az    = 90.0_wp
-                off_x = 0.5_wp
-                off_y = 0.0_wp
-             ELSEIF ( l == 2 )  THEN
-                az    = 0.0_wp
                 off_x = 0.0_wp
                 off_y = 0.5_wp
              ELSEIF ( l == 3 )  THEN
-                az    = 180.0_wp
-                off_x = 0.0_wp
+                az    = 270.0_wp
+                off_x = 1.0_wp
                 off_y = 0.5_wp
              ENDIF
@@ -1095,5 +1103,5 @@
                 surfaces%zs(mm)      = zu(surf_def_v(l)%k(m))
                 surfaces%azimuth(mm) = az
-                surfaces%zenith(mm)  = surfaces%fillvalue
+                surfaces%zenith(mm)  = 90.0_wp
                 i                    = i + 1
                 mm                   = mm + 1
@@ -1105,5 +1113,5 @@
                 surfaces%zs(mm)      = zu(surf_lsm_v(l)%k(m))
                 surfaces%azimuth(mm) = az
-                surfaces%zenith(mm)  = surfaces%fillvalue
+                surfaces%zenith(mm)  = 90.0_wp
                 i                    = i + 1
                 mm                   = mm + 1
@@ -1115,5 +1123,5 @@
                 surfaces%zs(mm)      = zu(surf_usm_v(l)%k(m))
                 surfaces%azimuth(mm) = az
-                surfaces%zenith(mm)  = surfaces%fillvalue
+                surfaces%zenith(mm)  = 90.0_wp
                 i                    = i + 1
                 mm                   = mm + 1
