<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Michael,<br>
<br>
I assume you are using TRNSYS16 coding style in your component.
I'm not sure that the getMaxLabelLength() function works with the
coding style.However, the function works fine in my TRNSYS'17'
coding style component.<br>
<br>
The getDeckFileName() seems to me that the function does not care
about C/C++ strings. I have got exactly same error.<br>
Unless, you modified the function to cope with C/C++ style, I
think that you can not avoid the access violation error.<br>
For example, I have added the following new function in the
TrnsysFunction.f90 to avoid the error.<br>
<br>
-TrnsysFunction.f90<br>
<br>
Function getDeckFileNameEx() bind(c,name="getDeckFileNameEx")<br>
!dec$ attributes dllexport :: getDeckFileNameEx<br>
Use TrnsysData<br>
Use, intrinsic :: iso_c_binding<br>
type(C_ptr) :: getDeckFileNameEx<br>
Character(len=maxPathLength) ret <br>
ret = trim(deckn1)//CHAR(0)<br>
getDeckFileNameEx = C_LOC(ret)<br>
End Function getDeckFileNameEx<br>
<br>
- C/C++ Component sourcecode<br>
extern "C" __declspec(dllimport) char* _cdecl
getDeckFileNameEx(void);<br>
<br>
char *dckfilename;<br>
dckfilename = getDeckFileNameEx(); <br>
<br>
I do not like this idea because an expensive Fortran compiler is
needed to build.<br>
Does anyone know that how to call FORTRAN function returns
characters?<br>
<br>
Best regards,<br>
<br>
Yuichi Yasuda<br>
quattro corporate design co.,ltd<br>
T2000 Bld. 4F, 1-11-29 Mita, Meguro-ku, Tokyo, 153-0062, Japan<br>
<a class="moz-txt-link-freetext" href="Tel:+81">Tel:+81</a> (0)3
5768 6744 Fax:+81 (0)3 5768 6745<br>
Email: <a class="moz-txt-link-abbreviated"
href="mailto:yasuda@qcd.co.jp">yasuda@qcd.co.jp</a><br>
<a class="moz-txt-link-freetext" href="http://www.qcd.co.jp/">http://www.qcd.co.jp/</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
On 2016/05/21 0:22, Michael Holzhauser via TRNSYS-users wrote:<br>
</div>
<blockquote
cite="mid:7D1E329D-9AEA-49CB-AD4E-90777F1DB4D2@mathematik.uni-kl.de"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Hello all,
<div class=""><br class="">
</div>
<div class="">I managed to build a customized TRNSYS Type in C++
by extending the Type202 example that is delivered with TRNSYS
17. I can access the input values and return the corresponding
output values without any problems. However, the communication
with the TRNSYS Core functions somehow don’t work. Whenever I
invoke some function that returns an integer value (like
getMaxLabelLength()), the result is NaN. Whenever I try to
invoke some function that returns characters (like
getDeckFileName()), TRNSYS crashes with something like „Access
violation at address XXXXX in module ‚TRNDLL.DLL‘. Write of
address XXXXX.“ or with „forttrl: severe (408): fort: (18):
Dummy character variable ‚GETLABEL@0‘ has length 300 which is
greater than actual variable length 1“ (in case of getLabel).</div>
<div class=""><br class="">
</div>
<div class="">As I read in other topics like this one, there
seemed to be several issues in the TRNSYS.h header file and the
library files long ago: </div>
<div class=""><a moz-do-not-send="true"
href="https://www.mail-archive.com/trnsys-users@engr.wisc.edu/msg00005.html"
class="">https://www.mail-archive.com/trnsys-users@engr.wisc.edu/msg00005.html</a></div>
<div class=""><br class="">
</div>
<div class="">However, 11 years later, is there a workaround for
this problem?</div>
<div class=""><br class="">
</div>
<div class="">Thanks in advance.</div>
<div class="">
<div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; orphans: 2; widows: 2;"
class=""><br class="Apple-interchange-newline">
--</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; orphans: 2; widows: 2;"
class=""><br class="">
</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; orphans: 2; widows: 2;"
class="">M.Sc. Michael Holzhauser<br class="">
AG Optimization<br class="">
University of Kaiserslautern<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><br
class="">
<br class="">
Paul-Ehrlich-Str. 14 - 451<br class="">
67663 Kaiserslautern, Germany<br class="">
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><br
class="">
Phone: <span class="Apple-tab-span" style="white-space: pre;"> </span>+49
(631) 205-2511<br class="">
E-mail: <a moz-do-not-send="true"
href="mailto:holzhauser@mathematik.uni-kl.de" class="">holzhauser@mathematik.uni-kl.de</a><br
class="">
<br class="">
</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
normal; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; orphans: 2; widows: 2;"
class=""><a moz-do-not-send="true"
href="http://www.mathematik.uni-kl.de/%7Eholzhauser"
class="">www.mathematik.uni-kl.de/~holzhauser</a></div>
</div>
<br class="">
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
TRNSYS-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:TRNSYS-users@lists.onebuilding.org">TRNSYS-users@lists.onebuilding.org</a>
<a class="moz-txt-link-freetext" href="http://lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.org">http://lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.org</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>