Actual source code: ex16f.F90

      1: ! Tests calling PetscOptionsSetValue() before PetscInitialize(): Fortran Example

      3: program main
      4: #include <petsc/finclude/petscsys.h>
      5:   use petscmpi  ! or mpi or mpi_f08
      6:   use petscsys

      8:   implicit none
      9:   PetscErrorCode :: ierr
     10:   PetscMPIInt  ::  rank, size
     11:   character(len=80) :: outputString

     13:   ! Every PETSc routine should begin with the PetscInitialize() routine.

     15:   PetscCallA(PetscOptionsSetValue(PETSC_NULL_OPTIONS, '-no_signal_handler', 'true', ierr))
     16:   PetscCallA(PetscInitialize(ierr))

     18:   ! We can now change the communicator universe for PETSc

     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))
     25: end program main

     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*/