Re: declaration order



<tholen@xxxxxxxxxxxx> wrote in message
news:ikeevo$qfv$1@xxxxxxxxxxxxxxxxxxxx
"robin" <robin51@xxxxxxxxxxx> writes:

This is old-fashioned code.
Better to define ARRAY as REAL :: ARRAY ( : )
Then you have:
SUBROUTINE SAMPLE (ARRAY)
IMPLICIT NONE
REAL :: ARRAY( : )
INTEGER :: N
N = UBOUND(ARRAY,1)

I'm unfamiliar with UBOUND. When was it introduced in the standard?


2003 I think.

Problem with this advice however, is that it (the "(:)" dimension for
ARRAY) requires that the subroutine has an "Explicit Interface". This is
best achieved by putting subroutine sample into a module, and USEing the
module in the calling code. There is nothing at all wrong with doing this,
in fact I reccommend it.

....So why did I call it a "problem"?

BECAUSE, if you don't make the interface explicit, the code won't do what
you want. It may fail to compile if you're lucky, or it may crash during
execution if you are less lucky. And if you're completely out of luck, it
will run with no apparrent problem, but produce the wrong answer.

--
Qolin

Email: my qname at domain dot com
Domain: qomputing


.



Relevant Pages