Re: Efficient way to pass different shaped arrays?



In article <YpydneFV4JVFwTnZnZ2dnUVZ_r-dnZ2d@xxxxxxxxxxx>,
glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:
John Harper wrote:

(snip)
FORALL(I=1:100,J=1:100) A(I,J) = MERGE(1.0, 0.0, I==J)

OK, but can you do something like:

SUBROUTINE B(array,X)
LOGICAL X
REAL, DIMENSION(MERGE(3,28,X),0:MERGE(0,10001,X)),INTENT(INOUT)::array
to select the appropriate dimensions?

(snip)>
I would say both [that and another suggestion] are pretty ugly, though.

True! IMHO that use of MERGE is an extension to f95 that's OK in
f2003. BTW, both g95 -std=f95 and Sun f95 -ansi allow it, printing
T 666. 666. 666.
with this program:

REAL:: d(3,0:0) = 333.0
CALL B(d,.TRUE.)
END
SUBROUTINE B(array,X)
LOGICAL X
REAL,INTENT(INOUT)::array(MERGE(3,28,X),0:MERGE(0,10001,X))
array = 2*array
PRINT "(L2,(3F5.0))",X,array
END SUBROUTINE B

Presumably Andy and Sun don't want to spend time implementing something
they'd just have to take out again from their f2003 compilers.

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.



Relevant Pages

  • Re: Efficient way to pass different shaped arrays?
    ... John Harper wrote: ... to select the appropriate dimensions? ... My previous suggestion would look something like ...
    (comp.lang.fortran)
  • Re: Complex roots of a non polynomial function
    ... (snip regarding zeros of complex functions) ... root finding, though. ... finding in two dimensions, ...
    (comp.lang.fortran)
  • Re: So why do kids need laptops?
    ... glen herrmannsfeldt wrote: ... at the cash register refused to take it: "It must be counterfeit. ... I asked for the manager. ...
    (comp.dsp)
  • Re: Buffer overflows in C.
    ... it will test subscripts and execute ... of the extensions was precisely to show how C could be improved. ...
    (comp.compilers.lcc)
  • programs writing programs
    ... <SNIP> ... > get their dimensions from parameter statements and a programmer ... I wonder what programs that write Fortran programs Dick Hendrickson ...
    (comp.lang.fortran)