I'm porting my Xeffort GUI library from Visual Fortran to FTN95 (among other compilers). The code uses a lot of 'smart' non-standard tricks (since VF has pretty much full capabilites of C language) and I'm trying to find out how to find equivalent constructs in FTN95.
In order to achieve as much as portability in 'main' code, I decided to implement my own version of ISO_C_BINDING module in favor of Cray pointers. I had to use some cheats to make it work on 'implementation' side. For example, here's how I build up a pointer to array of TYPE(X_POINT)'s: [pre] !***Low-level implementation (VF-specific) ***
!======================================= SUBROUTINE C_F_POINTERArray(cPtr, fPtr, iDim, iSizeOf)
TYPE VF_DIMENSION SEQUENCE INTEGER iExtent INTEGER iDistance INTEGER iLowerBound END TYPE VF_DIMENSION
TYPE VF_1D_DESCRIPTOR SEQUENCE INTEGER(INT_PTR_KIND()) lpAddress INTEGER nSize INTEGER iOffset INTEGER iAllocated INTEGER iRank #ifdef __INTEL_COMPILER INTEGER iWhatever #endif TYPE(VF_DIMENSION) Dim1 END TYPE VF_1D_DESCRIPTOR
INTEGER, PARAMETER:: VF_EXISTING = Z'03000001' INTEGER, PARAMETER:: VF_SECTPTR = Z'00000002' INTEGER, PARAMETER:: VF_OWNMEMORY = Z'00000004'
INTEGER(INT_PTR_KIND()):: cPtr TYPE(VF_1D_DESCRIPTOR):: fPtr INTEGER, INTENT(IN):: iDim INTEGER, INTENT(IN):: iSizeOf
fPtr%lpAddress = cPtr fPtr%nSize = iSizeOf fPtr%iOffset = -iSizeOf fPtr%iAllocated = VF_EXISTING fPtr%iRank = 1 #ifdef __INTEL_COMPILER fPtr%iWhatever = 0 #endif fPtr%Dim1%iExtent = iDim fPtr%Dim1%iDistance = iSizeOf fPtr%Dim1%iLowerBound = 1
END SUBROUTINE C_F_POINTERArray !================================== !***Interface to the rest of the code ***
MODULE ISO_C_BINDINGS
INTERFACE C_F_POINTER ... MODULE PROCEDURE C_F_POINTER_POINTS ... END INTERFACE
!======================================= SUBROUTINE C_F_POINTER_POINTS(cPtr, fPtr, iShape)
INTEGER(C_POINTER):: cPtr TYPE(X_POINT), POINTER:: fPtr(:) INTEGER, INTENT(IN):: iShape(:)
TYPE(X_POINT):: xPt INTEGER(C_CHAR):: Mold
INTERFACE SUBROUTINE C_F_POINTERArray(cPtr, fPtr, iShape, iSize) USE ISO_C_BINDING_TYPES USE XFTTYPES INTEGER(C_POINTER):: cPtr TYPE(X_POINT), POINTER:: fPtr(:) INTEGER:: iShape INTEGER:: iSize END SUBROUTINE C_F_POINTERArray END INTERFACE
CALL C_F_POINTERArray(cPtr, fPtr, iShape(1), SIZE(TRANSFER(xPt, (/Mold/))) )
END SUBROUTINE C_F_POINTER_POINTS
!=================================== !***Finally, F2003-like call ***
USE ISO_C_BINDING
TYPE(X_POINT), POINTER:: xMinMax(:)
CALL C_F_POINTER(lParam, xMinMax, (/5/)) [/pre] Now, to do the same in FTN95, I need to know the low-level format of FTN95 array-descriptor (namely, format of a pointer-to-array), as well as the calling convention (VF passes a reference to VF_1D_DESCRIPTOR structure, and I'd expect that similar mechanism is used in FTN95). Is this information available?
-- Jugoslav