[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Dynamic Loading - F77_FCN and F77_XFCN - compiler warnings
From: |
john |
Subject: |
Dynamic Loading - F77_FCN and F77_XFCN - compiler warnings |
Date: |
Sun, 22 Nov 1998 15:48:14 +0000 (GMT) |
Hello,
I was creating C++ wrapper to call fortran for an Airy function -
C++ attached below.
While compiling I get a series of warnings:
...
...
airy.cc:152: warning: variable `int nc' might be clobbered by `longjmp' or
`vfork'
airy.cc:154: warning: variable `int r' might be clobbered by `longjmp' or
`vfork'
airy.cc:154: warning: variable `int c' might be clobbered by `longjmp' or
`vfork'
/usr/local/include/octave/dMatrix.h:55: warning: variable `int m' might be
clobbered by `longjmp' or `vfork'
/usr/local/include/octave/dMatrix.h:55: warning: variable `int n' might be
clobbered by `longjmp' or `vfork'
...
...
They are something to do with F77_XFCN. Do they matter? Can they be made
to go away?
Thanks
John Smith
-----------------------------------------------------------------------------
//
// Octave routine for a dynamically loadable Airy Function
// Assembled by John Smith, address@hidden, but all the
// clever stuff is done by other people.
// 22 Nov 1998.
//
// Needs to be compiled with fortran routines zairy.f and zbiry.f and
// dependancies, which are available from:
//
// http://www.netlib.org/cgi-bin/netlibget.pl/amos/zairy.f
// http://www.netlib.org/cgi-bin/netlibget.pl/amos/zbiry.f
//
// These files should be renamed zairy.f-orig and zbiry.f-orig,
// and then automatically modified with the sed commands in the Makefile.
//
// I have been using a makefile looking like:
//
// all : airy.oct
//
// airy.oct : airy.cc zairy.f zbiry.f Makefile
// mkoctfile -d airy.cc zairy.f zbiry.f
//
// zairy.f : zairy.f-orig Makefile
// cat $< | \
// sed s/ZSQRT/YSQRT/ | \
// sed s/ZABS/YABS/ | \
// sed s/ZLOG/YLOG/ | \
// sed s/ZEXP/YEXP/ | \
// sed "/DECK I1MACH/,/ END/d" | \
// sed "/DECK D1MACH/,/ END/d" | \
// sed "/SUBROUTINE XERROR/,/ END/d" | \
// cat > $@
//
// zbiry.f : zbiry.f-orig Makefile
// cat $< | \
// sed "/SUBROUTINE ZAIRY/,/ END/d" | \
// sed "/SUBROUTINE ZSQRT/,/ END/d" | \
// sed "/SUBROUTINE ZEXP/,/ END/d" | \
// sed "/SUBROUTINE ZLOG/,/ END/d" | \
// sed "/SUBROUTINE ZDIV/,/ END/d" | \
// sed "/SUBROUTINE ZMLT/,/ END/d" | \
// sed "/SUBROUTINE ZMLRI/,/ END/d" | \
// sed "/SUBROUTINE ZASYI/,/ END/d" | \
// sed "/SUBROUTINE ZACAI/,/ END/d" | \
// sed "/SUBROUTINE ZS1S2/,/ END/d" | \
// sed "/SUBROUTINE ZSERI/,/ END/d" | \
// sed "/SUBROUTINE ZSHCH/,/ END/d" | \
// sed "/SUBROUTINE ZUCHK/,/ END/d" | \
// sed "/SUBROUTINE ZBKNU/,/ END/d" | \
// sed "/SUBROUTINE ZKSCL/,/ END/d" | \
// sed "/DOUBLE PRECISION FUNCTION ZABS/,/ END/d" | \
// sed "/DOUBLE PRECISION FUNCTION DGAMLN/,/ END/d" | \
// sed s/ZSQRT/YSQRT/ | \
// sed s/ZABS/YABS/ | \
// sed s/ZLOG/YLOG/ | \
// sed s/ZEXP/YEXP/ | \
// sed "/DECK I1MACH/,/ END/d" | \
// sed "/DECK D1MACH/,/ END/d" | \
// sed "/SUBROUTINE XERROR/,/ END/d" | \
// cat > $@
//
//
#include <octave/oct.h>
#include "f77-fcn.h"
extern "C"
{
int F77_FCN (zairy, ZAIRY) (double &, // zr argument
double &, // zi
int&, // id derivative ?
int&, // kode scale ?
double &, // air result
double &, // aii
int &, // nz underflow
int &) ; // ierr
int F77_FCN (zbiry, ZBIRY) (double &, // zr argument
double &, // zi
int&, // id derivative ?
int&, // kode scale ?
double &, // air result
double &, // aii
int &) ; // ierr
}
DEFUN_DLD (airy, args, nargout,
"AIRY Airy functions.\n\
W = AIRY(Z) return the Airy function, z a matrix.\n\
W = AIRY(0,Z) as AIRY(Z)\n\
W = AIRY(1,Z) return the derivative, Ai'(z)\n\
W = AIRY(2,Z) return BI Airy Functionm Bi(z)\n\
W = AIRY(3,Z) return the derivative, Bi'(z)\n\
W = AIRY(4,Z) returns Ai(z).exp(z.sqrt(z).2/3)\n\
Similarly AIRY(5,Z), AIRY(6,Z) and AIRY(7,Z) are scaled results\n\
\n\
[W,IERR] = AIRY(K,Z) return also a matrix of error flags\n\
ierr = 1 Illegal arguments.\n\
ierr = 2 Overflow\n\
ierr = 3 Loss of accuracy by argument reduction\n\
ierr = 4 Complete loss of accuracy, z too large\n\
ierr = 5 Algorithm failed to terminate\n\
\n\
")
{
octave_value_list retval ;
ComplexMatrix arg ;
Matrix flags ;
int nargin = args.length() ;
//
// Protective stuff
//
if (nargin != 1 && nargin != 2)
{
print_usage("airy");
return retval ;
}
if (args.length() == 2)
{
flags = args(0).matrix_value() ;
arg = args(1).complex_matrix_value() ;
}
else
{
flags = Matrix( 1, 1, 0.0 ) ;
arg = args(0).complex_matrix_value() ;
}
int arg_rows = arg.rows() ;
int arg_columns = arg.columns() ;
int flag_rows = flags.rows() ;
int flag_columns = flags.columns() ;
//
// More protective stuff
//
if ((arg_rows > 1 && flag_rows > 1 && arg_rows != flag_rows) ||
(arg_columns > 1 && flag_columns > 1 && arg_columns != flag_columns))
{
warning("Incompatible sizes of matrix arguments");
print_usage("airy") ;
return retval ;
}
int nr = arg_rows > flag_rows ? arg_rows : flag_rows;
int nc = arg_columns > flag_columns ? arg_columns : flag_columns;
Matrix errs ( nr, nc, 0.0 );
ComplexMatrix airy_vals ( nr, nc, 0.0 );
int routine ;
double zr ;
double zi ;
int id ;
int kode ;
double air ;
double aii ;
int nz ;
int err ;
for (int i=0; i<nr; i++)
for (int j=0; j<nc; j++)
{
int flag_i = i<flag_rows ? i : 0 ;
int flag_j = j<flag_columns ? j : 0 ;
switch ((int) (flags( flag_i, flag_j)))
{
case 0: id = 0 ; kode = 1 ; routine = 1 ; break ;
case 1: id = 1 ; kode = 1 ; routine = 1 ; break ;
case 2: id = 0 ; kode = 1 ; routine = 2 ; break ;
case 3: id = 1 ; kode = 1 ; routine = 2 ; break ;
case 4: id = 0 ; kode = 2 ; routine = 1 ; break ;
case 5: id = 1 ; kode = 2 ; routine = 1 ; break ;
case 6: id = 0 ; kode = 2 ; routine = 2 ; break ;
case 7: id = 1 ; kode = 2 ; routine = 2 ; break ;
default:
warning("Bad first argument");
id = 0 ; kode = 1 ; routine = 1 ; break ;
}
int arg_i = i<arg_rows ? i : 0 ;
int arg_j = j<arg_columns ? j : 0 ;
zr = arg(arg_i,arg_j).real() ;
zi = arg(arg_i,arg_j).imag() ;
if (routine == 1)
{
F77_XFCN (zairy, ZAIRY, ( zr, zi, id, kode, air, aii, nz, err ));
}
else
{
F77_XFCN (zbiry, ZBIRY, ( zr, zi, id, kode, air, aii, err ));
}
//
// Fix airy results that should be real -
// the scaled airy values are not real for negative arguments
//
if (zi == 0.0 && (kode == 1 || zr >= 0) )
aii = 0.0 ;
airy_vals( i, j) = Complex( air, aii ) ;
errs(i, j) = err ;
}
retval(0) = airy_vals ;
if (nargout == 2)
{
retval(1) = errs ;
}
return retval ;
}
- Dynamic Loading - F77_FCN and F77_XFCN - compiler warnings,
john <=