Galkowski, Jan wrote: > Joyful. > > I'm adapting a FORTRAN 77 package for use with R. Pretty > straightforward. > > Except for a glitch it took me some time to figure out. This existing > package has subroutines which have parameters called "NA". So, I called > subroutines like > > bnodes <- function(n, lst, lptr, lend, nodes, nb, na, nt) > { > ensure.all.numeric(list(n, lst, lptr, lend, nodes, nb, n.a, nt), > "all arguments to -bnodes- must be numeric") > out <- .Fortran("bnodes", N=as.integer(n), LIST=as.integer(lst), > LPTR=as.integer(lptr), LEND=as.integer(lend), > NODES=as.integer(nodes), > NB=as.integer(nb), NA=as.integer(na), > NT=as.integer(nt)) > return(out[5:8]) > } > > I had called routines successfully before, so I couldn't figure out what > was wrong. By elimination, I discovered that the parameter pass > > NA=as.integer(na) > > was to blame. So, thinking the right-hand-side (R's world) was the > problem, even if "na" wasn't recognized as "not available", I changed > to: > > bnodes <- function(n, lst, lptr, lend, nodes, nb, n.a, nt) > { > ensure.all.numeric(list(n, lst, lptr, lend, nodes, nb, n.a, nt), > "all arguments to -bnodes- must be numeric") > out <- .Fortran("bnodes", N=as.integer(n), LIST=as.integer(lst), > LPTR=as.integer(lptr), LEND=as.integer(lend), > NODES=as.integer(nodes), > NB=as.integer(nb), NA=as.integer(n.a), > NT=as.integer(nt)) > return(out[5:8]) > } > > No win. I would only be happy if I used > > bnodes <- function(n, lst, lptr, lend, nodes, nb, n.a, nt) > { > ensure.all.numeric(list(n, lst, lptr, lend, nodes, nb, n.a, nt), > "all arguments to -bnodes- must be numeric") > out <- .Fortran("bnodes", N=as.integer(n), LIST=as.integer(lst), > LPTR=as.integer(lptr), LEND=as.integer(lend), > NODES=as.integer(nodes), > NB=as.integer(nb), NAA=as.integer(n.a), > NT=as.integer(nt)) > return(out[5:8]) > } > > and had to actually change the FORTRAN code to comply. > > Sounds to me like there's a little room for improvement here. Should be > documented anyway. > Do the argument names even get used on the Fortran side?? AFAIK, it only matters for labeling the result.
Anyways, this has nothing to do with "not available", a name like PACK would get you equally confused. You are being bitten by partial argument matching: NA matches NAOK. One workaround is to add NAOK=FALSE explicitly to the call. Or just use lowercase names. -- 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 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ R-help@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.