本帖最后由 joezhr 于 2021-12-31 10:01 编辑
前辈好,很抱歉这么久才回复。以下是相关代码和报错信息,感谢您的帮助!
[Fortran] 纯文本查看 复制代码 Subroutine Qsort_Cell_Faces
Use OpenFoam, ONLY: Cell_Faces
Use,Intrinsic :: Iso_C_Binding, ONLY : C_Size_T
Use Ifport ! To Get Qsort
Use Share_Type
Interface
Subroutine Qsort_Element_Types(Array, Len, Isize, Comp)
Use, Intrinsic :: Iso_C_Binding, Only:C_Size_T
Use Share_Type
Type(Element_Type) Array(Len)
Integer(C_Size_T) Len, Isize
Integer, External :: Comp
!DIR$ IF DEFINED(_WIN64)
!DIR$ ATTRIBUTES ALIAS: 'QSORT' :: QSORT_element_types
!DIR$ ELSE
!DIR$ ATTRIBUTES ALIAS: '_QSORT' :: QSORT_element_types
!DIR$ ENDIF
End Subroutine Qsort_Element_Types
End Interface
Integer Lines
Type(Element_Type),Allocatable :: C(:)
Integer, External :: Cmp_Function
Integer (C_Size_T) :: Size_Of_Element, Size_Of_Array
Integer I
Lines=Size(Cell_Faces,1)
Allocate(C(Lines))
! 数组--派生(结构体)
Do I=1,Lines
C(I)%Elem_N = Cell_Faces(I,1)
C(I)%Face_N = Cell_Faces(I,2)
End Do
Size_Of_Array = Size(C)
Size_Of_Element = Sizeof(C(1))
Call Qsort_Element_Types(C, Size_Of_Array, Size_Of_Element, Cmp_Function) ! 结构体排序
! 派生(结构体)--数组
Do I=1,Lines
Cell_Faces(I,1)= C(I)%Elem_N
Cell_Faces(I,2)= C(I)%Face_N
End Do
Return
End Subroutine
|