在Fortran中产生进程

如何在Fortran中启动subprocess(比如执行shell命令等)?

在Node.js中,我们可以使用spawnexec来启动subprocess:

 var proc = require("child_process").spawn("ls", ["-l"]); proc.stdout.on("data", function (chunk) { console.log(chunk); }); // or var proc = require("child_process").exec("ls -l"], function (err, stdout, stderr) { ... }); 

上面的两个例子都运行ls -l (列出文件和目录)。 在Fortran中如何实现同样的function?

这看起来像一个“你怎么用钉枪扳手”式的问题,但我决定试一试谷歌,发现

https://gcc.gnu.org/onlinedocs/gfortran/EXECUTE_005fCOMMAND_005fLINE.html

  program test_exec integer :: i call execute_command_line ("external_prog.exe", exitstat=i) print *, "Exit status of external_prog.exe was ", i call execute_command_line ("reindex_files.exe", wait=.false.) print *, "Now reindexing files in the background" end program test_exec 

他们一直在向FORTRAN(2008规范)添加这样的东西,谁知道?

Interesting Posts