1 2 static char help[] = "Tests calling PetscOptionsSetValue() before PetscInitialize()\n\n"; 3 4 /*T 5 Concepts: introduction to PETSc; 6 Concepts: printing^in parallel 7 Processors: n 8 T*/ 9 10 #include <petscsys.h> 11 int main(int argc,char **argv) 12 { 13 PetscErrorCode ierr; 14 PetscMPIInt rank,size; 15 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. 24 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. 27 28 Since PetscOptionsSetValue() is called before the PetscInitialize() we cannot call 29 CHKERRQ() on the error code and just return it directly. 30 */ 31 ierr = PetscOptionsSetValue(NULL,"-no_signal_handler","true");if (ierr) return ierr; 32 ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr; 33 ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); 34 ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr); 35 ierr = PetscPrintf(PETSC_COMM_WORLD,"Number of processors = %d, rank = %d\n",size,rank);CHKERRQ(ierr); 36 ierr = PetscFinalize(); 37 return ierr; 38 } 39 40 41 /*TEST 42 43 test: 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)" 47 48 TEST*/ 49