platform and compiler issues in C


chaynes
12-05-2002, 10:01 AM
I have a program which uses the Powell method to minimize a function. When compiled on my PC using gcc v2.95.3 (under cygwin) I have no problem. However, on a linux machine (Red Hat 7.2 and 7.3) using gcc v2.96 it gives a completely different answer which is mostly garbage.

Printing out the variables and result each time the method is called by Powell shows that the first 3 calls are identical, however after that the output on the linux machine goes bad.

Here is the correct order from my PC:
0.500000 0.250000 0.500000 0.075000 0.075000 : -365.478546
0.25000000 0.50000000 0.07500000 0.07500000 : -365.478546
0.25000000 0.50000000 0.07500000 0.07500000 : -365.478546
0.75000000 0.50000000 0.07500000 0.07500000 : NaN
0.25000000 0.50000000 0.07500000 0.07500000 : -365.478546
0.44098300 0.50000000 0.07500000 0.07500000 : -362.878387
0.34552395 0.50000000 0.07500000 0.07500000 : -355.998749
0.35308057 0.50000000 0.07500000 0.07500000 : -355.805359
0.36081970 0.50000000 0.07500000 0.07500000 : -355.704102
0.39143935 0.50000000 0.07500000 0.07500000 : -356.389862

Here is the incorrect order from the linux machine:
0.500000 0.250000 0.500000 0.075000 0.075000 : -365.478546
0.25000000 0.50000000 0.07500000 0.07500000 : -365.478546
0.25000000 0.50000000 0.07500000 0.07500000 : -365.478546
0.75000000 0.50000000 0.07500000 0.07500000 : nan
0.75000000 0.50000000 0.07500000 0.07500000 : nan
0.74999899 0.50000000 0.07500000 0.07500000 : nan
0.74999899 0.50000000 0.07500000 0.07500000 : nan
0.86803395 0.50000000 0.07500000 0.07500000 : nan
0.74999899 0.50000000 0.07500000 0.07500000 : nan


I also tried compiling on a Sun running Solaris8 with gcc v2.95.2 which gave results similar to my PC. I also tried on Linux (Red Hat 6.2) with egcs-2.91.66 and I got the incorrect results. I am now out of different machines to experiment with, but no closer to an answer as to why the different results.

Any help would be appreciated.

-Chad Haynes