- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am writing to signal the following problem that I have bumped into. I am trying to run a program that I wrote some time ago and the following happens:
- Before purchasing the Intel compiler I was using a Lahey Fujitsu compiler and the program ran fine producing correct results
- Now that I am using the same program (with the necessary changes to link the IMSL subroutines) with Ifort the prgram still compiles correctly
- It also runs correctly until the last two subroutines
- The last subroutines produce unexpectedly some NaN output.
- The program uses large arrays and I have noticed that if I increase the size of the stack memory the problem with the “NaN” output gets milder, but it does not vanish altogether (with this I mean that there are fewer instances where the final two subroutines produce an “NaN” output)
Given the above I suspect that the problem may be that I am using more memory than Intel fortran can handle but since I don’t know much about its inner working I don’t know if my diagnosis is correct and I know even less regarding how I could fix the problem.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I doubt memory size is the problem. I suggest you look for variables that have not been initialised or incorrect argument lists for the routines (unless all are contained in modules - then the number and types of arguments can be checked of course). Increasing the stack means that the memory layout changes, which could affect the memory location and the contents thereof for uninitialised variables. If memory size was a problem, you would have seen messages about access violation and the like, not so much NaNs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Arjen suggest it is probable that your code has some bugs that remained hidden with the old compiler. Compile with /traceback /check:uninit which will throw errors if you use variables that have not been given a value. You can then locate and fix them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, indeed some of the elements in an array were not initialized. I believe the old compiler simply initialized to 0 everything that was not explicitely initialized and that's why I had not realized of the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is a well-known problem :). Fortran very explicitly guarantees no automatic initialisation will occur. Of course, memory management and compiler options may change that - as you have experienced - but the essence is that no such thing occurs, unless you explicitly do so. You can therefore not rely on variables having a value zero, they can in fact have any odd value, but it can be tricky to find the location in the code. Or even realise there is a problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use compiler flag /Qinit:zero which might 'fix' the problem. IMO this is just a quick bandage to apply whilst the proper cure is worked on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that you also have to set /Qinit:arrays for arrays to be zero-initialized with /Qinit:zero.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page