I want to create a FORTRAN cell in Mathematica.
pr = "PROGRAM test
Integer::a, b
a=3
b=9
print*, a, ' +', b, ' = ', a + b
print*, a, ' *', b, ' = ', a * b
END Program test
";
GFortran[inp_] := (
Export["temp1.f90", inp, "Text"];
Column@ReadList["!gfortran temp1.f90 && a.exe", String])
The function works fine:
GFortran[pr]
DeleteFile[{"temp1.f90", "a.exe"}]

Now with a cell
(CellPrint[
TextCell[
pr, "Program",
Evaluatable -> True,
CellEvaluationFunction -> (GFortran[#] &),
CellFrameLabels -> {{None, "Fortran"}, {None, None}}]];
SelectionMove[EvaluationNotebook[], Previous, CellContents])

File temp1.f90 is created, but not compiled, so there is no output. What could be wrong?
Edit:
I changed GFortran to
GFortran[inp_] := (
Export["temp1.f90", inp, "Text"];
Get["!gfortran temp1.f90"];
Column@ReadList["!a.exe", String])
Now the FORTRAN cell will have output, but only if temp1.f90 was compiled before cell execution


ReadList["!pause", String], or a simple file copy, etc., to see if the command is being run? – Mr.Wizard♦ Jul 11 '12 at 1:35CellEvaluationFunction -> ReadList["!pause", String]output is{Press any key to continue . . .}(,TextForm)– FDSg Jul 11 '12 at 1:45pr, "Program",in yourTextCellexpression. – Mr.Wizard♦ Jul 11 '12 at 2:19GFortran[inp_, _] :=andCellEvaluationFunction -> GFortran? – Mr.Wizard♦ Jul 11 '12 at 2:21GFortran[inp_, _]now everything compiles. – FDSg Jul 11 '12 at 2:32