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
