为什么gfortran有错误而ifort和pgf90没有错误?

问题描述 投票:0回答:1

我正在尝试安装一个名为 ESL-bundle 的软件包。当我尝试更改编译器时,它的一个模块(称为 futile)出错了。

我的操作:

git clone https://gitlab.com/ElectronicStructureLibrary/esl-bundle/-/tree/master
mkdir install && cd install
#export FC=<path of gfortran> # using pgf90 by default
../esl-bundle/install-bundle --conditions +yaml futile | tee ./install-1.log

我可以使用pgf90和ifort来编译它,但是gfortran给出错误:

esl-bundle/checkouts/futile-1.8/dicts/f_precisions.f90:95:29:

   95 |       k=int(f_loc(a(2))-f_loc(a(1)))
      |                             1
Error: Type mismatch in argument ‘routine’ at (1); passed REAL(4) to UNKNOWN

有一些函数计算某些类型的大小:

    function sizeof_r(av) result(k)
      !function documented here
      implicit none
      real(f_simple), intent(in) :: av
      real(f_simple), dimension(2) :: a
      integer :: k
      a(1)=av
         k = int(f_loc(a(2)) - f_loc(a(1)))
    end function sizeof_r

f_loc()的定义:

!> Function which identifies the address of the scalar object
!! associated to a unknown quantity
function f_loc(routine)
  use f_precisions, only: f_address
  implicit none
  external :: routine       !< Object
  integer(f_address) :: f_loc  !< Address of the object routine

  call getlongaddress(routine,f_loc)

end function f_loc

“例程”似乎没有导致问题的类型。

那么为什么 pgf90 和 ifort 可以处理这个问题而 gfortran 不能呢?我可以用一些编译器标志来修复它吗?

我想用gfortran编译它,因为我的程序主要基于它。

更新: 这个捆绑包相当古老,并且在许多科学软件中广泛使用,因此我不想调试或重写它的任何部分(尽管在今天看来这似乎很荒谬)。

compiler-errors fortran
1个回答
0
投票

最后我使用标志 -fallow-argumnet-mismatch 来避免此错误。我发现这个标志在其 mpi 版本中使用(使用 mpiifort 和 mpicc)。所以我猜这是这个程序中的常见操作。

我相信有更好的方法来计算类型的大小,但考虑到程序员的实际工作(99%科学家)和他们编写这个程序的时间,我认为没有必要关心它的内部实现。

© www.soinside.com 2019 - 2024. All rights reserved.