Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Command Lines

teclis77
Beginner
4,097 Views
I found some differences from an executable file generated by Visual Fortran and by Compiler Fortran with the same sources files, dll and static libraries.
In the command prompt I simply use

ifort *.f /libs:dll my_dynamic_libraries.lib /link my_static_libraries.lib

but I found some substantial differences...

How can I know which is the complete command lines used by Visual Studio?

Best Regards

Teclis
0 Kudos
22 Replies
Les_Neilson
Valued Contributor II
3,535 Views

If you are usingVS 6 you could look at the .plg file generated by a build.

In theVS 7 IDE you can look at Project -> Properties and under the Fortran option and the Linker option there are Command Line entries. Also you can look at the buildlog.htm file(s) for similar info to the plg files

Les

0 Kudos
Steven_L_Intel1
Employee
3,535 Views
The project log shows the compile command used. You can also look at the Fortran project properties, Command Line page, and it will show you all the compiler options used.
0 Kudos
teclis77
Beginner
3,535 Views
Even if I use the same command lines (copied from the log file, i.e. BuildLog.htm), one to generate obj files and the other to link the obj files, with the same sources files, I found the same differences in my results...

How is it possible?

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
Perhaps you have uninitialized variables? Perhaps you're using a different compiler in the IDE than on the command line?

Add /watch to the command line (you can do this on the command line property page in VS) and compare the path of the compiler being invoked.
0 Kudos
Intel_C_Intel
Employee
3,535 Views
Hello,
With unitialized variable a given executable can give different numerical results depending on how/when it is being executed. For example execution from DOS-prompt, TextPad or Visual Studio, may give entirely different results, simply because such a program is dependent on arbitrary values in memory that may be different in different execution environments. Or, execution at a later instant may give different results.
Regards,
Lars Petter Endresen
0 Kudos
teclis77
Beginner
3,535 Views
Hello,
I verified that from DOS-prompt and Visual Studio the calculation results are different, even if the executable file is the same.
Considering the fact that I am calling some DLL and some Static Libraries, do you think that I have to check the initialization of local variables starting only from the DLL ones? or I have to check all the local variables?

Teclis
0 Kudos
Les_Neilson
Valued Contributor II
3,535 Views

Youwould be wise torecompile and link everything with as many warnings on as possible. Particularly run the programfrom VS indebug mode so that if there are any uninitialised variables (it sounds very much as if that is the problem here) then you can catch and fix them easily and quickly.

You didn't say which version of VS you are using but :

In VS 6 look at Project->Settings->Fortran->Compilation Diagnostics there is a tick box for Uninitialised variables, and some other useful options too.

Also Fortran->Run Time for Array and string bounds plus under/overflows

In VS2003 look at Project->Settings->Fortran->Diagnostics (and Run Time) for the same sort of switches.
Les
0 Kudos
teclis77
Beginner
3,535 Views
Hello,
(I have an Intel Fortran 9.0 and Visual Studio .Net 2003)
I found a more specific problem...
If I run the exectuable file in the Visual Fortran Enviroment or in the Command Prompt Enviroment (only cmd.exe) I found the right results; but if I run the executable file in the Fortran compiler - DOS/prompt (/K ""..IntelCompilerFortran9.0IA32BinIFortVars.bat"") I found wrong solutions.

I tried to eliminate each SET line in IFortVars.bat, till I left it blank, but I found always wrong results.

So I delete the "/K" option, and I found right results, but I don't know the meaning of that option and I cannot compile my source files.

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
/K means keep the environment changes when the batch file ends.

My guess is that there's perhaps a PATH issue, with perhaps different DLLs being loaded in the different environments.
0 Kudos
teclis77
Beginner
3,535 Views
I check all the ifortvars.bat lines, and I found that my executable program works well when I hide (with a rem) the follow call

@call ".Microsoft Visual Studio .NET 2003Vc7BinVcvars32.bat"

How is it possible? In the Visual Studio enviroment my executable works well, while when I use the same bat-file (Vcvars32.bat) it doesn't work...

Moreover that file has only one command, able to point to another file bat, vsvars32.bat, where there are many sets.

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
It's adding something to PATH so that it is finding a DLL from the command line that it isn't finding in the IDE (or is finding a different one.)

Download Dependency Walker and run it on your program both with and without the call to vcvars32.bat. Note any DLLs that have a different path.
0 Kudos
teclis77
Beginner
3,535 Views
Sorry, but I don't understand how Dependency Walker works, i.e. how I can open the exe file in the two different enviroment. I want to say, I open the exe file in Dependency Walker, but I simply open , without any enviroment.

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
From the command line, type:

depends.exe /f:1 path-to-your-exe

In the Module pane, right click and choose Select all. Then right click and Copy File Paths. Paste this to a text file. Repeat the process from a command session that called vcvars32.bat. Compare the files.
0 Kudos
teclis77
Beginner
3,535 Views
We don't find any differences using depends.exe (in both enviroments).

But, analyzing the structure of the vsvars32.bat we find that commenting out one (or both) of the two first file rows the program works in the correct way. The two lines are reported in the following:

@SET VSINSTALLDIR=D:ProgrammiMicrosoft Visual Studio .NET 2003Common7IDE
@SET VCINSTALLDIR=D:ProgrammiMicrosoft Visual Studio .NET 2003

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
Are those variables defined if you comment those out?
0 Kudos
teclis77
Beginner
3,535 Views
No, both the variables are not set if commented out.

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
I'm left to conclude that there's an uninitialized variable somewhere in your program.
0 Kudos
teclis77
Beginner
3,535 Views
How can I check if I have some uninitialized variables?

Teclis
0 Kudos
Steven_L_Intel1
Employee
3,535 Views
Either debug it or add code that dumps out intermediate values to see where the results start to diverge. That will give you a clue as to where the problem is.
0 Kudos
teclis77
Beginner
3,416 Views
If you are sure that I have to initialize all the variables, do you think that this problem come from local variables of the main (or from other *.f files) or from local variables of my dynamical libraries?

Teclis
0 Kudos
Reply