This happens starting from MATLAB (7.14) R2012a onwards, where Environment variables for the three data streams STDIN, STDOUT and STDERR were set to -1.
To work around the issue, you may wrap your SYSTEM call which executes a FORTRAN script as follows:
In any program, there are three reserved streams that the program can read from and write to.
‘stdin’ is generally what is used as the input stream, such as when a program asks you to type something on the keyboard.
‘stdout’ is generally what is used as the output stream, such as when you use the WRITE function in FORTRAN.
‘stderr’ is generally what is used as the error stream, which is where a program will write the issues it is encountering, so that a developer or debugger can differentiate between output that is supposed to be seen and errors in the program that are discovered.
GFORTRAN-compiled programs attempt to open these three streams, and then unconditionally close them when they are finished. However, this is an issue for programs like MATLAB which interferes with the input and output of user processes which also read to and write from ‘stdin’, ‘stdout’, and ‘stderr’.
Therefore, from MATLAB (7.14) R2012a onwards, these three environment variables are set to -1 by default. Setting this to -1 will ensure that MATLAB has control over these streams, thereby allowing it to function correctly. While running a FORTRAN program which needs this access from within MATLAB, these changes have to be made temporarily.
When these variables are set to -1, note that MATLAB will not read from the ‘stdout’ and ‘stderr’ streams the FORTRAN script expects to write to, and it will not write to the ‘stdin’ stream the script expects to read from. This will cause the output of the program to not be captured in the command window.