kathy@HUEY.UDEL.EDU (Kathy Minnich) (09/20/85)
we're running VMS 4.1 with FORTRAN 4.2. one of my users is complaining about receiving different results from his fortran program when he runs it with the /nooptimize switch. he claims that the program will run slower (about 6 hours instead of 4 hours) and that the results differ. (he is working with random numbers, but says that the difference is very noticable.) if anyone knows in fact that this a bug with the optimization, then please let me know ... my user is now thinking that he's wasted over a month's worth of computer time because of the varying results and doesn't quite know which set to trust. thanks for any comments/information, kathy
kfield@BBNJ.ARPA (Ken Field) (09/20/85)
I have isolated a problem in a Fortran program (that we did not write) that ran ok under VMS 3.x but exhibited strange behavior under VMS 4.1. This may be of interest to those of you who are complaining about changes in results from Fortran programs under VMS 4.1. The problem is with a statement of the form if (a() .and. b) then ... where 'a()' is a function call that returns a logical value and 'b' is a logical variable. The function 'a' also has some side- effects. The problem is that the compiler (when run with the /optimize switch) generates code to check the value of 'b' first, and if 'b' evaluates to .false., then 'a' is not evaluated, leaving the side-effects undone. (Under VMS 3.x, 'a' was always evaluated.) I should note in the compiler's defense that the function 'a' is really only an entry point in another function and is never actually declared to be a function (as I said, I didn't write this program...). -Ken
stew%lhasa@HARVARD.HARVARD.EDU (09/20/85)
Fortran programs which rely on the order of evaluation of expressions are in error. Checking a variable before calling a function in a logical expression like (a() .and. b) is a valid and valuable optimization. If you must ensure that function a() is always called, make it two separate if's or call it and save the value before testing. Stew