在Fortran中生成进程

Ion*_*zău 1 fortran spawn child-process node.js

如何在Fortran中启动子进程(例如执行shell命令)?

在Node.js的,我们可以使用spawnexec启动子进程:

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) {
   ...
});
Run Code Online (Sandbox Code Playgroud)

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

inf*_*xed 5

这看起来像是"你怎么用钉套扳手开车"类型的问题,但我决定尝试谷歌上面找到它

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
Run Code Online (Sandbox Code Playgroud)

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

  • *谁知道?*很多人,这不是保密. (3认同)