- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
Recently I'm trying to compile an in-house solver from Windows to Linux. Firstly, I successfully installed Intel Fortran and mkl. However, something is wrong with Qsort_Element_Types when compiling in Linux. The message is :
I used Qsort_Element_Types as follow:
!****************************************************************************
! 功能: 对结构体进行排序,调用Intel库函数
!****************************************************************************
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(2), 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
Function Cmp_Function(C1, C2)
Use Share_Type
Implicit None
Type(Element_Type), Intent(In) :: C1
Type(Element_Type), Intent(In) :: C2
! Function Result:
Integer :: Cmp_Function
Cmp_Function=C1%Elem_N-C2%Elem_N
End Function
How to solve this problem? Any suggestions will be appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're welcome ;). Such constructions were necessary in the past, before we had Fortran 2003's Fortrna-C interfacing facilities, but luckily now we can leave it to the compiler in many cases to get it right.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try without the !DIR ALIAS for non-Windows platforms. I tried a small program without that and it simply worked. My guess is that it is also not required on Windows - the IPFORT module ought to take care of that and you can simply use:
use ifport, only: QSORT_element_types => QSORT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Arjen,
Your suggestion successfully solves my problem. It finally works!
Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're welcome ;). Such constructions were necessary in the past, before we had Fortran 2003's Fortrna-C interfacing facilities, but luckily now we can leave it to the compiler in many cases to get it right.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page