Small Scientific Programs
Threshold Summary
Count Exceedances
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.
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
readings ← [2, 5, 8, 11, 14]
8readings = [2, 5, 8, 11, 14]9limit = 10values this step[2, 5, 8, 11, 14]readingslimit ← 10
8readings = [2, 5, 8, 11, 14]9limit = 1010over_count = count(readings > limit)values this step10limitover_count ← 2
9limit = 1010over_count = count(readings > limit)11peak = maxval(readings)values this step2over_count[2, 5, 8, 11, 14]readings10limitpeak ← 14
10over_count = count(readings > limit)11peak = maxval(readings)12print '(I0, 1X, I0)', over_count, peakvalues this step14peak[2, 5, 8, 11, 14]readingsprint '(I0, 1X, I0)', over_count, peak
11 peak = maxval(readings)12 print '(I0, 1X, I0)', over_count, peak13end program threshold_summary_demooutput2 14values this step2over_count14peak
readings ← [2, 5, 8, 11, 14]
8readings = [2, 5, 8, 11, 14]9limit = 6values this step[2, 5, 8, 11, 14]readingslimit ← 6
8readings = [2, 5, 8, 11, 14]9limit = 610over_count = count(readings > limit)values this step6limitover_count ← 3
9limit = 610over_count = count(readings > limit)11peak = maxval(readings)values this step3over_count[2, 5, 8, 11, 14]readings6limitpeak ← 14
10over_count = count(readings > limit)11peak = maxval(readings)12print '(I0, 1X, I0)', over_count, peakvalues this step14peak[2, 5, 8, 11, 14]readingsprint '(I0, 1X, I0)', over_count, peak
11 peak = maxval(readings)12 print '(I0, 1X, I0)', over_count, peak13end program threshold_summary_demooutput3 14values this step3over_count14peak
readings ← [2, 5, 8, 11, 14]
8readings = [2, 5, 8, 11, 14]9limit = 12values this step[2, 5, 8, 11, 14]readingslimit ← 12
8readings = [2, 5, 8, 11, 14]9limit = 1210over_count = count(readings > limit)values this step12limitover_count ← 1
9limit = 1210over_count = count(readings > limit)11peak = maxval(readings)values this step1over_count[2, 5, 8, 11, 14]readings12limitpeak ← 14
10over_count = count(readings > limit)11peak = maxval(readings)12print '(I0, 1X, I0)', over_count, peakvalues this step14peak[2, 5, 8, 11, 14]readingsprint '(I0, 1X, I0)', over_count, peak
11 peak = maxval(readings)12 print '(I0, 1X, I0)', over_count, peak13end program threshold_summary_demooutput1 14values 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.