module constant
implicit none
real(8),parameter :: pi = 4.d0*datan(1.d0)
complex(8),parameter :: im=dcmplx(0.d0,1.d0)

integer(4),parameter :: nx = 64, ny = nx
real(8),parameter :: xmin = 0.d0, xmax = 2*pi, hx = (xmax-xmin)/dble(nx)
real(8),parameter :: ymin = 0.d0, ymax = 2*Pi, hy = (ymax-ymin)/dble(ny)

real(8) :: x(0:nx),y(0:ny)
real(8) :: umx(0:nx),umy(0:ny)
real(8) :: Vtemp(0:nx,0:ny)

real(8),parameter :: beta = 1.d0
real(8),parameter :: Per = (ymax-ymin)**2.d0/(2.d0*pi)
real(8),parameter :: eps = 1.d-4

real(8),parameter :: TFinal = Per ! in t variable
real(8),parameter :: dtMacro = Per/1.d4! in t variable
real(8),parameter :: dtMicro = Per/(4.d2) 
integer(4),parameter :: order = 4 ! gradient approximation order

! time splitting fourth order coeffcient

real(8),parameter :: w1 = 0.33780179798991440851d0
real(8),parameter :: w2 = 0.67560359597982881702d0
real(8),parameter :: w3 =-0.08780179798991440851d0
real(8),parameter :: w4 =-0.85120719795965763405d0

end module constant

	subroutine initial
!=======================================================================d
	use constant
	implicit none

	integer(4) :: i,j
	integer(4) :: nxh,nyh

	do i = 0,nx
	    x(i) = xmin+dble(i)*hx 
	enddo
	do j=0,ny
	   y(j) = ymin+dble(j)*hy 
	enddo

	nxh = nx/2
	do i= 0,nxh-1
		umx(i) = 2.d0*pi*dble(i)/(xmax-xmin)
	enddo
	do i = nx-1,nxh,-1
		umx(i) =  -2.d0*pi*dble(nx-i)/(xmax-xmin)
	enddo

      nyh = ny/2
	do j = 0,nyh-1
		umy(j)= 2.d0*pi*dble(j)/(ymax-ymin)
	enddo
	do j = ny-1,nyh,-1
	   umy(j) = -2.d0*pi*dble(ny-j)/(ymax-ymin)
	enddo

	do j = 0,ny-1
		do i = 0,nx-1
		vtemp(i,j) = eps*umx(i)**2.d0+umy(j)**2.d0
		enddo
	enddo

	end

	subroutine initial_2d(psi)
!======================================================================d
	use constant
	implicit none
	complex(8) :: psi(0:nx,0:ny)

	integer(4) :: i,j
	
	do  j = 0,ny
		do  i = 0,nx
		psi(i,j) = 1.d0+2.d0*cos(x(i))+2.d0*cos(y(j))
		enddo
	enddo

      end

