USE fft
have00=YES
totnproc=1
nprocy=1
myiproc=0
#define MPI_Barrier(MPI_COMM_WORLD)
VELOCITY=STRUCTURED ARRAY(u,v,w) OF COMPLEX
MOMFLUX=STRUCTURED ARRAY(uu,uv,vv,vw,ww,uw) OF COMPLEX
VELOCITY V(0..nx,-ny..ny,-1..nz+1)=0
MOMFLUX VV(0..nx,-ny..ny,-2..2)
INTEGER VVstart
INTEGER nxd=3*nx DIV 2 -1; DO INC nxd UNTIL FFTfit(nxd)
INTEGER nyd=3*ny -1; DO INC nyd UNTIL FFTfit(nyd)
ARRAY(0..nxd-1,0..nyd-1) OF VELOCITY Vd
ARRAY(0..nxd-1,0..nyd-1) OF MOMFLUX VVd
SUBROUTINE convolutions(INTEGER iz)
Vd=0; LOOP FOR ix=0 TO nx
DO Vd(ix,iy)=V(ix,iy,iz) FOR iy=0 TO ny
DO Vd(ix,nyd+iy)=V(ix,iy,iz) FOR iy=-ny TO -1
WITH Vd(ix,*): IFTU(u); IFTU(v); IFTU(w)
REPEAT LOOP
DO WITH Vd(*,iy): RFTU(u); RFTU(v); RFTU(w); FOR ALL iy
DO WITH Vd(ix,iy), VVd(ix,iy)
uu.REAL=u.REAL*u.REAL; uu.IMAG=u.IMAG*u.IMAG
uv.REAL=u.REAL*v.REAL; uv.IMAG=u.IMAG*v.IMAG
vv.REAL=v.REAL*v.REAL; vv.IMAG=v.IMAG*v.IMAG
vw.REAL=v.REAL*w.REAL; vw.IMAG=v.IMAG*w.IMAG
ww.REAL=w.REAL*w.REAL; ww.IMAG=w.IMAG*w.IMAG
uw.REAL=u.REAL*w.REAL; uw.IMAG=u.IMAG*w.IMAG
FOR ALL ix,iy
DO WITH VVd(*,iy): HFTU(uu); HFTU(uv); HFTU(vv); HFTU(vw); HFTU(ww); HFTU(uw) FOR ALL iy
LOOP FOR ix=0 TO nx
WITH VVd(ix,*): FFTU(uu); FFTU(uv); FFTU(vv); FFTU(vw); FFTU(ww); FFTU(uw)
DO VV(ix,iy,iz-VVstart)=VVd(ix,iy) FOR iy=0 TO ny
DO VV(ix,iy,iz-VVstart)=VVd(ix,nyd+iy) FOR iy=-ny TO -1
REPEAT LOOP
END convolutions