[R] DLL Memory Problem

Brian Habing habing at stat.sc.edu
Fri Apr 8 17:04:50 CEST 2005


Hello,

I have created a .dll file using G77 and MinGW on my PC (Windows 
2000).  After using dyn.load to bring it into R2.0.1, I then call the .dll 
through the function ccprox shown below.  It returns the correct 
values.  If I run it a second time though it returns different values, so 
it seems something is being placed oddly in memory.

If I unload and reload the .dll it works again the first time.

It does the same if I copy the compiled .dll over to my Windows XP machine.

Thank you for any help,

Brian Habing
habing at stat.sc.edu


The Fortran subroutine beings with:

	subroutine ccprox(nexmn,nitem,respmat2,covmatr,covmatt,
      $               cormatr,cormatt)

!ccccc This subroutine will calculate all the pairwise
!ccccc conditional covariances. An ending r means for
!ccccc rest score, an ending t means for total score.

	parameter (maxitem=100,maxexmn=10000,maxcats=10,ncells=1001)

!ccccc  ncells must be maxitem*maxcats+1

	integer nexmn,nitem,scoretemp,mscore
	integer	respmat(maxexmn,maxitem)
	integer	tscore(maxexmn) /maxexmn*0/
         integer tstemp(maxexmn) /maxexmn*0/
	integer natscore(ncells) /ncells*0/
         integer natemp(ncells) /ncells*0/
         integer i,j,k,l
	integer tcountt,tcountr,tcountt2,tcountr2
	real*8 respmat2(maxexmn,maxitem)
	real*8 pisum(ncells),plsum(ncells),pilsum(ncells)
	real*8 qisum(ncells),qlsum(ncells),qilsum(ncells)	
	real*8 pi2sum(ncells),pl2sum(ncells)
	real*8 qi2sum(ncells),ql2sum(ncells)
	real*8 covmatr(maxitem,maxitem),cormatr(maxitem,maxitem)
         real*8 covmatt(maxitem,maxitem),cormatt(maxitem,maxitem)
	real*8 sisl


The R function that is calling it is as follows (inputdata is a 400x10 
matrix of 0's and 1's
in the example I have been trying).

ccprox<-function(inputdata){
   nexmn<-length(inputdata[,1])
   nitem<-length(inputdata[1,])
   covmatr<-matrix(0,100,100)
   covmatt<-matrix(0,100,100)
   cormatr<-matrix(0,100,100)
   cormatt<-matrix(0,100,100)
   respmat2<-matrix(0,nrow=10000,ncol=100)
   respmat2[1:nexmn,1:nitem]<-as.matrix(inputdata)
   if (is.loaded("ccprox_")==TRUE){
   x<-(.C("ccprox_",as.integer(nexmn),as.integer(nitem),respmat2,
       covmatr,covmatt,cormatr,cormatt))
   list(covmatr=x[[4]][1:nitem,1:nitem],covmatt=x[[5]][1:nitem,1:nitem],
       cormatr=x[[6]][1:nitem,1:nitem],cormatt=x[[7]][1:nitem,1:nitem],)
     }
   else{
     warning("ccprox.dll was not loaded")
     NULL
   }
}




More information about the R-help mailing list