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

Re: Fortran foreign functions



>>Does the foreign function interface in MCL support Fortran code.  
It
>>appears to have direct support for C and Pascal, but does anyone 
have any
>>idea how difficult interfacing to Fortran (i.e. Language Systems 
Fortran)
>>code would be?  I know that this Fortran compiler spits out MPW 
object
>>files, but I suspect that there is more to it than that.
>
>My seive of a brain thinks it remembers someone doing this, but
>I'm not sure about it. FF-LOAD will certainly know how to link
>the Fortran code. The only difficulty I can think of is if the
>Fortran calling sequence is different from C or Pascal. Language
>Systems should be able to tell you about that.

Language Systems Fortran works fine with the FF interface.

The macro defffun, documented in the FF chapter of the MCL manual,
is specific to Fortran and handles the issue of the calling 
sequence (Fortran passes args in reverse order from C).

Some restrictions:

1. I have been unable to get I/O from Fortran or C.
2. I haven't figured out where Fortran FUNCTIONs return their 
values; in all of my code I use Fortran SUBROUTINEs, and modify
the arguments.

By the way,

1.  You can pass arrays of values to C or Fortran by allocating 
memory with _newptr, and carefully filling in/retreiving values 
using %put-long, %get-long, %put-double, and %copy-float.  Use 
type t to describe the argument to defffun/deffcfun, and pass
the pointer.

2.  It is possible to callback from Fortran to Lisp via C.  I 
think I could reconstruct what I did if you need to do this.

Sorry I missed the original post.  I hope this helps.

Greg Anglin
Statistical Computing Laboratory
University of Waterloo