[ < ] [ > ]   [Contents] [Index] [ ? ]

3.2 Calling the model code

When the model code is a subroutine, it can be called from another fortran program unit (or another program), and the model will be run each time the subroutine is called. This technique could be used, for example to perform optimization (see Adjoint model and optimisation with Miniker), or to run the model with different parameters.


[ < ] [ > ]   [Contents] [Index] [ ? ]

3.2.1 Turning the model into a subroutine

With cmz, one has to do a

 
sel monitor

in the ‘selseq.kumac’ file and create the KEEP that call the model code. See Overview of additional features setting.

With make ‘monitor’ should be added to the SEL variable in the ‘Makefile’, for example:

 
SEL = monitor

A file that call the principal subroutine should also be written, using the prefered language of the user. The additional object files should then be linked with the Miniker objects. To that aim they may be added to the miniker_user_objects variable.


[ < ] [ > ]   [Contents] [Index] [ ? ]

3.2.2 Calling the model subroutine

The model subroutine is called ‘principal’ and is called with the following arguments:

Subroutine: principal (Cost, ncall, integer_flag, file_suffix, info, idxerror)

Where Cost is a real number, real or double precision, and is set by the principal subroutine. It holds the value of the cost function if such function has been defined (the use and setting of a cost function is covered later, see Cost function coding and adjoint modeling). ncall is an integer which corresponds with the number of call to principal done so far, it should be initialized to 0 and its value should not be changed, as it is changed in the principal subroutine. integer_flag is an integer that can be set by the user to be accessed in the principal subroutine. For example its value could be used to set some flags in the ‘zinit’ sequence. file_suffix is a character string, that is suffixed to the output files names instead of ‘.data’. If the first character is the null character ‘char(0)’, the default suffix, ‘.data’ is appended. info and idxerror are integer used for error reporting. idxerror value is 0 if there was no error. It is negative for an alert, positive for a very serious error. The precise value determines where the error occured. info is an integer holding more precise information about the error. It is usually the information value from lapack. The precise meaning of these error codes is in tab:error_codes.

Source of error or warninginfoidxerror
state matrix inversion in kerinversion1
time advance system resolution in kersystem2
transfer propagator, (I - D) inversioninversion3
kalman analysis state matrix advance in phase space, (I - D) inversioninversion21
kalman analysis variance covariance matrix non positiveCholeski22
kalman analysis error matrix inversioninversion23
kalman error matrix advancesystem24
transfers determination linearity problem for transfers-1
transerts determination Newton D_loop does not converge-2

table 3.1: Meaning of error codes returned by principal.

In general more information than the provided arguments has to be passed to the principal subroutine, in that case a common block, to be written in the ‘zinit’ sequence can be used.


[Contents] [Index] [ ? ]

This document was generated by a tester on a sunny day using texi2html.