Hi, Using return values from
functions defined in FORTRAN is problematic, due to the different stack model
between the 2 languages. I solved the problem like this:
SUBROUTINE
GETLABEL2(i,j, outLabel) !i=unit #, j=label # !dec$ attributes
dllexport :: getLabel2 use TrnsysData use TrnsysConstants integer ::
i,j,k,m,n character (len=*)
:: outLabel m=0 do k=1,N_LABELS
if(LABEL_UNIT(k).eq.i) then m=m+1
if(m.eq.j) then do
n=1,maxLabelLength
outLabel(n:n)=LABEL(n,k) enddo endif endif enddo end SUBROUTINE
GETLABEL2 2. Use it in C++ a) add to
Trnsys.H: char* outLabel, int* lOutLabel);
char theLabel[2000]; int sizeLabel; int nLabel =1; GETLABEL2(&iunit,
&nLabel, theLabel, &sizeLabel); This will yield the name
of the 1st (nLabel) special card padded with spaces (you have to
scratch it out of “theLabel” by removing all trailing spaces. If you do not want to
modify trndll, you can use the method using External files described in my
earlier post. Werner De :
rgaray@labein.es [mailto:rgaray@labein.es]
|