[英]Compiling F77 with R CMD SHLIB for use in R package. Changing `-fmax-stack-var-size=`
I've inherited some F77 code from the 1980s that I'd like to eventually use in an R package that is on CRAN.我从 1980 年代继承了一些 F77 代码,我希望最终在 CRAN 上的 R 包中使用这些代码。 Basically I'll be substituting a slow function written in straight R with a
.Call
to a F77 subroutine that runs 100x faster.基本上,我将用一个
.Call
代替一个用直接 R 编写的慢函数,该函数运行速度提高了 100 倍。 I've done similar heavy lifting with C in the past.我过去曾用 C 做过类似的繁重工作。 However, when I compile the fortran subroutine via
R CMD SHLIB
I get a warning about one of the arrays being "larger than limit set by '-fmax-stack-var-size='".但是,当我通过
R CMD SHLIB
编译 fortran 子例程时,我收到一条警告,说其中一个数组“大于'-fmax-stack-var-size='”设置的限制。 I can fix this by compiling explicitly with gfortran
and setting -fmax-stack-var-size
appropriately.我可以通过使用
gfortran
显式编译并适当设置-fmax-stack-var-size
来解决此问题。 However, how can I set the flag when running R CMD SHLIB
?但是,如何在运行
R CMD SHLIB
时设置标志? In a Makevars
file?在
Makevars
文件中? Eventually, I'll include this in a new release and submit to CRAN and I want to head off any issues.最终,我会将其包含在新版本中并提交给 CRAN,我想解决任何问题。 Many thanks.
非常感谢。
Yes, in ~/.R/Makevars
for your compilations, in src/Makevars
for all builds of the package.是的,在
~/.R/Makevars
用于您的编译,在src/Makevars
用于包的所有构建。 CRAN has views on which options are portable so you may not be able to ship with the option in src/Makevars
. CRAN 对哪些选项是可移植的有意见,因此您可能无法在
src/Makevars
提供该选项。
Here is what I have:这是我所拥有的:
edd@rob:~$ grep ^F .R/Makevars
FLAGS=-Wall -O3 -g -pipe $(PEDANTIC) $(XTRAFLAGS)
FFLAGS=-O3 -g0 -Wall -pipe
FCFLAGS=-O3 -g0 -Wall -pipe
FC=$(CCACHE) gfortran
F77=$(CCACHE) gfortran
F95=$(CCACHE) gfortran
edd@rob:~$
where some of the other values are previoysly set as you can surmise.您可以猜测,其中一些其他值是预先设置的。 Note that there are several Fortran compiler variables, details as usual in Writing R Extensions .
请注意,有几个 Fortran 编译器变量,如通常的编写 R 扩展中的详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.