Dimension passing of imbedded matrices

Dimension passing of imbedded matrices

My understanding is that I can leave out explicit enumerstion of imbedded matrices

in the argument list. How does the called routine know the dimensions of the matrix?

Of course with Fortran 77, that feature was not available, but is with Fortran '95

Example with a 3x3 imbedded matrix:

REAL*8 A(20,20),SUM

CALL SUM_IT( A(3:5,5:7) , SUM)

END

SUBROUTINE SUM_IT(A,SUM)

REAL*8 A(:,:),SUM

SUM=0.0

DO IRA=1,NRA

DO ICA=1,NCA

SUM=SUM+A(IRA,ICA)

END

--------------------------------------------------------------------------------------------------------------

Now, how would the subroutine be able to get the quantities NRA and NCA?

I think there is a function I can call.

Is that the usual way to get those quantities?

I realize there is a SUM function, but this is just a simple example.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The language requires that you provide an "explicit interfsce" for SUM_IT that is visible to the caller because SUM_IT has an assumed-shape argument. The code you show does not do that and it is not legal. Typically you would put SUM_IT in a module and USE the module, or you can make it a CONTAINed routine.

The intrinsics you want are LBOUND and UBOUND.

Steve - Intel Developer Support

ive run across that double posting...not sure what's causing it...

anyhow try the Shape function. Size only returns number of elements,

see help file for details on Shape.

I understand the use of CONTAINS or USE, as Steve pointed out.

But how do the LAPACK math routines get around having to do that?

Is that a special trick they use?

Is that their special USE statement?

The LAPACK F77-interface routines require you to pass the individual array bounds.  The "F95 interface" routines require a USE that provides the explicit interface.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today