Question

I have a very odd problem related to the Portland Group FORTRAN 90 compiler. I am trying to run a code that relies on array overflow to work properly. I did not write this code! The originators had to compile it with the flag "-tp=piii" to force the compiler to refrain from optimizations that defeated the array overflow. I guess the idea is that compilers written for the old P3 were too primitive to do this sort of thing. Now, when I try to do the same thing, I get the message "pgf90-Fatal --tp piii is not supported in this installation." So I can't do the same thing.

So: Does pgf90 in its default operation defeat the sort of array overflow the code needs? The people I am working with obviously think it does. And, if it does, could there be some other flag(s) I could use to get what I need from the "-tp=piii" flag?

Bet you never thought you would get a question like this! Just think how I feel. And yes, I will be re-writing it as soon as I can convince my keepers to let me do it.

Was it helpful?

Solution

I'm no longer familiar with the PGI compiler and don't have its documentation to hand so can't guide you directly to the compiler option you want, but it will be indexed under something like array bounds or bounds checking.

Until Fortran 90 it was common practice to write code which ignored, or was ignorant of, array bounds. Much of the code that was written that way is still out in the wild and I (like most Fortran programmers) come across it regularly. Sadly (that's argumentative) so is the attitude that it is an acceptable way to write code; if I meet the attitude out in the wild I terminate it with extreme prejudice.

Rant over ... it is the default behaviour of at least some of the Fortran compilers currently in widespread use to not automatically generate code which, at run-time, has a tantrum when the program steps outside an array's boundaries. However, all of them will have an option to generate code which does include bounds checking at run-time.

Not checking array bounds at run time generally means faster code and most Fortran users are very interested in faster code which goes some way to explaining the default behaviour of compilers.

So, to conclude, you shouldn't have too much trouble reproducing the required behaviour of the code you've inherited. I'll be a little surprised if the PGI compiler doesn't default to not checking array bounds; but it will definitely have an option for switching the feature on or off.

OTHER TIPS

Just in case anyone ever runs into the same problem with the "piii" flag, recent PGI compilers do support this flag .... if you have the 32-bit libraries installed. And, as it turns out, I do not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top