- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello adam1fac,
perhaps you can try the following program:
This modified hello program will only exit when you press a keyboard key. Hope this helps.
Pedro
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
..or just program in a 'PAUSE' and it will ask you to press any key to continue...and close the console window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page