xref: /petsc/src/sys/objects/ftn-src/optionenum.F90 (revision 02c639afa00e507649aa5bac9084590bf17c181c)
16dd63270SBarry Smith#include "petsc/finclude/petscsys.h"
26dd63270SBarry Smith
36dd63270SBarry Smith#if defined(_WIN32) && defined(PETSC_USE_SHARED_LIBRARIES)
46dd63270SBarry Smith!DEC$ ATTRIBUTES DLLEXPORT::PetscOptionsGetEnum
56dd63270SBarry Smith!DEC$ ATTRIBUTES DLLEXPORT::PetscOptionsEnum
66dd63270SBarry Smith#endif
76dd63270SBarry Smith
8*02c639afSMartin Diehlsubroutine PetscOptionsGetEnum(po, pre, name, FArray, opt, set, ierr)
96dd63270SBarry Smith  use, intrinsic :: iso_c_binding
106dd63270SBarry Smith  use petscsysdef
116dd63270SBarry Smith  implicit none
126dd63270SBarry Smith
136dd63270SBarry Smith  character(*) pre, name
146dd63270SBarry Smith  character(*) FArray(*)
156dd63270SBarry Smith  PetscEnum                   :: opt
166dd63270SBarry Smith  PetscBool                   :: set
176dd63270SBarry Smith  PetscOptions                :: po
186dd63270SBarry Smith  PetscErrorCode, intent(out)  :: ierr
196dd63270SBarry Smith
20*02c639afSMartin Diehl  type(C_Ptr), dimension(:), pointer :: CArray
216dd63270SBarry Smith  character(kind=c_char), pointer   :: nullc => null()
226dd63270SBarry Smith  PetscInt   :: i, Len
23*02c639afSMartin Diehl  character(kind=C_char, len=99), dimension(:), pointer::list1
246dd63270SBarry Smith
256dd63270SBarry Smith  Len = 0
266dd63270SBarry Smith  do i = 1, 100
274820e4eaSBarry Smith    if (len_trim(Farray(i)) == 0) then
286dd63270SBarry Smith      Len = i - 1
296dd63270SBarry Smith      goto 100
306dd63270SBarry Smith    end if
316dd63270SBarry Smith  end do
326dd63270SBarry Smith100 continue
336dd63270SBarry Smith
34*02c639afSMartin Diehl  allocate (list1(Len), stat=ierr)
354820e4eaSBarry Smith  if (ierr /= 0) return
36*02c639afSMartin Diehl  allocate (CArray(Len + 1), stat=ierr)
374820e4eaSBarry Smith  if (ierr /= 0) return
386dd63270SBarry Smith  do i = 1, Len
396dd63270SBarry Smith    list1(i) = trim(FArray(i))//C_NULL_CHAR
406dd63270SBarry Smith    CArray(i) = c_loc(list1(i))
416dd63270SBarry Smith  end do
426dd63270SBarry Smith
436dd63270SBarry Smith  CArray(Len + 1) = c_loc(nullc)
446dd63270SBarry Smith  call PetscOptionsGetEnumPrivate(po, pre, name, CArray, opt, set, ierr)
45*02c639afSMartin Diehl  deallocate (CArray)
46*02c639afSMartin Diehl  deallocate (list1)
47*02c639afSMartin Diehlend subroutine
486dd63270SBarry Smith
49*02c639afSMartin Diehlsubroutine PetscOptionsEnum(opt, text, man, Flist, curr, ivalue, set, ierr)
506dd63270SBarry Smith  use, intrinsic :: iso_c_binding
516dd63270SBarry Smith  use petscsysdef
526dd63270SBarry Smith  implicit none
536dd63270SBarry Smith
546dd63270SBarry Smith  character(*) opt, text, man
556dd63270SBarry Smith  character(*) Flist(*)
566dd63270SBarry Smith  PetscEnum                   :: curr, ivalue
576dd63270SBarry Smith  PetscBool                   :: set
586dd63270SBarry Smith  PetscErrorCode, intent(out)  :: ierr
596dd63270SBarry Smith
60*02c639afSMartin Diehl  type(C_Ptr), dimension(:), pointer :: CArray
616dd63270SBarry Smith  character(kind=c_char), pointer   :: nullc => null()
626dd63270SBarry Smith  PetscInt   :: i, Len
63*02c639afSMartin Diehl  character(kind=C_char, len=99), dimension(:), pointer::list1
646dd63270SBarry Smith
656dd63270SBarry Smith  Len = 0
666dd63270SBarry Smith  do i = 1, 100
674820e4eaSBarry Smith    if (len_trim(Flist(i)) == 0) then
686dd63270SBarry Smith      Len = i - 1
696dd63270SBarry Smith      goto 100
706dd63270SBarry Smith    end if
716dd63270SBarry Smith  end do
726dd63270SBarry Smith100 continue
736dd63270SBarry Smith
74*02c639afSMartin Diehl  allocate (list1(Len), stat=ierr)
754820e4eaSBarry Smith  if (ierr /= 0) return
76*02c639afSMartin Diehl  allocate (CArray(Len + 1), stat=ierr)
774820e4eaSBarry Smith  if (ierr /= 0) return
786dd63270SBarry Smith  do i = 1, Len
796dd63270SBarry Smith    list1(i) = trim(Flist(i))//C_NULL_CHAR
806dd63270SBarry Smith    CArray(i) = c_loc(list1(i))
816dd63270SBarry Smith  end do
826dd63270SBarry Smith
836dd63270SBarry Smith  CArray(Len + 1) = c_loc(nullc)
846dd63270SBarry Smith  call PetscOptionsEnumPrivate(opt, text, man, CArray, curr, ivalue, set, ierr)
856dd63270SBarry Smith
86*02c639afSMartin Diehl  deallocate (CArray)
87*02c639afSMartin Diehl  deallocate (list1)
88*02c639afSMartin Diehlend subroutine PetscOptionsEnum
89