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

Re: [TRNSYS-users] Writing to external files with TYPES defined in external DLLs



Todd,

I am trying to write to an external file in a TYPE that I am developing. I
am using TRNSYS16 and CVF6.6, and am building the TYPE in an external DLL. I
have been able to write to any external file except for the UNIT's assigned
external file (as specified by the ASSIGN statement in the TRNSYS deck
file).

This looks very much like the problem that was described by another user (INQUIRE statement fails). Here is my answer again:

SHARING LOGICAL UNITS (FILES) BETWEEN DLL'S

Typical symptoms:
You assign a file in the TRNSYS input file and that file seems to be
inaccessible to user-Types compiled in an external DLL.
- An "Inquire" statement tells you that the Logical Unit is not
associated to a file
- Attempts to write to / read from the file create "fort.nnn" (where nnn
is the logical unit)

Solution:
If a TRNSYS Type uses a file that is opened and closed by the kernel
(i.e. a file managed through an "ASSIGN" statement in the deck, or an
"External File" in a Studio proforma), the logical unit is associated to
the actual file in TRNDll. If a Type that accesses the file is compiled
into a separate DLL in UserLib:
- Both DLL's must be linked to the DLL form of the Fortran run-time
libraries. Use "/libs:dll" in the command line, or set "Project
Settings\Fortran\Libraries" to "Single-threaded DLL" in the Visual
Studio ("Debug Single-threaded DLL" for debug configuration).
- Furthermore, all DLL's must be compiled in the same mode (Debug or
Release). Note that by default TRNSYS is shipped with a Release
TRNDll.dll, but a Debug DLL is available in "\Compilers\Cvf66\TRNDll\Debug".

Please let us know if this fixes your problem.

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