Reusing F77 Code and Libraries

Two ways to re-use old code using INTERFACE blocks :

Adding an Explicit Interface

Example

  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


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_course_fortran_90/_reml_grp/index.reml
On: 10/2/2003 at 10:33:52
Options: reml2 -i noindex -l long -o html -p multiple