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

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

Francesco_B_3
Beginner
320 Views

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 Kudos
3 Replies
mecej4
Honored Contributor III
320 Views

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 Kudos
IanH
Honored Contributor II
320 Views

or...

ifort fred.f90 && fred.exe

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
320 Views

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 Kudos
Reply