/*  ex3.c  -  Prometheus FORTRAN interface example (written in C!!!, sorry).
 *     - Consult the PETSc documentation for FORTRAN counterparts of PETSc routines
 *     - As FORTRAN passes integer argument as pointers we pass the addresses of integers in this example (eg, &ierr)
 *     - Appended underscores (eg, prom_init_local_) are not used in a FORTRAN program
int main( int argc, char **args )
    int ierr, flag, ii, memlev=0, nstep=1, niter=0, exe_number = 2, minc=4, one=1;
    int numnd, numel, nena, nen1a, nndf, *edges=0, *eq_id=0, *pepimethues;
    int npLoc, npGst,* proc_gnode=0,*ghost_gnode=0, *ghost_proc=0;
    Mat A;
    Vec x,b;
    Scalar energy, *coord=0;
    integer epimetheus = 0;

    PetscInitialize_(PETSC_NULL_CHARACTER, &ierr)                                CHKERRA(ierr);
    prom_init_parameters_( &epimetheus, &ierr );                                       CHKERRA(ierr);
    /* construct user data ... (eg, "coord", "edges", etc. as specified in the users guide) */

    /* local data */
    prom_init_local_( &epimetheus, coord, &numnd, &nndf, edges, &numel, &nena, &nen1a, &one, &minc, eq_id, &ierr );
    CHKERRA(ierr); // global data

    prom_init_global_( &epimetheus, &npLoc, &npGst, proc_gnode, ghost_gnode, ghost_proc, &ierr );

    /* init data is temporary -  free ...*/

    /* get objects*/
    prom_get_a_( &epimetheus, &A, &ierr ); CHKERRA(ierr);
    prom_get_b_( &epimetheus, &b, &ierr ); CHKERRA(ierr);

    /* assemble application data (A and b) into objects ...*/

     /* two exta levels*/
    prom_new_level_( &epimetheus, &ii, &ierr );                                                      CHKERRA(ierr);
    prom_new_level_( &epimetheus, &ii, &ierr );                                                      CHKERRA(ierr);

    /* get ready for solves*/
    prom_finalize_( &epimetheus, &ierr );                                                                      CHKERRA(ierr);

    /* solve*/
    prom_pre_solv_( &epimetheus, &nstep, &niter, &ierr );                        CHKERRA(ierr);
    prom_solv_( &epimetheus, &niter, &energy, &ierr );                               CHKERRA(ierr);

    /* look at ans ...*/
    prom_get_x_( &epimetheus, &x, &ierr );                                                  CHKERRA(ierr);

    /* clean up*/
    prom_destroy_( &epimetheus, &ierr );                                                                      CHKERRA(ierr);
    ierr = PetscFinalize();                                                                                                          CHKERRA(ierr);

    return 0;