c This program does nothing but print out whatever it would be doing c if it were doing something. It pretends to be a multigrid mu cycle. c It probably prints out more information than you want, so then you c may want to only leave, say, the relaxation printout, and delete the c rest, so that you can see better what each type of cycle looks like. c A skeleton multigrid cycle with cycle-index ivw. dimension u(1000),ur(1000) write(*,*)' # levels ?' read(*,*) m write(*,*)' cycle index (1 for V, 2 for W, etc.) ? ' read(*,*) ivw write(*,*)' pre-sweeps, postsweeps ? ' read(*,*)nu1,nu2 call mg(m,nu1,nu2,ivw,u,ur) stop end subroutine mg(m,nu1,nu2,ivw,u,ur) c c multigrid cycle c dimension u(1000),ur(1000),nk(10) c Start on the finest level -- m. k=m c Relax nu1 times (pre-relaxations). 5 do i=1,nu1 call relax(k) end do c If k=1, start going up to next-finer grid. if (k.eq.1) goto 10 c Restrict residuals and form right-hand sides on next coarser grid. call resu(k,k-1) k=k-1 c Set nk(k) initially equal to the cycle index ivw c (1 for V cycle, 2 for W cycle, etc.) nk(k)=ivw c Continue down to next-coarser grid. goto 5 10 continue c nr2 is used simply to allow extra sweeps on coarsest level. nu2 is c the number of post-relaxation sweeps. nr2=nu2 c if (k.eq.1) nr2=3 if (k.eq.1) nr2=nu2 c Relax nr2 times. do i=1,nr2 call relax(k) end do c If you're back on the finest level, then you have completed the c cycle. if (k.eq.m) then return end if c nk(k) counts how many cycles you have performed on intermediate c level k. nk(k)=nk(k)-1 c If nk(k)=0, then you have completed ivw cycles on this level. c Otherwise, you need to go down to the next-coarser level again. if (nk(k).gt.0) goto 5 c Interpolate and add the correction to the solution of next-finer c grid. call intadd(k+1,k) c Continue up k=k+1 goto 10 end c c subroutine relax(k) write(*,1)k 1 format(' relax on level',i2) return end c c subroutine resu(kf,kc) write(*,1)kf,kc 1 format(' restrict residuals from level',i2,' to level',i2) return end c c subroutine intadd(kf,kc) write(*,1)kc,kf 1 format(' interpolate and add correction of level',i2,' to solution & of level',i2) return end c c