Validation often records facts about the data instead of stopping at the first problem. A logical mask and count summarize which entries need review.

Program

Play the program to choose the limit and count readings above it.

limit
validation_flag.f90
Replay: real traced execution (multi-file project)
program validation_flag_demo
    implicit none
    integer :: readings(3)
    integer :: limit
    logical :: too_high(3)
    integer :: issue_count
    character(len=8) :: label

    readings = [4, 8, 12]
    limit = 10
    too_high = readings > limit
    issue_count = count(too_high)
    if (issue_count == 0) then
        label = 'clean'
    else
        label = 'review'
    end if
    print '(A, 1X, I0)', trim(label), issue_count
end program validation_flag_demo
program validation_flag_demo
    implicit none
    integer :: readings(3)
    integer :: limit
    logical :: too_high(3)
    integer :: issue_count
    character(len=8) :: label

    readings = [4, 8, 12]
    limit = 5
    too_high = readings > limit
    issue_count = count(too_high)
    if (issue_count == 0) then
        label = 'clean'
    else
        label = 'review'
    end if
    print '(A, 1X, I0)', trim(label), issue_count
end program validation_flag_demo
program validation_flag_demo
    implicit none
    integer :: readings(3)
    integer :: limit
    logical :: too_high(3)
    integer :: issue_count
    character(len=8) :: label

    readings = [4, 8, 12]
    limit = 15
    too_high = readings > limit
    issue_count = count(too_high)
    if (issue_count == 0) then
        label = 'clean'
    else
        label = 'review'
    end if
    print '(A, 1X, I0)', trim(label), issue_count
end program validation_flag_demo
  1. readings ← [4, 8, 12]

    9readings = [4, 8, 12]10limit = 10
    values this step[4, 8, 12]readings
  2. limit ← 10

    9readings = [4, 8, 12]10limit = 1011too_high = readings > limit
    values this step10limit
  3. too_high ← [F, F, T]

    10limit = 1011too_high = readings > limit12issue_count = count(too_high)
    values this step[F, F, T]too_high10limit
  4. issue_count ← 1

    11too_high = readings > limit12issue_count = count(too_high)13if (issue_count == 0) then
    values this step1issue_count[F, F, T]too_high
  5. issue_count == 0 ← .false.

    12issue_count = count(too_high)13if (issue_count == 0) then14    label = 'clean'
    values this step.false.issue_count == 01issue_count
  6. label ← review

    15else16    label = 'review'17end if
    values this stepreviewlabel
  7. print '(A, 1X, I0)', trim(label), issue_count

    17    end if18    print '(A, 1X, I0)', trim(label), issue_count19end program validation_flag_demo
    outputreview 1
    values this stepreviewlabel1issue_count
  1. readings ← [4, 8, 12]

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

    9readings = [4, 8, 12]10limit = 511too_high = readings > limit
    values this step5limit
  3. too_high ← [F, T, T]

    10limit = 511too_high = readings > limit12issue_count = count(too_high)
    values this step[F, T, T]too_high5limit
  4. issue_count ← 2

    11too_high = readings > limit12issue_count = count(too_high)13if (issue_count == 0) then
    values this step2issue_count[F, T, T]too_high
  5. issue_count == 0 ← .false.

    12issue_count = count(too_high)13if (issue_count == 0) then14    label = 'clean'
    values this step.false.issue_count == 02issue_count
  6. label ← review

    15else16    label = 'review'17end if
    values this stepreviewlabel
  7. print '(A, 1X, I0)', trim(label), issue_count

    17    end if18    print '(A, 1X, I0)', trim(label), issue_count19end program validation_flag_demo
    outputreview 2
    values this stepreviewlabel2issue_count
  1. readings ← [4, 8, 12]

    9readings = [4, 8, 12]10limit = 15
    values this step[4, 8, 12]readings
  2. limit ← 15

    9readings = [4, 8, 12]10limit = 1511too_high = readings > limit
    values this step15limit
  3. too_high ← [F, F, F]

    10limit = 1511too_high = readings > limit12issue_count = count(too_high)
    values this step[F, F, F]too_high15limit
  4. issue_count ← 0

    11too_high = readings > limit12issue_count = count(too_high)13if (issue_count == 0) then
    values this step0issue_count[F, F, F]too_high
  5. issue_count == 0 ← .true.

    12issue_count = count(too_high)13if (issue_count == 0) then14    label = 'clean'
    values this step.true.issue_count == 00issue_count
  6. label ← clean

    13if (issue_count == 0) then14    label = 'clean'15else
    values this stepcleanlabel
  7. print '(A, 1X, I0)', trim(label), issue_count

    17    end if18    print '(A, 1X, I0)', trim(label), issue_count19end program validation_flag_demo
    outputclean 0
    values this stepcleanlabel0issue_count
logical mask `readings > limit` compares every array element.
count `count(too_high)` converts validation flags into a summary number.
review label The final branch names whether the data is clean or needs review.