help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I load a fortran routine into Octave


From: John W. Eaton
Subject: Re: How can I load a fortran routine into Octave
Date: Tue, 6 Oct 1998 10:19:08 -0500 (CDT)

On  6-Oct-1998, A. Scottedward Hodel <address@hidden> wrote:

| To call FORTRAN directly from a .cc file (source for .oct), you will need
| to use the macros
|     F77_FCN    (prototype for a FORTRAN function)
|     F77_XFCN    (execute a FORTRAN function)
| each of these are called by routines in the octave liboctave directory.

Due to the lack of documentation, I think there's been some
misunderstanding about the purpose of these macros.  The first is used
to declare prototypes for Fortran subroutines.

Both can be used to call Fortran subroutines.  The difference between
the first and the second is that the second calls setjmp() before
calling the subroutine.  The call to setjmp() is used to provide a
place to jump in case the Fortran subroutine calls XSTOPX().  The
subroutine XSTOPX() is defined in Octave's libcruft library.  Unless
you want your Fortran code to be able to STOP and kill Octave, you
should replace all bare STOP statements with calls to XSTOPX() (for
examples, just grep the libcruft sources for XSTOPX).

So, if the Fortran subroutine you call can end up calling XSTOPX(),
you need to use F77_XFCN.  Otherwise, you can safely use F77_FCN,
which will also be faster, because it doesn't require the call to
setjmp() and copying the jmp_buf context data.

Also, for the F77_FCN and F77_XFCN macros, the assumption is that the
calling sequences are compatible with f2c.  Most Unixy Fortran
compilers are compatible, at least for subroutines.  Functions are
another story, and seem to be handled differently by some big-name
compilers (for example, HP's f77).

FWIW, I know about cfortran.h, but that seemed very complicated at the
time I started working on Octave, and I'm not sure that its copyright
terms are compatible with the GPL (please correct me if I'm wrong, as
it may be worth reconsidering now).

Thanks,

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]