subroutine nlps(isave,ac,as,kac,kas,bc,bs,kbc,kbs,wwac11,wwas11) c c $Header: /afs/pppl.gov/u/qpliu/cvsroot/codes/gryffin/src/old/nlps.f,v 4.0 1995/05/24 04:46:58 mbeer Exp $ c c Original "Slab" version of the NonLinear-PseudoSpectral subroutine. c Replaced by nlpsc.f for Cowley coordinates in toroidal geometry. c c Revision 3.0 1994/02/03 22:17:18 bdorland c No change from version 2.0. c c Revision 2.0 1994/02/03 20:49:13 hammett c Version 2.0: final release of the cosine/sine version c c Revision 1.1 1992/06/02 20:02:08 mbeer c Initial revision c c Revision 3.13 1992/04/01 22:56:12 bdorland c header and log added. c c c "NonLinear PseudoSpectral" BD c Given the fields a, b, ka, and kb this subroutine calculates the c Poisson bracket c {a,b} = da/dx db/dy - da/dy db/dx. c c The fields arrive in (x,ky,kz) space and must be transformed c with the appropriate derivatives into (x,y,z) space. c implicit none include 'itg.par' include 'itg.cmn' integer l,m,n,nindex,isave,step real vxmax,vymax real ac(lz,mz,nz,nspecz),as(lz,mz,nz,nspecz), * bc(lz,mz,nz,nspecz),bs(lz,mz,nz,nspecz), * kac(lz,mz,nz,nspecz),kas(lz,mz,nz,nspecz), * kbc(lz,mz,nz,nspecz),kbs(lz,mz,nz,nspecz), * kyas(lz,mz,nz,nspecz),kyac(lz,mz,nz,nspecz), * kybc(lz,mz,nz,nspecz),kybs(lz,mz,nz,nspecz) real kac21(lz,mz,nzz),kas21(lz,mz,nzz), * kbc21(lz,mz,nzz),kbs21(lz,mz,nzz), * kyac21(lz,mz,nzz),kyas21(lz,mz,nzz), * kybc21(lz,mz,nzz),kybs21(lz,mz,nzz) real kac22(lz*mzz*nzz),kyac22(lz*mzz*nzz), * kbc22(lz*mzz*nzz),kybc22(lz*mzz*nzz) real wwac22(lz*mzz*nzz), * wwac21(lz,mz,nzz),wwas21(lz,mz,nzz), * wwac11(lz,mz,nz,nspecz),wwas11(lz,mz,nz,nspecz),mr c Don't recalculate FFT's unnecessarily! c c isave determines which fields are new for this call: c isave=0 -> both fields are new c isave=1 -> "a" fields are the same as last time nlps was called c isave=2 -> "b" fields are the same as last time nlps was called c data step / 0 / save kac22,kyac22,kbc22,kybc22,step,vxmax,vymax c nindex=malias*nalias*ldb c if(isave.eq.0) then step=step+1 if(mod(step,2).eq.0) then vxmax=vxmax*cflx vymax=vymax*cfly n=ncycle-1 write(8,1000) vxmax, vymax, n vmax=max(vxmax,vymax) vxmax=0. vymax=0. 1000 format('vxmax = ',e16.8,' vymax = ',e16.8,i5) endif endif c c Calculate the d/dy terms: if(isave.ne.1) then do 10 n=1,nd do 10 m=1,md mr=float(mrr(m,n)) do 10 l=1,ldb kyac(l,m,n,1)=mr/y0*as(l,m,n,1) kyas(l,m,n,1)=-mr/y0*ac(l,m,n,1) 10 continue endif c if(isave.ne.2) then do 20 n=1,nd do 20 m=1,md mr=float(mrr(m,n)) do 20 l=1,ldb kybc(l,m,n,1)=mr/y0*bs(l,m,n,1) kybs(l,m,n,1)=-mr/y0*bc(l,m,n,1) 20 continue endif c c Transform the vectors i*kx*a, i*kx*b, i*ky*b and i*ky*a into z space: c if(isave.ne.1) then call zspace(kac,kas,kac21,kas21) call zspace(kyac,kyas,kyac21,kyas21) endif c if(isave.ne.2) then call zspace(kbc,kbs,kbc21,kbs21) call zspace(kybc,kybs,kybc21,kybs21) endif c c Then, transform the same vectors into y-space: c if(isave.ne.1) then call yspace(kac21,kas21,kac22) call yspace(kyac21,kyas21,kyac22) c c Check Courant condition: c if(mod(step,2).eq.0) then do 30 n=1,nindex vxmax=max(vxmax,abs(kyac22(n))) vymax=max(vymax,abs(kac22(n))) 30 continue endif c endif c if(isave.ne.2) then call yspace(kbc21,kbs21,kbc22) call yspace(kybc21,kybs21,kybc22) endif c c Perform the multiplications: c do 1 n=1,nindex wwac22(n)=(kbc22(n)*kyac22(n)-kac22(n)*kybc22(n))*float(malias) 1 continue c Transform wwac to ky call kyspace(wwac22,wwac21,wwas21) c Transform wwac,wwas to kz call kzspace(wwac21,wwas21,wwac11,wwas11) c c That's all! c not quite... c Dealias in the x-direction as well: c call kxspace(wwac11,wwas11) c return end