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

Is there any option in the intel fortran compiler (ifort) to compile and run the executable automatically after compiling?

Francesco_B_3
初学者
792 次查看

I know that it is possible to compile in IVF from CMD by using the ifort command. However, that command only compiles and does not run the executable upon finishing compiling. The .exe needs to be run sequentially by hand.

Is there any automatic option in the ifort driver to compile and run the .exe automatically?

Thanks in advance.

0 项奖励
3 回复数
mecej4
名誉分销商 III
792 次查看

This is trivial to do by writing a batch file. For example, file run.bat could contain:

ifort %1.f90
%1

and you could use it as

run hello

It is possible to expand this to account for the failure of the compilation, by deleting %1.exe before compiling, testing for the existence of %1.exe, etc.

0 项奖励
IanH
名誉分销商 III
792 次查看

or...

ifort fred.f90 && fred.exe

 

0 项奖励
jimdempseyatthecove
名誉分销商 III
792 次查看

Batch files are fine for simple compile and run situations. As your compile requirements get more complicated (many source files, different libraries, etc...) consider using MAKE or NMAKE as this is what these tools are designed to do.

Another option you have is the CMD processor has a command history capability. By entering UpArrow or DownArrow you can navigate through the command history. This will save you retyping the command the second time.

Jim Dempsey

0 项奖励
回复