Report Generation
Status Report
Selecting a Message
A report often maps a numeric state into a short human-readable status message.
Program
Play the program to choose a different state and print its report line.
status_report.f90
program status_report_demo
implicit none
integer :: status_code
character(len=12) :: label
character(len=30) :: report
status_code =
select case (status_code)
case (1)
label = 'ready'
case (2)
label = 'running'
case default
label = 'review'
end select
write(report, '(A, I0, A, A)') 'status ', status_code, ': ', trim(label)
print '(A)', trim(report)
end program status_report_demo
program status_report_demo
implicit none
integer :: status_code
character(len=12) :: label
character(len=30) :: report
status_code =
select case (status_code)
case (1)
label = 'ready'
case (2)
label = 'running'
case default
label = 'review'
end select
write(report, '(A, I0, A, A)') 'status ', status_code, ': ', trim(label)
print '(A)', trim(report)
end program status_report_demo
program status_report_demo
implicit none
integer :: status_code
character(len=12) :: label
character(len=30) :: report
status_code =
select case (status_code)
case (1)
label = 'ready'
case (2)
label = 'running'
case default
label = 'review'
end select
write(report, '(A, I0, A, A)') 'status ', status_code, ': ', trim(label)
print '(A)', trim(report)
end program status_report_demo
status code
`status_code` stores a compact state.
select case
`select case` maps the state to a readable label.
report text
The final report line combines the code and selected label.