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

Re: [TRNSYS-users] using a dll compiled with matlab



 

 


De : ahmed daoud [mailto:davidov44@yahoo.fr]
Envoyé : lundi 12 juin 2006 16:21
À : 'keilholz, werner'; trnsys-users@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