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

parameter definition with a subroutine argument

cep1dm
Beginner
233 Views

Hello,

Ineed to define a parameter(MMAX), with an argument from a subroutine (DISCR_PTS). With it I can afterwards define other variables ( A(NMAX,NMAX) ). The code looks like this:

subroutine MIN(DISCR_PTS)
INTEGER MMAX
PARAMETER (MMAX=DISCR_PTS)
real*8 A(NMAX,NMAX)

I get the following:

Error: This symbol must be a defined parameter or an argument of an inquiry function that evaluates to a compile-time constant. [DISCR_PTS]PARAMETER (MMAX=DISCR_PTS)

I cannot change how A is defined because it is info for a library. DISCR_PTS is an integer defined in an include file.

Can anyone give me a hint on how to solve this?

Thanks, Daniel

0 Kudos
1 Reply
Les_Neilson
Valued Contributor II
233 Views
The simple answer is to just use the dummy argument DISCR_PTS to dimension your array(s) As long as they are local to the subroutine the arrayswill be allocated automatically (and deallocated on exit from the subroutine)
I have in the past,come across stack overflow with automatic arrays for large values ofDISCR_PTS (well my version of it anyway) and so did an explicit allocate(a(discr_pts,discr_pts),stat=istat) for each array at the start of the subroutine.
Les
0 Kudos
Reply