Small Scientific Programs
Unit Conversion Pipeline
Scale Measurements
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.
unit_conversion_pipeline.f90
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 =
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 =
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 =
converted = readings * scale
total = sum(converted)
print '(F0.2)', total
end program unit_conversion_pipeline_demo
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.