[R] Problem defining a system of odes as a C library with lsoda

Dylan Childs D.Childs at sheffield.ac.uk
Sun Nov 6 20:39:10 CET 2005


I have been trying to make use of the odesolve library on my 
university's Linux grid - currently R version 2.0.1 is installed and 
the system runs 64-bit Scientific Linux based on Redhat. I cannot seem 
to get lsoda working when I define the model as a shared C library. For 
example, the following snippet uses the mymod.c example bundled with 
the package:

### START
rm(list=ls())
setwd("~/projects/test_odesolve")
invisible(file.remove("mymod.o","mymod.so"))
system("R CMD SHLIB mymod.c")
dyn.load("mymod.so")

require(odesolve)
parms <- c(k1 = 0.04, k2 = 1e4, k3=3e7)
my.atol <- c(1e-6, 1e-10, 1e-6)
times <- c(0, 4*10^(-1:10))
print(system.time(
                   out1 <- lsoda(c(1.0,0.0,0.0),times,"myderivs",
                                 parms,
                                 rtol=1e-4,atol=my.atol,jacfunc="myjac",
                                 dllname="mymod")
                   )
       )
### END

When I run this mymod.c compiles without any errors or warnings and the 
mymod.so library seems to load fine via dyn.load (the call 
is.loaded("mymod") returns TRUE for example). However, the call to 
lsoda fails with the following error:

Error in lsoda(c(1, 0, 0), times, "myderivs", parms, rtol = 1e-04, atol 
= my.atol,  :
	Confusion over the length of parms

This seems a very odd error message as the length of the parameter 
vector is definitely correct and if I run exactly the same script on my 
Mac everything works fine. Have I missed something obvious - is this 
something to do with using an older version of R for example?

Dr. Dylan Z. Childs
Department of Animal and Plant Sciences,
University of Sheffield,
Sheffield,
S10 2TN, UK.




More information about the R-help mailing list