Capacity reports often turn demand and capacity into a small reserve label that operators can scan quickly.

Program

Play the program to choose demand and inspect the reserve label.

demand
capacity_margin_report.f90
Replay: real traced execution (multi-file project)
program capacity_margin_report_demo
    implicit none
    integer :: demand
    integer :: capacity
    integer :: reserve
    character(len=8) :: status

    demand = 72
    capacity = 100
    reserve = capacity - demand
    if (reserve >= 25) then
        status = 'stable'
    else if (reserve >= 10) then
        status = 'watch'
    else
        status = 'tight'
    end if
    print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)
end program capacity_margin_report_demo
program capacity_margin_report_demo
    implicit none
    integer :: demand
    integer :: capacity
    integer :: reserve
    character(len=8) :: status

    demand = 88
    capacity = 100
    reserve = capacity - demand
    if (reserve >= 25) then
        status = 'stable'
    else if (reserve >= 10) then
        status = 'watch'
    else
        status = 'tight'
    end if
    print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)
end program capacity_margin_report_demo
program capacity_margin_report_demo
    implicit none
    integer :: demand
    integer :: capacity
    integer :: reserve
    character(len=8) :: status

    demand = 95
    capacity = 100
    reserve = capacity - demand
    if (reserve >= 25) then
        status = 'stable'
    else if (reserve >= 10) then
        status = 'watch'
    else
        status = 'tight'
    end if
    print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)
end program capacity_margin_report_demo
  1. demand ← 72

    8demand = 729capacity = 100
    values this step72demand
  2. capacity ← 100

    8demand = 729capacity = 10010reserve = capacity - demand
    values this step100capacity
  3. reserve ← 28

    9capacity = 10010reserve = capacity - demand11if (reserve >= 25) then
    values this step28reserve100capacity72demand
  4. if (reserve >= 25) then

    10reserve = capacity - demand11if (reserve >= 25) then12    status = 'stable'
    values this step28reserve
  5. status ← stable

    11if (reserve >= 25) then12    status = 'stable'13else if (reserve >= 10) then
    values this stepstablestatus
  6. print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)

    17    end if18    print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)19end program capacity_margin_report_demo
    output72 28 stable
    values this step72demand28reservestablestatus
  1. demand ← 88

    8demand = 889capacity = 100
    values this step88demand
  2. capacity ← 100

    8demand = 889capacity = 10010reserve = capacity - demand
    values this step100capacity
  3. reserve ← 12

    9capacity = 10010reserve = capacity - demand11if (reserve >= 25) then
    values this step12reserve100capacity88demand
  4. if (reserve >= 25) then

    10reserve = capacity - demand11if (reserve >= 25) then12    status = 'stable'
    values this step12reserve
  5. else if (reserve >= 10) then

    12    status = 'stable'13else if (reserve >= 10) then14    status = 'watch'
    values this step12reserve
  6. status ← watch

    13else if (reserve >= 10) then14    status = 'watch'15else
    values this stepwatchstatus
  7. print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)

    17    end if18    print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)19end program capacity_margin_report_demo
    output88 12 watch
    values this step88demand12reservewatchstatus
  1. demand ← 95

    8demand = 959capacity = 100
    values this step95demand
  2. capacity ← 100

    8demand = 959capacity = 10010reserve = capacity - demand
    values this step100capacity
  3. reserve ← 5

    9capacity = 10010reserve = capacity - demand11if (reserve >= 25) then
    values this step5reserve100capacity95demand
  4. if (reserve >= 25) then

    10reserve = capacity - demand11if (reserve >= 25) then12    status = 'stable'
    values this step5reserve
  5. else if (reserve >= 10) then

    12    status = 'stable'13else if (reserve >= 10) then14    status = 'watch'
    values this step5reserve
  6. status ← tight

    15else16    status = 'tight'17end if
    values this steptightstatus
  7. print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)

    17    end if18    print '(I0, 1X, I0, 1X, A)', demand, reserve, trim(status)19end program capacity_margin_report_demo
    output95 5 tight
    values this step95demand5reservetightstatus
reserve `capacity - demand` creates the margin used by the rest of the report.
tiered labels The `if`/`else if` chain maps reserve ranges to stable, watch, or tight.
operator output The printed line keeps the raw demand and derived reserve visible.