1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// wrapper for test_pressure_solve main
#include "confdefs.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <cstdlib>
#include <iostream>
using std::cerr;
using std::endl;
#ifdef HAVE_MPI
#include <mpi.h>
#endif
#ifdef HAVE_PETSC
#include <petsc.h>
#endif
extern "C"{
#ifdef HAVE_PYTHON
#include "python_statec.h"
#endif
void test_pressure_solve_();
}
int main(int argc, char **argv){
#ifdef HAVE_MPI
// This must be called before we process any arguments
MPI::Init(argc,argv);
// Undo some MPI init shenanigans
chdir(getenv("PWD"));
#endif
#ifdef HAVE_PYTHON
// Initialize the Python Interpreter
python_init_();
#endif
#ifdef HAVE_PETSC
static char help[] = "Use -help to see the help.\n\n";
PetscErrorCode ierr = PetscInitialize(&argc, &argv, NULL, help);
// PetscInitializeFortran needs to be called when initialising PETSc from C, but calling it from Fortran
// This sets all kinds of objects such as PETSC_NULL_OBJECT, PETSC_COMM_WORLD, etc., etc.
ierr = PetscInitializeFortran();
test_pressure_solve_();
PetscFinalize();
#ifdef HAVE_PYTHON
// Finalize the Python Interpreter
python_end_();
#endif
return 0;
#else
cerr << "ERROR: Not configured with PETSc, so test_pressure_solve is not gonna work!" << endl;
return 1;
#endif
}
|