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