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.

Etcetera.

Regards,

Adriaan van Os




_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to