'Is there anything like a "WAIT" function in Fortran?
I would like to create a Fortran program that staggers text to create a sort of rhythm. Is there any way to do this within the Fortran 90 standard?
Solution 1:[1]
Not within the standard. But it is not the sort of thing that is typically in the language standards, rather in the system-specific libraries.
The closest to the standard is the community-driven Fortran Standard Library which contains the stdlib_system module with the sleep() subroutine that calls the system-specific libraries for you. The integer argument is the number of milliseconds to wait.
Many compilers offer a sleep() intrinsic subroutine or function that will pause the execution for a certain number of seconds or miliseconds or some other time interval. See the manual to your compiler. E.g., https://gcc.gnu.org/onlinedocs/gfortran/SLEEP.html
There are also various system functions callable through the interoperability with C (Fortran 2003), such as the POSIX sleep(), usleep() or nanosleep(). Examples of calling them from Fortran are available on the web, e.g., here or here.
Similar system commands are also callable in various operating systems through the command line (execute_command_line in Fortran). E.g., sleep and
usleep in Linux.
Be also aware that the Fortran 90 standard is extremely old and that many of the intrinsic procedures available in standard Fortran came later.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
