PROGRAM swapmat
  IMPLICIT NONE
  
  DOUBLE PRECISION, PARAMETER :: pi = 3.14159265358979323846d0
  INTEGER, PARAMETER :: n = 100
  INTEGER, PARAMETER :: half = n/2
  DOUBLE PRECISION :: a(n), temp
  INTEGER :: j
  
  DO j=1,n
     a(j) = COS(pi * j / n)
  END DO
  
  DO j=1,half
     temp = a(j)
     a(j) = a(j+half)
     a(j+half) = temp
  END DO
  
END PROGRAM swapmat
