<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Webdings;
        panose-1:5 3 1 2 1 5 9 6 7 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Texte de bulles Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.TextedebullesCar
        {mso-style-name:"Texte de bulles Car";
        mso-style-priority:99;
        mso-style-link:"Texte de bulles";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1078091315;
        mso-list-type:hybrid;
        mso-list-template-ids:1149020814 67895297 67895299 67895301 67895297 67895299 67895301 67895297 67895299 67895301;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1
        {mso-list-id:1204253095;
        mso-list-type:hybrid;
        mso-list-template-ids:1603936786 -930960576 67895299 67895301 67895297 67895299 67895301 67895297 67895299 67895301;}
@list l1:level1
        {mso-level-start-at:4;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
@list l2
        {mso-list-id:1926113490;
        mso-list-type:hybrid;
        mso-list-template-ids:-1350774678 -1234292878 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l2:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:20.25pt;
        text-indent:-18.0pt;}
@list l2:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:56.25pt;
        text-indent:-18.0pt;}
@list l2:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:92.25pt;
        text-indent:-9.0pt;}
@list l2:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:128.25pt;
        text-indent:-18.0pt;}
@list l2:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:164.25pt;
        text-indent:-18.0pt;}
@list l2:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:200.25pt;
        text-indent:-9.0pt;}
@list l2:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:236.25pt;
        text-indent:-18.0pt;}
@list l2:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:272.25pt;
        text-indent:-18.0pt;}
@list l2:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:308.25pt;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Dear Anton,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>A quick answer to your questions :<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>1) and 2) During each time step, TRNSYS calls sequentially each type and update input variables of other types with calculated values from the current type, repeating this operation until output variables do not change anymore (successive substitutions algorithm). <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>The number of calls to a type in each time step is not limited to 3: I think you get confused by the table page 7-78 of the programmer’s guide, representing just un example assuming that convergence is reached for each time step at the second iteration.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>3) I have never used the dTdt vector, than I cannot answer to you on this specific point <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>4) A TRNSYS Types is basically a procedure which computes an array of outputs knowing the following array:<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo3'><![if !supportLists]><span lang=EN-US style='font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>         </span></span></span><![endif]><span lang=EN-US style='color:#1F497D'>An input array, provided by TRNSYS when calling the type.<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo3'><![if !supportLists]><span lang=EN-US style='font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>         </span></span></span><![endif]><span lang=EN-US style='color:#1F497D'>A parameter array, which is constant (TRNSYS passes it to the type, but normally it should not change from call to call)<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo3'><![if !supportLists]><span lang=EN-US style='font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>         </span></span></span><![endif]><span lang=EN-US style='color:#1F497D'>A static storage array, defined by the type during the initialization call, which is basically an additional parameter array<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo3'><![if !supportLists]><span lang=EN-US style='font-family:Symbol;color:#1F497D'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>         </span></span></span><![endif]><span lang=EN-US style='color:#1F497D'>A dynamic storage array, which can be used to store variables between iterations and time steps (your state vector, I imagine?)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Derivative of variables can also be computed by TRNSYS and used by a type but, as I told before, I am not very familiar with this.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>For your second point you should consider an issue common to many old codes : TRNSYS was first developed in FORTRAN 77, which considers all variables with the attribute SAVE (static variables, in C/C++ terms). Modern FORTRAN compilers do not consider any more all variables as static (you should define a variable explicitly with SAVE attribute to define a static variable), but as there are many old codes written in FORTRAN, they practically <i><u>always</u></i> give the possibility to use this old characteristics by a compiler directive (and I would be very surprised if next versions of Intel Visual FORTRAN would not give this possibility). <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>You are right, this is not a good programming practice, but the alternative would be to take all the code and insert the keyword SAVE to all variable definition. I understand that TRNSYS developers has better things to do...:-) By the way, the only problem with static variables is that you cannot optimize storage of data, but in my experience TRNSYS simulations are far from using much RAM.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Anyway, this feature explains the reason because, for example, if there is only one unit of the same type, you are not obliged to reread each time the parameters (which is the meaning of the code you sent to the forum).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Just a final note about INFO array : it is now possible (and even recommended) to use directly access functions to read inputs, parameters and storage arrays, for example in order to read the i-th input  you can use the statement <i>var = getInputValue(i)</i>, to read the i-th parameter : <i>par = getParameterValue(i)</i>, etc…<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>I hope this helps.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Best regards,</span><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-family:"Tahoma","sans-serif";color:#58595B'>Marcello Caciolo</span></b><span style='font-family:"Tahoma","sans-serif";color:#58595B'><br></span><span style='font-size:9.0pt;font-family:"Tahoma","sans-serif";color:#58595B'>Responsable Outils et Méthodes d'Analyse Energétique</span><span style='font-family:"Tahoma","sans-serif";color:#58595B'><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:gray'><img width=170 height=62 id="Image_x0020_1" src="cid:image001.jpg@01CE2183.67B9DF30" alt="cid:image003.jpg@01CD4E08.954D04D0"><br><b><br></b>Cellule Efficacité Energétique et Environnementale - Pôle Projets et Réalisations<br>46 Boulevard de la Prairie au Duc<br>BP 40119 - 44201 Nantes Cedex 02</span><span style='font-size:9.0pt;font-family:"Tahoma","sans-serif";color:#1F497D'><br></span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:gray'>Tél.: +33 02 40 41 06 57</span><span style='font-size:9.0pt;font-family:"Tahoma","sans-serif";color:#1F497D'><br><a href="mailto:prenom.nom@aximaseitha-gdfsuez.com"><span style='color:blue'>marcello.caciolo@cofelyaxima-gdfsuez.com</span></a></span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:gray'><o:p></o:p></span></p><p class=MsoNormal><span style='font-family:Webdings;color:#339966'>P</span><span style='font-size:10.0pt;font-family:Webdings;color:#339966'> </span><b><span style='font-size:7.5pt;font-family:"Arial","sans-serif";color:#339966'>Pensez à l'environnement avant d'imprimer ce message</span></b><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> trnsys-users-bounces@cae.wisc.edu [mailto:trnsys-users-bounces@cae.wisc.edu] <b>De la part de</b> Soppelsa Anton<br><b>Envoyé :</b> vendredi 15 mars 2013 11:34<br><b>À :</b> trnsys-users@cae.wisc.edu<br><b>Objet :</b> [TRNSYS-users] Types programming: Types-Kernel interface explanation<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-GB>Dear TRNSYS users,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>I have been looking for a while to the seventh section of the TRNSYS 17 manual in order to understand how and why the kernel calls a type in the way it does.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Notwithstanding my experience with simulation software like Matlab/Simulink, Scilab/XCos, Ptolemy II, I still have difficulties in understanding some aspects of the TRNSYS callbacks interface, e.g.:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoListParagraph style='margin-left:20.25pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span lang=EN-GB>What’s the purpose of the inter-step calls (iterations)<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:20.25pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span lang=EN-GB>Why they need to be exactly 3 (as I understood from the manual).<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:20.25pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>3)<span style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span lang=EN-GB>How the kernel make use of the vector dTdt (which I would have called dxdt).<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:20.25pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>4)<span style='font:7.0pt "Times New Roman"'>      </span></span></span><![endif]><span lang=EN-GB>Whether my understanding that Types can be used to implement the following mathematical models: y = g(x, u, t), dxdt = fc(x, u, t) (or x(t+1) = fd(x(t), u(t), t) in case of discrete systems), where t is the time, u is the input vector, x is the state vector and y is the output vector is correct.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Can anybody suggest me what is the right section of the manual to find an answer to these questions? I had no luck reading the programmer´s guide section of the manual.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>A second point is that I found puzzling the code example published therein. In the first time I though that my doubts where related to my scarce knowledge of the Fortran language (I am a C/C++ programmer) so I raised a point in a programmer community <a href="http://stackoverflow.com/questions/15414277/where-does-fortran-store-local-variables">http://stackoverflow.com/questions/15414277/where-does-fortran-store-local-variables</a> .  It turned out that the code published in the manual (which contains a pattern which I noticed has widespread to many other types) seems to rely on a Fortran language “feature” which is considered “bad programming practice”, is compiler-dependent and may not be supported any more in the future.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>As it seem to me impossible that such a “bomb” is present in the program without affecting the TRNSYS community I kindly ask the help of a TRNSYS expert to clarify this point.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Does anybody know if there a trnsys-devel mailing list?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Sincerely,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>  AS<o:p></o:p></span></p></div></body></html>