A general algorithm for compressible and incompressible flow. Stability analysis and explicit time integration