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

Re: [TRNSYS-users] DYNAMICDATA function in C++



Daniel,

 

I tried it out quickly it and seemed to work to the point where DYNDATA tries to read the data file (I don’t have one, so I didn’t check further).

It looks like it is called correctly. Are you sure your data file is OK?

 

It may be a good idea to remove the last argument. It is optional and implements a jump; with your setup, it would mean something like “GOTO 0” – no idea what happens in this case. You could try to replace

extern "C" __declspec(dllimport) void _cdecl DYNAMICDATA(int* lu,int* nind,int nx[],int* ny,double x[],double y[],int info[],int* n);

by

extern "C" __declspec(dllimport) void _cdecl DYNAMICDATA(int* lu,int* nind,int nx[],int* ny,double x[],double y[],int info[]);

 

(That’s what I did in my test).

 

If the problem persists, you should ask one of the FORTRAN gurus to try out our data file in a FORTRAN version.

 

Good luck,

 

Werner

 

De : Daniel.Kiehlmann@csiro.au [mailto:Daniel.Kiehlmann@csiro.au]
Envoyé : mercredi 21 avril 2010 03:06
À : keilholz, werner; TRNSYS-users@engr.wisc.edu
Objet : RE: [TRNSYS-users] DYNAMICDATA function in C++

 

Hi Werner,

Thank you for your answer.

I checked it and I know that the dynamicdata function is causing the error in TRNSYS.

I send you the function of the TRNSYS header file and the part of the code where it calls the that function (it’s the example which is explained in the TRNSYS manual).

 

extern "C" __declspec(dllimport) void _cdecl DYNAMICDATA(int* lu,int* nind,int nx[],int* ny,double x[],double y[],int info[],int* n);

 

...

int nind = 2;

       int nx[2];

       int ny = 2;

       double x[2];

       double y[2];

       int n=0;

       ...

       nx[0] = 3;          //3 values of second variable in file

       nx[1] = 2;           //2 values of first variable in file

       X[0] = T_evap;              //input1          

       x[1] = T_cond;              //input2

             

              DYNAMICDATA(&logical_unit,&nind,nx,&ny,x,y,info,&n);

 

       xout[0]=y[0];

       xout[1]=y[1];

       ...

 

 

 

 

Kind Regards

Daniel

 

From: keilholz, werner [mailto:werner.keilholz@cstb.fr]
Sent: Tuesday, 20 April 2010 6:27 PM
To: Kiehlmann, Daniel (DET, Newcastle); TRNSYS-users@engr.wisc.edu
Subject: RE: [TRNSYS-users] DYNAMICDATA function in C++

 

Hi Daniel,

 

It it hard to tell without looking @ some code, but I would bet on some argument type mismatch, or array size mismatch (your arrays must match the constants in TrnsysConstants.f90).

The TRNSYS kernel functions mainly want arguments passed by reference, like in

int a; doit(&a);

 

Set a breakpoint on the line that calls the function , F5 in DevStudio, navigate to Trnsys.exe, point to the deck to run, inspect the variables when the breakpoint is hit. F11 will basically debug into the TRNDll by using the debug version (you need to recompile TRNDll with a Fortran compiler).

 

Hope that helps (a little),

 

Werner

 

De : Daniel.Kiehlmann@csiro.au [mailto:Daniel.Kiehlmann@csiro.au]
Envoyé : mardi 20 avril 2010 05:20
À : TRNSYS-users@engr.wisc.edu
Objet : [TRNSYS-users] DYNAMICDATA function in C++

 

Dear all,

 

I’m trying to create a new component in C++ with a dynamicdata function.

 

It works when I build the solution in C++, but pulls out following error when I run this component in TRNSYS:

 

“Access violation at address 100048CC in module ‘TRNDLL.DLL’. Read of address 00000002”

 

Does anyone has some experience in using the dynamicdata function in C+ and can help me out?

 

 

Thanks very much in advance

 

Daniel Kiehlmann