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
program threshold_summary_demo
implicit none
integer :: readings(5)
integer :: limit
integer :: over_count
integer :: peak
readings = [2, 5, 8, 11, 14]
limit =
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 =
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 =
over_count = count(readings > limit)
peak = maxval(readings)
print '(I0, 1X, I0)', over_count, peak
end program threshold_summary_demo
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.