A good starting point may be http://www.mcs.anl.gov/petsc/petsc-current/src/mat/examples/tutorials/ex5.c.html :
Opens a separate file for each process and reads in ITS portion
of a large parallel matrix. Only requires enough memory to store
the processes portion of the matrix ONCE.
It makes use of MatSetValues()
to set values. Carefully read the documentation to understand what you should do : http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValues.html . The chapter of PETSC'manual on Mat will also help you.
If you would like to work with blocked matrix (BAIJ), you may use MatSetValuesBlocked()
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesBlocked.html#MatSetValuesBlocked
(and MatSetBlockSize()
)
Bye,