Call Fortran from Perl without saving I / O files

I use the Perl program to properly format user input into the input file for the Fortran program. Fortran creates an output file and an error file. The Fortran program is called from Perl, for example:

system "/mydirectories/fortranexecutable $inputfile $outputfile $errorfile";

I am wondering if there is a way to invoke Fortran executable without actually creating I / O / error files and saving them to disk before / after calling Fortran? I hope my question is clear, and not something too obvious. I am new to Perl and I have tried searching everywhere. Thank you in advance for your help.

+5
source share
2 answers

Fortran , Perl, . Fortran , / / .

Perl - ( ):

use File::Temp qw(tempdir);
use File::Spec::Functions qw(catfile);
use POSIX qw(mkfifo);

my $dir = tempdir(CLEANUP=>1);
my $inputfifo = catfile($dir, "input");
mkfifo($inputfifo, 0700) or die "mkfifo($inputfifo) failed: $!";
my $outputfifo = catfile($dir, "output");
mkfifo($outputfifo, 0700) or die "mkfifo(output$fifo) failed: $!";
my $errorfifo = catfile($dir, "error");
mkfifo($errorfifo, 0700) or die "mkfifo($errorfifo) failed: $!";

... open the FIFOs ...

system "/mydirectories/fortranexecutable $inputfifo $outputfifo $errorfifo";

... operate with the FIFOs to communicate with the Fortran code ...

... close FIFOs and remove $dir when finished ...
+5

. Fortran , $inputfile, $outputfile $errorfile , - .

Fortran , Fortran .

+3

All Articles