Actual source code: ex8f90.F90

      1: !
      2: !   Example of getting an enum value from the options database in Fortran

      4: #include "petsc/finclude/petsc.h"
      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:       Call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
     14:       if (ierr .ne. 0) then
     15:         print*,'Unable to initialize PETSc'
     16:         stop
     17:       endif
     18:       list1(1) = 'a123'
     19:       list1(2) = 'b456'
     20:       list1(3) = 'c789'
     21:       list1(4) = 'list1'
     22:       list1(5) = 'prefix_'
     23:       list1(6) = ''

     25:       write(*,20) list1(1)
     26: 20    format(A99)
     27:       call PetscOptionsGetEnum(PETSC_NULL_OPTIONS,'joe_','-jeff',list1,opt,set,ierr);CHKERRA(ierr)
     28:       write(*,*) 'opt is ', opt
     29:       write(*,*) 'set is ', set

     31:       Call PetscFinalize(ierr)
     32:       end

     38: !
     39: !/*TEST
     40: !
     41: !   build:
     42: !      requires: define(PETSC_USING_F2003) define(PETSC_USING_F90FREEFORM)
     43: !
     44: !   test:
     45: !      args: -joe_jeff b456
     46: !
     47: !TEST*/