A small scientific program often starts by converting raw measurements into analysis units.

Program

Play the program to choose the conversion scale and see the same readings summarized in different units.

scale
unit_conversion_pipeline.f90
Replay: real traced execution (multi-file project)
program unit_conversion_pipeline_demo
    implicit none
    real :: readings(3)
    real :: scale
    real :: converted(3)
    real :: total

    readings = [120.0, 150.0, 180.0]
    scale = 0.01
    converted = readings * scale
    total = sum(converted)
    print '(F0.2)', total
end program unit_conversion_pipeline_demo
program unit_conversion_pipeline_demo
    implicit none
    real :: readings(3)
    real :: scale
    real :: converted(3)
    real :: total

    readings = [120.0, 150.0, 180.0]
    scale = 0.001
    converted = readings * scale
    total = sum(converted)
    print '(F0.2)', total
end program unit_conversion_pipeline_demo
program unit_conversion_pipeline_demo
    implicit none
    real :: readings(3)
    real :: scale
    real :: converted(3)
    real :: total

    readings = [120.0, 150.0, 180.0]
    scale = 0.10
    converted = readings * scale
    total = sum(converted)
    print '(F0.2)', total
end program unit_conversion_pipeline_demo
  1. readings ← [120.0, 150.0, 180.0]

    8readings = [120.0, 150.0, 180.0]9scale = 0.01
    values this step[120.0, 150.0, 180.0]readings
  2. scale ← 0.010

    8readings = [120.0, 150.0, 180.0]9scale = 0.0110converted = readings * scale
    values this step0.010scale
  3. converted ← [1.20, 1.50, 1.80]

    9scale = 0.0110converted = readings * scale11total = sum(converted)
    values this step[1.20, 1.50, 1.80]converted[120.0, 150.0, 180.0]readings0.010scale
  4. total ← 4.50

    10converted = readings * scale11total = sum(converted)12print '(F0.2)', total
    values this step4.50total[1.20, 1.50, 1.80]converted
  5. print '(F0.2)', total

    11    total = sum(converted)12    print '(F0.2)', total13end program unit_conversion_pipeline_demo
    output4.50
    values this step4.50total
  1. readings ← [120.0, 150.0, 180.0]

    8readings = [120.0, 150.0, 180.0]9scale = 0.001
    values this step[120.0, 150.0, 180.0]readings
  2. scale ← 0.001

    8readings = [120.0, 150.0, 180.0]9scale = 0.00110converted = readings * scale
    values this step0.001scale
  3. converted ← [0.12, 0.15, 0.18]

    9scale = 0.00110converted = readings * scale11total = sum(converted)
    values this step[0.12, 0.15, 0.18]converted[120.0, 150.0, 180.0]readings0.001scale
  4. total ← 0.45

    10converted = readings * scale11total = sum(converted)12print '(F0.2)', total
    values this step0.45total[0.12, 0.15, 0.18]converted
  5. print '(F0.2)', total

    11    total = sum(converted)12    print '(F0.2)', total13end program unit_conversion_pipeline_demo
    output0.45
    values this step0.45total
  1. readings ← [120.0, 150.0, 180.0]

    8readings = [120.0, 150.0, 180.0]9scale = 0.10
    values this step[120.0, 150.0, 180.0]readings
  2. scale ← 0.100

    8readings = [120.0, 150.0, 180.0]9scale = 0.1010converted = readings * scale
    values this step0.100scale
  3. converted ← [12.00, 15.00, 18.00]

    9scale = 0.1010converted = readings * scale11total = sum(converted)
    values this step[12.00, 15.00, 18.00]converted[120.0, 150.0, 180.0]readings0.100scale
  4. total ← 45.00

    10converted = readings * scale11total = sum(converted)12print '(F0.2)', total
    values this step45.00total[12.00, 15.00, 18.00]converted
  5. print '(F0.2)', total

    11    total = sum(converted)12    print '(F0.2)', total13end program unit_conversion_pipeline_demo
    output45.00
    values this step45.00total
pipeline A conversion step can be separated from the final summary.
array scale `readings * scale` applies one scalar conversion to every element.
sum `sum(converted)` reduces the converted array to one reported value.