Hello, I have a Fortran subroutine which uses an optional argument in the call.
subroutine data (n,ns,alpha,covmat,x,y) integer, intent(in):: n,ns double precision, intent(in) :: alpha double precision, intent(in), optional ::covmat(n,ns) double precision, intent(out) :: x(n),y(n) .... end subroutine data I tried the following R wrapper for this subroutine and got an error saying, Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), : 'data' must be of a vector type, was 'NULL' I'm not sure if I passed the arguments correctly in the .Fortran() call. I couldn't find anything helpful online. I would really appreciate any help/comments. data1 <- function(n,ns,alpha,covmat=NULL){ tmp <- .Fortran("data", n = as.integer(n),ns= as.integer(ns) alpha=as.numeric(alpha),covmat=as.matrix(covmat), x=as.double(rep(0,n)),y=as.double(rep(0,n))) ) } result <- list(x=tmp$x, y=tmp$y) return(result) } Thanks, Vineetha [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.