Index: palm/trunk/SOURCE/cpulog_mod.f90
===================================================================
--- palm/trunk/SOURCE/cpulog_mod.f90	(revision 4537)
+++ palm/trunk/SOURCE/cpulog_mod.f90	(revision 4539)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! code re-structured,
+! cpu time per grid point and timestep does not included initialization and spinup any more
+! 
+! 4536 2020-05-17 17:24:13Z raasch
 ! restart I/O transfer speed added
 ! 
@@ -287,5 +291,5 @@
 
 !
-!--    Compute cpu-times in seconds
+!--    Compute CPU-times in seconds for the global non-overlapping measurements.
        log_point%mtime  = log_point%mtime  / norm
        log_point%sum    = log_point%sum    / norm
@@ -297,5 +301,5 @@
 
 !
-!--    Collect cpu-times from all PEs and calculate statistics
+!--    Collect CPU-times from all PEs and calculate statistics
        IF ( myid == 0 )  THEN
 !
@@ -348,5 +352,67 @@
 
 !
-!--    Write cpu-times
+!--    The same procedure again for the special measurements.
+!
+!--    Compute cpu-times in seconds
+       log_point_s%mtime  = log_point_s%mtime  / norm
+       log_point_s%sum    = log_point_s%sum    / norm
+       log_point_s%vector = log_point_s%vector / norm
+       WHERE ( log_point_s%counts /= 0 )
+          log_point_s%mean = log_point_s%sum / log_point_s%counts
+       END WHERE
+
+!
+!--    Collect CPU-times from all PEs and calculate statistics
+#if defined( __parallel )
+!
+!--    Set barrier in order to avoid that PE0 receives log_point_s-data
+!--    while still busy with receiving log_point-data (see above)
+       CALL MPI_BARRIER( comm2d, ierr )
+#endif
+       IF ( myid == 0 )  THEN
+!
+!--       Initialize temporary arrays needed for statistics
+          pe_min = log_point_s%sum
+          pe_max = log_point_s%sum    ! need to be set in case of 1 PE
+          pe_rms = 0.0_dp
+
+#if defined( __parallel )
+!
+!--       Receive data from all PEs
+          DO  i = 1, numprocs-1
+             CALL MPI_RECV( pe_tmp(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, MPI_ANY_SOURCE,    &
+                            MPI_ANY_TAG, comm2d, status, ierr )
+             sender = status(MPI_SOURCE)
+             pe_log_points(:,sender) = pe_tmp
+          ENDDO
+          pe_log_points(:,0) = log_point_s%sum   ! Results from PE0
+!
+!--       Calculate mean of all PEs, store it on log_point_s%sum
+!--       and find minimum and maximum
+          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)
+                pe_min(iii) = MIN( pe_min(iii), pe_log_points(iii,i) )
+                pe_max(iii) = MAX( pe_max(iii), pe_log_points(iii,i) )
+             ENDDO
+             log_point_s(iii)%sum = log_point_s(iii)%sum / numprocs
+!
+!--          Calculate rms
+             DO  i = 0, numprocs-1
+                pe_rms(iii) = pe_rms(iii) + ( pe_log_points(iii,i) - log_point_s(iii)%sum )**2
+             ENDDO
+             pe_rms(iii) = SQRT( pe_rms(iii) / numprocs )
+          ENDDO
+       ELSE
+!
+!--       Send data to PE0 (pe_max is used as temporary storage to send
+!--       the data in order to avoid sending the data type log)
+          pe_max = log_point_s%sum
+          CALL MPI_SEND( pe_max(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, 0, 0, comm2d, ierr )
+#endif
+
+       ENDIF
+!
+!--    Write CPU-times for the non-overlapping measurements.
        IF ( myid == 0 )  THEN
 !
@@ -360,8 +426,8 @@
 
 !
-!--       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.
+!--       Time for initialization (2) and spinup (41) are not included here!
           IF ( nr_timesteps_this_run /= 0 )  THEN
-             average_cputime = log_point(1)%sum / REAL( ngp_3d(0), KIND=dp ) /                     &
+             average_cputime = log_point_s(10)%sum / REAL( ngp_3d(0), KIND=dp ) /                  &
                                REAL( nr_timesteps_this_run, KIND=dp ) * 1E6_dp     ! in micro-sec
           ELSE
@@ -399,70 +465,6 @@
        ENDIF
 
-
-!
-!--    The same procedure again for the individual measurements.
-!
-!--    Compute cpu-times in seconds
-       log_point_s%mtime  = log_point_s%mtime  / norm
-       log_point_s%sum    = log_point_s%sum    / norm
-       log_point_s%vector = log_point_s%vector / norm
-       WHERE ( log_point_s%counts /= 0 )
-          log_point_s%mean = log_point_s%sum / log_point_s%counts
-       END WHERE
-
-!
-!--    Collect cpu-times from all PEs and calculate statistics
-#if defined( __parallel )
-!
-!--    Set barrier in order to avoid that PE0 receives log_point_s-data
-!--    while still busy with receiving log_point-data (see above)
-       CALL MPI_BARRIER( comm2d, ierr )
-#endif
-       IF ( myid == 0 )  THEN
-!
-!--       Initialize temporary arrays needed for statistics
-          pe_min = log_point_s%sum
-          pe_max = log_point_s%sum    ! need to be set in case of 1 PE
-          pe_rms = 0.0_dp
-
-#if defined( __parallel )
-!
-!--       Receive data from all PEs
-          DO  i = 1, numprocs-1
-             CALL MPI_RECV( pe_tmp(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, MPI_ANY_SOURCE,    &
-                            MPI_ANY_TAG, comm2d, status, ierr )
-             sender = status(MPI_SOURCE)
-             pe_log_points(:,sender) = pe_tmp
-          ENDDO
-          pe_log_points(:,0) = log_point_s%sum   ! Results from PE0
-!
-!--       Calculate mean of all PEs, store it on log_point_s%sum
-!--       and find minimum and maximum
-          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)
-                pe_min(iii) = MIN( pe_min(iii), pe_log_points(iii,i) )
-                pe_max(iii) = MAX( pe_max(iii), pe_log_points(iii,i) )
-             ENDDO
-             log_point_s(iii)%sum = log_point_s(iii)%sum / numprocs
-!
-!--          Calculate rms
-             DO  i = 0, numprocs-1
-                pe_rms(iii) = pe_rms(iii) + ( pe_log_points(iii,i) - log_point_s(iii)%sum )**2
-             ENDDO
-             pe_rms(iii) = SQRT( pe_rms(iii) / numprocs )
-          ENDDO
-       ELSE
-!
-!--       Send data to PE0 (pe_max is used as temporary storage to send
-!--       the data in order to avoid sending the data type log)
-          pe_max = log_point_s%sum
-          CALL MPI_SEND( pe_max(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, 0, 0, comm2d, ierr )
-#endif
-
-       ENDIF
-
-!
-!--    Write cpu-times
+!
+!--    Write CPU-times for special measurements.
        IF ( myid == 0 )  THEN
 !
Index: palm/trunk/SOURCE/palm.f90
===================================================================
--- palm/trunk/SOURCE/palm.f90	(revision 4537)
+++ palm/trunk/SOURCE/palm.f90	(revision 4539)
@@ -21,8 +21,11 @@
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! log point name changed
+! 
+! 4535 2020-05-15 12:07:23Z raasch
 ! bugfix for restart data format query
 ! 
@@ -407,5 +410,5 @@
     IF ( write_binary )  THEN
 
-       CALL cpu_log( log_point(22), 'wrd_local', 'start' )
+       CALL cpu_log( log_point(22), 'write-restart-data', 'start' )
 
        CALL location_message( 'writing restart data', 'start' )
@@ -453,5 +456,5 @@
        CALL location_message( 'writing restart data', 'finished' )
 
-       CALL cpu_log( log_point(22), 'wrd_local', 'stop' )
+       CALL cpu_log( log_point(22), 'write-restart-data', 'stop' )
        
     ENDIF
Index: palm/trunk/SOURCE/read_restart_data_mod.f90
===================================================================
--- palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 4537)
+++ palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 4539)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! location message added
+! 
+! 4536 2020-05-17 17:24:13Z raasch
 ! binary version incremented
 ! 
@@ -1438,5 +1441,7 @@
 !
 !-- Read data from previous model run.
-    CALL cpu_log( log_point_s(14), 'rrd_local', 'start' )
+    CALL cpu_log( log_point_s(14), 'read-restart-data-local', 'start' )
+
+    CALL location_message( 'reading local restart data', 'start' )
 
     IF ( TRIM( restart_data_format_input ) == 'fortran_binary' )  THEN
@@ -2482,7 +2487,8 @@
     ENDIF
 
+    CALL location_message( 'reading local restart data', 'finished' )
 !
 !-- End of time measuring for reading binary data
-    CALL cpu_log( log_point_s(14), 'rrd_local', 'stop' )
+    CALL cpu_log( log_point_s(14), 'read-restart-data-local', 'stop' )
 
  END SUBROUTINE rrd_local
Index: palm/trunk/SOURCE/restart_data_mpi_io_mod.f90
===================================================================
--- palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4537)
+++ palm/trunk/SOURCE/restart_data_mpi_io_mod.f90	(revision 4539)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! checks added, if index limits in header are exceeded
+! bugfix in rrd_mpi_io_int_2d
+! 
+! 4536 2020-05-17 17:24:13Z raasch
 ! messages and debug output converted to PALM routines
 ! 
@@ -178,6 +182,6 @@
 
     INTEGER(KIND=rd_offset_kind)                ::  header_char_index
-    INTEGER, PARAMETER                          ::  max_nr_text=128
-    CHARACTER(LEN=128), DIMENSION(max_nr_text)  ::  text_lines
+    INTEGER, PARAMETER                          ::  max_nr_char=128
+    CHARACTER(LEN=128), DIMENSION(max_nr_char)  ::  text_lines
 
     INTEGER(KIND=rd_offset_kind)                ::  header_real_index
@@ -186,5 +190,5 @@
     REAL(KIND=wp), DIMENSION(max_nr_real)       ::  real_values
 
-    INTEGER(KIND=rd_offset_kind)                ::  header_arr_index
+    INTEGER(KIND=rd_offset_kind)                ::  header_array_index
     INTEGER, PARAMETER                          ::  max_nr_arrays=600
     CHARACTER(LEN=32), DIMENSION(max_nr_arrays) ::  array_names
@@ -456,6 +460,6 @@
     header_int_index   = 1
     header_char_index  = 1
-    header_real_index   = 1
-    header_arr_index   = 1
+    header_real_index  = 1
+    header_array_index = 1
 
     int_names    = ' '
@@ -852,5 +856,5 @@
              CALL MPI_FILE_SET_VIEW( fh, array_position, MPI_INTEGER, ft_2di_nb, 'native',         &
                                      MPI_INFO_NULL, ierr )
-             CALL MPI_FILE_READ_ALL( fh, array_2d, SIZE( array_2d ), MPI_INTEGER, status, ierr )
+             CALL MPI_FILE_READ_ALL( fh, array_2di, SIZE( array_2di ), MPI_INTEGER, status, ierr )
           ENDIF
           CALL sm_io%sm_node_barrier()
@@ -1101,4 +1105,8 @@
 
 
+    IF ( header_int_index == max_nr_int )  THEN
+       STOP '+++ maximum number of INTEGER entries in restart file header exceeded'
+    ENDIF
+
     int_names(header_int_index)  = name
     int_values(header_int_index) = value
@@ -1118,4 +1126,8 @@
 
 
+    IF ( header_real_index == max_nr_real )  THEN
+       STOP '+++ maximum number of REAL entries in restart file header exceeded'
+    ENDIF
+
     real_names(header_real_index)  = name
     real_values(header_real_index) = value
@@ -1146,7 +1158,11 @@
 
 
-    array_names(header_arr_index)  = name
-    array_offset(header_arr_index) = array_position
-    header_arr_index = header_arr_index + 1
+    IF ( header_array_index == max_nr_arrays )  THEN
+       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+    ENDIF
+
+    array_names(header_array_index)  = name
+    array_offset(header_array_index) = array_position
+    header_array_index = header_array_index + 1
 
     IF ( include_total_domain_boundaries )  THEN
@@ -1207,7 +1223,11 @@
 
 
-    array_names(header_arr_index)  = name
-    array_offset(header_arr_index) = array_position
-    header_arr_index = header_arr_index + 1
+    IF ( header_array_index == max_nr_arrays )  THEN
+       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+    ENDIF
+
+    array_names(header_array_index)  = name
+    array_offset(header_array_index) = array_position
+    header_array_index = header_array_index + 1
 
     IF ( ( nxr-nxl + 1 + 2 * nbgp ) == SIZE( data, 2 ) )  THEN
@@ -1278,7 +1298,11 @@
 
 
-    array_names(header_arr_index)  = name
-    array_offset(header_arr_index) = array_position
-    header_arr_index = header_arr_index + 1
+    IF ( header_array_index == max_nr_arrays )  THEN
+       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+    ENDIF
+
+    array_names(header_array_index)  = name
+    array_offset(header_array_index) = array_position
+    header_array_index = header_array_index + 1
 
     IF ( include_total_domain_boundaries )  THEN
@@ -1347,7 +1371,11 @@
 
 
-    array_names(header_arr_index)  = name
-    array_offset(header_arr_index) = array_position
-    header_arr_index = header_arr_index + 1
+    IF ( header_array_index == max_nr_arrays )  THEN
+       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+    ENDIF
+
+    array_names(header_array_index)  = name
+    array_offset(header_array_index) = array_position
+    header_array_index = header_array_index + 1
 
 #if defined( __parallel )
@@ -1411,4 +1439,8 @@
 
 
+    IF ( header_char_index == max_nr_char )  THEN
+       STOP '+++ maximum number of CHARACTER entries in restart file header exceeded'
+    ENDIF
+
     lo_line      = name
     lo_line(33:) = text
@@ -1687,7 +1719,11 @@
     offset = 0
 
-    array_names(header_arr_index)  = name
-    array_offset(header_arr_index) = array_position
-    header_arr_index = header_arr_index + 1
+    IF ( header_array_index == max_nr_arrays )  THEN
+       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+    ENDIF
+
+    array_names(header_array_index)  = name
+    array_offset(header_array_index) = array_position
+    header_array_index = header_array_index + 1
 
 !
@@ -1822,8 +1858,12 @@
 #endif
 
+    IF ( header_array_index == max_nr_arrays )  THEN
+       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+    ENDIF
+
     offset = 0
-    array_names(header_arr_index)  = name
-    array_offset(header_arr_index) = array_position
-    header_arr_index = header_arr_index + 1
+    array_names(header_array_index)  = name
+    array_offset(header_array_index) = array_position
+    header_array_index = header_array_index + 1
 
 !
@@ -2052,10 +2092,17 @@
     ENDIF
 !
-!-- In case of 2d-data, name is writen only once
+!-- In case of 2d-data, name is written only once
     IF ( lo_first_index == 1 )  THEN
-       array_names(header_arr_index)  = name
-       array_offset(header_arr_index) = array_position
-       header_arr_index = header_arr_index + 1
-    ENDIF
+
+       IF ( header_array_index == max_nr_arrays )  THEN
+          STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
+       ENDIF
+
+       array_names(header_array_index)  = name
+       array_offset(header_array_index) = array_position
+       header_array_index = header_array_index + 1
+
+    ENDIF
+
 #if defined( __parallel )
     IF ( sm_io%is_sm_active() )  THEN
@@ -2155,5 +2202,5 @@
        tgh%nr_char   = header_char_index - 1
        tgh%nr_real   = header_real_index - 1
-       tgh%nr_arrays = header_arr_index - 1
+       tgh%nr_arrays = header_array_index - 1
        tgh%total_nx  = lb%nx + 1
        tgh%total_ny  = lb%ny + 1
