List Info

Thread: calling Fortran code, unresolved symbols




calling Fortran code, unresolved symbols
country flaguser name
United States
2007-04-12 09:28:53
I am trying to call the Fortran routine dbspvd (calculates
B-splines)
from the Slatec library.  Its interface looks like this
(more info at [1]):

      SUBROUTINE DBSPVD (T, K, NDERIV, X, ILEFT, LDVNIK,
VNIKX, WORK)
C     Description of Arguments
C         Input      T,X are double precision
C          T       - knot vector of length N+K, where
C                    N = number of B-spline basis functions
C                    N = sum of knot multiplicities-K
C          K       - order of the B-spline, K .GE. 1
C          NDERIV  - number of derivatives = NDERIV-1,
C                    1 .LE. NDERIV .LE. K
C          X       - argument of basis functions,
C                    T(K) .LE. X .LE. T(N+1)
C          ILEFT   - largest integer such that
C                    T(ILEFT) .LE. X .LT.  T(ILEFT+1)
C          LDVNIK  - leading dimension of matrix VNIKX
C
C         Output     VNIKX,WORK are double precision
C          VNIKX   - matrix of dimension at least (K,NDERIV)
contain-
C                    ing the nonzero basis functions at X
and their
C                    derivatives columnwise.
C          WORK    - a work vector of length (K+1)*(K+2)/2

I have two questions:

1. AFAIK Fortran calls everything by reference, so I need to
pass
pointers.  Would the following be correct?

(alien:def-alien-routine "dbspvd_" c-call:void
  (knots (* integer) :in)		; the knots
  (k (* integer) :in)			; order of the spline
  (nderiv (* integer) :in)		; number of derivatives to
calculate
  (x (* double-float) :in)		; x
  (ileft (* integer) :in)		; interval index
  (ldvnik (* integer) :in)		; leading dimension of the
matrix (usually k)
  (vnikx (* double-float) :in)		; result goes here, dim:
[k,nderiv]
  (work (* double-float) :in))		; work area, length:
(k+1)*(k+2)/2


2. I have compliled the slatec libary and it loads
correctly.  But
when I complile he above code, CMUCL complains about
Undefined foreign
symbol: "dbspvd_" [Condition of type
KERNEL:SIMPLE-PROGRAM-ERROR].  Note that

$ nm -D /usr/local/lib/libslatec.so | grep dbspvd
0020b010 T dbspvd_

What I am doing wrong?

Thanks,

Tamas

[1] http://www.
netlib.org/slatec/src/dbspvd.f


Re: calling Fortran code, unresolved symbols
country flaguser name
France
2007-04-13 16:45:32
>>>>> "tkp" == Tamas K Papp
<tpappPrinceton.EDU> writes:

  tkp> 2. I have compliled the slatec libary and it loads
correctly.  But
  tkp> when I complile he above code, CMUCL complains
about Undefined foreign
  tkp> symbol: "dbspvd_" [Condition of type
KERNEL:SIMPLE-PROGRAM-ERROR].  Note that
  tkp> 
  tkp> $ nm -D /usr/local/lib/libslatec.so | grep dbspvd
  tkp> 0020b010 T dbspvd_

  what does (sys:foreign-symbol-address "dbspvd_")
return?  It is
  possible that the shared library did not in fact load
correctly. 

  BTW you can determine the dependencies of a shared library
by using
  ldd, for example

% ldd /usr/lib/libz.so.1.2.3
        libc.so.6 => /lib/libc.so.6 (0x00002ab17a635000)
        /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)
  
-- 
Eric Marsden



[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )