Dear Frank,
In principle, your approach should work (I agree with a previous post saying that the type number should not be 151 to avoid conflicts with existing components; Numbers > 200 should be fine).
A good way to check if your Dll is generated correctly is to use a dependency walker. You can get a free one at
http://www.dependencywalker.com/
This tool allows listing the functions provided by the DLL. It should show one with the name of your type (e.g. TYPE201), with the following attributes:
1. E^= C
2. Ordinal = 1, Hint = 0 (shouldn't really matter if it is different)
3. Function = TYPE201
4. Entry point = some number
If the function does not show up at all, you should make sure it is exported. If 1. is not "C", you should look up how to change the "calling conventions" to "C" in the manual of your compiler.
Hope this helps,
Werner
-----Message d'origine-----
De : Frank Giese [mailto:f.giese@solitem.de]
Envoyé : jeudi 29 mai 2008 08:17
À : trnsys-users@engr.wisc.edu
Objet : [TRNSYS-users] creating new type with freeware fortran compiler g95
Hello!
I tried to create a new module by dropping a .dll file into the
.../UserLib/ReleaseDLLs but it didn't work so far:
Simulation Studio had following error messages:
TRNSYS Message 199 : TRNSYS found at least one user DLL in the UserLib
directory. (Note: Only DLL's including Types that are used in the
simulation are loaded)
Reported information : 0 user DLLs were loaded
after searching in "D:\Programme\Trnsys16_1\UserLib\ReleaseDLLs"
So, TRNSYS found the .dll file but didn't load it up and I don't know why.
How I created the .dll file:
-Precompiling my fortran file (type151.for) including the files:
TrnsysConstants.f90, TrnsysFunctions.f90, TrnsysData.f90,
typeck.for,messages.f90, linkck.f90.
-I had problems with the messages.f90 file, because of the command "use
kernel 32". Since it is only for message purpose I deleted this command
line including the call
RaiseException(EXCEPTION_NONCONTINUABLE_EXCEPTION, 0, 0, 0). After this,
there was no problem.
- Compiling the .dll file with the following command line:
g95 -shared -mrtd -o type151.dll type151.for TrnsysConstants.o
TrnsysFunctions.o TrnsysData.o typeck.o messages.o linkck.o
- Copying this file to the .../UserLib/ReleaseDLLs and starting
Simulation Studio with the type 151
My questions:
-Doesn't it work due to the way I created the .dll? or
-Doesn't it work due to some path missing in another file (TRNDLL.lib)?
-Did anybody else figure it out how it works with a free compiler such
as watcom or g95?
Thank you in advance,
Frank Giese