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

Using a batch file (instead of ifort) to execute the compiler in Visual Studio

ferrad01
Beginner
1,742 Views
Is there any way to tell VS2008 to use a different method to invoke the ifort compiler? We have a client who requires us to compile our files for them using a batch file (acomp.bat) they have provided. I guess it basically does a bunch of stuff, calls ifort, then does more stuff afterwards. I don't necessarily want to have to get into what it does.

In our old batch build system, this is easy as I just replace ifort with icomp.bat in the build process' batch files. However I am porting this to Dev Studio 2008 and want to tell devenv to use icomp.bat instead of ifort.
0 Kudos
8 Replies
Arjen_Markus
Honored Contributor II
1,742 Views
You can use the Intel Fortran compiler outside of VS2008 - I do that a lot for small programs (I find using VS 2008 for programs of one source file a bit heavy).

I simply open a DOS box described as "Fortran Build Environment for IA-32" from the Start menu
and then the environment variables are set to the correct values.

The secret is that ifortvars.bat is run with the argument "ia32". You find that in the bin subdirectory
of the installation directory. If you include that batch file in "icomp.bat", then it should work fine.
(Probably best to putsetlocal/endlocal commands in there to prevent the environment from growing
each time you invoke icomp.bat)

Regards,

Arjen
0 Kudos
ferrad01
Beginner
1,742 Views
Thanks Arjen, that's essentially what I have already: a build environment outside of VS2008. However I'm trying to standardize all our build systems to use VS2008, but this particular build falls a little outside the rules.
0 Kudos
Arjen_Markus
Honored Contributor II
1,742 Views

Ah, that was not clear to me - I can not help with that particular type of question.

Regards,

Arjen

0 Kudos
Steven_L_Intel1
Employee
1,742 Views
It may be possible to do this, but I haven't tried it. The key is that VS will issue the "ifort" command in an environment where PATH is set up using the list of directories shown under Tools > Options > Intel Visual Fortran > Compilers > Executable Files. If you could arrange it so that this list had an added folder at the top which contained an ifort.exe or ifort.bat which then did what you wanted, it might work. Your substitute "ifort" would need to pass along the complete command line.

A problem I see is that your client's acomp.bat is probably not prepared to get a long list of options as VS will supply. Is there perhaps another way to accomplish this by having a "Custom Build Step" or maybe a Pre-Buid and Post-Build event?
0 Kudos
ferrad01
Beginner
1,742 Views
I am using the Custom Steps to do the link, as they have a special alink.bat as well. This is OK as I just use their alink.bat in the pre-Link step and throw away the results of the regular link. However I can't do the compilation step this way as this requires executing acomp.bat for each of the source files. I suppose I could put the entire list of Fortran files in the pre-Link step, but that sounds horribly messy.
0 Kudos
Steven_L_Intel1
Employee
1,742 Views
What does this batch file do? I haven't played with this too much, you may be able to do something with a custom build step which can run a specified command on an indivisual source file, though I think it is only a file that it doesn't already know what to do with.
0 Kudos
ferrad01
Beginner
1,742 Views
I dissected the compiler batch file and extracted the compiler arguments. I have put those into Visual Studio and used ifort, and I'm checking now to see if that works. In terms of the link batch file, I can't dissect that so I'm using their link as a pre-link step, whcih seems to work. The real link fails, but I don't need it. It would be good if I could avoid performing this link somehow.
0 Kudos
ferrad01
Beginner
1,742 Views
Back to this: is there any way to cleanly stop the build process after the PreLink Event? ie. to not do the actual link. At the moment I force an ErrorLevel 1 which stops the Build.
0 Kudos
Reply