Modules at Scale
Renamed Import
Local Module Names
A use statement can rename an imported procedure so the local code reads clearly.
Program
Play the program to choose a meter count and call the imported function through its local name.
renamed_import.f90
module unit_tools
implicit none
contains
function centimeters(meters) result(cm)
integer, intent(in) :: meters
integer :: cm
cm = meters * 100
end function centimeters
end module unit_tools
program renamed_import_demo
use unit_tools, only: to_cm => centimeters
implicit none
integer :: meters
integer :: total_cm
meters =
total_cm = to_cm(meters)
print '(I0)', total_cm
end program renamed_import_demo
module unit_tools
implicit none
contains
function centimeters(meters) result(cm)
integer, intent(in) :: meters
integer :: cm
cm = meters * 100
end function centimeters
end module unit_tools
program renamed_import_demo
use unit_tools, only: to_cm => centimeters
implicit none
integer :: meters
integer :: total_cm
meters =
total_cm = to_cm(meters)
print '(I0)', total_cm
end program renamed_import_demo
module unit_tools
implicit none
contains
function centimeters(meters) result(cm)
integer, intent(in) :: meters
integer :: cm
cm = meters * 100
end function centimeters
end module unit_tools
program renamed_import_demo
use unit_tools, only: to_cm => centimeters
implicit none
integer :: meters
integer :: total_cm
meters =
total_cm = to_cm(meters)
print '(I0)', total_cm
end program renamed_import_demo
rename
`to_cm => centimeters` gives the imported function a local name.
module API
The original module still exports `centimeters`.
local clarity
The program can choose a shorter or domain-specific call name.