[TRNSYS-users] using a dll compiled with matlab
keilholz, werner
werner.keilholz at cstb.fr
Mon Jun 12 07:36:17 PDT 2006
_____
De : ahmed daoud [mailto:davidov44 at yahoo.fr]
Envoyé : lundi 12 juin 2006 16:21
À : 'keilholz, werner'; trnsys-users at engr.wisc.edu
Objet : RE: [TRNSYS-users] using a dll compiled with matlab
Hi Werner,
Actually I am using the type 155 but I want to win in speed simulation by
compiling the matlab program into a Dll and use it instead of calling the
matlab program with the type 155. I understand that I must write a wrapper
according to TRNSYS calling conventions. So I have a question, Can I create
a skeleton FORTRAN program using the procedure of adding a new component and
after this call in the fortran program the Dll that I create using Matlab
compiler.
Yes, that should be feasible ...
You could take a look at Userlib.f90 in the TRNSYS kernel to see how it's
done in FORTRAN - this part of the code uses the LoadLibary function to
access user-written DLLs. You'd have to figure out what the MATLAB
function's API looks like, LoadLibrary() it, get a pointer to that function
using GetProcAddress() and finally call it (using the pointer) with the
TRNSYS data from XIN, PAR, etc.
The Userlib.f90 is somewhat hard to understand, because it handles multiple
DLLs (containing multiple types), but if you look up LoadLibary and
GetProcAddress in the Compiler documentation or in Google, you should find
some nice and simple examples.
Hope this helps,
Werner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20060612/33256926/attachment-0005.htm>
More information about the TRNSYS-users
mailing list