Re: Fortran assumed-shape array problems with MPI



On May 30, 7:46 pm, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx> wrote:
Jane Smith wrote:

(snip)

I think that I did not explain my problem very well.
The exact situation is I try to pass an array X(3, 5, 7, 9) to a
subroutine
and declare that array inside the subroutine (dummy argument) as
X(:, :, :, :),

You mean like CALL SUB(X(3,5,7,9))?

In that case it just passes the one element to the called routine.

CALL SUB(X)

passes the whole array, including the dimensions.

CALL SUB(X(3:5,2:3,4:7,5:9))

passes a subarray of the appropriate starting and ending bounds.

Also, you should have an interface so that the calling
routine knows that it is passing as an assumed shape
array. This is most important.

and when I tried to access, say, the value of X(1,2,2,2) inside the
subroutine, it gives a message
"Subscript out of range" and shows a message that the array vector has
lower bound=1,
upper bound=1, dimension=1, which means that it is recognizing X as a
scalar argument.
The ANL webpage that I posted above expresses this problem as
" An MPI subroutine with an assumed-size dummy argument may be passed
an actual scalar argument. "

This is a different problem. First, this is for assumed size
arrays and is for MPI routines, that is, those that belong to
the MPI system. It is not legal in Fortran, but likely works
much of the time, to pass a scalar variable in place of a one
element array. Note that it is legal in C, where MPI originated.
(That is, a pointer to a scalar is equivalent to a one element
array.)

by which I think they meant that MPI-using fortran recognizes

> assumed-shape dummy-argument array as a scalar.
> Does anybody know of a good solution other than passing

the bounds to the subroutine together?

-- glen

Hi, I still think that I mis-explained my problem.
So, here is the new post.
----------------------------------------------------------------------
Hi, I am using fortran 90 (PGI) with MPI (mpif90) and I faced a
situation that fortran mis-recognizes an assumed-shape dummy
argument as a scalar.

The situation that I faced is as follows. I have an array called
X, with bound (1:3, 1:5, 1:7, 1:9). And, it is put in a subroutine
called SUB, by calling 'CALL SUB(X)'. In the subroutine,
instead of declaring X as dimension(3,5,7,9), I declared it as
(:, :, :, :) (assumed-shape array).
And, when I tried to access an element of X, say, by putting
a=X(1,2,2,2), it showed the message that the index is out of
range, saying that X has upperbound=lowerbound=dimension=1.

And, I found in the ANL webpage that the failure of assumed-shape
array in fortran with MPI is known.

Is anybody aware of a solution to this problem other than passing
the bounds together and putting the exact bounds inside, i.e.,
is there any way to use the assumed-shape dummmy argument array
with MPI?

Do we need an interface to use assumed-shape array ? (I thought
that it is a common feature in fortran 90). What interface do we need?




.



Relevant Pages

  • 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)
  • 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.basic.visual.misc)
  • 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.basic.visual.misc)
  • Re: memory leak help!
    ... a loop from the main program. ... REPLACE THE NEW COMPLEX INTO ORIGINAL ARRAY x ... END OF SUBROUTINE SCEUA ... IMPLICIT NONE ...
    (comp.lang.fortran)
  • 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)