On 11/13/2017 10:20 AM, Adriaan van Os wrote: > brian wrote: >> Anyone with any past experience here? It seems I have two choices, to >> try to call the FORTRAN subroutines from FreePascal or to port the >> FORTRAN code to Pascal, I'm looking for advice... > > It is no problem calling FORTRAN from either C or FreePascal (or at > least not on UNIX-like platforms like Mac OS X, havn't tried for > Windows). The LAPACK package <http://www.netlib.org/lapack/> for > example (also installed in the Mac system software) is written in > Fortran. Some key points: > > 1. Lapack Fortran arrays are column-major (where column elements are > contiguous in memory) > 2. Lapack Fortran arrays are 1-base indexed > 3. Lapack Fortran parameters are always passed by reference, even if > they are value parameters > > So, for example, DGETRF > > ===================================================================== > SUBROUTINE DGETRF( M, N, A, LDA, IPIV, INFO ) > * > * -- LAPACK computational routine (version 3.X) -- > * -- LAPACK is a software package provided by Univ. of Tennessee, -- > * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG > Ltd..-- > * November 2011 > * > * .. Scalar Arguments .. > INTEGER INFO, LDA, M, N > * .. > * .. Array Arguments .. > INTEGER IPIV( * ) > DOUBLE PRECISION A( LDA, * ) > * .. > > > function dgetrf_ > ( constref theNumRows : LapackInt; > constref theNumColumns : LapackInt; > theMatrixPtr : LapackArrayOfDoublePtr; > constref theLeadingDimension : LapackInt; > thePivotIndicesPtr : LapackArrayOfIntPtr; > var theInfo : LapackInt): LapackResult; > cdecl; external; > > where (it's just an example) > > LapackInt = Int32; > LapackLongBool = Int32; > LapackResult = Int32; > LapackDouble = double; > LapackArrayOfIntPtr = ^Int32; > LapackArrayOfLongBoolPtr = ^Int32; > LapackArrayOfDoublePtr = ^double; > > The "constref" for value parameters makes sure they are passed by > reference, which is what Fortram requires. >
Thanks, Adriaan, that's exactly what I needed. :) I'm going to be writing for a Debian platform (I should have mentioned that, the original code is from a Unix minicomputer) so there hopefully shouldn't be a problem. If I can just chunk up some of the FORTRAN code and re-use the calculation routines (which I don't understand anyway, the statistics are at a level that's over my head) then it will make life a lot easier. Brian. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal