LAPACK Archives

[Lapack] Calling lapack from c code


Hello,

yes yes. Your program was written in C and you were using sunperf lapack 
library with SUN LAPACK C interface. Now you want to move to LAPACK from 
Netlib and then you loose the SUN C support.

SUN did a nice job in term of C support for LAPACK. Basically all the 
LAPACK functions have a corresponding C functions with a C name where you 
pass the arguments by value. This feature (support of C) although 
desirable is not in LAPACK from Netlib so you will most likely need to 
deal with the C/Fortran compatibility by yourself.

For the line you gave us, your call should now look like:

[1] #define f77_dgels dgels_
[2] extern void f77_dgels(
        char *trans, int *m, int *n, int *nrhs, double *a,
        int *lda, double *b, int *ldb, double *work, int *lwork,
        int *info );
[3] f77_dgels("N",&(data.n_ind),&(data.n_col),&(ny),data.xwork,
        &(data.n_ind), data.ywork,&(data.n_ind),flag);

[1] is useful to be portable and flexible what the Fortran compiler mangle 
the routine names. Typically g77 will add one underscore, etc.
[2] is the prototype of your function
[3] is the call to the function (Note that 'N' gives "N").

This is basically what you were saying by:

My problem is should i rewrite the code so that the calls to lapack are 
done in the correct manner (the name ending with a _ and with parameter 
passing by refernce)

If you have a few calls to LAPACK routines in your code, you can go ahead 
and change them this way.

Now if this is too much cumbersome or if you feel the C code is going to 
be 'ugly, we do have a project that has started for providing C support. 
Please have a look at:
        http://icl.cs.utk.edu/~delmas/lapwrapc.html
This work is not released in LAPACK yet but might be soon, so any feedback 
from user welcome.

-j





We recently work on this problem




On Thu, 29 Jun 2006, Mahen Jayawardena wrote:

Hi,

I'm trying to do some modifications to a program which was written for 
the Sun solaris platform. The coding also uses some calls for lapack. 
The code works fine on Sun machines. I want to port it to intel/Linux. I 
have installed both lapack and clapack. But am not sure how the 
compiling and linking should be done.

The orginal code calls a lapack routine as:

dgels('N',data.n_ind,data.n_col,ny,data.xwork,data.n_ind,
      data.ywork,data.n_ind,flag);

but the clapack calls a routine in a diiferent manner and passes 
parameters by reference.



My problem is should i rewrite the code so that the calls to lapack are 
done in the correct manner (the name ending with a _ and with parameter 
passing by refernce)

Or is there a way that this can be automated by using somekind of 
fortran-to-c interface and using lapack instead of clapack.

Have never used lapack or done cross language work, so any help is 
greatly appreciated, Also is there some refernce available for this type 
of work? Thanks again

Mahen




<Prev in Thread] Current Thread [Next in Thread>


For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or