Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Executable problem Windows 7

adam1fac
Beginner
1,165 Views
Hi,

I am an engineer and only write Fortran programs as and when required. In the past I have used Linux to create my code but in my present job I am using Windows 7. I only need to create a cmd line program to perform some calculations but I have a really basic problem that everytime I create an executable and run it, the cmd prompt instantly closes. This occurs even with a Hello World program!

I can see it completes the statetment in the code, it just closes the cmd prompt before I can see the output. I have have the same problem on either Windows 7 32 or 64bit. Does anybody know how I can resolve this?

Thanks,
Adam
0 Kudos
7 Replies
Arjen_Markus
Honored Contributor II
1,165 Views
This is a consequence of using a program that is running from a graphical user-interface.
The console window exists only for the program's sake and disappears right after the
program finishes.

Open a DOS-box (via Start/Run ..., type "cmd" as the command). That gives you a command
window, like xterm in Linux, that exists independent of any program you run.

Regards,

Arjen
0 Kudos
adam1fac
Beginner
1,165 Views
Ok thanks Arjen, yeah that works. But it is really annoying to have type in the directory each time rather than clicking on an icon. I am sure that on occasions in the past when I have used xp or vista the program launched form the executable itself.
0 Kudos
Arjen_Markus
Honored Contributor II
1,165 Views
Well, there used to be an option/feature that the DOS box would remain open. You had to do that via
the so-called PIF editor. What I normally do, is start the DOS box from my file manager and then
I am in the right directory (that is not possible via "Windows Explorer", AFAIK, but it is via "Total Commander", my personal favourite for working with files on Windows).

Regards,

Arjen
0 Kudos
psantos
Beginner
1,165 Views
Hello adam1fac,

perhaps you can try the following program:

[fortran]Program Hello
   USE IFPORT
   USE IFCORE
   implicit none
   LOGICAL(4)       pressed / .FALSE. /
   write(*,'(A)') 'Hello World!'
   write(*,'(A)') 'Press any key to close ...'
   DO WHILE (.NOT. pressed)   
        pressed = PEEKCHARQQ ( )
        CALL SLEEPQQ (200)
   END DO
End Program Hello[/fortran]

This modified hello program will only exit when you press a keyboard key. Hope this helps.

Pedro
0 Kudos
anthonyrichards
New Contributor III
1,165 Views
..or just program in a 'PAUSE' and it will ask you to press any key to continue...and close the console window.
0 Kudos
Steven_L_Intel1
Employee
1,165 Views
Let me suggest an easy alternative. If you are building from the command line, add /libs:qwin to the ifort command. If you are building in Visual Studio, select "QuickWin" as the project type rather than console. Your program will run when you double-click the EXE and the console output will appear in a window which will stay around until you request that it be closed.
0 Kudos
peterklaver
Beginner
1,165 Views
Quoting adam1fac
Ok thanks Arjen, yeah that works. But it is really annoying to have type in the directory each time rather than clicking on an icon. I am sure that on occasions in the past when I have used xp or vista the program launched form the executable itself.

In Windows 7, you can over a folder in the Explorer window, and that brings up a menu that includes "Open command window here". That will save you some typing, although Steve's suggestion is (not surprisingly) the most elegant.
0 Kudos
Reply