help-octave
[Top][All Lists]
Advanced

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

Re: Fortran


From: Przemek Klosowski
Subject: Re: Fortran
Date: Tue, 15 May 2001 10:50:12 -0400

   How can I dinamically link my FORTRAN functions with Octave? In the manual 
only a
   C++ function is described and I don't know how to write a C++ wrapper
   funtion (because I don't know C++....).

You can pretty much write C in a C++ file. Take a template of an
octave external C++ function (there's a short example 'oregonator.cc')
in the octave source distribution, and change it for your needs. It
is compiled with the command 'mkoctfile' which is also provided w/octave.

 Linking FORTRAN to octave may vary depending on your platform; different
compilers use different conventions for passing parameters and results.
It's not difficult, just tedious:

        - all parameters are passed to and from FORTRAN by reference,
          and need to be declared as pointers in C/C++          

        - Fortran may prepend or append underscores to function names;
          You can check it by compiling a FORTRAN routine and looking
          for symbols  it defines:

                cat a.f
                      subroutine a
                      end
      
                g77 -Wall -c a.f
                nm a.o
                 00000000 T a_              <--- G77 appends underscores
                 00000000 t gcc2_compiled.

        - fortran strings might be passed funny: g77 uses the convention
          of passing by reference, and appending an integer argument holding
          the length of the string (passed BY VALUE) to the end of FORTRAN 
          argument list. The above is from memory--I might have gotten the
          details slightly wrong.

Perhaps Octave has some mechanism that takes care of some of these details---
I haven't needed FORTRAN in a while. Can anyone help?


        przemek



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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