Two ways to re-use old code using INTERFACE blocks :
MODULE my_interfaces INTERFACE SUBROUTINE sub_1(a, b, c) REAL, INTENT(IN) :: a(:) INTEGER, INTENT(IN) :: b CHARACTER(LEN=*), INTENT(IN) :: c ENDSUBROUTINE sub_1 SUBROUTINE sub_2(time, distance) REAL, INTENT(INOUT) :: time, distance ENDSUBROUTINE sub_2 ENDINTERFACE ENDMODULE my_interfaces PROGRAM use_interface USE my_interfaces REAL, DIMENSION(1:3) :: a = (/1, 2, 3/) ! -- array initialisation; REAL :: t, d CALL sub_1(a, 2, 'Hello') ... CALL sub_2(t, d) ... ENDPROGRAM use_interface SUBROUTINE sub_1(a, b, c) REAL, INTENT(IN) :: a(:) INTEGER, INTENT(IN) :: b CHARACTER(LEN=*), INTENT(IN) :: c ... ENDSUBROUTINE sub_1 SUBROUTINE sub_2(time, distance) REAL, INTENT(INOUT) :: time, distance ... ENDSUBROUTINE sub_2 |
...previous | up (conts) | next... |