<table cellspacing="0" cellpadding="0" border="0"><tr><td valign="top">Thank you David,<br/><br/>I'm using a logical unit as a parameter in my type, utilizing the assign feature. The fortran code is written in f90 free format. I'm using labels and goto command. This seems to give the kernel trouble in opening and reading the file automatically. If i explicitly define the file name in the fortran code, it works perfect (making the assign feature redundant). After the struggle, I converted the code to a fixed fortran format , file extension became *.for. The generated dll now works for multiple text files when used with multiple types, using the assign feature, finally achieving my objective.<br/><br/>I don't know why it works with fixed fortran format but not with the free format. There must be something I missed or an f90 library not installed in my machine.<br/><br/>Thanks again,<br/>Saleh<br/>Sent from Yahoo! Mail for iPhone<br/><br/><br/>Sent from
Yahoo! Mail for iPhone</td></tr></table> <div id="_origMsg_">
<div>
<br />
<div>
<div style="font-size:0.9em">
<hr size="1">
<b>
<span style="font-weight:bold">From:</span>
</b>
David BRADLEY <d.bradley@tess-inc.com>; <br>
<b>
<span style="font-weight:bold">To:</span>
</b>
saleh saadi <salehsnjsaadi404@yahoo.com>; TRNSYS users mailing list at the Solar Energy Lab, UW-Madison <trnsys-users@cae.wisc.edu>; <br>
<b>
<span style="font-weight:bold">Subject:</span>
</b>
Re: [TRNSYS-users] Read an external text file in a new TRNSYS TYPE <br>
<b>
<span style="font-weight:bold">Sent:</span>
</b>
Wed, Jun 5, 2013 8:04:35 PM <br>
</div>
<br>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top">
Saleh,<br>
What you are trying to do was very difficult in TRNSYS 16. There
are improved methods in Trnsys17, however.<br>
<br>
The only real way to get a file name to a Type is to do as other
Types do and make use of the ASSIGN keyword that associates a file
name with an integer logical unit number. The logical unit number is
then given as a parameter to the Type. The problem then is that with
this method, the TRNSYS kernel automatically opens the file that has
been ASSIGNED. You need to close the file from your component in
order to reopen and read it. To complicate matters, your Type only
knows the logical unit number, not the file name so you will need to
write some new TRNSYS kernel access functions that allow you to
close the file from your Type.<br>
<br>
In TRNSYS 17, there is a keyword called DESIGNATE. It is the same
as ASSIGN except that the file will not be opened by the kernel. We
also added a number of access functions that allow your Type to
retrieve the name and location of the file based on knowing only its
DESIGNATED logical unit number.<br>
Best,<br>
David<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 6/3/2013 15:34, saleh saadi wrote:<br>
</div>
<blockquote
type="cite">
<div style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;">
<div></div>
<div>
<div class="MsoNormal">Hello TRNSYS users, </div>
<div class="MsoNormal"><br>
</div>
<div style="font-size:16px;font-family:times new roman, new york, times, serif;background-color:transparent;
font-style:normal;" class="MsoNormal"><span style="color:rgb(255, 0,
0);"><span style="font-weight:bold;">Background: </span></span></div>
<div class="MsoNormal">I’m developing a type to be used in
TRNSYS 16.1 where I use
external text file to read some parameters. More
specifically, it is a
multilayer wall system where layers descriptions are
provided through an
external text file. This requires an open file command with
an explicit file
name in my Fortran code. I compiled the code using <a rel="nofollow"
name="OLE_LINK4"></a><a rel="nofollow"
name="OLE_LINK3"><span
style="">CVF 6.6</span></a> using
virtual machine with XP. <span style=""> </span>That
works
perfect when I have one wall type (one text file provided).
It also works for multiple wall units (two copies of the
type in the simulation studio) where if I change inputs of
one wall unit I could see the changes. This means that the
code works ok when multiple walls are used. However, I have
to use only one text file. <br>
</div>
<div style="color:rgb(0, 0, 255);font-size:16px;font-family:times new roman, new york, times, serif;background-color:transparent;font-style:normal;"
class="MsoNormal"><br>
</div>
<div style="color:rgb(0, 0, 255);font-size:16px;font-family:times new roman, new york, times, serif;background-color:transparent;font-style:normal;"
class="MsoNormal">Up to this point, the DLL works well! <br>
</div>
<div style="color:rgb(0, 0, 255);font-size:16px;font-family:times new roman, new york, times, serif;background-color:transparent;font-style:normal;"
class="MsoNormal"><br>
</div>
<br>
</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;">For this TYPE to work for
multiple wall systems (different walls with different designs)
, I need the code (or the generated DLL) to read multiple text
files (one for each wall). Therefore, I tried to comment the
open command in the fortran code and use the
inquire command without the explicit file name. I compiled
again and run the TRNSYS project. I got a message showing
that the file is not found. I know that the inquire command in
fortran will not
open the file but I wanted the code to open the text file
using the logical
unit rather than the explicit file name. I tried this with
different PCs but I got the same error. I then downloaded IVF
with MS2010 and compiled the code with exactly
the same error. <br>
</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;"><br>
<div class="MsoNormal">I took this fortran code and I use one
of my old PC vista win32bits
with CVF 6.6 compiler and the DLL works fine for multiple
units and multiple
text files. I was wondering what makes the DLL generated by
this old PC works
and others generated by virtual machine not. Unfortunately,
my OLD PC has
crashed after windows update(!!) and can’t have access to
the compiler anymore. </div>
<div class="MsoNormal"><br>
</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;" class="MsoNormal">In all
cases above, I can compile the code and DLL is generated
without any error. The error is generated once I run the
project in TRNSYS. <br>
</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;" class="MsoNormal"><br>
</div>
<div class="MsoNormal"><span style="font-weight:bold;"><span
style="color:rgb(255, 0, 0);">My questions: </span></span></div>
<div class="MsoNormal">Is there a way or a command to open a
text file using logical unit rather than an explicit
file name?. or that is not possible in fortran? </div>
<div class="MsoNormal"> </div>
<div class="MsoNormal">I hope that somebody can offer a help
on this. <br>
</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;" class="MsoNormal"><br>
</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;" class="MsoNormal">thanks,</div>
<div style="color:rgb(0, 0, 0);font-size:16px;
font-family:times new roman, new york, times, serif;
background-color:transparent;font-style:normal;" class="MsoNormal">Saleh
Al-Saadi <br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
TRNSYS-users mailing list
<a rel="nofollow" class="moz-txt-link-abbreviated" ymailto="mailto:TRNSYS-users@cae.wisc.edu" target="_blank" href="javascript:return">TRNSYS-users@cae.wisc.edu</a>
<a rel="nofollow" class="moz-txt-link-freetext" target="_blank" href="https://mailman.cae.wisc.edu/listinfo/trnsys-users">https://mailman.cae.wisc.edu/listinfo/trnsys-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature">--
***************************
David BRADLEY
Principal
Thermal Energy Systems Specialists, LLC
22 North Carroll Street - suite 370
Madison, WI 53703 USA
P:+1.608.274.2577
F:+1.608.278.1475
<a rel="nofollow" class="moz-txt-link-abbreviated" ymailto="mailto:d.bradley@tess-inc.com" target="_blank" href="javascript:return">d.bradley@tess-inc.com</a>
<a rel="nofollow" class="moz-txt-link-freetext" target="_blank" href="http://www.tess-inc.com">http://www.tess-inc.com</a>
<a rel="nofollow" class="moz-txt-link-freetext" target="_blank" href="http://www.trnsys.com">http://www.trnsys.com</a></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>