Consider the following module containing procedure interfaces:
MODULE my_interfaces
IMPLICIT NONE
INTERFACE
SUBROUTINE sub1(A,B,C)
REAL, INTENT(IN), DIMENSION(:) :: A
INTEGER, INTENT(IN) :: B
CHARACTER(LEN=*), INTENT(IN) :: C
END SUBROUTINE sub1
SUBROUTINE sub2(time,dist)
... ! etc
END SUBROUTINE sub2
END INTERFACE
END MODULE my_interfaces
this can be used in the main program and will make the interfaces for sub1 and sub2 visible,
PROGRAM use_of_module
USE my_interfaces
IMPLICIT NONE
CALL sub1((/1.0,3.141,0.57112/),2,'Yobot')
CALL sub2(t,d)
END PROGRAM use_of_module
SUBROUTINE sub1(A,B,C)
...
END SUBROUTINE sub1
SUBROUTINE sub2(time,dist)
...
END SUBROUTINE sub2
Even though the module contains all possible interfaces and can simply be USE d to make the interfaces visible this is not the best way to use modules; we should use encapsulation.
Return to corresponding overview page