The obsolete Fortran 66 statement
pause had various behaviors depending on the operating system and compiler.
pause was used for three different purposes in the Fortran 66/77 era:
- (most common use) program waits forever, until the user pressed the Enter key, ignoring typed input.
- wait for user to type text on
stdin, assigning the typed text to a variable.
- (very old programs) drop to a system shell, allowing any shell command to be used
Modern Fortran “pause” replacement
Each of the three styles above can be replaced with unambiguous modern Fortran 2018 code.
Wait till Enter
In this case, the program merely waits for the Enter key, ignoring any console input.
use, intrinsic:: iso_fortran_env, only: stdin=>input_unit print *, 'Now I am waiting for you to push Enter.' read(stdin,*)
The program then proceeds.
Wait till user input
In this case, the program stores user-typed text into a variable.
use, intrinsic:: iso_fortran_env, only: stdin=>input_unit character(80) :: userinp print *, 'Type something at me, then push Enter.' read(stdin,*) userinp
Execute system command
This is a dangerous practice, I can’t see any modern use for it, so I’m omitting this example. In general to execute system commands from Fortran use