I just joined the list and appologize if this has been answered before but I am trying to interface between R and the Compaq Visual Fortran compiler version 6.6 for Windows. I found the following instructions on the web -- and an example. When I follow these directions exactly. R 2.0.0 crashes. Has anyone had any experience with this? Below are the instructions that I located: Thanks Dan Stram Professor Department of Preventive Medicine Division of Genetic Epidemiology and Biostatistics University of Southern California 1540 Alcazar Street, Suite 220 Los Angeles, CA 90033 tel 323-442-1817 fax 323-442-2349 email stram at usc.edu web http://www-rcf.usc.edu/~stram These notes were written by J.R.M. Hosking. Using Fortran routines from R with CVF 1. Take a working Fortran subroutine, and put its name in an ATTRIBUTES DLLEXPORT directive to ensure that the routine name is exported from the DLL that will be built. Example: SUBROUTINE MYSUB(X,N,XMEAN) CDEC$ ATTRIBUTES DLLEXPORT :: MYSUB IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION X(N) XMEAN=0D0 DO 10 J=1,N XMEAN=XMEAN+X(J) 10 CONTINUE XMEAN=XMEAN/N RETURN END 2. Compile and link the routine using the CVF options /assume:underscore and /dll. E.g., supposing that the routine is in a file rtest.f, at the command prompt type df rtest.f /assume:underscore /dll This will create a file rtest.dll file that should be kept, and .obj, .lib and .exp files that are not needed for R and can be deleted. (/assume:underscore is needed because R expects that a routine name exported from a DLL will have an underscore appended to it, but CVF does not do this by default.) 3. Now from an R command prompt, use dyn.load to load the DLL and .Fortan("MYSUB",...) to call the function. Example: > dyn.load("E:\\rtest.dll") > is.loaded(symbol.For("MYSUB")) [1] TRUE > x<-1:6 > .Fortran("MYSUB",as.double(x),as.integer(length(x)),xmean=double(1)) [[1]] [1] 1 2 3 4 5 6 [[2]] [1] 6 $xmean [1] 3.5 >
sepideh shokohi
2004-Dec-03 09:54 UTC
[R] help : the datail of Fortran subroutine that use in R
How can I see the datail of Fortran subroutine that use in R. for example I want to see detail of "emn" routine that wrote in Fortran. .Fortran("emn", s$d, old, start, tobs, s$p, s$psi, s$n, s$x, s$npatt, s$r, s$mdpst, s$nmdp, tmp, tmp, numeric(s$p), mle, tau, m, mu0, lambdainv)[[3]] it was in em.norm in norm package. With regards Sepideh Shokohi __________________________________________________ [[alternative HTML version deleted]]
Roger Bivand
2004-Dec-03 10:45 UTC
[R] help : the datail of Fortran subroutine that use in R
On Fri, 3 Dec 2004, sepideh shokohi wrote:> > How can I see the datail of Fortran subroutine that use in R. > for example I want to see detail of "emn" routine that wrote in Fortran. > > > .Fortran("emn", s$d, old, start, tobs, s$p, > s$psi, s$n, s$x, s$npatt, s$r, s$mdpst, s$nmdp, tmp, > tmp, numeric(s$p), mle, tau, m, mu0, lambdainv)[[3]]Download the source package norm_1.0-9.tar.gz from your nearest CRAN mirror and unpack it in a suitable temporary directory. Look in the norm/src directory for the Fortran file containing the code for the emn subroutine. If you are using Windows, you have probably installed a pre-compiled version of the package; to read the Fortran/C/C++ code, you need the source package.> > it was in em.norm in norm package. > > With regards > Sepideh Shokohi > > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no
Uwe Ligges
2004-Dec-03 10:58 UTC
[R] help : the datail of Fortran subroutine that use in R
sepideh shokohi wrote:> How can I see the datail of Fortran subroutine that use in R. > for example I want to see detail of "emn" routine that wrote in Fortran. > > > .Fortran("emn", s$d, old, start, tobs, s$p, > s$psi, s$n, s$x, s$npatt, s$r, s$mdpst, s$nmdp, tmp, > tmp, numeric(s$p), mle, tau, m, mu0, lambdainv)[[3]] > > it was in em.norm in norm package.Download the source package "norm" and look into its sub-directory "src". Uwe Ligges> With regards > Sepideh Shokohi > > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html