Date: 2022-03-04T17:37:17+00:00

Actual source code: ex16.c

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

      4: /*T
      5:    Concepts: introduction to PETSc;
      6:    Concepts: printing^in parallel
      7:    Processors: n
      8: T*/

     10: #include <petscsys.h>
     11: int main(int argc,char **argv)
     12: {
     14:   PetscMPIInt    rank,size;

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

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

     28:     Since PetscOptionsSetValue() is called before the PetscInitialize() we cannot call
     29:     CHKERRQ() on the error code and just return it directly.
     30:   */
     31:   PetscOptionsSetValue(NULL,"-no_signal_handler","true");if (ierr) return ierr;
     32:   PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
     33:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
     34:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
     35:   PetscPrintf(PETSC_COMM_WORLD,"Number of processors = %d, rank = %d\n",size,rank);
     36:   PetscFinalize();
     37:   return ierr;
     38: }

     40: /*TEST

     42:    test:
     43:       requires: defined(PETSC_USE_LOG)
     44:       nsize: 2
     45:       args: -options_view -get_total_flops
     46:       filter: egrep -v "(cuda_initialize|malloc|display|nox|Total flops|saws_port_auto_select|vecscatter_mpi1|options_left|error_output_stdout|check_pointer_intensity|use_gpu_aware_mpi|checkstack)"

     48: TEST*/