FortranForm
FortranForm[expr]
prints as a Fortran language version of expr.
Details
- Standard arithmetic functions and certain control structures are translated.
- When an input evaluates to FortranForm[expr], FortranForm does not appear in the output. »
- The width of output lines must be set explicitly by giving the option PageWidth->n for the relevant output stream.
- SetOptions[$Output,PageWidth->72] uses a line width of 72 characters for standard Wolfram Language output.
- No declarations are generated.
Examples
open allclose allBasic Examples (1)
Applications (1)
Properties & Relations (2)
When an input evaluates to FortranForm[expr], FortranForm does not appear in the output:
Out is assigned the value x2, not FortranForm[x^2]:
FortranForm formats expressions like Fortran code:
CForm formats expressions like C code:
Possible Issues (2)
Additional Fortran function definitions may be needed to run the code:
Even when an output omits FortranForm from the top level, it is not stripped from subexpressions:
The output does not have FortranForm in it:
However, the variable e does have FortranForm in it, which may affect subsequent evaluations:
The product is not evaluated due to the intervening FortranForm:
Assign variables first and then apply FortranForm to the result to maintain computability:
Text
Wolfram Research (1988), FortranForm, Wolfram Language function, https://reference.wolfram.com/language/ref/FortranForm.html.
CMS
Wolfram Language. 1988. "FortranForm." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FortranForm.html.
APA
Wolfram Language. (1988). FortranForm. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FortranForm.html