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

I need help with a fortran foreign function problem.



I have defined the following _simple_ fortran subroutine:

      real*8 function square(x)
      real*8 x

      square = x*x
      end

I compiled this to the file Simple.f.o with Language Systems Fortran.

      FORTRAN Simple.f

Then, in MCL I executed the following

(ff-load
    #P"Simple.f.o"
    :libraries '(#P"FORTRANlib.o")
    :ffenv-name 'fortran
    :replace t)

(defffun (square "SQUARE")
  ((double-float :double :by-reference))
  :double :stack)

Both of these statements execute without a hitch.  However when I call the
function, I get some strange results:

? (square 3.0)
7.082514406397959E-305
?

Can anyone explain how I can get the subroutine's return value properly.  I
have succeeded in calling other subroutines and passing arguments by
reference to compute values, but I would like to be able to use functions
as well.

I wasn't sure if my problem was on the MCL side or the Fortran side...

--Thanks.