subroutine posten(dt) c c (* old comment Determine wkin,wmgt,wki and wenr at time step=ne-1 c like preenr but had an option to adjust dt. *) c c c I'm not sure why, it probably has something to do with variable c timestep, but here grtmx is recalculated. c c implicit none include 'itg.par' include 'itg.cmn' c real den2m(mz,nz),v2m(mz,nz),tpar2m(mz,nz),tp2m(mz,nz) real u2(mz,nz),edif,etot,dt(mz),dum real den2,v2,tpar2,tp2,wenrn,dedt,dt1 integer m,n c call volsq(potential,potential,dum,u2) if(ncycle.gt.2) then do n=1,nd do m=1,md edif=u2(m,n)-grtmx(ne,m,n) etot=u2(m,n)+grtmx(ne,m,n) if (abs(etot).lt.1.0e-33) then grtmx(ne,m,n) = 0.0 else grtmx(ne,m,n)=edif/(2.*dt(m)*etot) endif enddo enddo else do n=1,nd do m=1,md grtmx(ne,m,n)=0.0 enddo enddo endif c c c calculate energy conservation, 2nd order accurate in dt c call volsq(density,density,den2,den2m) call volsq(u_par,u_par,v2,v2m) call volsq(t_par,t_par,tpar2,tpar2m) call volsq(t_perp,t_perp,tp2,tp2m) c c Without subcycling, this calculation only makes sense if all modes are c being advanced with the same time step. It is not vital in the c linear cases, so replace dt with dt(md) as elsewhere: c dt1=dt(md) wenrn=0.5*(den2+v2+tpar2/2.+tp2) dedt=(dt1/dtold*(wenr-pwenr) . +dtold/dt1*(wenrn-wenr))/(dt1+dtold) if(wenrn.ne.0.) then pcerr(ne)=(dedt-drive)/wenrn else pcerr(ne)=0. endif return end