- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody. I am trying to debug a code containing 33000 lines which has been developed in earlier fortran compilers. Running this code in Visual Studio 2010 reveals a series of problems/errors. For instance, the values of certain variables change when I put a write statement in the code. As soon as I remove (comment) the line the value of the variables changes back. Can anyone help me and tell me what the source of problem would be.
I think there are un-initialized (or undefined) variables in the code which results to this behavior. If this is so, can anyone tell me what the best way is to detect them or force the compiler to give error compilation in these cases.
I appreciate the the helps.
Thanks
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use IMPLICIT NONE in ALL routines.
it will start with a mess of errors, but will be well worth the effort to clean them up
same goes for common blocks/modules/etc. I expect it has common blocks? since you say 'earlier fortran compilers'
which one would that be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
..and also remember that local variables are not automatically SAVEd between calls by the INTEL compiler, so if the code depends on values being saved between calls to a routine, you have to put SAVE at the start of the routine. The Compaq/Digital Fortran compiler automatically SAVEd variables. Module variables retain their values as a matter of course. Remember also that Initialisation of memory locations can differ between DEBUG and RELEASE runs of the same code (as they do with Visual Studio and Intel compiler), so you can get different results for that reason also, if uninitialised variables exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hadi,
did you consider the use of the compiler option /check:uninit ? That will cause an error message during runtime if a variable is undefined
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was impressed by Dave Barker's presentation:
http://www.nas.nasa.gov/hecc/assets/pdf/training/UnInit_Fix_your_code_2012_10_31.pdf
Unfortunately, it's based on linux (does Windows need to be more difficult?)
The general idea of causing signaling NaN to trap seems good.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have Intel Fortran Studio XE, Intel Parallel Studio XE or Intel Cluster Studio XE, you can use the Static Analysis feature to do a whole-program correctness check including for uninitialized variables. The compiler's run-time checking is somewhat limited. Anthony has some good advice above.
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