Hello, I am trying to call a FORTRAN subroutine within R and something really strange happens: I have a dll-library, that I load with dyn.load('mpbvv.dll'). I have checked the [Ordinal/Name Pointer] Table for the function within the library that I want to call - it is there (objdump - p mpbvv.dll). Then, I have written an R-wrapper to call the FORTRAN subroutine, which works fine. SInce I have 200 "points", at which I have to evaluate the function, I have to call it 200 times. It works about 100 times just fine and then R crashes. The values for which the function is evaluated are almost the same, there no sudden big differences. The only thing that is probably not really ok is that is.loaded('mpbvv.dll') returns FALSE. But if I call getLoadedDLLs(), the library is loaded> getLoadedDLLs()Filename base base methods C:/Programme/R/R-2.7.1/library/methods/libs/methods.dll grDevices C:/Programme/R/R-2.7.1/library/grDevices/libs/grDevices.dll stats C:/Programme/R/R-2.7.1/library/stats/libs/stats.dll mpbvv E:/Zoe/DA/mpbvv.dll Dynamic.Lookup base FALSE methods FALSE grDevices FALSE stats FALSE mpbvv TRUE I am loading four more libraries: library('actuar') library('bbmle') library('polynom') library('NORMT3') Could this be a problem? I don't have any idea why R crashes. Do you? Thanks a lot for your advice in advance! Cheers, Zoe [[alternative HTML version deleted]]
Zornitsa Luleva wrote:> Hello, > > I am trying to call a FORTRAN subroutine within R and something really > strange happens: > > I have a dll-library, that I load with dyn.load('mpbvv.dll'). I have checked > the [Ordinal/Name Pointer] Table for the function within the library that I > want to call - it is there (objdump - p mpbvv.dll). > > Then, I have written an R-wrapper to call the FORTRAN subroutine, which > works fine. SInce I have 200 "points", at which I have to evaluate the > function, I have to call it 200 times. It works about 100 times just fine > and then R crashes. The values for which the function is evaluated are > almost the same, there no sudden big differences. > > The only thing that is probably not really ok is that is.loaded('mpbvv.dll') > returns FALSE. But if I call getLoadedDLLs(), the library is loaded > >> getLoadedDLLs() >> > Filename > base base > methods C:/Programme/R/R-2.7.1/library/methods/libs/methods.dll > grDevices C:/Programme/R/R-2.7.1/library/grDevices/libs/grDevices.dll > stats C:/Programme/R/R-2.7.1/library/stats/libs/stats.dll > mpbvv E:/Zoe/DA/mpbvv.dll > Dynamic.Lookup > base FALSE > methods FALSE > grDevices FALSE > stats FALSE > mpbvv TRUE > I am loading four more libraries: > > library('actuar') > library('bbmle') > library('polynom') > library('NORMT3') > > Could this be a problem? > > I don't have any idea why R crashes. Do you? > >The most common case is that people's argument lists to .Fortran do not match up with the expected types and dimensions of the subroutine. This may (e.g.) cause you to write past the end of an array, leading to memory corruption that will not be discovered until it trips up the memory management some time later. Turning gctorture() on may provoke the error to occur sooner and become easier to pinpoint.> Thanks a lot for your advice in advance! >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On Mon, 18 Aug 2008, Zornitsa Luleva wrote:> Hello, > > I am trying to call a FORTRAN subroutine within R and something really > strange happens:Did you read the posting guide? It suggests the R-devel list for questions about 'C, C++ etc', and Fortran is part of the 'etc'.> I have a dll-library, that I load with dyn.load('mpbvv.dll'). I have checked > the [Ordinal/Name Pointer] Table for the function within the library that I > want to call - it is there (objdump - p mpbvv.dll). > > Then, I have written an R-wrapper to call the FORTRAN subroutine, which > works fine. SInce I have 200 "points", at which I have to evaluate the > function, I have to call it 200 times. It works about 100 times just fine > and then R crashes. The values for which the function is evaluated are > almost the same, there no sudden big differences. > > The only thing that is probably not really ok is that is.loaded('mpbvv.dll') > returns FALSE.Correctly: please do read the help before posting: ?is.loaded has symbol: a character string giving a symbol name. not, note, a DLL name.> But if I call getLoadedDLLs(), the library is loaded >> getLoadedDLLs() > Filename > base base > methods C:/Programme/R/R-2.7.1/library/methods/libs/methods.dll > grDevices C:/Programme/R/R-2.7.1/library/grDevices/libs/grDevices.dll > stats C:/Programme/R/R-2.7.1/library/stats/libs/stats.dll > mpbvv E:/Zoe/DA/mpbvv.dll > Dynamic.Lookup > base FALSE > methods FALSE > grDevices FALSE > stats FALSE > mpbvv TRUE > I am loading four more libraries: > > library('actuar') > library('bbmle') > library('polynom') > library('NORMT3') > > Could this be a problem? > > I don't have any idea why R crashes. Do you?Most likely an error in your code. Perhaps a mismatch (in type, in length) between what you pass .Fortran and what your code expects? Without the reproducible example the posting guide asks for we can only guess.> Thanks a lot for your advice in advance! > > Cheers, > Zoe > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.PLEASE do. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595