024. Put functions and subroutines in modules to ensure that interfaces are checked#
topic: Procedures
Fortran procedures should be defined in modules to ensure that interfaces are checked.
module m
contains
integer function area(length, width)
integer, intent(in) :: length, width
area = length*width
end
end module m
program main
use m
print*,area(3,4) ! 12
end program main
12
Fortran procedures should be defined in modules to
— FortranTip (@fortrantip) December 19, 2021
ensure that interfaces are checked.
module m
contains
integer function area(length,width)
integer, intent(in) :: length,width
area = length*width
end
end module m
program main
use m
print*,area(3,4) ! 12
end program main
- 1
Compiled using
GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
with no flags