[TRNSYS-users] Read an external text file in a new TRNSYS TYPE

David BRADLEY d.bradley at tess-inc.com
Wed Jun 5 13:04:35 PDT 2013

   What you are trying to do was very difficult in TRNSYS 16. There are 
improved methods in Trnsys17, however.

   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.

   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.

On 6/3/2013 15:34, saleh saadi wrote:
> Hello TRNSYS users,
> Background:
> 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 CVF 
> 6.6 using virtual machine with XP. 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.
> Up to this point, the DLL works well!
> 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.
> 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.
> 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 
> My questions:
> 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?
> I hope that somebody can offer a help on this.
> thanks,
> Saleh Al-Saadi
> _______________________________________________
> TRNSYS-users mailing list
> TRNSYS-users at cae.wisc.edu
> https://mailman.cae.wisc.edu/listinfo/trnsys-users

Thermal Energy Systems Specialists, LLC
22 North Carroll Street - suite 370
Madison, WI  53703 USA

d.bradley at tess-inc.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20130605/f627e9d4/attachment-0001.htm>

More information about the TRNSYS-users mailing list