program ctpack_test1d

  use ctpack
  implicit none
  integer, parameter :: im=4, km=4
  real(8), parameter :: xmin=-1.0D0, xmax=1.0D0
  real(8), parameter :: eps=1.0D-14

  real(8), dimension(0:im) :: z

  integer :: k, i, m

  call ctinitial(im,km,xmin,xmax)
  z(:) = 2*g_x**2 - 1
  write(6,*) 'z = T_2(x)'
  write(6,*) t_g(z)
  write(6,*) 
  write(6,*) g_t(t_g(z)) - z
  write(6,*) 
  write(6,*) g_t(t_dx_t(t_g(z))) - 4*g_x

  write(6,*) 
  write(6,*) 'z = T_4(x)'
  z(:) = 8*g_x**4 - 8*g_x**2 + 1
  write(6,*) t_g(z)
  write(6,*) 
  write(6,*) g_t(t_g(z)) - z
  write(6,*) 
  write(6,*) g_t(t_dx_t(t_g(z))) - ( 32*g_x**3 - 16 * g_x )

end program ctpack_test1d
