This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: guile and Fortran?


>>>>> "Paul" == Paul Emsley <Paul.Emsley@chem.gla.ac.uk> writes:

    Paul>        I have an old fortran library that I would like to
    Paul> extend with guile (i.e, I want to write scheme programs that
    Paul> use these functions).

    Paul>       What is the best/quickest (hopefully the same) way of
    Paul> doing this?

I've found the easiest way is to wrap the functions in C and then use
swig to wrap the C for guile.  That sounds a little convoluted, but
since SWIG lets you have inline functions it's not bad.

The basic swig code looks something like this.

%inline{
void yoursub(int ivar, float rvar) {
     yoursub_(&ivar,&rvar);
}
%}

would wrap

      subroutine yoursub(ivar,rvar)
      return
      end

I've wrapped a lot of code like this and it's worked pretty well.

Cheers,
Clark

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]