Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

Debugging Fortran routine fails sometimes

tundres
Beginner
485 Views
Hi,
I am calling a fortran routine in a dll from c#. This routine calculate some properties from a system. If the system it's not possible, I get an error code and I try another parameters.
Well, that worked until today, but only in debug mode. Also, in release works as expected and the routine calculate something but in debug mode, the routine give always backan error code.
That's not big deal, if it works in release but still, it's very weird and disconcerting. It is possible that by debugging the results from the fortran routine are different than in release? Should I review the configuration of the compiler?
0 Kudos
3 Replies
TimP
Honored Contributor III
485 Views
Since you haven't given any information to narrow it down, all the usual considerations about debugging such differences are in play, not limited to uninitialized variables and array subscript violations, whether you set /fp:source, do you depend on implicit double precision evaluation of expressions, ...
0 Kudos
tundres
Beginner
485 Views
You are completly right. I set the compiler option Warn for undeclared symbols to yes and...I got 13000 warnings. Many of them for the use of undeclared variables.

If I set the option Local Variable Storage to: All Variables SAVE (Q/Save) it seems to worl better but I don't know yet if it works completly.

I don't understand, why a programmer should use variables without declaration and initialisation...and I don't understand either, why a compiler should allow such a thing.

In any case, thank you to point me to the right direction :)
0 Kudos
Les_Neilson
Valued Contributor II
485 Views
Using variables without declaration :
Fortran has what is known as "implicit typing"
If the programmer does not say what type a variable is (explicit typing)then the compiler chooses a type based on the variable name. If the name begins with one of the letters I,J,K,L,M, or N then it is assumed to be integer, otherwise it is assumed to be real.

Using variables without initialisation :
Some programmers have used compilers/linker/loader that automatically assigned an initial value to variables (0 for integers and 0.0 for real) And then they have continued to assume this practice with other compilers. Unfortunately not alldo this -though theremay bea flag to do so. (cf /Qzero in the help)

/Qsave-from the help :
"If a routine is invoked more than once, this option forces the local variables to retain their values from the last invocation. The save option ensures that the final results on the exit of the routine is saved on memory and can be reused at the next occurrence of that routine."

Read that carefully.It may or may not be what was intended to happen!

Les
0 Kudos
Reply