Here is an example of a subroutine template file.
In[4]:= !!sub.mf subroutine sub(x,y,z) double precision x,y(<* yarray = Array[y,2]; ylength = Length[yarray] *>),z(<* ylength *>) <* (***** Mathematica definition *****) expr = yarray^2 - f /@ Table[x^i,{i,ylength}]; (***** FORTRAN Translation *****) FortranAssign[z,expr,AssignToArray->{y}] *> return endArrays are best declared inside the type declaration statement at the beginning of the file, when dimensioning information is required for the first time. The source code file is now generated.
In[5]:= Splice["sub.mf",FormatType->OutputForm]; In[6]:= !!sub.f subroutine sub(x,y,z) double precision x,y(2),z(2) z(1)=-f(x)+y(1)**2 z(2)=-f(x**2)+y(2)**2 return endThe function f in this subroutine is as yet undefined and an ANSI compatibility warning message is output to the screen. An example definition is given in the next section.