Re: F2CL ODEPACK problems.

Raymond Toy <[email protected]> Tue, 17 Aug 2004 17:00:17 -0400
Newsgroups gmane.lisp.clocc.general
Message-ID <[email protected]>
>>>>> "Marco" == Marco Antoniotti <[email protected]> writes:

    Marco> Hi


    Marco> I think I got another problem with odepack-lsode.

    Marco> I wrote the following routine, which, AFAIU, is a translation of the
    Marco> Fortran example given in the main opkdmain.f file from netlib (sorry if
    Marco> it is long.)

[snip]

    Marco> I tracked down this error to the DPREPJ routine in the call to the JEX
    Marco> local function, which expects a 2D array, but it seems to get a 1D array
    Marco> slice.

    Marco> Is this the correct diagnosis?  Is this a Fortran trick to pass around
    Marco> things that can be seen of different shapes at different times?

You are correct.  All arrays in Fortran are in column-major order,
which doesn't fit well with Lisp's (and C) row-major order.  Thus, in
f2cl, all arrays are converted to 1D arrays.  You will have to do the
same thing.  (It might have been beneficial to take the Fortran
example and run f2cl over it to see what happens.  And then write your
own lisp version.)

You can use the fref and fset macros to access the multi-dimensional
arrays.  In Fortran, if you have an array with dimensions x(8,10), and
you want to access element x(1,2), you can use 

    (fref x (1 2) ((1 8) (1 10)))

(I think.)  The last arg there gives the upper and lower bounds on the
dimensions of the array so that fref can access the right element.
(Fortran arrays can have negative indices.)

Let me know if this solves your problem.

Ray





-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285