Workflow Composition
Request Score Workflow
Call and Combine
A workflow can call an internal function, return a derived value, and combine it with local state.
Program
Play the program to choose a request count and watch the call contribute to the final score.
request_score_workflow.f90
program request_score_workflow_demo
implicit none
integer :: request_count
integer :: base_points
integer :: bonus_points
integer :: total_points
request_count =
base_points = 10
bonus_points = score_bonus(request_count)
total_points = base_points + bonus_points
print '(I0, 1X, I0)', request_count, total_points
contains
function score_bonus(count) result(points)
integer, intent(in) :: count
integer :: points
points = count * 3
end function score_bonus
end program request_score_workflow_demo
program request_score_workflow_demo
implicit none
integer :: request_count
integer :: base_points
integer :: bonus_points
integer :: total_points
request_count =
base_points = 10
bonus_points = score_bonus(request_count)
total_points = base_points + bonus_points
print '(I0, 1X, I0)', request_count, total_points
contains
function score_bonus(count) result(points)
integer, intent(in) :: count
integer :: points
points = count * 3
end function score_bonus
end program request_score_workflow_demo
program request_score_workflow_demo
implicit none
integer :: request_count
integer :: base_points
integer :: bonus_points
integer :: total_points
request_count =
base_points = 10
bonus_points = score_bonus(request_count)
total_points = base_points + bonus_points
print '(I0, 1X, I0)', request_count, total_points
contains
function score_bonus(count) result(points)
integer, intent(in) :: count
integer :: points
points = count * 3
end function score_bonus
end program request_score_workflow_demo
internal function
`contains` lets the program define a local function used by the main workflow.
call step
`score_bonus(request_count)` jumps to the function and returns a value.
composition
The final total combines local state with the function result.