[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
linking fortran subs
From: |
Phil Cummins |
Subject: |
linking fortran subs |
Date: |
Fri, 25 May 2001 13:48:45 +0900 |
Hello,
I am using octave-2.0.16 on a Redhat Linux system.
I am trying to use mkoctave to compile a C++ program
which I can call from octave. The original program is
a C program which calls some routines in a library compiled
from fortran. To call the frotran subroutines I use
pointer arguments, to conform with fortran's pass-by-reference,
and add an underscore after the subroutine names. (there are
also some character string arguments). In any
case the C program works OK.
To convert to a C++ program which I can call from octave,
I followed the famous "oregonator" example in converting
from C to C++. This also works fine, except when I try to
call the fortran subroutines. I find that if I have calls
to these subroutines, there are undefined symbols - e.g.,
I call a fortran subroutine called "assign", which I
call from C as assign_(). But when I try this in the
C++ program using mkoctave, I get error messages about
undefined symbols, as inicated below:
C program function prototype:
void assign_(int *, int *, char *, int);
C program function call statement:
assign_(&unit_10,&mode,"ttim1.lis",9);
Error message after conversion to C++ and called from octave:
/home/cummins/src/seis/ttimes/octtst.oct: undefined symbol:
assign___FPiT0Pci
I looked in the liboctave/dMatrix.cc to see how lapack
routines are called, which lead me to try something like:
Function prototype:
extern "C"
{
int F77_FCN (assign, ASSIGN) (int *, int *, char *, int);
}
and
F77_FCN (assign, ASSIGN) (&unit_10,&mode,"ttim1.lis",9);
But this again gives me undefined symbols:
error: /home/cummins/src/seis/ttimes/octtst.oct: undefined symbol: s_rsue:
/home/cummins/src/seis/ttimes/octtst.oct `FSocttst__Fv'
error: /home/cummins/src/seis/ttimes/octtst.oct: undefined symbol: s_rsue:
/home/cummins/src/seis/ttimes/octtst.oct `_FSocttst__Fv'
error: unable to load functions from /home/cummins/src/seis/ttimes/octtst.oct
I guess it's pretty obvious that I have no clue about how
to use this F77_FCN fortran interface. Can anyone please
tell me, is this what I need to use? And if so, could someone
please point me to some documentation or comments in the
octave source that might help me learn what to do?
Many thanks
-- Phil Cummins
---------------------------------------------------------------------
Phil R Cummins address@hidden
Frontier Research for Subduction Dynamics tel(i/d):81/0-468-67-3393
JAMSTEC, 2-15 Natsushima-cho fax(i/d):81/0-468-67-3409
Yokosuka 237-0061, Japan
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- linking fortran subs,
Phil Cummins <=