subroutine chtmst(u,v,ek,dtin,cfl,nx,ny) c***************************************************************** c c impose the cfl condition on the time step and calculate the c total kinetic energy. c c dtin -> maximal time step c cfl -> cfl number c dt <- time step c ek <- total kinetic energy c c***************************************************************** integer i,j,nx,ny double precision u(nx,ny),v(nx,ny), + h,hinv,ek,dtin,cfl,uvmax,dt common/meshsz/h,hinv common/timest/dt uvmax = 0.D0 ek = 0.D0 do 10 j=1,ny do 10 i=1,nx uvmax = dmax1(dabs(u(i,j)),dabs(v(i,j)),uvmax) ek = ek + u(i,j)*u(i,j) + v(i,j)*v(i,j) 10 continue * ek = 0.5D0*ek*h*h * total kinetic energy if(uvmax .eq. 0.D0) then dt = dtin else dt = dmin1(dtin,cfl*h/uvmax) endif end