Actual source code: ex16.c


  2: static char help[] = "Tests calling PetscOptionsSetValue() before PetscInitialize()\n\n";

  4: #include <petscsys.h>
  5: int main(int argc, char **argv)
  6: {
  7:   PetscMPIInt rank, size;

  9:   /*
 10:     Every PETSc routine should begin with the PetscInitialize() routine.
 11:     argc, argv - These command line arguments are taken to extract the options
 12:                  supplied to PETSc and options supplied to MPI.
 13:     help       - When PETSc executable is invoked with the option -help,
 14:                  it prints the various options that can be applied at
 15:                  runtime.  The user can use the "help" variable place
 16:                  additional help messages in this printout.

 18:     Since when PetscInitialize() returns with an error the PETSc data structures
 19:     may not be set up hence we cannot call PetscCall() hence directly return the error code.

 21:     Since PetscOptionsSetValue() is called before the PetscInitialize() we cannot call
 22:     PetscCall() on the error code and just return it directly.
 23:   */
 24:   PetscOptionsSetValue(NULL, "-no_signal_handler", "true");
 26:   PetscInitialize(&argc, &argv, (char *)0, help);
 27:   MPI_Comm_size(PETSC_COMM_WORLD, &size);
 28:   MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
 29:   PetscPrintf(PETSC_COMM_WORLD, "Number of processors = %d, rank = %d\n", size, rank);
 30:   PetscFinalize();
 31:   return 0;
 32: }

 34: /*TEST

 36:    test:
 37:       requires: defined(PETSC_USE_LOG)
 38:       nsize: 2
 39:       args: -options_view -get_total_flops
 40:       filter: grep -E -v "(cuda_initialize|Total flops|options_left)"

 42: TEST*/