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