Please consult the following code for implementing a similar standalone GMRES solver in C with MPI support https://github.com/aaronjridley/GITM/blob/476f28d7cf72a39bfc356ce1dce70f8ed9612533/share/Library/src/ModLinearAdvection.f90