linking with intel fortran

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
karose
Posts: 3
Joined: Wed Nov 26, 2008 6:07 pm

linking with intel fortran

Post by karose »

I am a new used to Zeus and want to use it for fortran coding. This may be a dumb question but I cannot get my code to link by using the command line under the compiler options.

I am using Intel fortran and I can get the code to compile and link in a dos window. I first have to execute the ifortvars.bat in the dos window but then it works fine.

The command line within the compiler in Zeus is:
c:\"Program Files"\intel\Compiler\Fortran\10.0.025\IA32\Bin\ifort $FN

The code compiles but then no linking to get an executable.

I am sure I am just missing something easy.

Thanks

Kenny
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi Kenny,
I first have to execute the ifortvars.bat in the dos window but then it works fine.
Compiler/linker environments that need a setup batch file to be run first can be a little more problematic to configure :(

The good news is they can be configured quite easily by wrapping the setup batch file within a special compiler/link batch file :)

For example this is how I get Zeus to compile a c/c++ file using the MSVC++ compiler.

The MSVC++ compiler is similar in that for the compile and link to work the vsvars32.bat needs to be run first to setup the environment. Below is the batch file code that I use to make this work within Zeus.

Assume the following batch code lives in a file calle zcc.cmd and it is saved to the Zeus install directory:

Code: Select all

@echo off

rem Setup the build path details
call "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"

rem Check for a temp folder (note: MSVC needs a temp folder)
if not exist d:\temp\ goto next1
set tmp=d:\temp
set temp=d:\temp

:next1
rem Check for a temp folder
if not exist c:\temp\ goto next2
set tmp=c:\temp
set temp=c:\temp

:next2

rem Name a file to capture the errors
set ErrorFile=%1.err

rem Delete the error file if it exists
if exist %ErrorFile% del %ErrorFile%

rem Run the build
cl.exe -W4 %1 > %ErrorFile%

rem Display the error output
if exist %ErrorFile% type %ErrorFile%

rem Delete the error output file
if exist %ErrorFile% del %ErrorFile%
Now to get Zeus to compile a MSVC c/c++ file all that needs to be done is set this batch file as the compiler option for the c/c++ document type as follows:

Code: Select all

zcc.cmd $fn
The $fn becomes the %1 variable of the batch file and the compiler errors are written to $fn.err error file. At the end of the batch file the errors file is then piped to standard output and hence will also be displayed inside of Zeus ;)
The command line within the compiler in Zeus is:
c:\"Program Files"\intel\Compiler\Fortran\10.0.025\IA32\Bin\ifort $FN

So to make this work for your Fortran environment I would guess all you need do is change this batch file slightly.

Change these lines of the batch code:

Code: Select all

rem Setup the build path details
call "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
to be something like this:

Code: Select all

rem Setup the build path details
call "c:\Program Files\intel\Compiler\Fortran\10.0.025\IA32\Bin\ifortvars.bat"
to these lines of batch code:

Code: Select all

rem Run the build
cl.exe -W4 %1 > %ErrorFile%
to be something like this:

Code: Select all

rem Run the build 
ifort.exe -options %1 > %ErrorFile%
Where -options shown above represents any extra command line options that you may need to give the fortran compiler.

If there are no extra options then the command line should be something like:

Code: Select all

rem Run the build 
ifort.exe %1 > %ErrorFile%
This may be a dumb question but I cannot get my code to link by using the command line under the compiler options.

To get the linker to work I would create a second linking batch file similar to the zcc.cmd above. You could then create a workspace for you Fortran project and add this linker batch file to the build options of the Workspace, Options menu.

One final hint is to use the Options, Editor Options menu and turn on the Debug tools, macros and executables option. With this option enabled Zeus will send the command lines to the Zeus debug output window.

When I have a DOS command line that is not working inside Zeus, what usually helps is copying the command from the Zeus debug window, opening a DOS prompt using the Zeus Tools, Dos Shell menu and then try running the command at the DOS prompt command line ;)

Cheers Jussi
Last edited by jussij on Fri Nov 28, 2008 5:00 am, edited 1 time in total.
karose
Posts: 3
Joined: Wed Nov 26, 2008 6:07 pm

almost

Post by karose »

This works in that it now compiles and links, except $FN is not recognized as a macro. IFORT looks for a file with the name "$FN".

It works when I put the exact file name in place of the $FN in the batch program.

I have modified your batch program, and then I put the "C:\zeus\newbatch.cmd" in the command line under the compile tab.

Maybe I should it somewhere else? You mention a default document type.

So almost there. Is there a reason the $FN would not be recognized as zeus macro command?

Thanks
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

This works in that it now compiles and links, except $FN is not recognized as a macro. IFORT looks for a file with the name "$FN".

That was a typing error on my part. I have corrected my post above with the correct information.
It works when I put the exact file name in place of the $FN in the batch program.
The %1 will also contain the exact file name.
Maybe I should it somewhere else? You mention a default document type.
If you put the command in the compiler option of the fortran document type it means that when ever you use the compiler compile menu inside a fortran document the batch file will be used.

If you put the command in the default document type it means that whenever you use the compiler, compile menu inside a document that does not define a compiler option or does not belong to a document type then this batch file will be used.

So the best place to put it is in the Fortran document type.

But the thrid options is to define a workspace and put the compile/build options there:

http://www.zeusedit.com/forum/viewtopic.php?t=33
Is there a reason the $FN would not be recognized as zeus macro command?

Just my bad typing ;)

Cheers Jussi
Post Reply