[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More fortran to oct help
From: |
Paul Thomas |
Subject: |
Re: More fortran to oct help |
Date: |
Sat, 27 Mar 2004 08:22:33 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 |
Zine Smith wrote:
The help regarding T96 into Octave was great. Thank
you. I am having some trouble thought getting
everything to link and I have reached my end. The ld
error I'm getting from mkoctfile and the wrapper c++
code is below. Thank you for your help
Zine
-----Error------
$ mkoctfile tsyganenko96.cc T96.f
tsyganenko96.o(.text+0x107c): In function
`_Z4Ft96RK17octave_value_listi':
/home/SmithZB/dev/Tsyganenko/tsyganenko96.cc:48:
undefined reference to `_t96_'
collect2: ld returned 1 exit statu
Zine,
The version below did it for me, with fortran subroutine T96ONE - your
undefined reference to _t96_ comes about because you invoke t96 in
F77_FUNC and F77_XFCN. You sent the linker scurrying off to find a
symbol _t96_, which it was unable to find. Args 1 and 2 should be
lower case and uppercase versions of the name of the fortran subroutine.
Paul T
#include <octave/oct.h>
#include <octave/f77-fcn.h>
extern "C"
{
int F77_FUNC (t96one, T96ONE)\
(const int& IOPT,\
const double* PARMOD,\
const double& PS,\
const double& X,\
const double& Y,\
const double& Z,\
const double& BX,\
const double& BY,\
const double& BZ);
}
DEFUN_DLD (t96, args, ,\
"- Loadable Function: [Bx, By, Bz] = t96 (PM, Ps, x, y, z)\n\
\n\
Inputs: PM\t-\tArray(10) with Solar wind pressure in nanopascals in
PM(1)\n\
Dst index in PM(2)\n\
By of the IMF in PM(3)\n\
& Bz of the IMFin PM(4)\n\
Ps\t-\tGeotilt angle in radians\n\
x,y,z\t-\tGSM position (RE)\n\
Outputs: Bx,By,Bz\t-\tMagnetic field at x,y,z" )
{
octave_value_list retval;
const int dummy_integer = 0;
Matrix PM;
const double x=args(2).double_value(),\
y=args(3).double_value(),\
z=args(4).double_value();
const double Ps=args(1).double_value();
double Bx, By, Bz;
PM = args(0).matrix_value();
F77_XFCN (t96one , T96ONE,\
(dummy_integer, PM.fortran_vec(), Ps, x, y, z, Bx, By, Bz));
if (f77_exception_encountered)
{
error ("unrecoverable error in t96");
return retval;
}
retval(0) = octave_value(Bx);
retval(1) = octave_value(By);
retval(2) = octave_value(Bz);
return retval;
}
-------------------------------------------------------------
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
-------------------------------------------------------------