Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3172)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3173)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! Revise output of surface quantities in case of overhanging structures
+! 
+! 3045 2018-05-28 07:55:41Z Giersch
 ! error messages revised
 ! 
@@ -1257,4 +1260,7 @@
     CHARACTER (LEN=*) :: variable !< 
  
+    LOGICAL      ::  match_def !< flag indicating natural-type surface
+    LOGICAL      ::  match_lsm !< flag indicating natural-type surface
+    LOGICAL      ::  match_usm !< flag indicating urban-type surface
 
     INTEGER(iwp) ::  i                  !< grid index x direction
@@ -1288,20 +1294,31 @@
              ENDDO
           ELSEIF ( TRIM(variable(4:)) == TRIM('cssws*') )        THEN
-             DO  m = 1, surf_def_h(0)%ns
-                 i = surf_def_h(0)%i(m)
-                 j = surf_def_h(0)%j(m)
-                 chem_species(lsp)%cssws_av(j,i) = chem_species(lsp)%cssws_av(j,i) + surf_def_h(0)%cssws(lsp,m)
-             ENDDO 
-             DO  m = 1, surf_lsm_h%ns
-                 i = surf_lsm_h%i(m)
-                 j = surf_lsm_h%j(m)
-                 chem_species(lsp)%cssws_av(j,i) = chem_species(lsp)%cssws_av(j,i) + surf_lsm_h%cssws(lsp,m)
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   match_def = surf_def_h(0)%start_index(j,i) <=               &
+                               surf_def_h(0)%end_index(j,i)
+                   match_lsm = surf_lsm_h%start_index(j,i) <=                  &
+                               surf_lsm_h%end_index(j,i)
+                   match_usm = surf_usm_h%start_index(j,i) <=                  &
+                               surf_usm_h%end_index(j,i)
+
+                   IF ( match_def )  THEN
+                      m = surf_def_h(0)%end_index(j,i)
+                      chem_species(lsp)%cssws_av(j,i) =                        &
+                                             chem_species(lsp)%cssws_av(j,i) + &
+                                             surf_def_h(0)%cssws(lsp,m)
+                   ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                      m = surf_lsm_h%end_index(j,i)
+                      chem_species(lsp)%cssws_av(j,i) =                        &
+                                             chem_species(lsp)%cssws_av(j,i) + &
+                                             surf_lsm_h%cssws(lsp,m)
+                   ELSEIF ( match_usm )  THEN
+                      m = surf_usm_h%end_index(j,i)
+                      chem_species(lsp)%cssws_av(j,i) =                        &
+                                             chem_species(lsp)%cssws_av(j,i) + &
+                                             surf_usm_h%cssws(lsp,m)
+                   ENDIF
+                ENDDO
              ENDDO
-             DO  m = 1, surf_usm_h%ns
-                 i = surf_usm_h%i(m)
-                 j = surf_usm_h%j(m)
-                 chem_species(lsp)%cssws_av(j,i) = chem_species(lsp)%cssws_av(j,i) + surf_usm_h%cssws(lsp,m)
-             ENDDO
-
           ENDIF
        ENDDO
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 3172)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 3173)
@@ -28,4 +28,8 @@
 ! -----------------
 ! $Id$
+! Revise output of surface radiation quantities in case of overhanging 
+! structures
+! 
+! 3172 2018-07-26 12:06:06Z suehring
 ! Bugfixes:
 !  - temporal work-around for calculation of effective radiative surface 
@@ -7497,4 +7501,7 @@
     CHARACTER (LEN=*) :: variable !< 
 
+    LOGICAL      ::  match_lsm !< flag indicating natural-type surface
+    LOGICAL      ::  match_usm !< flag indicating urban-type surface
+    
     INTEGER(iwp) ::  i !< 
     INTEGER(iwp) ::  j !< 
@@ -7597,14 +7604,18 @@
                 DO  i = nxl, nxr
                    DO  j = nys, nyn
-                      DO m = surf_lsm_h%start_index(j,i),                      &
-                             surf_lsm_h%end_index(j,i)
+                      match_lsm = surf_lsm_h%start_index(j,i) <=               &
+                                  surf_lsm_h%end_index(j,i)
+                      match_usm = surf_usm_h%start_index(j,i) <=               &
+                                  surf_usm_h%end_index(j,i)
+
+                     IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                         m = surf_lsm_h%end_index(j,i)
                          rad_net_av(j,i) = rad_net_av(j,i) +                   &
-                                           surf_lsm_h%rad_net(m)
-                      ENDDO
-                      DO m = surf_usm_h%start_index(j,i),                      &
-                             surf_usm_h%end_index(j,i)
+                                         surf_lsm_h%rad_net(m)
+                      ELSEIF ( match_usm )  THEN
+                         m = surf_usm_h%end_index(j,i)
                          rad_net_av(j,i) = rad_net_av(j,i) +                   &
-                                           surf_usm_h%rad_net(m)
-                      ENDDO
+                                         surf_usm_h%rad_net(m)
+                      ENDIF
                    ENDDO
                 ENDDO
@@ -7615,14 +7626,18 @@
                 DO  i = nxl, nxr
                    DO  j = nys, nyn
-                      DO m = surf_lsm_h%start_index(j,i),                      &
-                             surf_lsm_h%end_index(j,i)
+                      match_lsm = surf_lsm_h%start_index(j,i) <=               &
+                                  surf_lsm_h%end_index(j,i)
+                      match_usm = surf_usm_h%start_index(j,i) <=               &
+                                  surf_usm_h%end_index(j,i)
+
+                      IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                         m = surf_lsm_h%end_index(j,i)
                          rad_lw_in_xy_av(j,i) = rad_lw_in_xy_av(j,i) +         &
-                                                surf_lsm_h%rad_lw_in(m)
-                      ENDDO
-                      DO m = surf_usm_h%start_index(j,i),                      &
-                             surf_usm_h%end_index(j,i)
+                                         surf_lsm_h%rad_lw_in(m)
+                      ELSEIF ( match_usm )  THEN
+                         m = surf_usm_h%end_index(j,i)
                          rad_lw_in_xy_av(j,i) = rad_lw_in_xy_av(j,i) +         &
-                                                surf_usm_h%rad_lw_in(m)
-                      ENDDO
+                                         surf_usm_h%rad_lw_in(m)
+                      ENDIF
                    ENDDO
                 ENDDO
@@ -7633,14 +7648,18 @@
                 DO  i = nxl, nxr
                    DO  j = nys, nyn
-                      DO m = surf_lsm_h%start_index(j,i),                      &
-                             surf_lsm_h%end_index(j,i)
+                      match_lsm = surf_lsm_h%start_index(j,i) <=               &
+                                  surf_lsm_h%end_index(j,i)
+                      match_usm = surf_usm_h%start_index(j,i) <=               &
+                                  surf_usm_h%end_index(j,i)
+
+                      IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                         m = surf_lsm_h%end_index(j,i)
                          rad_lw_out_xy_av(j,i) = rad_lw_out_xy_av(j,i) +       &
-                                                   surf_lsm_h%rad_lw_out(m)
-                      ENDDO
-                      DO m = surf_usm_h%start_index(j,i),                      &
-                             surf_usm_h%end_index(j,i)
+                                                 surf_lsm_h%rad_lw_out(m)
+                      ELSEIF ( match_usm )  THEN
+                         m = surf_usm_h%end_index(j,i)
                          rad_lw_out_xy_av(j,i) = rad_lw_out_xy_av(j,i) +       &
-                                                  surf_usm_h%rad_lw_out(m)
-                      ENDDO
+                                                 surf_usm_h%rad_lw_out(m)
+                      ENDIF
                    ENDDO
                 ENDDO
@@ -7651,14 +7670,18 @@
                 DO  i = nxl, nxr
                    DO  j = nys, nyn
-                      DO m = surf_lsm_h%start_index(j,i),                      &
-                             surf_lsm_h%end_index(j,i)
+                      match_lsm = surf_lsm_h%start_index(j,i) <=               &
+                                  surf_lsm_h%end_index(j,i)
+                      match_usm = surf_usm_h%start_index(j,i) <=               &
+                                  surf_usm_h%end_index(j,i)
+
+                      IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                         m = surf_lsm_h%end_index(j,i)
                          rad_sw_in_xy_av(j,i) = rad_sw_in_xy_av(j,i) +         &
-                                                  surf_lsm_h%rad_sw_in(m)
-                      ENDDO
-                      DO m = surf_usm_h%start_index(j,i),                      &
-                             surf_usm_h%end_index(j,i)
+                                                surf_lsm_h%rad_sw_in(m)
+                      ELSEIF ( match_usm )  THEN
+                         m = surf_usm_h%end_index(j,i)
                          rad_sw_in_xy_av(j,i) = rad_sw_in_xy_av(j,i) +         &
                                                 surf_usm_h%rad_sw_in(m)
-                      ENDDO
+                      ENDIF
                    ENDDO
                 ENDDO
@@ -7669,14 +7692,18 @@
                 DO  i = nxl, nxr
                    DO  j = nys, nyn
-                      DO m = surf_lsm_h%start_index(j,i),                      &
-                             surf_lsm_h%end_index(j,i)
+                      match_lsm = surf_lsm_h%start_index(j,i) <=               &
+                                  surf_lsm_h%end_index(j,i)
+                      match_usm = surf_usm_h%start_index(j,i) <=               &
+                                  surf_usm_h%end_index(j,i)
+
+                      IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                         m = surf_lsm_h%end_index(j,i)
                          rad_sw_out_xy_av(j,i) = rad_sw_out_xy_av(j,i) +       &
-                                                   surf_lsm_h%rad_sw_out(m)
-                      ENDDO
-                      DO m = surf_usm_h%start_index(j,i),                      &
-                             surf_usm_h%end_index(j,i)
+                                                 surf_lsm_h%rad_sw_out(m)
+                      ELSEIF ( match_usm )  THEN
+                         m = surf_usm_h%end_index(j,i)
                          rad_sw_out_xy_av(j,i) = rad_sw_out_xy_av(j,i) +       &
-                                                   surf_usm_h%rad_sw_out(m)
-                      ENDDO
+                                                 surf_usm_h%rad_sw_out(m)
+                      ENDIF
                    ENDDO
                 ENDDO
Index: palm/trunk/SOURCE/sum_up_3d_data.f90
===================================================================
--- palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 3172)
+++ palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 3173)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix for last commit
+! 
+! 3170 2018-07-25 15:19:37Z suehring
 ! Revise output of surface quantities in case of overhanging structures
 ! 
@@ -595,9 +598,9 @@
                       IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ghf_av(j,i) = ghf_av(j,i) +                           &
                                          surf_lsm_h%ghf(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ghf_av(j,i) = ghf_av(j,i) +                           &
                                          surf_usm_h%frac(ind_veg_wall,m)  *    &
                                          surf_usm_h%wghf_eb(m)        +        &
@@ -678,13 +681,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ol_av(j,i) = ol_av(j,i) +                             &
                                          surf_def_h(0)%ol(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ol_av(j,i) = ol_av(j,i) +                             &
                                          surf_lsm_h%ol(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ol_av(j,i) = ol_av(j,i) +                             &
                                          surf_usm_h%ol(m)
                       ENDIF
@@ -884,14 +887,14 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         qsws_av(j,i) = qsws_av(j,i) +                         &
                                          surf_def_h(0)%qsws(m) *               &
                                          waterflux_output_conversion(k)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         qsws_av(j,i) = qsws_av(j,i) +                         &
                                          surf_lsm_h%qsws(m) * l_v
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         qsws_av(j,i) = qsws_av(j,i) +                         &
                                          surf_usm_h%qsws(m) * l_v
                       ENDIF
@@ -922,9 +925,9 @@
                       IF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         r_a_av(j,i) = r_a_av(j,i) +                           &
                                          surf_lsm_h%r_a(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         r_a_av(j,i) = r_a_av(j,i) +                           &
                                          surf_usm_h%frac(ind_veg_wall,m)  *    &
                                          surf_usm_h%r_a(m)       +             & 
@@ -988,14 +991,14 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         shf_av(j,i) = shf_av(j,i) +                           &
                                          surf_def_h(0)%shf(m)  *               &
                                          heatflux_output_conversion(k)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         shf_av(j,i) = shf_av(j,i) +                           &
                                          surf_lsm_h%shf(m) * cp
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         shf_av(j,i) = shf_av(j,i) +                           &
                                          surf_usm_h%shf(m) * cp
                       ENDIF
@@ -1017,13 +1020,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ssws_av(j,i) = ssws_av(j,i) +                         &
                                          surf_def_h(0)%ssws(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ssws_av(j,i) = ssws_av(j,i) +                         &
                                          surf_lsm_h%ssws(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ssws_av(j,i) = ssws_av(j,i) +                         &
                                          surf_usm_h%ssws(m)
                       ENDIF
@@ -1045,13 +1048,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ts_av(j,i) = ts_av(j,i) +                             &
                                          surf_def_h(0)%ts(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ts_av(j,i) = ts_av(j,i) +                             &
                                          surf_lsm_h%ts(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         ts_av(j,i) = ts_av(j,i) +                             &
                                          surf_usm_h%ts(m)
                       ENDIF
@@ -1112,13 +1115,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         us_av(j,i) = us_av(j,i) +                             &
                                          surf_def_h(0)%us(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         us_av(j,i) = us_av(j,i) +                             &
                                          surf_lsm_h%us(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         us_av(j,i) = us_av(j,i) +                             &
                                          surf_usm_h%us(m)
                       ENDIF
@@ -1173,13 +1176,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0_av(j,i) = z0_av(j,i) +                             &
                                          surf_def_h(0)%z0(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0_av(j,i) = z0_av(j,i) +                             &
                                          surf_lsm_h%z0(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0_av(j,i) = z0_av(j,i) +                             &
                                          surf_usm_h%z0(m)
                       ENDIF
@@ -1201,13 +1204,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0h_av(j,i) = z0h_av(j,i) +                           &
                                          surf_def_h(0)%z0h(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0h_av(j,i) = z0h_av(j,i) +                           &
                                          surf_lsm_h%z0h(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0h_av(j,i) = z0h_av(j,i) +                           &
                                          surf_usm_h%z0h(m)
                       ENDIF
@@ -1229,13 +1232,13 @@
                       IF ( match_def )  THEN
                          m = surf_def_h(0)%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0q_av(j,i) = z0q_av(j,i) +                           &
                                          surf_def_h(0)%z0q(m)
                       ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
                          m = surf_lsm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0q_av(j,i) = z0q_av(j,i) +                           &
                                          surf_lsm_h%z0q(m)
                       ELSEIF ( match_usm )  THEN
                          m = surf_usm_h%end_index(j,i)
-                         tsurf_av(j,i) = tsurf_av(j,i) +                       &
+                         z0q_av(j,i) = z0q_av(j,i) +                           &
                                          surf_usm_h%z0q(m)
                       ENDIF
