## `generate::fortran` -- generate FORTRAN formatted string

#### Introduction

`generate::fortran(`e`)` generates FORTRAN output for the MuPAD expression `e`.

#### Call(s)

`generate::fortran(e)`

#### Parameters

`e` | - | an expression, equation or list of equations

#### Returns

`generate::fortran` returns a `string` containing FORTRAN code.

#### Related Functions

`fprint`, `print`, `generate::Macrofort::genFor`, `generate::optimize`

#### Details

- A MuPAD expression is converted into a FORTRAN expression.
- An equation is used to represent an assignment in FORTRAN. The type of the assignment is assumed to be `double`.
- A list of equations may be used to represent a sequence of assignments in FORTRAN.
- The output string may be printed to a file using `fprint`. Use the printing option `Unquoted` to remove quotes and to expand special characters like newlines and tabs.
- `generate::optimize` may be used to optimize the input before generating the FORTRAN code.
- `generate::Macrofort::genFor` is a more general function for generating FORTRAN code with more options.

#### Example 1

A list of equations is converted into a sequence of assignments:

    >> generate::fortran( [ x[1]=y[2+i]^2*(y[1]+sin(z)),
                            x[2]=tan(x[1]^4) ] ):
       print(Unquoted,%)

                             x(1) = y(i+2)**2*(sin(z)+y(1))
                             x(2) = tan(x(1)**4)

#### Example 2

The code produced by `generate::fortran` is not optimized:

    >> print(Unquoted,
             generate::fortran([x = a + b, y = (a + b)^2])):

                                      x = a+b
                                      y = (a+b)**2

`generate::optimize` tries to reduce the number of operations:

    >> print(Unquoted,
             generate::fortran(
                 generate::optimize([x = a + b, y = (a + b)^2])
             )):

                                         x = a+b
                                         y = x*x

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000