Actual source code: ex16f.F90
petsc-3.14.6 2021-03-30
1: ! Tests calling PetscOptionsSetValue() before PetscInitialize(): Fortran Example
3: program main
4: #include <petsc/finclude/petscsys.h>
5: use petscsys
7: implicit none
8: PetscErrorCode :: ierr
9: PetscMPIInt :: myRank,mySize
10: character(len=80) :: outputString
12: ! Every PETSc routine should begin with the PetscInitialize() routine.
14: call PetscOptionsSetValue(PETSC_NULL_OPTIONS,"-no_signal_handler","true",ierr)
15: call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
16: if (ierr/=0) then
17: write(6,*) 'Unable to initialize PETSc'
18: stop
19: endif
21: ! Since when PetscInitialize() returns with an error the PETSc data structures
22: ! may not be set up hence we cannot call CHKERRA() hence directly return the error code.
24: ! Since PetscOptionsSetValue() is called before the PetscInitialize() we cannot call
25: ! CHKERRA() on the error code and just return it directly.
27: ! We can now change the communicator universe for PETSc
29: call MPI_Comm_size(MPI_COMM_WORLD,mySize,ierr); CHKERRA(ierr)
30: call MPI_Comm_rank(MPI_COMM_WORLD,myRank,ierr); CHKERRA(ierr)
31: write(outputString,*) 'Number of processors =',mySize,'rank =',myRank,'\n'
32: call PetscPrintf(PETSC_COMM_WORLD,outputString,ierr); CHKERRA(ierr)
33: call PetscFinalize(ierr)
35: end program main
37: !/*TEST
38: !
39: ! test:
40: ! requires: define(PETSC_USE_LOG)
41: ! nsize: 2
42: ! args: -options_view -get_total_flops
43: ! filter: egrep -v "(malloc|display|nox|Total flops|saws_port_auto_select|vecscatter_mpi1|options_left|error_output_stdout|check_pointer_intensity|cuda_initialize|use_gpu_aware_mpi)"
44: !
45: !TEST*/