MODULE swap_module

  IMPLICIT NONE
  
  INTERFACE swap
    MODULE PROCEDURE swap_reals, swap_integers
  END INTERFACE
  
  CONTAINS
  
  SUBROUTINE swap_reals(a,b)
  
    REAL :: a, b, temp
  
    temp = a; a = b; b = temp
  
  END SUBROUTINE swap_reals

  SUBROUTINE swap_integers(a,b)
  
    INTEGER :: a, b, temp
  
    temp = a; a = b; b = temp
  
  END SUBROUTINE swap_integers
  
END MODULE swap_module
!=========================================================
PROGRAM test_swap

  USE swap_module
  
  IMPLICIT NONE
  REAL :: x = 1.1, y = 2.2
  INTEGER :: i = 1, j = 2

  CALL swap(x, y)
  WRITE(*,*) 'x = ',x, ' y = ',y  

  CALL swap(i, j)
  WRITE(*,*) 'i = ',i, ' j = ',j  
  
END PROGRAM test_swap