A batch summary can filter accepted values, count them, and compute an average for reporting.

Program

Play the program to choose a quality limit and watch the accepted count and average change.

batch_summary_case.f90
program batch_summary_case_demo
    implicit none
    integer :: values(4)
    integer :: limit
    integer :: accepted_count
    integer :: total
    real :: average
    integer :: i

    values = [4, 8, 11, 15]
    limit = 
    accepted_count = 0
    total = 0
    do i = 1, 4
        if (values(i) <= limit) then
            accepted_count = accepted_count + 1
            total = total + values(i)
        end if
    end do
    average = real(total) / real(max(1, accepted_count))
    print '(I0, 1X, F0.1)', accepted_count, average
end program batch_summary_case_demo
program batch_summary_case_demo
    implicit none
    integer :: values(4)
    integer :: limit
    integer :: accepted_count
    integer :: total
    real :: average
    integer :: i

    values = [4, 8, 11, 15]
    limit = 
    accepted_count = 0
    total = 0
    do i = 1, 4
        if (values(i) <= limit) then
            accepted_count = accepted_count + 1
            total = total + values(i)
        end if
    end do
    average = real(total) / real(max(1, accepted_count))
    print '(I0, 1X, F0.1)', accepted_count, average
end program batch_summary_case_demo
program batch_summary_case_demo
    implicit none
    integer :: values(4)
    integer :: limit
    integer :: accepted_count
    integer :: total
    real :: average
    integer :: i

    values = [4, 8, 11, 15]
    limit = 
    accepted_count = 0
    total = 0
    do i = 1, 4
        if (values(i) <= limit) then
            accepted_count = accepted_count + 1
            total = total + values(i)
        end if
    end do
    average = real(total) / real(max(1, accepted_count))
    print '(I0, 1X, F0.1)', accepted_count, average
end program batch_summary_case_demo
filter `values(i) <= limit` chooses which readings belong in the summary.
safe average `max(1, accepted_count)` avoids division by zero.
case composition The example combines arrays, loops, guards, and reporting.