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 */ 24*d0609cedSBarry Smith PetscCall(PetscOptionsSetValue(NULL,"-no_signal_handler","true")); 259566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc,&argv,(char*)0,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 39362febeeSStefano Zampini 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)" 40c4762a1bSJed Brown 41c4762a1bSJed Brown TEST*/ 42