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

Dimension passing of imbedded matrices

WSinc
Neuer Beitragender I
585Aufrufe

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 Antworten
Steven_L_Intel1
Mitarbeiter
585Aufrufe

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.

bmchenry
Neuer Beitragender II
585Aufrufe

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.

WSinc
Neuer Beitragender I
585Aufrufe

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?

Steven_L_Intel1
Mitarbeiter
585Aufrufe

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.

Antworten