Actual source code: bagenum.F
petsc-3.10.5 2019-03-28
2: #include "petsc/finclude/petscsys.h"
4: #if defined(_WIN32) && defined(PETSC_USE_SHARED_LIBRARIES)
5: !DEC$ ATTRIBUTES DLLEXPORT::PetscBagRegisterEnum
6: #endif
7: Subroutine PetscBagRegisterEnum(bag,addr,FArray,def,n,h,ierr)
8: use,intrinsic :: iso_c_binding
9: implicit none
11: PetscBag bag
12: character(*) n,h
13: character(*) FArray(*)
14: PetscEnum :: def
15: PetscErrorCode,intent(out) :: ierr
16: PetscReal addr(*)
18: Type(C_Ptr),Dimension(:),Pointer :: CArray
19: character(kind=c_char),pointer :: nullc => null()
20: PetscInt :: i,Len
21: Character(kind=C_char,len=256),Dimension(:),Pointer::list1
23: do i=1,256
24: if (len_trim(Farray(i)) .eq. 0) then
25: Len = i-1
26: goto 100
27: endif
28: if (len_trim(Farray(i)) .gt. 255) then
29: PETSC_ERR_ARG_OUTOFRANGE
30: return
31: endif
32: enddo
33: PETSC_ERR_ARG_OUTOFRANGE
34: return
36: 100 continue
38: Allocate(list1(Len),stat=ierr)
39: if (ierr .ne. 0) return
40: Allocate(CArray(Len+1),stat=ierr)
41: if (ierr .ne. 0) return
42:
43: do i=1,Len
44: list1(i) = trim(FArray(i))//C_NULL_CHAR
45: enddo
47: CArray = (/(c_loc(list1(i)),i=1,Len),c_loc(nullc)/)
48: call PetscBagRegisterEnumPrivate(bag,addr,CArray,def,n,h,ierr)
49: DeAllocate(CArray)
50: DeAllocate(list1)
51: End Subroutine