## `generate::Macrofort::init` -- initialize genFor

#### Introduction

`Mac::init` (where `Mac:=generate::Macrofort`) initializes the global variables for every call to `Mac::genFor`, the Macrofort FORTRAN code generator.

This procedure must be called before the first call to `Mac::genFor`. It initializes the various counters used internally by Macrofort for label generation within used within e.g.: do-loops and format statements. It also sets the variables for precision, comments, optimization, I/O settings, input and output file definition to their default values although these can be subsequently modified by subsidiary routines (mentioned in the list of ``Related Functions'').

#### Call(s)

`generate::Macrofort::init()`

#### Returns

the void object of domain type `DOM_NULL`

#### Side Effects

Default values for global variables `Mac::genFor` are set.

#### Related Functions

`generate::Macrofort::genFor`, `generate::Macrofort::setOptimizedOption`, `generate::Macrofort::setIOSettings`, `generate::Macrofort::setPrecisionOption`, `generate::Macrofort::setAutoComment`, `generate::Macrofort::openOutputFile`, `generate::Macrofort::closeOutputFile`, `generate::optimize`, `generate::fortran`

#### Details

- With `Mac:=generate::Macrofort`, these are the subsidiary routines to `Mac::init` and `Mac::genFor` within the ``macrofort'' domain:
  `Mac::setAutoComment`
    allows for the automatic generation of FORTRAN comments.
  `Mac::setPrecisionOption`
    allows the choice of tailoring FORTRAN code in single, double or quadruple precision.
  `Mac::setIOSettings`
    allows the user to choose the settings for FORTRAN I/O statements.
  `Mac::setOptimizedOption`
    allows for the choice of optimization.
  `Mac::openOutputfile`
    opens an ascii file for the FORTRAN code.
  `Mac::closeOutputfile`
    closes the file open by `Mac::openOutputfile`.
  See the help-files of these individual procedures for more details and information about the default values set by `Mac::init`.

#### Example 1

This example shows how `Mac::init` (with `Mac:=generate::Macrofort`) automatically takes care of the labeling in the FORTRAN output generated by `Mac::genFor`. The output is the ascii file `"test.f"`

    >> Mac := generate::Macrofort:
       Mac::init():
       Mac::openOutputFile("test.f"):
       Mac::genFor(["continue",label]):
       Mac::genFor(["do",label,i,1,m,-1]):
       Mac::closeOutputFile():
       delete i, m, label:

The output file `"test.f"` is:

           1000 continue
                do 1000, i=1,m,-1

As we can see, the labeling was done automatically without the user having to worry about it.

See the help-file for `Mac::genFor` for a more comprehensive list of examples.

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