Fortran 中有类似 "WAIT" 的函数吗?

Is there anything like a "WAIT" function in Fortran?

我想创建一个 Fortran 程序,它可以交错文本以创建一种节奏。在 Fortran 90 标准中有什么方法可以做到这一点吗?

不在标准之内。但这通常不是语言标准中的那种东西,而是 system-specific 库中的东西。

最接近标准的是 community-driven Fortran Standard Library which contains the stdlib_system 模块,其中包含 sleep() 子例程,可为您调用 system-specific 库。整数参数是等待的毫秒数。

许多编译器提供了一个 sleep() 内部子例程或函数,可以将执行暂停一定的秒数或毫秒数或其他时间间隔。请参阅编译器手册。例如,https://gcc.gnu.org/onlinedocs/gfortran/SLEEP.html

还有各种系统函数可通过与 C (Fortran 2003) 的互操作性调用,例如 POSIX sleep(), usleep() or nanosleep(). Examples of calling them from Fortran are available on the web, e.g., here or here.

类似的系统命令也可以通过命令行在各种操作系统中调用(execute_command_line 在 Fortran 中)。例如,sleepusleep 在 Linux.


另请注意,Fortran 90 标准非常古老,标准 Fortran 中可用的许多内部过程都是后来出现的。