T.R | Title | User | Personal Name | Date | Lines |
---|
1267.1 | | QUARK::LIONEL | Free advice is worth every cent | Tue Apr 22 1997 10:21 | 4 |
| The contents of LIMITS.INC is the same in both cases - what should it be?
I can't tell what the behavior is that you don't understand.
Steve
|
1267.2 | Perhaps this is the answer | WIBBIN::NOYCE | Pulling weeds, pickin' stones | Tue Apr 22 1997 11:19 | 5 |
| Also, what platform (VAX or Alpha) and what version of FORTRAN?
VAX FORTRAN compilers prior to V5 (I think) only checked whether the
final computed address was within the bounds of the array. V5 and later,
and (I think) all Alpha FORTRAN compilers, check each individual subscript.
|
1267.3 | Humblest apologies. | COMICS::EDWARDSN | Dulce et decorum est pro PDP program | Wed Apr 23 1997 04:48 | 13 |
| Sorry, my mistake, cut and paste error.
Second case should be:
$ CREATE LIMITS.INC
integer lim1, lim2
parameter (lim1=3,lim2=1)
and this is with Fortran FORT V6.5-188 on OpenVMS VAX 7.1
I'm having a bad week... make that month.
Neil.
|
1267.4 | | QUARK::LIONEL | Free advice is worth every cent | Wed Apr 23 1997 10:33 | 4 |
| Ah - that's because a last bound of 1 is treated the same as * and is not
bounds-checked.
Steve
|
1267.5 | | TLE::EKLUND | Always smiling on the inside! | Wed Apr 23 1997 10:56 | 14 |
| It is fairly common practice to use a last bound of 1
when the actual bound is something else. The last bound is
not needed in the address computation, and so many lazy
programmers just give 1, as if they had given *. In the 1966
Fortran Standard, * had not yet been invented. Because
of this, we specifically do NOT check the upper bound of
the last subscript if the bound is EITHER * or 1. We check
every other subscript against the actual lower and upper
bounds - at compile time if possible, otherwise at run time
(all assuming /check=bound was specified).
Cheers!
Dave Eklund
|
1267.6 | Is there any way of turning this feature off? | COMICS::EDWARDSN | Dulce et decorum est pro PDP program | Thu Apr 24 1997 10:43 | 5 |
| Can this be turned off?
Would it be possible to request a product enhancement to allow
for the turning off of this feature.
Neil.
|
1267.7 | | QUARK::LIONEL | Free advice is worth every cent | Thu Apr 24 1997 11:17 | 4 |
| Sure, you can request anything. Why is this important? Does your customer
regularly declare arrays with bounds of 1:1? What for?
Steve
|
1267.8 | You have a point. | COMICS::EDWARDSN | Dulce et decorum est pro PDP program | Thu Apr 24 1997 11:45 | 17 |
| After pausing to laugh long and hard I realize that it does, indeed
seem to be a rather peculiar request.
I think that the small example mirrors what they are doing in terms
of their simulation model. I can only assume that the data they collect
may have a number of passes through and that the collected data lives
in an array which is dimensioned by the last number.
Thus, the simulation will always be run at least once and maybe many
times.
Hence the bound checking, since they want to check on only one run
since to perform 2 runs would take much longer to make sure that there
are no bounds inconsistencies in this area.
I think that's what he's doing, I can't be sure. It could even be something
wierd involving parallel universes, but it's probably best not to pry.
|
1267.9 | Adjustable arrays to the rescue | QUARK::LIONEL | Free advice is worth every cent | Thu Apr 24 1997 12:06 | 29 |
| Suggest the following as an alternative, if this is important to them. This
will check all the bounds no matter what they are:
PROGRAM MAINPROG
IMPLICIT NONE
INCLUDE 'LIMITS.INC'
INTEGER I,J
REAL X (LIM1, LIM2)
CALL SUBPROG (X,LIM1,LIM2)
DO I=1, LIM2+1
X (1, I) = 0.0
ENDDO
STOP
END
SUBROUTINE SUBPROG (Y,LIM1,LIM2)
IMPLICIT NONE
INTEGER M,N,LIM1,LIM2
REAL Y (LIM1, LIM2)
WRITE (*,*) ' Subprog array limits = ', lim1, lim2
DO m = 1, lim1+1
DO n= 1, lim2+1
WRITE (*,*) ' accessing array with m, n = ', m,n
y (m,n) = m + n
WRITE (*,*) ' array access ok for m,n = ', m,n
ENDDO
ENDDO
RETURN
END
|