Re: passing only the real parts of a complex array to a function



Kamaraju Kusumanchi <kk288@xxxxxxxxxxx> wrote:
(snip)

call increment(real(b, DP))
(snip)

subroutine increment(p)
implicit none
real(DP) :: p(3)
p(:) = p(:) + 1.0_DP
end subroutine increment


When a subroutine is called with an expression instead
of a variable (scalar or array) the called routine can't
change the argument, and even if it was allowed, that wouldn't
change the components of the expression.

Even PL/I pseudo-variables won't do this, though you
can do some other interesting things with IMAG() in PL/I, one
of my favorite being a DO variable:

X=0;
DO imag(x)=1 TO 100;
PUT SKIP LIST(X,SQRT(X));
END;

in PL/I will print a table of square roots of imaginary
numbers, but it won't work as a subroutine argument.
(At least I don't think it will.)

Use a temporary array, assign the values to it, pass that
array, and then get the returned values out.

-- glen
.



Relevant Pages

  • newbie: passing parameters to subroutine
    ... I am trying to use an array to hold the results of a subroutine. ... the value I get back in the calling function is not the same ...
    (comp.lang.fortran)
  • Re: g95 wish list
    ... (big snip on dimension of (1) ... > have a bounds check which fails if the subroutine references X. ... allowing the full dimension information to be ... > the possibility of a check as to whether you passed an array of size 2 ...
    (comp.lang.fortran)
  • Re: passing functions or subroutines in a subroutine
    ... They are not quite as general as function pointers in C, ... a DIMENSION statement which would make it an array. ...
    (comp.lang.fortran)
  • Re: PL/I CAN - #9
    ... >>Does it generate a temporary array intermediate? ... > This does reverse the array. ... are used immediately in PL/I. ...
    (comp.lang.fortran)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)