Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29235 Discussions

General question re: porting between PC and Linux

mdfischer
Beginner
591 Views
I have been given some code that was originally run on PC, compiled using Visual Fortran. I have been charged with porting this code to Linux (compile using pgf77) and getting the output to match as closely as possible. I've gotten everything working, but the output still varies greatly (more than 10% difference) between the 2 versions. I think I have it narrowed down to a single max calculation:

In the PC version, there is a line something like:

variable = max1(variable, 0.0)
where variable has been declared as real.

When I run the code with max1, my output averages 10% low. When I change this to max, my output averages 10% too high. I'm hoping there is some middle ground I can get to somehow! I'm sure it has something to do with how each compiler treats max and max1, but I'm not sure about that kind of stuff. I was hoping someone might have a suggestion?

Thanks
Michele
0 Kudos
2 Replies
Steven_L_Intel1
Employee
591 Views
MAX1 truncates the result to integer, so that would definitely affect the result. I think you're going to have to analyze the intermediate results to see where the difference appears. I can't imagine that the compilers you're using treat MAX/MAX1 differently.

Steve
0 Kudos
mdfischer
Beginner
591 Views
Ok, I've looked a little further into this problem and I have a little more information. I think I've figured out what is going on, I just can't figure out why:

I've placed a few write statements within my code, it generally looks like this:

---------------------------------------------------

Do i=1,42

some calculations involving variable

write (*,*) variable
variable = MAX1(variable,0.0)
write (*,*) variable

Enddo

---------------------------------------------------

So let's say that before the MAX1 statement, variable is 100. For some reason, after the MAX1 statement variable becomes -100. But this only happens on the final iteration of the do-loop. And this only happens in the Linux version, not the PC. I have no idea why this happens. Does anybody else?

0 Kudos
Reply