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

Stop the world, my program wants to get off...

IanH
Honored Contributor II
334 Views
A feature request masquerading as a question... when running from within Visual Studio without debugging (i.e. via menu path Debug > Start without Debugging under VS2005) - whether the console window stays open at the end of the program (with the "Press any key to continue . . ." message) seems to depend on how the program ended. Is this by design? If so, what exactly is the design and what is the rationale for it?

Here's a little program to demonstrate what I'm talking about. The options marked with a star result in the console window rudely absconding at program termination under VS2005 and the VS2008 shell.

[fortran]!> A program that ... stops!

PROGRAM FullStopAhead

  IMPLICIT NONE 
  
  CHARACTER(*), PARAMETER :: fmt_a = "(A)"
  CHARACTER :: option 
  
  !*****************************************************************************  
  
  loop_the_loop: DO
    ! Gently instruct the user.
    PRINT fmt_a, 'Choose one of the following ways of terminating this &
        &program:'
    PRINT fmt_a, '  A - end-program-stmt'
    PRINT fmt_a, '  B - stop-stmt with no stop-code'
    PRINT fmt_a, '  C - stop-stmt with a stop-code of 0'
    PRINT fmt_a, '  D - stop-stmt with a stop-code of 1 (*)'
    PRINT fmt_a, '  E - stop-stmt with a stop-code of &
        &''scalar-default-char-constant-expr'''
    PRINT fmt_a, '  F - error-stop-stmt with no stop-code (*)'
    PRINT fmt_a, '  G - error-stop-stmt with a stop-code of 0'
    PRINT fmt_a, '  H - error-stop-stmt with a stop-code of 1 (*)'
    PRINT fmt_a, '  I - error-stop-stmt with a stop-code of &
        &''scalar-default-char-constant-expr'' (*)'
    
    ! Get their selection.
    READ fmt_a, option 
    
    ! Upper case their selection.  
    IF (LGE(option, 'a') .AND. LLE(option, 'z'))  &
        option = ACHAR(IACHAR(option) - (IACHAR('a') - IACHAR('A')))
    
    ! Act on their selection.
    SELECT CASE (option)
    CASE ('A'); EXIT loop_the_loop
    CASE ('B'); STOP
    CASE ('C'); STOP 0
    CASE ('D'); STOP 1
    CASE ('E'); STOP 'scalar-default-char-constant-expr'
    CASE ('F'); ERROR STOP
    CASE ('G'); ERROR STOP 0
    CASE ('H'); ERROR STOP 1
    CASE ('I'); ERROR STOP 'Reactor meltdown detected - stop &
        &debugging and start running!!!'
    END SELECT
    
    ! Provide positive feedback to the user.
    PRINT fmt_a, 'Reading comprehension or basic keyboarding skills &
        &failure detected.  Replace user and try the operation again.'
  END DO loop_the_loop
END PROGRAM FullStopAhead
[/fortran]


How are the console windows being kept open after the process has terminated? Is there a little helper process/batch file or similar acting as an intermediary?
0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
334 Views
IanH,

It appears from your *'d and non-*'d comments that if you report "success" the console window stays open, conversely if you report "error" the window goes away (including error message). Terminatiion w/rt to consol window's presistance should be consistant. The O/S may be interfering with this.

Jim Dempsey
0 Kudos
jimdempseyatthecove
Honored Contributor III
334 Views
IanH,

I forgot to mention that the way I handle this is to launch a CMD (console) window with the IVF context (something like Start | Programs | Intel | Intel Visual Fortran Command Window). Then leave that open along with Visual Studio. Type the command in once, observe results or error message. Click in IDE, make edits, compile, Click in Console Window, hit Up-Arrow (returns last command), edit if reqired (e.g. change parameter), Enter. Repeat as necessary.

If you have a Notes.txt in your solution file, you can copy/paste the command line into there for use after reboot. Don't forget that you can also use BATCH (CMD scripts) files to launch your test sessions. With batch files you can program in permutations of run time arguments.

Note, that for a console window, when your program is outputting pertanant text,you can right-click on the title bar and mark© console textto clip board. Then dump this into your IDE Notes.txt or other place such as CheckThis.txt then use Excel and open text file as comma delimited or column delimite text. You can then run totals, charts etc...

Jim Dempsey
0 Kudos
Steven_L_Intel1
Employee
334 Views
VS uses a mechanism similar to what I illustrate in this article. In your case, I think that any non-success exit from the program makes the window go away.
0 Kudos
Reply