- Miniker 102 manual
- - 2 Miniker model programming

## 2.4 Controlling the run

- 2.4.1 Executing code at the end of each time step
- 2.4.2 Controlling the printout and data output

It is possible to add code that will be executed at the end of each time step. It is also possible to specify which time step leads to a printout on standard output. For maximal control, the code running te model may be turned into a subroutine to be called from another fortran (or C) program, this possibility is covered in Calling the model code.

### 2.4.1 Executing code at the end of each time step

The code in the sequence ‘`zsteer`’ is executed at the end of each time step. It is possible to change the time step length (variable `dt`) verify that the non linearity are not too big, or perform discontinuous modifications of the states. One available variable `res` might be usefull for time step monitoring. At the end of the time step, as soon as φ has been computed, a numerical test is applied on a pseudo relative quadratic residual between φ = f(η(t - dt) + dφ (`ffl`), where dφ is given by the system resolution in `ker`,and φ = f(η),φ), Fortran variable (`ff`):

    ! ========================================================
    ! test linearite ffl - ff
    ! ========================================================
    if (istep.gt.1)
    < res=0.; <io=1,m; res = res +(ffl(io)-ff(io))**2/max(one,ff(io)*ff(io)); >;
      if (res .gt. TOL_FFL)
      < print*,'*** pb linearite : res > TOL_FFL a istep',istep,res,' > ',TOL_FFL;
        do io=1,m < z_pr: io,ff(io),ff(io)-ffl(io); >;
      >;
    >;

This test hence applies only for non linearities in tranfer models. Nevertheless, `res` might be usefull to monitor the time step `dt` in `ZSTEER` and eventually go backward one step (`goto :ReDoStep:`). This can more appropriatly be coded in the (empty in default case) sequence `zstep`, inserted just before time-advancing states and `time` variables in ‘`principal`’.

It is also possible to fix the value of the criterium `TOL_FFL` in ‘`zinit`’ different from its default value of 10-3 – independent of the Fortran precision.

Many other variables are available, including

`istep`

  The step number;

`couplage(.)`

  The TEF coupling matrix between transfers;

`H`

  The Jacobian matrix corresponding with:

`Bb`

  The Jacobian matrix corresponding with:

`Bt`

  The Jacobian matrix corresponding with:

`D`

  The Jacobian matrix corresponding with:

`aspha`

  The state advance matrix;

`dneta`
`dphi`

  the variable increments;

One should be aware of that the linearity test concerns the preceding step. We have yet no example of managing the time-step.

### 2.4.2 Controlling the printout and data output

The printout on standard output is performed if the variable `zprint` of type `logical` is true. Therefore it is possible to control this printout by setting `zprint` false or true. For example the following code, in sequence ‘`zsteer`’, triggers printing for every `modzprint` time step and the two following time steps:

    ZPRINT = mod(istep+1,modzprint).eq.0;
    Zprint = zprint .or. mod(istep+1,modzprint).eq.1;
    Zprint = zprint .or. mod(istep+1,modzprint).eq.2;

The data output to ‘`.data`’ files described in Running a simulation and using the output is performed if the `logical` variable `zout` is true. For example the following code, in ‘`zsteer`’, triggers output to ‘`.data`’ files every `modzout` step.

    Zout = mod(istep,modzout).eq.0;

This document was generated on a sunny day using texi2html.