- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
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?

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page