Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28632 Discussions

Dimension passing of imbedded matrices

WSinc
New Contributor I
242 Views

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.

0 Kudos
4 Replies
Steven_L_Intel1
Employee
242 Views

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.

0 Kudos
bmchenry
New Contributor II
242 Views

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.

0 Kudos
WSinc
New Contributor I
242 Views

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?

0 Kudos
Steven_L_Intel1
Employee
242 Views

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.

0 Kudos
Reply