From jeroen at berkeley.edu  Tue Jun 20 12:52:59 2017
From: jeroen at berkeley.edu (Jeroen Ooms)
Date: Tue, 20 Jun 2017 12:52:59 +0200
Subject: [Rd] Fortran programs not writing stdout on windows
Message-ID: <CABFfbXs5L6pLGcGaRs6S=UYRZkheep3aQvYUvpy-M=xgODRCxg@mail.gmail.com>

A user has reported an issue that appears when a fortran executable is
called via R on Windows. I am unsure if this expected behavior or a
bug in Fortran or in how R calls Windows executables.

The problem is that when the fortran program is called from R, stdout
gets written to a file "fort.6" instead of stdout. When the same
executable is called from the terminal it works fine and prints to
stdout. This unexpected behavior is unfortunate for R wrappers that
rely on captured output.

A minimal example is available from github [1] and can be installed with

   devtools::install_github("jeroen/ftest")
   ftest::hello()

When running ftest::hello() on linux, R will properly capture output.
However on Windows it will return an empty string, and a file 'fort.6'
gets created in the working directory instead.

The executables can be found in: system.file("bin", package = "ftest")

Interestingly if we open a command line terminal and run the same
executable it prints output to stdout. So perhaps it has to do with
the way R invokes CreateProcess() on Windows?

[1] https://github.com/jeroen/ftest



[Rd] Fortran programs not writing stdout on windows
Jeroen Ooms