PCG has three ways of handling the matrix and preconditioner data structures.
First of all, PCG has one supported data structure: the Regular Grid Stencil storage. This corresponds to the type of matrices arising from having the same finite difference or finite element stencil on each grid point of a Cartesian product grid. Such matrices are trivially stored in multi-dimensional arrays. After the user sets up the matrix array and the right hand side vector, PCG solves the system (this is called Top Level Usage of PCG).
Secondly, the user can pass matrix and preconditioner arrays, plus two integer arrays for each, to iterative method routines on the Iterative Method Level of PCG. Additionally, now the user has to supply routines to perform the matrix vector product and the preconditioner solve, plus their transposes for methods such as BiCG that need them.
Thirdly, PCG supports Reverse Communication Usage: no matrix or preconditioner structures whatsoever are passed to the iterative routines. Instead, when a product or solve operations needs to be performed, the iterative routine will save its internal state, and return control to the user program with a request to perform that operation.
1 continue call CG( .... IREQ .... IVA, IVQL ... FWK ...) if ( IREQ .eq. JAV ) then c perform matrix-vector product to the vector FWK(IVQR) c leaving the result in FWK(IVA) else if ( IREQ .eq. JQLV ) c apply left preconditioner to the vector FWK(IVA) c leaving the result in FWK(IVQR) else ..... end if goto 1Control is also returned to the user for the convergence test, but inner products are still performed inside the iterative routine.
The Regular Grid Stencil storage scheme incorporates the possibility of having multiple physical variables per grid point; see section 2.3.1.