Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 3571)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 3572)
@@ -28,4 +28,9 @@
 ! -----------------
 ! $Id$
+! Add filling the short- and longwave radiation flux arrays (e.g. diffuse, 
+! direct, reflected, resedual) for all surfaces. This is required to surface
+! outputs in suface_output_mod. (M. Salim)
+! 
+! 3571 2018-11-28 09:24:03Z moh.hefny
 ! Add an epsilon value to compare values in if statement to fix possible 
 ! precsion related errors in raytrace routines.
@@ -692,5 +697,5 @@
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rad_sw_out_xy_av !< average of outgoing shortwave radiation at surface
 !
-!-- Land surface albedos for solar zenith angle of 60Â° after Briegleb (1992)     
+!-- Land surface albedos for solar zenith angle of 60° after Briegleb (1992)     
 !-- (shortwave, longwave, broadband):   sw,      lw,      bb,
     REAL(wp), DIMENSION(0:2,1:33), PARAMETER :: albedo_pars = RESHAPE( (/& 
@@ -788,7 +793,7 @@
                                              rrtm_cfc22vmr,  & !< CFC22 volume mixing ratio (g/mol)
                                              rrtm_ch4vmr,    & !< CH4 volume mixing ratio
-                                             rrtm_cicewp,    & !< in-cloud ice water path (g/mÂ²)
+                                             rrtm_cicewp,    & !< in-cloud ice water path (g/m2)
                                              rrtm_cldfr,     & !< cloud fraction (0,1)
-                                             rrtm_cliqwp,    & !< in-cloud liquid water path (g/mÂ²)
+                                             rrtm_cliqwp,    & !< in-cloud liquid water path (g/m2)
                                              rrtm_co2vmr,    & !< CO2 volume mixing ratio (g/mol)
                                              rrtm_emis,      & !< surface emissivity (0-1)  
@@ -1710,10 +1715,24 @@
           ALLOCATE( surf_lsm_h%rad_sw_in(1:surf_lsm_h%ns)  )
           ALLOCATE( surf_lsm_h%rad_sw_out(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_sw_dir(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_sw_dif(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_sw_ref(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_sw_res(1:surf_lsm_h%ns) )
           ALLOCATE( surf_lsm_h%rad_lw_in(1:surf_lsm_h%ns)  )
           ALLOCATE( surf_lsm_h%rad_lw_out(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_lw_dif(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_lw_ref(1:surf_lsm_h%ns) )
+          ALLOCATE( surf_lsm_h%rad_lw_res(1:surf_lsm_h%ns) )
           surf_lsm_h%rad_sw_in  = 0.0_wp 
           surf_lsm_h%rad_sw_out = 0.0_wp 
+          surf_lsm_h%rad_sw_dir = 0.0_wp 
+          surf_lsm_h%rad_sw_dif = 0.0_wp 
+          surf_lsm_h%rad_sw_ref = 0.0_wp 
+          surf_lsm_h%rad_sw_res = 0.0_wp 
           surf_lsm_h%rad_lw_in  = 0.0_wp 
           surf_lsm_h%rad_lw_out = 0.0_wp 
+          surf_lsm_h%rad_lw_dif = 0.0_wp 
+          surf_lsm_h%rad_lw_ref = 0.0_wp 
+          surf_lsm_h%rad_lw_res = 0.0_wp 
        ENDIF
        IF ( .NOT. ALLOCATED ( surf_usm_h%rad_sw_in )  .AND.                    &
@@ -1721,10 +1740,24 @@
           ALLOCATE( surf_usm_h%rad_sw_in(1:surf_usm_h%ns)  )
           ALLOCATE( surf_usm_h%rad_sw_out(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_sw_dir(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_sw_dif(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_sw_ref(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_sw_res(1:surf_usm_h%ns) )
           ALLOCATE( surf_usm_h%rad_lw_in(1:surf_usm_h%ns)  )
           ALLOCATE( surf_usm_h%rad_lw_out(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_lw_dif(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_lw_ref(1:surf_usm_h%ns) )
+          ALLOCATE( surf_usm_h%rad_lw_res(1:surf_usm_h%ns) )
           surf_usm_h%rad_sw_in  = 0.0_wp 
           surf_usm_h%rad_sw_out = 0.0_wp 
+          surf_usm_h%rad_sw_dir = 0.0_wp 
+          surf_usm_h%rad_sw_dif = 0.0_wp 
+          surf_usm_h%rad_sw_ref = 0.0_wp 
+          surf_usm_h%rad_sw_res = 0.0_wp 
           surf_usm_h%rad_lw_in  = 0.0_wp 
           surf_usm_h%rad_lw_out = 0.0_wp 
+          surf_usm_h%rad_lw_dif = 0.0_wp 
+          surf_usm_h%rad_lw_ref = 0.0_wp 
+          surf_usm_h%rad_lw_res = 0.0_wp 
        ENDIF
        DO  l = 0, 3
@@ -1733,10 +1766,27 @@
              ALLOCATE( surf_lsm_v(l)%rad_sw_in(1:surf_lsm_v(l)%ns)  )
              ALLOCATE( surf_lsm_v(l)%rad_sw_out(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_sw_dir(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_sw_dif(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_sw_ref(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_sw_res(1:surf_lsm_v(l)%ns) )
+
              ALLOCATE( surf_lsm_v(l)%rad_lw_in(1:surf_lsm_v(l)%ns)  )
              ALLOCATE( surf_lsm_v(l)%rad_lw_out(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_lw_dif(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_lw_ref(1:surf_lsm_v(l)%ns) )
+             ALLOCATE( surf_lsm_v(l)%rad_lw_res(1:surf_lsm_v(l)%ns) )
+
              surf_lsm_v(l)%rad_sw_in  = 0.0_wp 
-             surf_lsm_v(l)%rad_sw_out = 0.0_wp 
+             surf_lsm_v(l)%rad_sw_out = 0.0_wp
+             surf_lsm_v(l)%rad_sw_dir = 0.0_wp
+             surf_lsm_v(l)%rad_sw_dif = 0.0_wp
+             surf_lsm_v(l)%rad_sw_ref = 0.0_wp
+             surf_lsm_v(l)%rad_sw_res = 0.0_wp
+
              surf_lsm_v(l)%rad_lw_in  = 0.0_wp 
              surf_lsm_v(l)%rad_lw_out = 0.0_wp 
+             surf_lsm_v(l)%rad_lw_dif = 0.0_wp 
+             surf_lsm_v(l)%rad_lw_ref = 0.0_wp 
+             surf_lsm_v(l)%rad_lw_res = 0.0_wp 
           ENDIF
           IF ( .NOT. ALLOCATED ( surf_usm_v(l)%rad_sw_in )  .AND.              &
@@ -1744,10 +1794,24 @@
              ALLOCATE( surf_usm_v(l)%rad_sw_in(1:surf_usm_v(l)%ns)  )
              ALLOCATE( surf_usm_v(l)%rad_sw_out(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_sw_dir(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_sw_dif(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_sw_ref(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_sw_res(1:surf_usm_v(l)%ns) )
              ALLOCATE( surf_usm_v(l)%rad_lw_in(1:surf_usm_v(l)%ns)  )
              ALLOCATE( surf_usm_v(l)%rad_lw_out(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_lw_dif(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_lw_ref(1:surf_usm_v(l)%ns) )
+             ALLOCATE( surf_usm_v(l)%rad_lw_res(1:surf_usm_v(l)%ns) )
              surf_usm_v(l)%rad_sw_in  = 0.0_wp 
-             surf_usm_v(l)%rad_sw_out = 0.0_wp 
+             surf_usm_v(l)%rad_sw_out = 0.0_wp
+             surf_usm_v(l)%rad_sw_dir = 0.0_wp
+             surf_usm_v(l)%rad_sw_dif = 0.0_wp
+             surf_usm_v(l)%rad_sw_ref = 0.0_wp
+             surf_usm_v(l)%rad_sw_res = 0.0_wp
              surf_usm_v(l)%rad_lw_in  = 0.0_wp 
              surf_usm_v(l)%rad_lw_out = 0.0_wp 
+             surf_usm_v(l)%rad_lw_dif = 0.0_wp 
+             surf_usm_v(l)%rad_lw_ref = 0.0_wp 
+             surf_usm_v(l)%rad_lw_res = 0.0_wp 
           ENDIF
        ENDDO
@@ -3200,5 +3264,5 @@
 !
 !--       Calculate liquid water path and cloud fraction for each column.
-!--       Note that LWP is required in g/mÂ² instead of kg/kg m.
+!--       Note that LWP is required in g/m2 instead of kg/kg m.
           rrtm_cldfr  = 0.0_wp
           rrtm_reliq  = 0.0_wp
@@ -3386,5 +3450,5 @@
 !
 !--             Calculate liquid water path and cloud fraction for each column.
-!--             Note that LWP is required in g/mÂ² instead of kg/kg m.
+!--             Note that LWP is required in g/m2 instead of kg/kg m.
                 rrtm_cldfr  = 0.0_wp
                 rrtm_reliq  = 0.0_wp
@@ -5136,4 +5200,9 @@
            surf_usm_h%rad_sw_in(m)  = surfinsw(i)
            surf_usm_h%rad_sw_out(m) = surfoutsw(i)
+           surf_usm_h%rad_sw_dir(m) = surfinswdir(i)
+           surf_usm_h%rad_sw_dif(m) = surfinswdif(i)
+           surf_usm_h%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -        &
+                                      surfinswdif(i)
+           surf_usm_h%rad_sw_res(m) = surfins(i)
            surf_usm_h%rad_lw_in(m)  = surfinlw(i)
            surf_usm_h%rad_lw_out(m) = surfoutlw(i)
@@ -5141,4 +5210,7 @@
                                       surfinlw(i) - surfoutlw(i)
            surf_usm_h%rad_net_l(m)  = surf_usm_h%rad_net(m)
+           surf_usm_h%rad_lw_dif(m) = surfinlwdif(i)
+           surf_usm_h%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_usm_h%rad_lw_res(m) = surfinl(i)
 !
 !--     northward-facding
@@ -5146,4 +5218,9 @@
            surf_usm_v(0)%rad_sw_in(m)  = surfinsw(i)
            surf_usm_v(0)%rad_sw_out(m) = surfoutsw(i)
+           surf_usm_v(0)%rad_sw_dir(m) = surfinswdir(i)
+           surf_usm_v(0)%rad_sw_dif(m) = surfinswdif(i)
+           surf_usm_v(0)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_usm_v(0)%rad_sw_res(m) = surfins(i)
            surf_usm_v(0)%rad_lw_in(m)  = surfinlw(i)
            surf_usm_v(0)%rad_lw_out(m) = surfoutlw(i)
@@ -5151,4 +5228,7 @@
                                          surfinlw(i) - surfoutlw(i)
            surf_usm_v(0)%rad_net_l(m)  = surf_usm_v(0)%rad_net(m)
+           surf_usm_v(0)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_usm_v(0)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_usm_v(0)%rad_lw_res(m) = surfinl(i)
 !
 !--     southward-facding
@@ -5156,4 +5236,9 @@
            surf_usm_v(1)%rad_sw_in(m)  = surfinsw(i)
            surf_usm_v(1)%rad_sw_out(m) = surfoutsw(i)
+           surf_usm_v(1)%rad_sw_dir(m) = surfinswdir(i)
+           surf_usm_v(1)%rad_sw_dif(m) = surfinswdif(i)
+           surf_usm_v(1)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_usm_v(1)%rad_sw_res(m) = surfins(i)
            surf_usm_v(1)%rad_lw_in(m)  = surfinlw(i)
            surf_usm_v(1)%rad_lw_out(m) = surfoutlw(i)
@@ -5161,4 +5246,7 @@
                                          surfinlw(i) - surfoutlw(i)
            surf_usm_v(1)%rad_net_l(m)  = surf_usm_v(1)%rad_net(m)
+           surf_usm_v(1)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_usm_v(1)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_usm_v(1)%rad_lw_res(m) = surfinl(i)
 !
 !--     eastward-facing
@@ -5166,4 +5254,9 @@
            surf_usm_v(2)%rad_sw_in(m)  = surfinsw(i)
            surf_usm_v(2)%rad_sw_out(m) = surfoutsw(i)
+           surf_usm_v(2)%rad_sw_dir(m) = surfinswdir(i)
+           surf_usm_v(2)%rad_sw_dif(m) = surfinswdif(i)
+           surf_usm_v(2)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_usm_v(2)%rad_sw_res(m) = surfins(i)
            surf_usm_v(2)%rad_lw_in(m)  = surfinlw(i)
            surf_usm_v(2)%rad_lw_out(m) = surfoutlw(i)
@@ -5171,4 +5264,7 @@
                                          surfinlw(i) - surfoutlw(i)
            surf_usm_v(2)%rad_net_l(m)  = surf_usm_v(2)%rad_net(m)
+           surf_usm_v(2)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_usm_v(2)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_usm_v(2)%rad_lw_res(m) = surfinl(i)
 !
 !--     westward-facding
@@ -5176,4 +5272,9 @@
            surf_usm_v(3)%rad_sw_in(m)  = surfinsw(i)
            surf_usm_v(3)%rad_sw_out(m) = surfoutsw(i)
+           surf_usm_v(3)%rad_sw_dir(m) = surfinswdir(i)
+           surf_usm_v(3)%rad_sw_dif(m) = surfinswdif(i)
+           surf_usm_v(3)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_usm_v(3)%rad_sw_res(m) = surfins(i)
            surf_usm_v(3)%rad_lw_in(m)  = surfinlw(i)
            surf_usm_v(3)%rad_lw_out(m) = surfoutlw(i)
@@ -5181,4 +5282,7 @@
                                          surfinlw(i) - surfoutlw(i)
            surf_usm_v(3)%rad_net_l(m)  = surf_usm_v(3)%rad_net(m)
+           surf_usm_v(3)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_usm_v(3)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_usm_v(3)%rad_lw_res(m) = surfinl(i)
 !
 !--     (2) land surfaces
@@ -5187,8 +5291,16 @@
            surf_lsm_h%rad_sw_in(m)  = surfinsw(i)
            surf_lsm_h%rad_sw_out(m) = surfoutsw(i)
+           surf_lsm_h%rad_sw_dir(m) = surfinswdir(i)
+           surf_lsm_h%rad_sw_dif(m) = surfinswdif(i)
+           surf_lsm_h%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -        &
+                                         surfinswdif(i)
+           surf_lsm_h%rad_sw_res(m) = surfins(i)
            surf_lsm_h%rad_lw_in(m)  = surfinlw(i)
            surf_lsm_h%rad_lw_out(m) = surfoutlw(i)
            surf_lsm_h%rad_net(m)    = surfinsw(i) - surfoutsw(i) +          &
                                       surfinlw(i) - surfoutlw(i)
+           surf_lsm_h%rad_lw_dif(m) = surfinlwdif(i)
+           surf_lsm_h%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_lsm_h%rad_lw_res(m) = surfinl(i)
 !
 !--     northward-facding
@@ -5196,8 +5308,16 @@
            surf_lsm_v(0)%rad_sw_in(m)  = surfinsw(i)
            surf_lsm_v(0)%rad_sw_out(m) = surfoutsw(i)
+           surf_lsm_v(0)%rad_sw_dir(m) = surfinswdir(i)
+           surf_lsm_v(0)%rad_sw_dif(m) = surfinswdif(i)
+           surf_lsm_v(0)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_lsm_v(0)%rad_sw_res(m) = surfins(i)
            surf_lsm_v(0)%rad_lw_in(m)  = surfinlw(i)
            surf_lsm_v(0)%rad_lw_out(m) = surfoutlw(i)
            surf_lsm_v(0)%rad_net(m)    = surfinsw(i) - surfoutsw(i) +       &
                                          surfinlw(i) - surfoutlw(i)
+           surf_lsm_v(0)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_lsm_v(0)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_lsm_v(0)%rad_lw_res(m) = surfinl(i)
 !
 !--     southward-facding
@@ -5205,8 +5325,16 @@
            surf_lsm_v(1)%rad_sw_in(m)  = surfinsw(i)
            surf_lsm_v(1)%rad_sw_out(m) = surfoutsw(i)
+           surf_lsm_v(1)%rad_sw_dir(m) = surfinswdir(i)
+           surf_lsm_v(1)%rad_sw_dif(m) = surfinswdif(i)
+           surf_lsm_v(1)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_lsm_v(1)%rad_sw_res(m) = surfins(i)
            surf_lsm_v(1)%rad_lw_in(m)  = surfinlw(i)
            surf_lsm_v(1)%rad_lw_out(m) = surfoutlw(i)
            surf_lsm_v(1)%rad_net(m)    = surfinsw(i) - surfoutsw(i) +       &
                                          surfinlw(i) - surfoutlw(i)
+           surf_lsm_v(1)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_lsm_v(1)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_lsm_v(1)%rad_lw_res(m) = surfinl(i)
 !
 !--     eastward-facing
@@ -5214,8 +5342,16 @@
            surf_lsm_v(2)%rad_sw_in(m)  = surfinsw(i)
            surf_lsm_v(2)%rad_sw_out(m) = surfoutsw(i)
+           surf_lsm_v(2)%rad_sw_dir(m) = surfinswdir(i)
+           surf_lsm_v(2)%rad_sw_dif(m) = surfinswdif(i)
+           surf_lsm_v(2)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_lsm_v(2)%rad_sw_res(m) = surfins(i)
            surf_lsm_v(2)%rad_lw_in(m)  = surfinlw(i)
            surf_lsm_v(2)%rad_lw_out(m) = surfoutlw(i)
            surf_lsm_v(2)%rad_net(m)    = surfinsw(i) - surfoutsw(i) +       &
                                          surfinlw(i) - surfoutlw(i)
+           surf_lsm_v(2)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_lsm_v(2)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_lsm_v(2)%rad_lw_res(m) = surfinl(i)
 !
 !--     westward-facing
@@ -5223,8 +5359,16 @@
            surf_lsm_v(3)%rad_sw_in(m)  = surfinsw(i)
            surf_lsm_v(3)%rad_sw_out(m) = surfoutsw(i)
+           surf_lsm_v(3)%rad_sw_dir(m) = surfinswdir(i)
+           surf_lsm_v(3)%rad_sw_dif(m) = surfinswdif(i)
+           surf_lsm_v(3)%rad_sw_ref(m) = surfinsw(i) - surfinswdir(i) -     &
+                                         surfinswdif(i)
+           surf_lsm_v(3)%rad_sw_res(m) = surfins(i)
            surf_lsm_v(3)%rad_lw_in(m)  = surfinlw(i)
            surf_lsm_v(3)%rad_lw_out(m) = surfoutlw(i)
            surf_lsm_v(3)%rad_net(m)    = surfinsw(i) - surfoutsw(i) +       &
                                          surfinlw(i) - surfoutlw(i)
+           surf_lsm_v(3)%rad_lw_dif(m) = surfinlwdif(i)
+           surf_lsm_v(3)%rad_lw_ref(m) = surfinlw(i) - surfinlwdif(i)
+           surf_lsm_v(3)%rad_lw_res(m) = surfinl(i)
         ENDIF
 
Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 3571)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 3572)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! Define short- and longwave radiation flux arrays (e.g. diffuse, direct,
+! reflected, resedual) for all surfaces. This is required to surface outputs
+! in suface_output_mod. (M. Salim)
+! 
+! 3560 2018-11-23 09:20:21Z raasch
 ! Surface restoring in restarts commented. Some formatting. 
 ! 
@@ -392,6 +397,13 @@
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_lw_in           !< incoming longwave radiation
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_lw_out          !< emitted longwave radiation
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_lw_dif          !< incoming longwave radiation from sky
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_lw_ref          !< incoming longwave radiation from reflection
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_lw_res          !< resedual longwave radiation in surface after last reflection step
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_sw_in           !< incoming shortwave radiation
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_sw_out          !< emitted shortwave radiation
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_sw_dir          !< direct incoming shortwave radiation
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_sw_dif          !< diffuse incoming shortwave radiation
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_sw_ref          !< incoming shortwave radiation from reflection
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_sw_res          !< resedual shortwave radiation in surface after last reflection step
        
 
Index: palm/trunk/SOURCE/surface_output_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_output_mod.f90	(revision 3571)
+++ palm/trunk/SOURCE/surface_output_mod.f90	(revision 3572)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Added short- and longwave radiation flux arrays (e.g. diffuse, direct,
+! reflected, resedual) for all surfaces (M. Salim)
+! 
+! 3494 2018-11-06 14:51:27Z suehring
 ! Bugfix in gathering surface data from different types and orientation. 
 ! Output of total number of surfaces and vertices added.
@@ -2003,4 +2007,207 @@
                                                surf_lsm_v(3)%r_s,              &
                                                surf_usm_v(3)%r_s ) 
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_sw_dir' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_sw_dir,       &
+                                               surf_def_h(1)%rad_sw_dir,       &
+                                               surf_lsm_h%rad_sw_dir,          &
+                                               surf_usm_h%rad_sw_dir,          &
+                                               surf_def_v(0)%rad_sw_dir,       &
+                                               surf_lsm_v(0)%rad_sw_dir,       &
+                                               surf_usm_v(0)%rad_sw_dir,       &
+                                               surf_def_v(1)%rad_sw_dir,       &
+                                               surf_lsm_v(1)%rad_sw_dir,       &
+                                               surf_usm_v(1)%rad_sw_dir,       &
+                                               surf_def_v(2)%rad_sw_dir,       &
+                                               surf_lsm_v(2)%rad_sw_dir,       &
+                                               surf_usm_v(2)%rad_sw_dir,       &
+                                               surf_def_v(3)%rad_sw_dir,       &
+                                               surf_lsm_v(3)%rad_sw_dir,       &
+                                               surf_usm_v(3)%rad_sw_dir )
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_sw_dif' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_sw_dif,       &
+                                               surf_def_h(1)%rad_sw_dif,       &
+                                               surf_lsm_h%rad_sw_dif,          &
+                                               surf_usm_h%rad_sw_dif,          &
+                                               surf_def_v(0)%rad_sw_dif,       &
+                                               surf_lsm_v(0)%rad_sw_dif,       &
+                                               surf_usm_v(0)%rad_sw_dif,       &
+                                               surf_def_v(1)%rad_sw_dif,       &
+                                               surf_lsm_v(1)%rad_sw_dif,       &
+                                               surf_usm_v(1)%rad_sw_dif,       &
+                                               surf_def_v(2)%rad_sw_dif,       &
+                                               surf_lsm_v(2)%rad_sw_dif,       &
+                                               surf_usm_v(2)%rad_sw_dif,       &
+                                               surf_def_v(3)%rad_sw_dif,       &
+                                               surf_lsm_v(3)%rad_sw_dif,       &
+                                               surf_usm_v(3)%rad_sw_dif )
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_sw_ref' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_sw_ref,       &
+                                               surf_def_h(1)%rad_sw_ref,       &
+                                               surf_lsm_h%rad_sw_ref,          &
+                                               surf_usm_h%rad_sw_ref,          &
+                                               surf_def_v(0)%rad_sw_ref,       &
+                                               surf_lsm_v(0)%rad_sw_ref,       &
+                                               surf_usm_v(0)%rad_sw_ref,       &
+                                               surf_def_v(1)%rad_sw_ref,       &
+                                               surf_lsm_v(1)%rad_sw_ref,       &
+                                               surf_usm_v(1)%rad_sw_ref,       &
+                                               surf_def_v(2)%rad_sw_ref,       &
+                                               surf_lsm_v(2)%rad_sw_ref,       &
+                                               surf_usm_v(2)%rad_sw_ref,       &
+                                               surf_def_v(3)%rad_sw_ref,       &
+                                               surf_lsm_v(3)%rad_sw_ref,       &
+                                               surf_usm_v(3)%rad_sw_ref )
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_sw_res' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_sw_res,       &
+                                               surf_def_h(1)%rad_sw_res,       &
+                                               surf_lsm_h%rad_sw_res,          &
+                                               surf_usm_h%rad_sw_res,          &
+                                               surf_def_v(0)%rad_sw_res,       &
+                                               surf_lsm_v(0)%rad_sw_res,       &
+                                               surf_usm_v(0)%rad_sw_res,       &
+                                               surf_def_v(1)%rad_sw_res,       &
+                                               surf_lsm_v(1)%rad_sw_res,       &
+                                               surf_usm_v(1)%rad_sw_res,       &
+                                               surf_def_v(2)%rad_sw_res,       &
+                                               surf_lsm_v(2)%rad_sw_res,       &
+                                               surf_usm_v(2)%rad_sw_res,       &
+                                               surf_def_v(3)%rad_sw_res,       &
+                                               surf_lsm_v(3)%rad_sw_res,       &
+                                               surf_usm_v(3)%rad_sw_res )
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_lw_dif' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_lw_dif,       &
+                                               surf_def_h(1)%rad_lw_dif,       &
+                                               surf_lsm_h%rad_lw_dif,          &
+                                               surf_usm_h%rad_lw_dif,          &
+                                               surf_def_v(0)%rad_lw_dif,       &
+                                               surf_lsm_v(0)%rad_lw_dif,       &
+                                               surf_usm_v(0)%rad_lw_dif,       &
+                                               surf_def_v(1)%rad_lw_dif,       &
+                                               surf_lsm_v(1)%rad_lw_dif,       &
+                                               surf_usm_v(1)%rad_lw_dif,       &
+                                               surf_def_v(2)%rad_lw_dif,       &
+                                               surf_lsm_v(2)%rad_lw_dif,       &
+                                               surf_usm_v(2)%rad_lw_dif,       &
+                                               surf_def_v(3)%rad_lw_dif,       &
+                                               surf_lsm_v(3)%rad_lw_dif,       &
+                                               surf_usm_v(3)%rad_lw_dif )
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_lw_ref' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_lw_ref,       &
+                                               surf_def_h(1)%rad_lw_ref,       &
+                                               surf_lsm_h%rad_lw_ref,          &
+                                               surf_usm_h%rad_lw_ref,          &
+                                               surf_def_v(0)%rad_lw_ref,       &
+                                               surf_lsm_v(0)%rad_lw_ref,       &
+                                               surf_usm_v(0)%rad_lw_ref,       &
+                                               surf_def_v(1)%rad_lw_ref,       &
+                                               surf_lsm_v(1)%rad_lw_ref,       &
+                                               surf_usm_v(1)%rad_lw_ref,       &
+                                               surf_def_v(2)%rad_lw_ref,       &
+                                               surf_lsm_v(2)%rad_lw_ref,       &
+                                               surf_usm_v(2)%rad_lw_ref,       &
+                                               surf_def_v(3)%rad_lw_ref,       &
+                                               surf_lsm_v(3)%rad_lw_ref,       &
+                                               surf_usm_v(3)%rad_lw_ref )
+               ELSE
+!
+!--               Output of averaged data
+                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
+                                        REAL( average_count_surf, KIND=wp )
+                  surfaces%var_av(:,n_out) = 0.0_wp
+                                                        
+               ENDIF
+
+            CASE ( 'rad_lw_res' )
+!
+!--            Output of instantaneous data
+               IF ( av == 0 )  THEN
+                  CALL surface_output_collect( surf_def_h(0)%rad_lw_res,       &
+                                               surf_def_h(1)%rad_lw_res,       &
+                                               surf_lsm_h%rad_lw_res,          &
+                                               surf_usm_h%rad_lw_res,          &
+                                               surf_def_v(0)%rad_lw_res,       &
+                                               surf_lsm_v(0)%rad_lw_res,       &
+                                               surf_usm_v(0)%rad_lw_res,       &
+                                               surf_def_v(1)%rad_lw_res,       &
+                                               surf_lsm_v(1)%rad_lw_res,       &
+                                               surf_usm_v(1)%rad_lw_res,       &
+                                               surf_def_v(2)%rad_lw_res,       &
+                                               surf_lsm_v(2)%rad_lw_res,       &
+                                               surf_usm_v(2)%rad_lw_res,       &
+                                               surf_def_v(3)%rad_lw_res,       &
+                                               surf_lsm_v(3)%rad_lw_res,       &
+                                               surf_usm_v(3)%rad_lw_res )
                ELSE
 !
@@ -2753,4 +2960,130 @@
                                            surf_usm_v(3)%r_s, n_out ) 
 
+
+            CASE ( 'rad_sw_dir' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_sw_dir,           &
+                                           surf_def_h(1)%rad_sw_dir,           &
+                                           surf_lsm_h%rad_sw_dir,              &
+                                           surf_usm_h%rad_sw_dir,              &
+                                           surf_def_v(0)%rad_sw_dir,           &
+                                           surf_lsm_v(0)%rad_sw_dir,           &
+                                           surf_usm_v(0)%rad_sw_dir,           &
+                                           surf_def_v(1)%rad_sw_dir,           &
+                                           surf_lsm_v(1)%rad_sw_dir,           &
+                                           surf_usm_v(1)%rad_sw_dir,           &
+                                           surf_def_v(2)%rad_sw_dir,           &
+                                           surf_lsm_v(2)%rad_sw_dir,           &
+                                           surf_usm_v(2)%rad_sw_dir,           &
+                                           surf_def_v(3)%rad_sw_dir,           &
+                                           surf_lsm_v(3)%rad_sw_dir,           &
+                                           surf_usm_v(3)%rad_sw_dir, n_out )
+            CASE ( 'rad_sw_dif' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_sw_dif,           &
+                                           surf_def_h(1)%rad_sw_dif,           &
+                                           surf_lsm_h%rad_sw_dif,              &
+                                           surf_usm_h%rad_sw_dif,              &
+                                           surf_def_v(0)%rad_sw_dif,           &
+                                           surf_lsm_v(0)%rad_sw_dif,           &
+                                           surf_usm_v(0)%rad_sw_dif,           &
+                                           surf_def_v(1)%rad_sw_dif,           &
+                                           surf_lsm_v(1)%rad_sw_dif,           &
+                                           surf_usm_v(1)%rad_sw_dif,           &
+                                           surf_def_v(2)%rad_sw_dif,           &
+                                           surf_lsm_v(2)%rad_sw_dif,           &
+                                           surf_usm_v(2)%rad_sw_dif,           &
+                                           surf_def_v(3)%rad_sw_dif,           &
+                                           surf_lsm_v(3)%rad_sw_dif,           &
+                                           surf_usm_v(3)%rad_sw_dif, n_out )
+
+            CASE ( 'rad_sw_ref' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_sw_ref,           &
+                                           surf_def_h(1)%rad_sw_ref,           &
+                                           surf_lsm_h%rad_sw_ref,              &
+                                           surf_usm_h%rad_sw_ref,              &
+                                           surf_def_v(0)%rad_sw_ref,           &
+                                           surf_lsm_v(0)%rad_sw_ref,           &
+                                           surf_usm_v(0)%rad_sw_ref,           &
+                                           surf_def_v(1)%rad_sw_ref,           &
+                                           surf_lsm_v(1)%rad_sw_ref,           &
+                                           surf_usm_v(1)%rad_sw_ref,           &
+                                           surf_def_v(2)%rad_sw_ref,           &
+                                           surf_lsm_v(2)%rad_sw_ref,           &
+                                           surf_usm_v(2)%rad_sw_ref,           &
+                                           surf_def_v(3)%rad_sw_ref,           &
+                                           surf_lsm_v(3)%rad_sw_ref,           &
+                                           surf_usm_v(3)%rad_sw_ref, n_out )
+               
+            CASE ( 'rad_sw_res' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_sw_res,           &
+                                           surf_def_h(1)%rad_sw_res,           &
+                                           surf_lsm_h%rad_sw_res,              &
+                                           surf_usm_h%rad_sw_res,              &
+                                           surf_def_v(0)%rad_sw_res,           &
+                                           surf_lsm_v(0)%rad_sw_res,           &
+                                           surf_usm_v(0)%rad_sw_res,           &
+                                           surf_def_v(1)%rad_sw_res,           &
+                                           surf_lsm_v(1)%rad_sw_res,           &
+                                           surf_usm_v(1)%rad_sw_res,           &
+                                           surf_def_v(2)%rad_sw_res,           &
+                                           surf_lsm_v(2)%rad_sw_res,           &
+                                           surf_usm_v(2)%rad_sw_res,           &
+                                           surf_def_v(3)%rad_sw_res,           &
+                                           surf_lsm_v(3)%rad_sw_res,           &
+                                           surf_usm_v(3)%rad_sw_res, n_out )
+
+            CASE ( 'rad_lw_dif' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_lw_dif,           &
+                                           surf_def_h(1)%rad_lw_dif,           &
+                                           surf_lsm_h%rad_lw_dif,              &
+                                           surf_usm_h%rad_lw_dif,              &
+                                           surf_def_v(0)%rad_lw_dif,           &
+                                           surf_lsm_v(0)%rad_lw_dif,           &
+                                           surf_usm_v(0)%rad_lw_dif,           &
+                                           surf_def_v(1)%rad_lw_dif,           &
+                                           surf_lsm_v(1)%rad_lw_dif,           &
+                                           surf_usm_v(1)%rad_lw_dif,           &
+                                           surf_def_v(2)%rad_lw_dif,           &
+                                           surf_lsm_v(2)%rad_lw_dif,           &
+                                           surf_usm_v(2)%rad_lw_dif,           &
+                                           surf_def_v(3)%rad_lw_dif,           &
+                                           surf_lsm_v(3)%rad_lw_dif,           &
+                                           surf_usm_v(3)%rad_lw_dif, n_out )
+
+            CASE ( 'rad_lw_ref' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_lw_ref,           &
+                                           surf_def_h(1)%rad_lw_ref,           &
+                                           surf_lsm_h%rad_lw_ref,              &
+                                           surf_usm_h%rad_lw_ref,              &
+                                           surf_def_v(0)%rad_lw_ref,           &
+                                           surf_lsm_v(0)%rad_lw_ref,           &
+                                           surf_usm_v(0)%rad_lw_ref,           &
+                                           surf_def_v(1)%rad_lw_ref,           &
+                                           surf_lsm_v(1)%rad_lw_ref,           &
+                                           surf_usm_v(1)%rad_lw_ref,           &
+                                           surf_def_v(2)%rad_lw_ref,           &
+                                           surf_lsm_v(2)%rad_lw_ref,           &
+                                           surf_usm_v(2)%rad_lw_ref,           &
+                                           surf_def_v(3)%rad_lw_ref,           &
+                                           surf_lsm_v(3)%rad_lw_ref,           &
+                                           surf_usm_v(3)%rad_lw_ref, n_out )
+
+            CASE ( 'rad_lw_res' )
+               CALL surface_output_sum_up( surf_def_h(0)%rad_lw_res,           &
+                                           surf_def_h(1)%rad_lw_res,           &
+                                           surf_lsm_h%rad_lw_res,              &
+                                           surf_usm_h%rad_lw_res,              &
+                                           surf_def_v(0)%rad_lw_res,           &
+                                           surf_lsm_v(0)%rad_lw_res,           &
+                                           surf_usm_v(0)%rad_lw_res,           &
+                                           surf_def_v(1)%rad_lw_res,           &
+                                           surf_lsm_v(1)%rad_lw_res,           &
+                                           surf_usm_v(1)%rad_lw_res,           &
+                                           surf_def_v(2)%rad_lw_res,           &
+                                           surf_lsm_v(2)%rad_lw_res,           &
+                                           surf_usm_v(2)%rad_lw_res,           &
+                                           surf_def_v(3)%rad_lw_res,           &
+                                           surf_lsm_v(3)%rad_lw_res,           &
+                                           surf_usm_v(3)%rad_lw_res, n_out )
+
          END SELECT
       ENDDO
@@ -3311,5 +3644,9 @@
             CASE ( 'rad_net' )
 
-            CASE ( 'rad_lw_in', 'rad_lw_out', 'rad_sw_in', 'rad_sw_out' )
+            CASE ( 'rad_lw_in', 'rad_lw_out', 'rad_lw_dif', 'rad_lw_ref',     &
+                   'rad_lw_res' )
+
+            CASE ( 'rad_sw_in', 'rad_sw_out', 'rad_sw_dif', 'rad_sw_ref',     &
+                   'rad_sw_res', 'rad_sw_dir' )
 
             CASE ( 'ghf' )
