Example Generic Subroutine swap (cont.)

    INTERFACE swap   ! generic name
    
       SUBROUTINE swapreal (a,b)
    
          REAL, INTENT(INOUT)::a,b
      
       END SUBROUTINE swapreal
    
       SUBROUTINE swapint (a, b)
    
          INTEGER, INTENT(INOUT)::a,b
    
       END SUBROUTINE swapint
    
    END INTERFACE
    

  • In the main program, only the generic name is used
  •    INTEGER :: m,n
       REAL :: x,y
    
       ...
    
       CALL swap(m,n)
       CALL swap(x,y)
    


Ohio Supercomputer Center Procedures and Modules
23 of 38