generics - 具有 ifort 编译器的通用内部过程

标签 generics compiler-construction fortran intel-fortran fortran2003

以下内容适用于 gfortran 或 f95,但不适用于 ifort:

  interface add
     procedure addr, addi
  end interface add

  real a, b
  integer i, j

  data a, b, i, j /1.0, 2.0, 1, 2/


  call add(a,b)
  call add(i,j)

  stop
  contains 

  subroutine addr(x,y)
  real x, y
  print *, x+y
  return
  end subroutine addr

  subroutine addi(m, n)
  integer m, n
  print *, m+n
  return
  end subroutine addi

  end

ifort 返回此错误:

  error #6643: This statement is incorrectly positioned.
            procedure addr, addi
   ---------^
  error #8168: Parentheses are required after the PROCEDURE keyword.
            procedure addr, addi
  ---------^

假设任何模块过程都不能使用(我们不想在模块中包含addr和addi)并且必须使用ifort作为编译器。 任何帮助将不胜感激。

最佳答案

英特尔 Fortran 12.1.5 不支持没有前导 MODULE 关键字的procedure-stmt(错误引用的接口(interface) block 内的语句)的形式或含义。

(因此,编译器将该行归类为procedure-declaration-stmt - 因此出现两个错误。)

Fortran 2003 标准中引入了不带前导模块的过程语句的形式,Fortran 2008 标准中引入了将内部过程作为通用接口(interface)后面的特定过程的能力。

考虑到您所声明的不能使用模块过程的要求,除非 Intel Fortran 支持该特定的 Fortran 2008 功能,否则没有解决办法。

关于generics - 具有 ifort 编译器的通用内部过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11732122/

相关文章:

fortran - 在 Fortran 90 中使用高斯消元法计算 4 方程组中的浮点误差

arrays - 将未知大小的数组(子例程输出)传递给另一个子例程

c# - 实现基本接口(interface)问题

Java 泛型编译错误 - 不明白该错误

generics - 为什么在实现特征时需要重复我的泛型类型约束?

c - 如何在二进制代码中找到函数边界

c++ - 在 C++ 代码中使用 "umlauts"

c++ - 在 Fortran 77 中使用 C++ 类对象

java - 如何调用不同泛型类型的方法

parsing - 为什么要构建 AST walker 而不是让节点负责自己的输出?