File: Calling-the-model-code.html

package info (click to toggle)
texi2html 1.82%2Bdfsg1-6
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 35,236 kB
  • sloc: perl: 15,901; xml: 6,075; sh: 3,977; makefile: 501
file content (197 lines) | stat: -rw-r--r-- 10,468 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Copyright (C) 2004, 2005, 2006, 2007 Alain Lahellec

Copyright (C) 2004, 2005, 2006, 2007 Patrice Dumas

Copyright (C) 2004, Ste'phane Hallegatte

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover text and with no Back-Cover Text.  
A copy of the license is included in the section entitled "GNU Free 
Documentation License."

 -->
<!-- Created on a sunny day by texi2html
texi2html was written by: 
            Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Miniker 102 manual: 3.2 Calling the model code</title>

<meta name="description" content="Miniker 102 manual: 3.2 Calling the model code">
<meta name="keywords" content="Miniker 102 manual: 3.2 Calling the model code">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
@import "mini_ker_tex4ht_math.css";
@import "mini_ker_tex4ht_tex.css";

a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Calling-the-model-code"></a>
<ul class="toc"><li><a href="mini_ker.html#Top">Miniker 102 manual</a> </li>
<li><ul class="toc"><li><a href="Advanced-programming.html#Advanced-programming">3. Advanced Miniker programming</a> </li>
</ul></li>
</ul>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="Selecting-features.html#Selecting-features" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Turning-the-model-into-a-subroutine" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mini_ker.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concepts-index.html#Concepts-index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mini_ker_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Calling-the-model-code-1"></a>
<h2 class="section"> 3.2 Calling the model code </h2>
<ul class="toc">
<li> <a href="#Turning-the-model-into-a-subroutine">3.2.1 Turning the model into a subroutine</a> </li>
<li> <a href="#The-model-subroutine">3.2.2 Calling the model subroutine</a> </li>
</ul>

<p>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 <a href="Adjoint-model-and-optimisation.html#Adjoint-model-and-optimisation">Adjoint model and optimisation with Miniker</a>), or to run the model with different parameters.
</p>

<hr size="2">
<a name="Turning-the-model-into-a-subroutine"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Calling-the-model-code" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#The-model-subroutine" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mini_ker.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concepts-index.html#Concepts-index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mini_ker_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Turning-the-model-into-a-subroutine-1"></a>
<h3 class="subsection"> 3.2.1 Turning the model into a subroutine </h3>


<p>With cmz, one has to do a 
</p><table><tr><td>&nbsp;</td><td><pre class="example">sel monitor
</pre></td></tr></table>
<p>in the &lsquo;<tt>selseq.kumac</tt>&rsquo; file and create the KEEP that call the 
model code. See <a href="Selecting-features.html#Selecting-features">Overview of additional features setting</a>.
</p>
<p>With make &lsquo;<samp>monitor</samp>&rsquo; should be added to the <code>SEL</code> variable in
the &lsquo;<tt>Makefile</tt>&rsquo;, for example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">SEL = monitor
</pre></td></tr></table>

<p>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 <code>miniker_user_objects</code> variable.
</p>
<hr size="2">
<a name="The-model-subroutine"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Turning-the-model-into-a-subroutine" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="1D-gridded-model.html#g_t1D-gridded-model" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mini_ker.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concepts-index.html#Concepts-index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mini_ker_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Calling-the-model-subroutine"></a>
<h3 class="subsection"> 3.2.2 Calling the model subroutine </h3>

<p>The model subroutine is called &lsquo;<samp>principal</samp>&rsquo; and is called with the 
following arguments:
</p>
<dl>
<dt><a name="index-principal"></a><u>Subroutine:</u> <b>principal</b><i> (Cost, ncall, integer_flag, file_suffix, info, idxerror)</i></dt>
<dd><p>Where <var>Cost</var> is a real number, <code>real</code> or <code>double precision</code>, 
and is set by the <code>principal</code>
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 <a href="Adjoint-model-and-optimisation.html#Cost-function-coding-and-adjoint-modeling">Cost function coding and adjoint modeling</a>). 
<var>ncall</var> is an integer which corresponds with the number of 
call to <code>principal</code> done so far, it should be initialized to 0 and 
its value should not be changed, as it is changed in the <code>principal</code>
subroutine.
<var>integer_flag</var> is an integer that can be set by the user to be accessed 
in the <code>principal</code> subroutine. For example its value could be used to
set some flags in the &lsquo;<tt>zinit</tt>&rsquo; sequence.
<var>file_suffix</var> is a character string, that is suffixed to the output files
names instead of &lsquo;<samp>.data</samp>&rsquo;. If the first character is the null character 
&lsquo;<samp>char(0)</samp>&rsquo;, the default suffix, &lsquo;<samp>.data</samp>&rsquo; is appended.
<var>info</var> and <var>idxerror</var> are integer used for error reporting.
<var>idxerror</var> 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.
<var>info</var> 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 <a href="#tab_003aerror_005fcodes">tab:error_codes</a>.
</p></dd></dl>

<div class="float"><a name="tab_003aerror_005fcodes"></a>
<table>
<thead><tr><th>Source of error or warning</th><th><code>info</code></th><th><code>idxerror</code></th></tr></thead>
<tr><td>state matrix inversion in ker</td><td>inversion</td><td>1</td></tr>
<tr><td>time advance system resolution in ker</td><td>system</td><td>2</td></tr>
<tr><td>transfer propagator,       (I - D) inversion</td><td>inversion</td><td>3</td></tr>
<tr><td>kalman analysis state matrix advance in phase space,       (I - D) inversion</td><td>inversion</td><td>21</td></tr>
<tr><td>kalman analysis variance covariance matrix non positive</td><td>Choleski</td><td>22</td></tr>
<tr><td>kalman analysis error matrix inversion</td><td>inversion</td><td>23</td></tr>
<tr><td>kalman error matrix advance</td><td>system</td><td>24</td></tr>
<tr><td>transfers determination linearity problem for transfers</td><td></td><td>-1</td></tr>
<tr><td>transerts determination Newton D_loop does not converge</td><td></td><td>-2</td></tr>
</table>

</div><p><strong>table 3.1: Meaning of error codes returned by principal.
</strong>
</p>
<p>In general more information than the provided arguments has to be passed 
to the <code>principal</code> subroutine, in that case a <code>common</code> block,
to be written in the &lsquo;<tt>zinit</tt>&rsquo; sequence can be used.
</p>

<hr size="2">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="mini_ker.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concepts-index.html#Concepts-index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mini_ker_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>a tester</em> on <em>a sunny day</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html</em></a>.
 </font>
 <br>

</p>
</body>
</html>