Changeset 4539


Ignore:
Timestamp:
May 18, 2020 2:05:17 PM (5 years ago)
Author:
raasch
Message:

checks added, if index limits in header are exceeded (restart_data_mpi_io_mod), bugfix in rrd_mpi_io_int_2d, location and log_point names added/modified, cpu time per grid point and timestep does not included initialization and spinup any more (cpulog_mod)

Location:
palm/trunk/SOURCE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/cpulog_mod.f90

    r4536 r4539  
    2525! -----------------
    2626! $Id$
     27! code re-structured,
     28! cpu time per grid point and timestep does not included initialization and spinup any more
     29!
     30! 4536 2020-05-17 17:24:13Z raasch
    2731! restart I/O transfer speed added
    2832!
     
    287291
    288292!
    289 !--    Compute cpu-times in seconds
     293!--    Compute CPU-times in seconds for the global non-overlapping measurements.
    290294       log_point%mtime  = log_point%mtime  / norm
    291295       log_point%sum    = log_point%sum    / norm
     
    297301
    298302!
    299 !--    Collect cpu-times from all PEs and calculate statistics
     303!--    Collect CPU-times from all PEs and calculate statistics
    300304       IF ( myid == 0 )  THEN
    301305!
     
    348352
    349353!
    350 !--    Write cpu-times
     354!--    The same procedure again for the special measurements.
     355!
     356!--    Compute cpu-times in seconds
     357       log_point_s%mtime  = log_point_s%mtime  / norm
     358       log_point_s%sum    = log_point_s%sum    / norm
     359       log_point_s%vector = log_point_s%vector / norm
     360       WHERE ( log_point_s%counts /= 0 )
     361          log_point_s%mean = log_point_s%sum / log_point_s%counts
     362       END WHERE
     363
     364!
     365!--    Collect CPU-times from all PEs and calculate statistics
     366#if defined( __parallel )
     367!
     368!--    Set barrier in order to avoid that PE0 receives log_point_s-data
     369!--    while still busy with receiving log_point-data (see above)
     370       CALL MPI_BARRIER( comm2d, ierr )
     371#endif
     372       IF ( myid == 0 )  THEN
     373!
     374!--       Initialize temporary arrays needed for statistics
     375          pe_min = log_point_s%sum
     376          pe_max = log_point_s%sum    ! need to be set in case of 1 PE
     377          pe_rms = 0.0_dp
     378
     379#if defined( __parallel )
     380!
     381!--       Receive data from all PEs
     382          DO  i = 1, numprocs-1
     383             CALL MPI_RECV( pe_tmp(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, MPI_ANY_SOURCE,    &
     384                            MPI_ANY_TAG, comm2d, status, ierr )
     385             sender = status(MPI_SOURCE)
     386             pe_log_points(:,sender) = pe_tmp
     387          ENDDO
     388          pe_log_points(:,0) = log_point_s%sum   ! Results from PE0
     389!
     390!--       Calculate mean of all PEs, store it on log_point_s%sum
     391!--       and find minimum and maximum
     392          DO  iii = 1, SIZE( log_point )
     393             DO  i = 1, numprocs-1
     394                log_point_s(iii)%sum = log_point_s(iii)%sum + pe_log_points(iii,i)
     395                pe_min(iii) = MIN( pe_min(iii), pe_log_points(iii,i) )
     396                pe_max(iii) = MAX( pe_max(iii), pe_log_points(iii,i) )
     397             ENDDO
     398             log_point_s(iii)%sum = log_point_s(iii)%sum / numprocs
     399!
     400!--          Calculate rms
     401             DO  i = 0, numprocs-1
     402                pe_rms(iii) = pe_rms(iii) + ( pe_log_points(iii,i) - log_point_s(iii)%sum )**2
     403             ENDDO
     404             pe_rms(iii) = SQRT( pe_rms(iii) / numprocs )
     405          ENDDO
     406       ELSE
     407!
     408!--       Send data to PE0 (pe_max is used as temporary storage to send
     409!--       the data in order to avoid sending the data type log)
     410          pe_max = log_point_s%sum
     411          CALL MPI_SEND( pe_max(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, 0, 0, comm2d, ierr )
     412#endif
     413
     414       ENDIF
     415!
     416!--    Write CPU-times for the non-overlapping measurements.
    351417       IF ( myid == 0 )  THEN
    352418!
     
    360426
    361427!
    362 !--       Get total time in order to calculate CPU-time per gridpoint and
    363 !--       timestep
     428!--       Get total time in order to calculate CPU-time per gridpoint and timestep.
     429!--       Time for initialization (2) and spinup (41) are not included here!
    364430          IF ( nr_timesteps_this_run /= 0 )  THEN
    365              average_cputime = log_point(1)%sum / REAL( ngp_3d(0), KIND=dp ) /                     &
     431             average_cputime = log_point_s(10)%sum / REAL( ngp_3d(0), KIND=dp ) /                  &
    366432                               REAL( nr_timesteps_this_run, KIND=dp ) * 1E6_dp     ! in micro-sec
    367433          ELSE
     
    399465       ENDIF
    400466
    401 
    402 !
    403 !--    The same procedure again for the individual measurements.
    404 !
    405 !--    Compute cpu-times in seconds
    406        log_point_s%mtime  = log_point_s%mtime  / norm
    407        log_point_s%sum    = log_point_s%sum    / norm
    408        log_point_s%vector = log_point_s%vector / norm
    409        WHERE ( log_point_s%counts /= 0 )
    410           log_point_s%mean = log_point_s%sum / log_point_s%counts
    411        END WHERE
    412 
    413 !
    414 !--    Collect cpu-times from all PEs and calculate statistics
    415 #if defined( __parallel )
    416 !
    417 !--    Set barrier in order to avoid that PE0 receives log_point_s-data
    418 !--    while still busy with receiving log_point-data (see above)
    419        CALL MPI_BARRIER( comm2d, ierr )
    420 #endif
    421        IF ( myid == 0 )  THEN
    422 !
    423 !--       Initialize temporary arrays needed for statistics
    424           pe_min = log_point_s%sum
    425           pe_max = log_point_s%sum    ! need to be set in case of 1 PE
    426           pe_rms = 0.0_dp
    427 
    428 #if defined( __parallel )
    429 !
    430 !--       Receive data from all PEs
    431           DO  i = 1, numprocs-1
    432              CALL MPI_RECV( pe_tmp(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, MPI_ANY_SOURCE,    &
    433                             MPI_ANY_TAG, comm2d, status, ierr )
    434              sender = status(MPI_SOURCE)
    435              pe_log_points(:,sender) = pe_tmp
    436           ENDDO
    437           pe_log_points(:,0) = log_point_s%sum   ! Results from PE0
    438 !
    439 !--       Calculate mean of all PEs, store it on log_point_s%sum
    440 !--       and find minimum and maximum
    441           DO  iii = 1, SIZE( log_point )
    442              DO  i = 1, numprocs-1
    443                 log_point_s(iii)%sum = log_point_s(iii)%sum + pe_log_points(iii,i)
    444                 pe_min(iii) = MIN( pe_min(iii), pe_log_points(iii,i) )
    445                 pe_max(iii) = MAX( pe_max(iii), pe_log_points(iii,i) )
    446              ENDDO
    447              log_point_s(iii)%sum = log_point_s(iii)%sum / numprocs
    448 !
    449 !--          Calculate rms
    450              DO  i = 0, numprocs-1
    451                 pe_rms(iii) = pe_rms(iii) + ( pe_log_points(iii,i) - log_point_s(iii)%sum )**2
    452              ENDDO
    453              pe_rms(iii) = SQRT( pe_rms(iii) / numprocs )
    454           ENDDO
    455        ELSE
    456 !
    457 !--       Send data to PE0 (pe_max is used as temporary storage to send
    458 !--       the data in order to avoid sending the data type log)
    459           pe_max = log_point_s%sum
    460           CALL MPI_SEND( pe_max(1), SIZE( log_point ), MPI_DOUBLE_PRECISION, 0, 0, comm2d, ierr )
    461 #endif
    462 
    463        ENDIF
    464 
    465 !
    466 !--    Write cpu-times
     467!
     468!--    Write CPU-times for special measurements.
    467469       IF ( myid == 0 )  THEN
    468470!
  • palm/trunk/SOURCE/palm.f90

    r4535 r4539  
    2121! -----------------
    2222!
    23 ! 
     23!
    2424! Former revisions:
    2525! -----------------
    2626! $Id$
     27! log point name changed
     28!
     29! 4535 2020-05-15 12:07:23Z raasch
    2730! bugfix for restart data format query
    2831!
     
    407410    IF ( write_binary )  THEN
    408411
    409        CALL cpu_log( log_point(22), 'wrd_local', 'start' )
     412       CALL cpu_log( log_point(22), 'write-restart-data', 'start' )
    410413
    411414       CALL location_message( 'writing restart data', 'start' )
     
    453456       CALL location_message( 'writing restart data', 'finished' )
    454457
    455        CALL cpu_log( log_point(22), 'wrd_local', 'stop' )
     458       CALL cpu_log( log_point(22), 'write-restart-data', 'stop' )
    456459       
    457460    ENDIF
  • palm/trunk/SOURCE/read_restart_data_mod.f90

    r4536 r4539  
    2525! -----------------
    2626! $Id$
     27! location message added
     28!
     29! 4536 2020-05-17 17:24:13Z raasch
    2730! binary version incremented
    2831!
     
    14381441!
    14391442!-- Read data from previous model run.
    1440     CALL cpu_log( log_point_s(14), 'rrd_local', 'start' )
     1443    CALL cpu_log( log_point_s(14), 'read-restart-data-local', 'start' )
     1444
     1445    CALL location_message( 'reading local restart data', 'start' )
    14411446
    14421447    IF ( TRIM( restart_data_format_input ) == 'fortran_binary' )  THEN
     
    24822487    ENDIF
    24832488
     2489    CALL location_message( 'reading local restart data', 'finished' )
    24842490!
    24852491!-- End of time measuring for reading binary data
    2486     CALL cpu_log( log_point_s(14), 'rrd_local', 'stop' )
     2492    CALL cpu_log( log_point_s(14), 'read-restart-data-local', 'stop' )
    24872493
    24882494 END SUBROUTINE rrd_local
  • palm/trunk/SOURCE/restart_data_mpi_io_mod.f90

    r4536 r4539  
    2424! -----------------
    2525! $Id$
     26! checks added, if index limits in header are exceeded
     27! bugfix in rrd_mpi_io_int_2d
     28!
     29! 4536 2020-05-17 17:24:13Z raasch
    2630! messages and debug output converted to PALM routines
    2731!
     
    178182
    179183    INTEGER(KIND=rd_offset_kind)                ::  header_char_index
    180     INTEGER, PARAMETER                          ::  max_nr_text=128
    181     CHARACTER(LEN=128), DIMENSION(max_nr_text)  ::  text_lines
     184    INTEGER, PARAMETER                          ::  max_nr_char=128
     185    CHARACTER(LEN=128), DIMENSION(max_nr_char)  ::  text_lines
    182186
    183187    INTEGER(KIND=rd_offset_kind)                ::  header_real_index
     
    186190    REAL(KIND=wp), DIMENSION(max_nr_real)       ::  real_values
    187191
    188     INTEGER(KIND=rd_offset_kind)                ::  header_arr_index
     192    INTEGER(KIND=rd_offset_kind)                ::  header_array_index
    189193    INTEGER, PARAMETER                          ::  max_nr_arrays=600
    190194    CHARACTER(LEN=32), DIMENSION(max_nr_arrays) ::  array_names
     
    456460    header_int_index   = 1
    457461    header_char_index  = 1
    458     header_real_index   = 1
    459     header_arr_index  = 1
     462    header_real_index  = 1
     463    header_array_index = 1
    460464
    461465    int_names    = ' '
     
    852856             CALL MPI_FILE_SET_VIEW( fh, array_position, MPI_INTEGER, ft_2di_nb, 'native',         &
    853857                                     MPI_INFO_NULL, ierr )
    854              CALL MPI_FILE_READ_ALL( fh, array_2d, SIZE( array_2d ), MPI_INTEGER, status, ierr )
     858             CALL MPI_FILE_READ_ALL( fh, array_2di, SIZE( array_2di ), MPI_INTEGER, status, ierr )
    855859          ENDIF
    856860          CALL sm_io%sm_node_barrier()
     
    11011105
    11021106
     1107    IF ( header_int_index == max_nr_int )  THEN
     1108       STOP '+++ maximum number of INTEGER entries in restart file header exceeded'
     1109    ENDIF
     1110
    11031111    int_names(header_int_index)  = name
    11041112    int_values(header_int_index) = value
     
    11181126
    11191127
     1128    IF ( header_real_index == max_nr_real )  THEN
     1129       STOP '+++ maximum number of REAL entries in restart file header exceeded'
     1130    ENDIF
     1131
    11201132    real_names(header_real_index)  = name
    11211133    real_values(header_real_index) = value
     
    11461158
    11471159
    1148     array_names(header_arr_index)  = name
    1149     array_offset(header_arr_index) = array_position
    1150     header_arr_index = header_arr_index + 1
     1160    IF ( header_array_index == max_nr_arrays )  THEN
     1161       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     1162    ENDIF
     1163
     1164    array_names(header_array_index)  = name
     1165    array_offset(header_array_index) = array_position
     1166    header_array_index = header_array_index + 1
    11511167
    11521168    IF ( include_total_domain_boundaries )  THEN
     
    12071223
    12081224
    1209     array_names(header_arr_index)  = name
    1210     array_offset(header_arr_index) = array_position
    1211     header_arr_index = header_arr_index + 1
     1225    IF ( header_array_index == max_nr_arrays )  THEN
     1226       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     1227    ENDIF
     1228
     1229    array_names(header_array_index)  = name
     1230    array_offset(header_array_index) = array_position
     1231    header_array_index = header_array_index + 1
    12121232
    12131233    IF ( ( nxr-nxl + 1 + 2 * nbgp ) == SIZE( data, 2 ) )  THEN
     
    12781298
    12791299
    1280     array_names(header_arr_index)  = name
    1281     array_offset(header_arr_index) = array_position
    1282     header_arr_index = header_arr_index + 1
     1300    IF ( header_array_index == max_nr_arrays )  THEN
     1301       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     1302    ENDIF
     1303
     1304    array_names(header_array_index)  = name
     1305    array_offset(header_array_index) = array_position
     1306    header_array_index = header_array_index + 1
    12831307
    12841308    IF ( include_total_domain_boundaries )  THEN
     
    13471371
    13481372
    1349     array_names(header_arr_index)  = name
    1350     array_offset(header_arr_index) = array_position
    1351     header_arr_index = header_arr_index + 1
     1373    IF ( header_array_index == max_nr_arrays )  THEN
     1374       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     1375    ENDIF
     1376
     1377    array_names(header_array_index)  = name
     1378    array_offset(header_array_index) = array_position
     1379    header_array_index = header_array_index + 1
    13521380
    13531381#if defined( __parallel )
     
    14111439
    14121440
     1441    IF ( header_char_index == max_nr_char )  THEN
     1442       STOP '+++ maximum number of CHARACTER entries in restart file header exceeded'
     1443    ENDIF
     1444
    14131445    lo_line      = name
    14141446    lo_line(33:) = text
     
    16871719    offset = 0
    16881720
    1689     array_names(header_arr_index)  = name
    1690     array_offset(header_arr_index) = array_position
    1691     header_arr_index = header_arr_index + 1
     1721    IF ( header_array_index == max_nr_arrays )  THEN
     1722       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     1723    ENDIF
     1724
     1725    array_names(header_array_index)  = name
     1726    array_offset(header_array_index) = array_position
     1727    header_array_index = header_array_index + 1
    16921728
    16931729!
     
    18221858#endif
    18231859
     1860    IF ( header_array_index == max_nr_arrays )  THEN
     1861       STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     1862    ENDIF
     1863
    18241864    offset = 0
    1825     array_names(header_arr_index)  = name
    1826     array_offset(header_arr_index) = array_position
    1827     header_arr_index = header_arr_index + 1
     1865    array_names(header_array_index)  = name
     1866    array_offset(header_array_index) = array_position
     1867    header_array_index = header_array_index + 1
    18281868
    18291869!
     
    20522092    ENDIF
    20532093!
    2054 !-- In case of 2d-data, name is writen only once
     2094!-- In case of 2d-data, name is written only once
    20552095    IF ( lo_first_index == 1 )  THEN
    2056        array_names(header_arr_index)  = name
    2057        array_offset(header_arr_index) = array_position
    2058        header_arr_index = header_arr_index + 1
    2059     ENDIF
     2096
     2097       IF ( header_array_index == max_nr_arrays )  THEN
     2098          STOP '+++ maximum number of 2d/3d-array entries in restart file header exceeded'
     2099       ENDIF
     2100
     2101       array_names(header_array_index)  = name
     2102       array_offset(header_array_index) = array_position
     2103       header_array_index = header_array_index + 1
     2104
     2105    ENDIF
     2106
    20602107#if defined( __parallel )
    20612108    IF ( sm_io%is_sm_active() )  THEN
     
    21552202       tgh%nr_char   = header_char_index - 1
    21562203       tgh%nr_real   = header_real_index - 1
    2157        tgh%nr_arrays = header_arr_index - 1
     2204       tgh%nr_arrays = header_array_index - 1
    21582205       tgh%total_nx  = lb%nx + 1
    21592206       tgh%total_ny  = lb%ny + 1
Note: See TracChangeset for help on using the changeset viewer.