An algorithm is developed for adjusting glacier surface-velocity vectors, given on the nodes of a square grid, so that they obey a central-difference approximation of the continuity equation. Also required on the grid nodes are the glacier thickness, the ratio of the surface-velocity to the average velocity in the column, and the difference between the mass balance and the thickness change. All these other variables are assumed to be known exactly, and only the surface-velocity field is adjusted. The result is optimum in the sense that the magnitude of the adjustment is minimized. Either the relative or the absolute adjustment can be minimized, depending on how weights are specified. No restriction is placed on the shape of the solution region, and no boundary condition is required. The algorithm is not iterative. The algorithm first forms a parallel flow field that satisfies the continuity equation, and then uses a stream function to add a divergenceless field to it. The stream function that leads to the minimum velocity adjustment is obtained as four independent, interlacing solutions covering the solution region. For each of the four, a well-conditioned, sparse-matrix system of simultaneous linear equations is solved. A compact, sub-optimum, well-behaved iterative procedure is also developed for transforming part of the velocity adjustment into an adjustment of the thickness field.