! Gauss-Seidel iteration for Poisson's equation ! ============================================= USE gnuplot ! prepare for plotting ARRAY(0..20,0..40) OF REAL var,rhs ! declare and allocate ARRAY variables var=0; rhs=0 DO var(i,HI)=1 FOR ALL i ! assign some boundary conditions LOOP FOR 100 TIMES ! main iteration loop LOOP FOR i=LO+1 TO HI-1 AND j=LO+1 TO HI-1 var(i,j)=[var(i,j+1)+var(i,j-1)+var(i+1,j)+var(i-1,j) + rhs(i,j)]/4 REPEAT LOOP ! these three lines are the core iteration REPEAT LOOP SPLOT var READ ! wait on input and keep plot displayed until Enter is pressed !( A single LOOP instruction can loop over several indices. Indices are implicitly declared. Various LOOP and DO forms are available. Round, square and curly brackets can be used like in mathematics. !)