Index: palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 2977)
+++ palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 3014)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: nzb_do and nzt_do were not used for 3d data output
+! Added pc_transpiration_rate
+! 
+! 2977 2018-04-17 10:27:57Z kanani
 ! Implement changes from branch radiation (r2948-2971) with minor modifications,
 ! plus some formatting.
@@ -230,4 +234,5 @@
     REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  lad_s            !< lad on scalar-grid
     REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  pc_heating_rate  !< plant canopy heating rate
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  pc_transpiration_rate  !< plant canopy transpiration rate
 
     SAVE
@@ -243,5 +248,5 @@
 !
 !-- Public variables and constants
-    PUBLIC pc_heating_rate, canopy_mode, cthf, dt_plant_canopy, lad, lad_s,   &
+    PUBLIC pc_heating_rate, pc_transpiration_rate, canopy_mode, cthf, dt_plant_canopy, lad, lad_s,   &
            pch_index
            
@@ -315,4 +320,7 @@
           unit = 'K s-1'
     
+       CASE ( 'pcm_transpirationrate' )
+          unit = 'kg kg-1 s-1'
+
        CASE ( 'pcm_lad' )
           unit = 'm2 m-3'
@@ -404,9 +412,7 @@
 !> Subroutine defining 3D output variables
 !------------------------------------------------------------------------------!
- SUBROUTINE pcm_data_output_3d( av, variable, found, local_pf, fill_value )
- 
-    USE control_parameters,                                                    &
-        ONLY :  nz_do3d
- 
+ SUBROUTINE pcm_data_output_3d( av, variable, found, local_pf, fill_value,     &
+                                nzb_do, nzt_do )
+  
     USE indices
 
@@ -423,9 +429,11 @@
     INTEGER(iwp) ::  k      !< 
     INTEGER(iwp) ::  k_topo !< topography top index
+    INTEGER(iwp) ::  nzb_do !< lower limit of the data output (usually 0)
+    INTEGER(iwp) ::  nzt_do !< vertical upper limit of the data output (usually nz_do3d)
 
     LOGICAL      ::  found !< 
 
     REAL(wp)     ::  fill_value
-    REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb:nz_do3d) ::  local_pf !< 
+    REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) ::  local_pf !< 
 
 
@@ -449,5 +457,18 @@
             ENDDO
          ENDIF
-    
+   
+       CASE ( 'pcm_transpirationrate' )
+         IF ( av == 0 )  THEN
+            DO  i = nxl, nxr
+               DO  j = nys, nyn
+                  IF ( pch_index_ji(j,i) /= 0 )  THEN
+                     k_topo = get_topography_top_index_ji( j, i, 's' )
+                     DO  k = k_topo, k_topo + pch_index_ji(j,i)
+                        local_pf(i,j,k) = pc_transpiration_rate(k-k_topo,j,i)
+                     ENDDO
+                  ENDIF
+               ENDDO
+            ENDDO
+         ENDIF
     
       CASE ( 'pcm_lad' )
@@ -497,5 +518,5 @@
      SELECT CASE ( TRIM( var ) )
 
-        CASE ( 'pcm_heatrate', 'pcm_lad' )
+        CASE ( 'pcm_heatrate', 'pcm_lad', 'pcm_transpirationrate')
            grid_x = 'x'
            grid_y = 'y'
@@ -873,5 +894,6 @@
 
           ALLOCATE( cum_lai_hf(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                 &
-                    pc_heating_rate(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                    pc_heating_rate(nzb:nzt+1,nysg:nyng,nxlg:nxrg),            & 
+                    pc_transpiration_rate(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
 !
 !--       Piecewise calculation of the cumulative leaf area index by vertical
@@ -1397,7 +1419,6 @@
 
                       kk = k - k_wall   !- lad arrays are defined flat
-                      tend(k,j,i) = tend(k,j,i) -                              &
-                                       lsec *                                  &
-                                       lad_s(kk,j,i) *                         &
+                      pc_transpiration_rate(kk,j,i) =  - lsec                  &
+                                       * lad_s(kk,j,i) *                       &
                                        SQRT( ( 0.5_wp * ( u(k,j,i) +           &
                                                           u(k,j,i+1) )         &
@@ -1411,4 +1432,6 @@
                                            ) *                                 &
                                        ( q(k,j,i) - lsc )
+
+                      tend(k,j,i) = tend(k,j,i) + pc_transpiration_rate(kk,j,i)
                    ENDDO
                 ENDDO
@@ -1728,9 +1751,8 @@
 
              DO  k = k_wall + 1, k_wall + pch_index_ji(j,i)
-
-                kk = k - k_wall
-                tend(k,j,i) = tend(k,j,i) -                                    &
-                                 lsec *                                        &
-                                 lad_s(kk,j,i) *                               &
+                kk = k - k_wall  !- lad arrays are defined flat
+
+                pc_transpiration_rate(kk,j,i) = - lsec                         &
+                                 * lad_s(kk,j,i) *                             &
                                  SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
                                                     u(k,j,i+1) )               &
@@ -1744,4 +1766,7 @@
                                      ) *                                       &
                                  ( q(k,j,i) - lsc )
+
+                tend(k,j,i) = tend(k,j,i) + pc_transpiration_rate(kk,j,i)
+
              ENDDO   
 
