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

RE: Transmit a String to a UserType



Jochen,

The deck filename is available in a common block called DECKNAME. Note that
the Deck file's Logical Unit is also available in a common block
(COMMON/LUNITS/) but by the time your Type is called, that logical unit is
not accessible anymore.
To read the deck file, you have to insert the following instructions in your
Type:

COMMON /DECKNAME/DECKN1
COMMON /LUNITS/LUR,LUW,IFORM,LUK
...
If(INFO(7).eq.-1)Then ! Very first call
 Open(LUR,FILE=DECKN1,status='old')
 ...
Endif
...
Read(LUR, ...) (your read statement)
...
If(INFO(8)=-1)Then ! Very last call
 close(LUR)
Endif
...

(Using LUR is not mandatory, it just seems logical to me and it makes sure
you will have no conflicts since the deck file is not accessed by the kernal
at that time)

However, please note that your technique is risky: think of what will happen
if you want to use two instances of your Type or if another Type does the
same thing. 

It is also likely NOT to work for further TRNSYS versions, especially if you
use IISiBat. The way IISiBat inserts comments might change in the future and
could create conflicts with your comments. But if you are ready to test it
and tweak it when IISiBat or TRNSYS changes, it's a nice workaround! 

Cheers,

Michaël Kummert

_________________________________________________________

Michaël Kummert

Solar Energy Laboratory - University of Wisconsin-Madison
1303 Engr Res Bldg, 1500 Engineering Drive
Madison, WI 53706

Tel: +1 (608) 263-1589
Fax: +1 (608) 262-8464
E-mail: kummert@engr.wisc.edu

SEL Web Site: http://sel.me.wisc.edu 
TRNSYS Web Site: http://sel.me.wisc.edu/trnsys



-----Original Message-----
From: owner-trnsys@relay.doit.wisc.edu
[mailto:owner-trnsys@relay.doit.wisc.edu] On Behalf Of Jochen Wriske
Sent: Wednesday, April 09, 2003 08:24
To: trnsys@relay.doit.wisc.edu
Subject: AW: Transmit a String to a UserType


David,
thank you for your information and tips. The Format-statement-problem was
just an example and does not really fit to my problem. 
Now I've found a solution. It uses a trick and is not really perfect, but it
works.
The user-type is defined with one Parameter and the type of this paramter
ist 'string'. If a string 'MyString' has to be available in the
Fortran-Code, in the parameter-field I enter '1 * MyString'. TRNSYS
interpretes this entry as '1', followed by a comment '* MyString'. The
user-code then opens the *.dck-File and reads every line until it gets this
string. Of course, string manipulations in Fortran are a little complicated,
but it works without any errors.

There is another question according to this problem:
I open the *.dck file by using the command:
    OPEN( 17, FILE="Project1.dck")
I woult prefer it to get a file number that is generated dynamically. Is
there any function implemented that I can use?
The file name "project1.dck" may be wrong if the user saves the *.dck file
by using another name. I suppose there must be a way to get access to the
actual *.dck-file. Maybe the variable "LUR" is helpful, but when using it I
always got errors.

I hope I could explain my ideas and questions...

Regards
    Jochen
--
Dipl.-Ing. Jochen Wriske
Lehrstuhl für Technische Thermodynamik
RWTH Aachen
Tel. 0241 / 80 98153
Fax. 0241 / 80 92255