Index: palm/trunk/SOURCE/cpulog_mod.f90
===================================================================
--- palm/trunk/SOURCE/cpulog_mod.f90	(revision 2265)
+++ palm/trunk/SOURCE/cpulog_mod.f90	(revision 2266)
@@ -25,4 +25,9 @@
 ! -----------------
 ! $Id$
+! bugfix: cpu-time per grid point is now calculated using ngp_3d in order to
+! avoid integer overflow,
+! some re-formatting
+! 
+! 2119 2017-01-17 16:51:50Z raasch
 !
 ! 2118 2017-01-17 16:38:49Z raasch
@@ -126,5 +131,5 @@
                
     USE indices,                                                               &
-        ONLY: nx, ny, nz
+        ONLY: ngp_3d, nx, ny, nz
         
     USE kinds
@@ -256,6 +261,6 @@
                first )  THEN
              WRITE( message_string, * ) 'negative time interval occured',      &
-                         ' &PE',myid,' L=STOP "',TRIM(log_event%place),'" new=', &
-                         mtime,' last=',log_event%mtime,' isum=',log_event%isum
+                       ' &PE',myid,' L=STOP "',TRIM(log_event%place),'" new=', &
+                       mtime,' last=',log_event%mtime,' isum=',log_event%isum
              CALL message( 'cpu_log', 'PA0177', 0, 1, -1, 6, 0 )
              first = .FALSE.
@@ -266,6 +271,6 @@
           IF ( log_event%sum < 0.0  .AND.  first )  THEN
              WRITE( message_string, * ) 'negative time interval occured',      &
-                         ' &PE',myid,' L=STOP "',TRIM(log_event%place),'" sum=', &
-                                         log_event%sum,' mtime=',log_event%mtime
+                       ' &PE',myid,' L=STOP "',TRIM(log_event%place),'" sum=', &
+                       log_event%sum,' mtime=',log_event%mtime
              CALL message( 'cpu_log', 'PA0178', 0, 1, -1, 6, 0 )
              first = .FALSE.
@@ -276,5 +281,6 @@
           log_event%ivect    = 0.0_wp
        ELSE
-          message_string = 'unknown modus of time measurement: ' // TRIM( modus )
+          message_string = 'unknown modus of time measurement: ' //            &
+                           TRIM( modus )
           CALL message( 'cpu_log', 'PA0179', 0, 1, -1, 6, 0 )
        ENDIF
@@ -368,6 +374,6 @@
           ALLOCATE( pe_max( SIZE( log_point ) ) )
           pe_max = log_point%sum
-          CALL MPI_SEND( pe_max(1), SIZE( log_point ), MPI_REAL, 0, myid, comm2d, &
-                         ierr )
+          CALL MPI_SEND( pe_max(1), SIZE( log_point ), MPI_REAL, 0, myid,      &
+                         comm2d, ierr )
 #endif
 
@@ -387,8 +393,10 @@
 
 !
-!--       Get total time in order to calculate CPU-time per gridpoint and timestep
+!--       Get total time in order to calculate CPU-time per gridpoint and
+!--       timestep
           IF ( nr_timesteps_this_run /= 0 )  THEN
-             average_cputime = log_point(1)%sum / REAL( (nx+1) * (ny+1) * nz, KIND=wp ) / &
-                               REAL( nr_timesteps_this_run, KIND=wp ) * 1E6_wp  ! in micro-sec
+             average_cputime = log_point(1)%sum / REAL( ngp_3d(0), KIND=wp ) / &
+                               REAL( nr_timesteps_this_run, KIND=wp ) * 1E6_wp
+                               ! in micro-sec
           ELSE
              average_cputime = -1.0_wp
@@ -399,15 +407,15 @@
           CALL check_open( 18 )
 #if defined( __parallel )
-          WRITE ( 18, 100 )  TRIM( run_description_header ),                          &
-                             numprocs * threads_per_task, pdims(1), pdims(2),         &
-                             threads_per_task, nx+1, ny+1, nz, nr_timesteps_this_run, &
-                             average_cputime
+          WRITE ( 18, 100 )  TRIM( run_description_header ),                   &
+                             numprocs * threads_per_task, pdims(1), pdims(2),  &
+                             threads_per_task, nx+1, ny+1, nz,                 &
+                             nr_timesteps_this_run, average_cputime
 
           WRITE ( 18, 110 )
 #else
-          WRITE ( 18, 100 )  TRIM( run_description_header ),                          &
-                             numprocs * threads_per_task, 1, 1,                       &
-                             threads_per_task, nx+1, ny+1, nz, nr_timesteps_this_run, &
-                             average_cputime
+          WRITE ( 18, 100 )  TRIM( run_description_header ),                   &
+                             numprocs * threads_per_task, 1, 1,                &
+                             threads_per_task, nx+1, ny+1, nz,                 &
+                             nr_timesteps_this_run, average_cputime
 
           WRITE ( 18, 110 )
@@ -470,5 +478,6 @@
           DO  iii = 1, SIZE( log_point )
              DO  i = 1, numprocs-1
-                log_point_s(iii)%sum = log_point_s(iii)%sum + pe_log_points(iii,i)
+                log_point_s(iii)%sum = log_point_s(iii)%sum +                  &
+                                       pe_log_points(iii,i)
                 pe_min(iii) = MIN( pe_min(iii), pe_log_points(iii,i) )
                 pe_max(iii) = MAX( pe_max(iii), pe_log_points(iii,i) )
@@ -479,5 +488,5 @@
              DO  i = 0, numprocs-1
                 pe_rms(iii) = pe_rms(iii) + (                                  &
-                                    pe_log_points(iii,i) - log_point_s(iii)%sum &
+                                   pe_log_points(iii,i) - log_point_s(iii)%sum &
                                             )**2
              ENDDO
