Tag: gfortran

如何将可分配数组传递给Fortran中的子例程

下面的代码是返回一个分段错误,因为我试图通过的可分配数组没有被正确识别(大小返回1,当它应该是3)。 在这个页面(http://www.eng-tips.com/viewthread.cfm?qid=170599)一个类似的例子似乎表明它应该在F95中正常工作; 我的代码文件有一个.F90扩展名,但我试图将其更改为F95,我正在使用gfortran进行编译。 我的猜测是,问题应该以我将可分配数组传递给子例程的方式进行; 我究竟做错了什么? !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! PROGRAM test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! IMPLICIT NONE DOUBLE PRECISION,ALLOCATABLE :: Array(:,:) INTEGER :: iii,jjj ALLOCATE(Array(3,3)) DO iii=1,3 DO jjj=1,3 Array(iii,jjj)=iii+jjj PRINT*,Array(iii,jjj) ENDDO ENDDO CALL Subtest(Array) END PROGRAM !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! SUBROUTINE Subtest(Array) DOUBLE PRECISION,ALLOCATABLE,INTENT(IN) :: Array(:,:) INTEGER :: iii,jjj PRINT*,SIZE(Array,1),SIZE(Array,2) DO iii=1,SIZE(Array,1) DO jjj=1,SIZE(Array,2) PRINT*,Array(iii,jjj) ENDDO ENDDO END SUBROUTINE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!

由R包调用的Fortran代码仅在Linux上导致段错误崩溃

我正在尝试使用smwrQW R软件包。 我可以让它在Windows机器上工作( example("censReg", "smwrQW") )。 但是,在Linux机器上运行相同的代码会导致我立即发生段错误。 我相信我已经跟踪到以下行的错误。 您应该能够使用Docker和以下命令重现此行为: docker pull rocker/tidyverse docker run -it rocker/tidyverse /bin/bash sudo apt-get install ed Rscript -e "devtools::install_github('USGS-R/smwrBase')" Rscript -e "devtools::install_github('USGS-R/smwrGraphs')" Rscript -e "devtools::install_github('USGS-R/smwrStats')" Rscript -e "devtools::install_github('USGS-R/smwrQW')" Rscript -e "example('censReg', package = 'smwrQW')" Docker版本的gfortran(6.3.0)与RTools版本之间不匹配是否导致问题? 见http://www.thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/#the-solution 我遇到了两个令人费解的怪癖。 首先,如果我在上面链接的那一行之前设置了一个断点( browser() ),那么就没有错误。 其次,Travis的构建似乎已经过去了。