xref: /petsc/src/sys/tutorials/ex16f.F90 (revision 3f02e49b19195914bf17f317a25cb39636853415)
1! Tests calling PetscOptionsSetValue() before PetscInitialize(): Fortran Example
2
3program main
4#include <petsc/finclude/petscsys.h>
5  use petscmpi  ! or mpi or mpi_f08
6  use petscsys
7
8  implicit none
9  PetscErrorCode :: ierr
10  PetscMPIInt  ::  rank, size
11  character(len=80) :: outputString
12
13  ! Every PETSc routine should begin with the PetscInitialize() routine.
14
15  PetscCallA(PetscOptionsSetValue(PETSC_NULL_OPTIONS, '-no_signal_handler', 'true', ierr))
16  PetscCallA(PetscInitialize(ierr))
17
18  ! We can now change the communicator universe for PETSc
19
20  PetscCallMPIA(MPI_Comm_size(MPI_COMM_WORLD, size, ierr))
21  PetscCallMPIA(MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr))
22  write (outputString, *) 'Number of processors =', size, 'rank =', rank, '\n'
23  PetscCallA(PetscPrintf(PETSC_COMM_WORLD, outputString, ierr))
24  PetscCallA(PetscFinalize(ierr))
25end program main
26
27!/*TEST
28!
29!   test:
30!      requires: defined(PETSC_USE_LOG)
31!      nsize: 2
32!      args: -options_view -get_total_flops
33!      filter: grep -E -v "(Total flops)"
34!
35!TEST*/
36