Re: Implementing JAVA interfaces in FORTRAN 20xx



On 26 août, 01:33, e p chandler <e...@xxxxxxxx> wrote:
On Aug 25, 8:17 pm, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx> wrote:



e p chandler wrote:

(snip)

Please explain how this does any real good in Fortran at all. As I
understand it, you can not pass an array of integers to a routine
which expects an array of elements, each of which is of derived type,
each of which consists only of an integer.

In Java, you can't have arrays of objects, but only
arrays of object reference variables. The closest you
would get in Fortran would be arrays of pointers.
Oops, no arrays of pointers, arrays of structures
containing pointers.

Now, can you use a pointer to integer equivalently
to a pointer to a structure containing only an
integer? Or one with the integer at the beginning?

-- glen

I just want to

call wonder_routine(int_array)

where int_array is an ordinary array of integers. I don't care what
the routine does underneath. I do know that I get a type mismatch
error when I pass an array of integers to a routine expecting an array
of a derived type.

So right now I'm close to serious mirth when what I thought was a
relatively straight forward question about Fortran is answered in
terms of Java _and_ the properties of pointers in C! :-)

- e

You might try to solve the problem with an equivalence :

TYPE :: integer_type
SEQUENCE
INTEGER :: value
END TYPE

integer :: vector(10)
type(integer_type) :: other(10)
equivalence (vector,other)

!.. you fulfill vector

CALL wonder_routine(other)
.



Relevant Pages

  • Re: qsort and arbitrary types
    ... > There is a C library routine called qsort which can be passed ... > an array of arbitrary type, the length of the array, the ... The qsort routine passes such pointers without ...
    (comp.lang.fortran)
  • Re: a history question
    ... >> arrays of pointers. ... > (especially if it can be circumvented easily with a derived type)? ... There is simply no syntax for declaring an array of pointers. ... This is the declaration of a pointer to an array. ...
    (comp.lang.fortran)
  • Re: qsort and arbitrary types
    ... > It may, or may not, be related to pointers in Fortran. ... > an array of arbitrary type, the length of the array, the ... The qsort routine passes such pointers without ... is it possible to write such data type ...
    (comp.lang.fortran)
  • Array of pointers as a component of a derived type
    ... an array of pointers cannot be implemented ... we have a derived type A ... Changing the sequence ...
    (comp.lang.fortran)
  • Re: Parsing parameters of User Defined types
    ... or find documented examples of how to initialize an array ... of a derived type. ... it is still a continuous string subject to line continuation limits. ...
    (comp.lang.fortran)