A module can hold reusable procedures while the main program focuses on choosing inputs and printing results.

Program

Play the program to choose a factor and call a procedure through the module API.

module_api_call.f90
module scale_api
    implicit none
contains
    function scaled_count(count, factor) result(total)
        integer, intent(in) :: count
        integer, intent(in) :: factor
        integer :: total
        total = count * factor
    end function scaled_count
end module scale_api

program module_api_call_demo
    use scale_api, only: scaled_count
    implicit none
    integer :: factor
    integer :: total

    factor = 
    total = scaled_count(8, factor)
    print '(I0, 1X, I0)', factor, total
end program module_api_call_demo
module scale_api
    implicit none
contains
    function scaled_count(count, factor) result(total)
        integer, intent(in) :: count
        integer, intent(in) :: factor
        integer :: total
        total = count * factor
    end function scaled_count
end module scale_api

program module_api_call_demo
    use scale_api, only: scaled_count
    implicit none
    integer :: factor
    integer :: total

    factor = 
    total = scaled_count(8, factor)
    print '(I0, 1X, I0)', factor, total
end program module_api_call_demo
module scale_api
    implicit none
contains
    function scaled_count(count, factor) result(total)
        integer, intent(in) :: count
        integer, intent(in) :: factor
        integer :: total
        total = count * factor
    end function scaled_count
end module scale_api

program module_api_call_demo
    use scale_api, only: scaled_count
    implicit none
    integer :: factor
    integer :: total

    factor = 
    total = scaled_count(8, factor)
    print '(I0, 1X, I0)', factor, total
end program module_api_call_demo
module A module groups reusable procedures behind a named API.
use only `use scale_api, only: scaled_count` imports one public procedure.
main program The program chooses inputs and delegates the calculation.