PRINCIPAL: CN=Henry Zongaro/OU=Toronto/O=IBM
FormName:
SwipeFrom: Henry Zongaro/Toronto/IBM @ IBMCA
ValidationTesting: 0
oldfrom: CN=Henry Zongaro/OU=Toronto/O=IBM
Hi Wes,
The various Fortran standards permit the evaluation of the two
sub-expressions "K.GT.0" and "X(K).GT.0." to occur in any order, so the
correct way to guard the evaluation of X(K) would be to write:
IF (K .GT. 0) THEN
IF (X(K) .GT. 0.) THEN
. . .
Having said that, XLF normally generates "short-circuit" code for
logical expressions that should have protected the evaluation of X(K) by
the check for K > 0. Because this behaviour isn't required by the
standard, this is something that should only be relied on for performance
benefits - not to enforce a certain order of evaluation or to ensuring
guarding occurs.
There could be a bug in the compiler if the code as written is producing
an error. Could you send me a small complete test case that demonstrates the
problem along with any options you're using, and also let me know which
version of the compiler you're using.
Thanks,
Henry
--------------------------------------------------------------------
Henry Zongaro XL Fortran/XL HPF Compiler Development
IBM SWS Toronto Lab Tie Line 778-6044 Phone (416) 448-6044
Internet id: [log in to unmask]
[log in to unmask] on 02/12/97 08:07:26
Please respond to [log in to unmask] @ internet
To: [log in to unmask] @ internet
cc:
Subject: IF evaluation
A problem I have had more than once, but most recently using xlf:
The following statement
IF (K.GT.0 .AND. X(K).GT.0.) THEN
produces an error condition when K=0 and X is dimensioned in a normal way,
i.e., 0 is an invalid subscript for X.
My question is whether this behavior is a violation of the FORTRAN standard.
Thanks, Wes
Dr. W. J. Metzger Experimental High Energy Physics Group
tel. +31-24-3653127 Faculty of Natural Sciences
+31-24-3652099 (secr.) University of Nijmegen
fax. +31-24-3652191 Toernooiveld 1
telex 48228 wina nl 6525 ED Nijmegen, The Netherlands
e-mail: [log in to unmask] or [log in to unmask]
or [log in to unmask] [log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|