1c4762a1bSJed Brown static char help[] = "Tests calling PetscOptionsSetValue() before PetscInitialize()\n\n";
2c4762a1bSJed Brown
3c4762a1bSJed Brown #include <petscsys.h>
main(int argc,char ** argv)4d71ae5a4SJacob Faibussowitsch int main(int argc, char **argv)
5d71ae5a4SJacob Faibussowitsch {
6c4762a1bSJed Brown PetscMPIInt rank, size;
7c4762a1bSJed Brown
8c4762a1bSJed Brown /*
9c4762a1bSJed Brown Every PETSc routine should begin with the PetscInitialize() routine.
10c4762a1bSJed Brown argc, argv - These command line arguments are taken to extract the options
11c4762a1bSJed Brown supplied to PETSc and options supplied to MPI.
12c4762a1bSJed Brown help - When PETSc executable is invoked with the option -help,
13c4762a1bSJed Brown it prints the various options that can be applied at
14c4762a1bSJed Brown runtime. The user can use the "help" variable place
15c4762a1bSJed Brown additional help messages in this printout.
16c4762a1bSJed Brown
17c4762a1bSJed Brown Since when PetscInitialize() returns with an error the PETSc data structures
189566063dSJacob Faibussowitsch may not be set up hence we cannot call PetscCall() hence directly return the error code.
19c4762a1bSJed Brown
20c4762a1bSJed Brown Since PetscOptionsSetValue() is called before the PetscInitialize() we cannot call
219566063dSJacob Faibussowitsch PetscCall() on the error code and just return it directly.
22c4762a1bSJed Brown */
23d0609cedSBarry Smith PetscCall(PetscOptionsSetValue(NULL, "-no_signal_handler", "true"));
24327415f7SBarry Smith PetscFunctionBeginUser;
25*c8025a54SPierre Jolivet PetscCall(PetscInitialize(&argc, &argv, NULL, help));
269566063dSJacob Faibussowitsch PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
279566063dSJacob Faibussowitsch PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
289566063dSJacob Faibussowitsch PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Number of processors = %d, rank = %d\n", size, rank));
299566063dSJacob Faibussowitsch PetscCall(PetscFinalize());
30b122ec5aSJacob Faibussowitsch return 0;
31c4762a1bSJed Brown }
32c4762a1bSJed Brown
33c4762a1bSJed Brown /*TEST
34c4762a1bSJed Brown
35c4762a1bSJed Brown test:
36dfd57a17SPierre Jolivet requires: defined(PETSC_USE_LOG)
37c4762a1bSJed Brown nsize: 2
38c4762a1bSJed Brown args: -options_view -get_total_flops
39e9a33e21SBarry Smith filter: grep -E -v "(cuda_initialize|Total flops)"
40c4762a1bSJed Brown
41c4762a1bSJed Brown TEST*/
42