I'm trying to figure how to make Mathematica interact with a Fortran program that takes 2 parameters in a first input line, 3 parameters in a second input line and produces two lines as outputs. Below a simple example to illustrate my point:
program par
implicit none
integer :: i,j
integer :: k,l,m
read (*,*) i, j
read (*,*) k, l, m
write (*,*) (i+j)*k, (i+j)-2*l
write (*,*) 2*l, 3*m, i-j
end program par
When I run the code below in Mathematica, I get "EndOfFile" as a result.
pr = StartProcess["par"];
g[i_, j_, k_, l_, m_] := (Write[pr, ToString[i], ToString[j]];
Write[pr, ToString[k], ToString[l], ToString[m]]; Read[pr,Number];Read[pr, Number]);
g[1, 2, 3, 4, 5]
Any help would be highly appreciated. Cheers.
Write
may be running the numbers together with no spaces but cant test here..try adding," ",
to the lists $\endgroup$