Actual source code: ex8f90.F90

  1: !
  2: !   Example of getting an enum value from the options database in Fortran
  3: #include "petsc/finclude/petsc.h"
  4: program main
  5:   use petsc
  6:   implicit none

  8:   PetscErrorCode :: ierr
  9:   character(len=99) list1(6)
 10:   PetscEnum :: opt = -1
 11:   PetscBool :: set = PETSC_FALSE

 13:   PetscCallA(PetscInitialize(ierr))
 14:   list1(1) = 'a123'
 15:   list1(2) = 'b456'
 16:   list1(3) = 'c789'
 17:   list1(4) = 'list1'
 18:   list1(5) = 'prefix_'
 19:   list1(6) = ''

 21:   write (*, 20) list1(1)
 22: 20 format(A99)
 23:   PetscCallA(PetscOptionsGetEnum(PETSC_NULL_OPTIONS, 'joe_', '-jeff', list1, opt, set, ierr))
 24:   write (*, *) 'opt is ', opt
 25:   write (*, *) 'set is ', set

 27:   PetscCallA(PetscFinalize(ierr))
 28: end program main
 29: !
 30: !/*TEST
 31: !
 32: !   test:
 33: !      args: -joe_jeff b456
 34: !
 35: !TEST*/