Rupert Swarbrick | 1 Dec 2010 01:43
Picon
Gravatar

Fortran ffi question


Hi,

Is it possible to define subroutines with output parameters using the
Fortran FFI? I'm trying to wrap (some of!) arpack[1] and, following the
example in the manual[2], want to do something with DSAUPD.

The interface for DSAUPD is defined at [3], but basically it's a
subroutine that takes loads of parameters, some of which are
input/output.

I tried the following:
USING: alien.fortran kernel ;
FROM: alien.libraries => deploy-library ;
IN: geometry.arpack.ffi

<<
"arpack" "libarpack.so.2" gfortran-abi add-fortran-library
"arpack" deploy-library 
>>

LIBRARY: arpack

SUBROUTINE: DSAUPD
  ( !INTEGER IDO, CHARACTER*1 BMAT, INTEGER N, CHARACTER*2 WHICH,
    INTEGER NEV, DOUBLE-PRECISION TOL, !DOUBLE-PRECISION(*) RESID,
    INTEGER NCV, !DOUBLE-PRECISION(*) V, INTEGER LDV,
    !INTEGER(11) IPARAM, !INTEGER(11) IPNTR,
(Continue reading)

Joe Groff | 1 Dec 2010 02:36
Picon
Gravatar

Re: Fortran ffi question

On Wed, Dec 1, 2010 at 6:13 AM, Rupert Swarbrick <rswarbrick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:


Hi,

Is it possible to define subroutines with output parameters using the
Fortran FFI? I'm trying to wrap (some of!) arpack[1] and, following the
example in the manual[2], want to do something with DSAUPD.

The interface for DSAUPD is defined at [3], but basically it's a
subroutine that takes loads of parameters, some of which are
input/output.

I tried the following:

USING: alien.fortran kernel ;
FROM: alien.libraries => deploy-library ;
IN: geometry.arpack.ffi

<<
"arpack" "libarpack.so.2" gfortran-abi add-fortran-library
"arpack" deploy-library
>>

LIBRARY: arpack

SUBROUTINE: DSAUPD
 ( !INTEGER IDO, CHARACTER*1 BMAT, INTEGER N, CHARACTER*2 WHICH,
   INTEGER NEV, DOUBLE-PRECISION TOL, !DOUBLE-PRECISION(*) RESID,
   INTEGER NCV, !DOUBLE-PRECISION(*) V, INTEGER LDV,
   !INTEGER(11) IPARAM, !INTEGER(11) IPNTR,
   !DOUBLE-PRECISION(*) WORKD, !DOUBLE-PRECISION(*) WORKL,
   INTEGER LWORKL, !INTEGER INFO ) ;

You've got the right idea, Rupert, but there was a bug in the SUBROUTINE: and FUNCTION: parsing words that caused them to define the words with the wrong stack effect. I've pushed a fix.

-Joe

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Rupert Swarbrick | 3 Dec 2010 01:54
Picon
Gravatar

Re: Fortran ffi question

Joe Groff <arcata@...> writes:
> You've got the right idea, Rupert, but there was a bug in the SUBROUTINE:
> and FUNCTION: parsing words that caused them to define the words with the
> wrong stack effect. I've pushed a fix.
>

Brill! I'll keep playing, thanks.

Rupert
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk

Gmane