I have a Fortran project that uses an iterative method for solving a nonlinear set of model equations. At each step, the algorithmic steps work towards driving the difference between successive iterates towards zero. Convergence is declared when the relative difference is small enough ex. 1.0E-05.
When running this project with MSVS2017 and IVF 18.104.22.168 [IA-32], the iterative process begins to stagnate after a few iterations and the relative difference does not go below 0.01. However, when running the same project from the IA-32 command line, the successive iterations converge rapidly to a relative error that is below 1.0E-05 to 1.0E-06. Are there any suggestions for what may be causing this discrepancy? I do not want to make algorithmic refinements unless I have to.
The command line compile options (same as those in the MSVS2017 project) are:
/nologo /debug:full /Od /warn:interfaces /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /Qm32 /c
First, are you certain that you are using the exact same compiler? Take off /nologo and change the option in Visual Studio to show the compiler version. Second, how certain are you that the command options are the same? You can go to the Command line property page in VS and see what the options there are.
A third possibility is that a bug in your program is sensitive to the order in which objects are linked, for example a reference to uninitialized memory. Compiler checks won't always find these.
My usual advice in these situations, once the above issues have been ruled out, is to instrument the program so that it writes intermediate state to a file. Run the program both ways and compare the outputs to see where things start to diverge. This will let you zoom in on the key calculation (hopefully there is just one!) that is responsible for the difference, and that will likely give you a clue as to how to resolve it.
I investigated options1,2,3 and did not find any differences between the settings for the command line vs the IDE. There is only one compiler installed on my computer and only one main program linking to a library. The command line compile option was taken from the IDE. Could the floating point options ex. /fp:precise, /fp:source etc. be an issue although none of these have been explictly changed from the default in the IDE or command line?
Check to see if the DLL's used are the same for each environment.
Consider using "Process Explorer".
for an example of using Process Explorer to locate the DLLs as used by the process Outlook.exe.
(you change the instructions to explor YourProgram.exe as it is run in each environment).
Note, the Process Explorer will show the DLLs as used, not as referenced/called.
as used == what actually was loaded via path search
as referenced == name of, but not path to