[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



Thank you David,

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.

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.

Thanks again,
Saleh
Sent from Yahoo! Mail for iPhone


Sent from Yahoo! Mail for iPhone


From: David BRADLEY <d.bradley@tess-inc.com>;
To: saleh saadi <salehsnjsaadi404@yahoo.com>; TRNSYS users mailing list at the Solar Energy Lab, UW-Madison <trnsys-users@cae.wisc.edu>;
Subject: Re: [TRNSYS-users] Read an external text file in a new TRNSYS TYPE
Sent: Wed, Jun 5, 2013 8:04:35 PM

Saleh,
  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.
Best,
 David



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 TRNSYS.

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@cae.wisc.edu
https://mailman.cae.wisc.edu/listinfo/trnsys-users

-- 
***************************
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
d.bradley@tess-inc.com

http://www.tess-inc.com
http://www.trnsys.com