Index: /palm/trunk/SOURCE/average_3d_data.f90
===================================================================
--- /palm/trunk/SOURCE/average_3d_data.f90	(revision 4557)
+++ /palm/trunk/SOURCE/average_3d_data.f90	(revision 4558)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! bugfix: average_count_3d is set to integer 0
+! 
+! 4514 2020-04-30 16:29:59Z suehring
 ! Enable output of qsurf and ssurf
 ! 
@@ -463,5 +466,5 @@
 !
 !-- Reset the counter
-    average_count_3d = 0.0
+    average_count_3d = 0_iwp
 
     CALL cpu_log( log_point(35), 'average_3d_data', 'stop' )
Index: /palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4557)
+++ /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4558)
@@ -28,4 +28,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: - reset RTM output average values after each averaging timestep to zero
+!         - correct calculation of rtm_rad_net_av
+! 
+! 4555 2020-06-05 21:52:00Z moh.hefny
 ! Bugfix in averaging PC and MRT related quantities
 ! 
@@ -9982,6 +9986,6 @@
                  IF ( .NOT.  ALLOCATED(surfradnet_av) )  THEN
                      ALLOCATE( surfradnet_av(nsurfl) )
-                     surfradnet_av = 0.0_wp
                  ENDIF
+                 surfradnet_av = 0.0_wp
 
              CASE ( 'rtm_rad_insw' )
@@ -9989,6 +9993,6 @@
                  IF ( .NOT.  ALLOCATED(surfinsw_av) )  THEN
                      ALLOCATE( surfinsw_av(nsurfl) )
-                     surfinsw_av = 0.0_wp
                  ENDIF
+                 surfinsw_av = 0.0_wp
 
              CASE ( 'rtm_rad_inlw' )
@@ -9996,6 +10000,6 @@
                  IF ( .NOT.  ALLOCATED(surfinlw_av) )  THEN
                      ALLOCATE( surfinlw_av(nsurfl) )
-                     surfinlw_av = 0.0_wp
                  ENDIF
+                 surfinlw_av = 0.0_wp
 
              CASE ( 'rtm_rad_inswdir' )
@@ -10003,6 +10007,6 @@
                  IF ( .NOT.  ALLOCATED(surfinswdir_av) )  THEN
                      ALLOCATE( surfinswdir_av(nsurfl) )
-                     surfinswdir_av = 0.0_wp
                  ENDIF
+                 surfinswdir_av = 0.0_wp
 
              CASE ( 'rtm_rad_inswdif' )
@@ -10010,6 +10014,6 @@
                  IF ( .NOT.  ALLOCATED(surfinswdif_av) )  THEN
                      ALLOCATE( surfinswdif_av(nsurfl) )
-                     surfinswdif_av = 0.0_wp
                  ENDIF
+                 surfinswdif_av = 0.0_wp
 
              CASE ( 'rtm_rad_inswref' )
@@ -10017,6 +10021,6 @@
                  IF ( .NOT.  ALLOCATED(surfinswref_av) )  THEN
                      ALLOCATE( surfinswref_av(nsurfl) )
-                     surfinswref_av = 0.0_wp
                  ENDIF
+                 surfinswref_av = 0.0_wp
 
              CASE ( 'rtm_rad_inlwdif' )
@@ -10024,6 +10028,6 @@
                 IF ( .NOT.  ALLOCATED(surfinlwdif_av) )  THEN
                      ALLOCATE( surfinlwdif_av(nsurfl) )
-                     surfinlwdif_av = 0.0_wp
                  ENDIF
+                 surfinlwdif_av = 0.0_wp
 
              CASE ( 'rtm_rad_inlwref' )
@@ -10031,6 +10035,6 @@
                  IF ( .NOT.  ALLOCATED(surfinlwref_av) )  THEN
                      ALLOCATE( surfinlwref_av(nsurfl) )
-                     surfinlwref_av = 0.0_wp
                  ENDIF
+                 surfinlwref_av = 0.0_wp
 
              CASE ( 'rtm_rad_outsw' )
@@ -10038,6 +10042,6 @@
                  IF ( .NOT.  ALLOCATED(surfoutsw_av) )  THEN
                      ALLOCATE( surfoutsw_av(nsurfl) )
-                     surfoutsw_av = 0.0_wp
                  ENDIF
+                 surfoutsw_av = 0.0_wp
 
              CASE ( 'rtm_rad_outlw' )
@@ -10051,6 +10055,6 @@
                  IF ( .NOT.  ALLOCATED(surfins_av) )  THEN
                      ALLOCATE( surfins_av(nsurfl) )
-                     surfins_av = 0.0_wp
                  ENDIF
+                 surfins_av = 0.0_wp
 
              CASE ( 'rtm_rad_reslw' )
@@ -10058,6 +10062,6 @@
                  IF ( .NOT.  ALLOCATED(surfinl_av) )  THEN
                      ALLOCATE( surfinl_av(nsurfl) )
-                     surfinl_av = 0.0_wp
                  ENDIF
+                 surfinl_av = 0.0_wp
 
              CASE ( 'rtm_rad_pc_inlw' )
@@ -10072,6 +10076,6 @@
                  IF ( .NOT.  ALLOCATED(pcbinsw_av) )  THEN
                      ALLOCATE( pcbinsw_av(1:npcbl) )
-                     pcbinsw_av = 0.0_wp
                  ENDIF
+                 pcbinsw_av = 0.0_wp
 
              CASE ( 'rtm_rad_pc_inswdir' )
@@ -10079,6 +10083,6 @@
                  IF ( .NOT.  ALLOCATED(pcbinswdir_av) )  THEN
                      ALLOCATE( pcbinswdir_av(1:npcbl) )
-                     pcbinswdir_av = 0.0_wp
                  ENDIF
+                 pcbinswdir_av = 0.0_wp
 
              CASE ( 'rtm_rad_pc_inswdif' )
@@ -10086,6 +10090,6 @@
                  IF ( .NOT.  ALLOCATED(pcbinswdif_av) )  THEN
                      ALLOCATE( pcbinswdif_av(1:npcbl) )
-                     pcbinswdif_av = 0.0_wp
                  ENDIF
+                 pcbinswdif_av = 0.0_wp
 
              CASE ( 'rtm_rad_pc_inswref' )
@@ -10093,6 +10097,6 @@
                  IF ( .NOT.  ALLOCATED(pcbinswref_av) )  THEN
                      ALLOCATE( pcbinswref_av(1:npcbl) )
-                     pcbinswref_av = 0.0_wp
                  ENDIF
+                 pcbinswref_av = 0.0_wp
 
              CASE ( 'rtm_mrt_sw' )
@@ -10334,5 +10338,7 @@
               DO isurf = dirstart(ids), dirend(ids)
                  IF ( surfl(id,isurf) == idsint_u  .OR.  surfl(id,isurf) == idsint_l )  THEN
-                    surfradnet_av(isurf) = surfinsw(isurf) - surfoutsw(isurf) +  surfinlw(isurf) - surfoutlw(isurf)
+                    surfradnet_av(isurf) = surfradnet_av(isurf) +               &
+                                           surfinsw(isurf) - surfoutsw(isurf) + &
+                                           surfinlw(isurf) - surfoutlw(isurf)
                  ENDIF
               ENDDO
@@ -10629,5 +10635,5 @@
               DO isurf = dirstart(ids), dirend(ids)
                   IF ( surfl(id,isurf) == idsint_u  .OR.  surfl(id,isurf) == idsint_l )  THEN
-                      surfradnet_av(isurf) = surfinsw_av(isurf) / REAL( average_count_3d, kind=wp )
+                      surfradnet_av(isurf) = surfradnet_av(isurf) / REAL( average_count_3d, kind=wp )
                   ENDIF
               ENDDO
