Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Parameter passing and Interfaces

$
0
0

Greetings,

I can't seem too get the behavior I want in the following case.

I have an interface that looks like this:

      INTERFACE
        SUBROUTINE SUBA(PA_FP)
          REAL(4) PA_FP(:)
        END SUBROUTINE
      END INTERFACE

When I call that subroutine using a 1D Array, everything compiles and works fine.  However, if I have a 2D array and I call the subroutine as such:

REAL(4) ARRAY2D(10,20)

C Some code...

DO I = 1, 20
  CALL SUBA(ARRAY2D(1,I))
END DO

I get a compile error #6634: The shape matching rules of actual arguments and dummy arguments have been violated.
 

Clearly, the interface defines the parameter as a 1D array but by passing the parameter as I did above, I'm actually passing the address of a scalar.  So I tried calling it like this, instead:

REAL(4) ARRAY2D(10,20)

C Some code...

DO I = 1, 20
  CALL SUBA(ARRAY2D(:,I))
END DO

The compiler is now happy, but I'm not getting the expected behavior from within SUBA.  SUBA does not see the proper array content.

Note that without the interface definition, the first method works just fine.

So what's the proper way of calling SUBA in the case of a 2D Array, such that SUBA "sees" the 1D array only?

Steve?

(hey, it's always you ;) )

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles