Sample ZPL Program: Jacobi

/****
   *   Jacobi Iterations
  *
 ****/

program jacobi;

---------- Declarations ----------

config var
  n       : integer = 5;      -- problem size
  epsilon : float   = 0.0001; -- epsilon value end condition

region
  R    = [1..n,   1..n  ]; -- problem region
  BigR = [0..n+1, 0..n+1]; --    with borders

direction
  north = [-1,  0]; -- cardinal directions
  east  = [ 0,  1];
  south = [ 1,  0];
  west  = [ 0, -1];

---------- Entry Procedure ----------

procedure jacobi();
var
  A, Temp : [BigR] float;
  delta   :        float;
[R] begin

  ---------- Initialization ----------

  A := 0.0;
  [north of R] A := 0.0;
  [east  of R] A := 0.0;
  [west  of R] A := 0.0;
  [south of R] A := 1.0;

  ---------- Main Computation ----------

  repeat
    Temp := (A@north + A@east + A@south + A@west) / 4.0;
    delta := max<< abs(A-Temp);
    A := Temp;
  until delta < epsilon;

  ---------- Print Results ----------

  writeln(A);
end;