A compact analysis can count how many measurements cross a threshold while also reporting the peak value.

Program

Play the program to choose the threshold and watch the summary change.

limit
threshold_summary.f90
Replay: real traced execution (multi-file project)
program threshold_summary_demo
    implicit none
    integer :: readings(5)
    integer :: limit
    integer :: over_count
    integer :: peak

    readings = [2, 5, 8, 11, 14]
    limit = 10
    over_count = count(readings > limit)
    peak = maxval(readings)
    print '(I0, 1X, I0)', over_count, peak
end program threshold_summary_demo
program threshold_summary_demo
    implicit none
    integer :: readings(5)
    integer :: limit
    integer :: over_count
    integer :: peak

    readings = [2, 5, 8, 11, 14]
    limit = 6
    over_count = count(readings > limit)
    peak = maxval(readings)
    print '(I0, 1X, I0)', over_count, peak
end program threshold_summary_demo
program threshold_summary_demo
    implicit none
    integer :: readings(5)
    integer :: limit
    integer :: over_count
    integer :: peak

    readings = [2, 5, 8, 11, 14]
    limit = 12
    over_count = count(readings > limit)
    peak = maxval(readings)
    print '(I0, 1X, I0)', over_count, peak
end program threshold_summary_demo
  1. readings ← [2, 5, 8, 11, 14]

    8readings = [2, 5, 8, 11, 14]9limit = 10
    values this step[2, 5, 8, 11, 14]readings
  2. limit ← 10

    8readings = [2, 5, 8, 11, 14]9limit = 1010over_count = count(readings > limit)
    values this step10limit
  3. over_count ← 2

    9limit = 1010over_count = count(readings > limit)11peak = maxval(readings)
    values this step2over_count[2, 5, 8, 11, 14]readings10limit
  4. peak ← 14

    10over_count = count(readings > limit)11peak = maxval(readings)12print '(I0, 1X, I0)', over_count, peak
    values this step14peak[2, 5, 8, 11, 14]readings
  5. print '(I0, 1X, I0)', over_count, peak

    11    peak = maxval(readings)12    print '(I0, 1X, I0)', over_count, peak13end program threshold_summary_demo
    output2 14
    values this step2over_count14peak
  1. readings ← [2, 5, 8, 11, 14]

    8readings = [2, 5, 8, 11, 14]9limit = 6
    values this step[2, 5, 8, 11, 14]readings
  2. limit ← 6

    8readings = [2, 5, 8, 11, 14]9limit = 610over_count = count(readings > limit)
    values this step6limit
  3. over_count ← 3

    9limit = 610over_count = count(readings > limit)11peak = maxval(readings)
    values this step3over_count[2, 5, 8, 11, 14]readings6limit
  4. peak ← 14

    10over_count = count(readings > limit)11peak = maxval(readings)12print '(I0, 1X, I0)', over_count, peak
    values this step14peak[2, 5, 8, 11, 14]readings
  5. print '(I0, 1X, I0)', over_count, peak

    11    peak = maxval(readings)12    print '(I0, 1X, I0)', over_count, peak13end program threshold_summary_demo
    output3 14
    values this step3over_count14peak
  1. readings ← [2, 5, 8, 11, 14]

    8readings = [2, 5, 8, 11, 14]9limit = 12
    values this step[2, 5, 8, 11, 14]readings
  2. limit ← 12

    8readings = [2, 5, 8, 11, 14]9limit = 1210over_count = count(readings > limit)
    values this step12limit
  3. over_count ← 1

    9limit = 1210over_count = count(readings > limit)11peak = maxval(readings)
    values this step1over_count[2, 5, 8, 11, 14]readings12limit
  4. peak ← 14

    10over_count = count(readings > limit)11peak = maxval(readings)12print '(I0, 1X, I0)', over_count, peak
    values this step14peak[2, 5, 8, 11, 14]readings
  5. print '(I0, 1X, I0)', over_count, peak

    11    peak = maxval(readings)12    print '(I0, 1X, I0)', over_count, peak13end program threshold_summary_demo
    output1 14
    values this step1over_count14peak
mask count `count(readings > limit)` counts the true values in a logical mask.
peak `maxval(readings)` finds the largest measurement.
summary pair The program reports both exceedance count and peak value.