语句标签字段中的非法字符 - 编译 .f 扩展名时
Illegal character in statement label field - when compiling .f extension
我尝试使用 ifort 编译 .f 文件。
我收到以下错误:
/.../wreqvr.f(2):错误 #5149:语句标签字段 [h] 中的非法字符
该文件是 GNU C 库的一部分。
----^
来自以下建议:
https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/293662
-> 表示将扩展名 .f 更改为 .f90 有效。
还有其他解决办法吗? (我不想更改扩展名,因为代码由 git... 管理)
我在我的旧机器上使用了相同的 ifort 版本,它运行良好,没有错误。
不明白为什么会出现这个错误
我的旧机和新机唯一的区别就是centos版本(老6,新7)
gcc 版本与此错误有关吗?
我添加了部分代码和错误信息。这里:coord.f 文件
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header is separate from features.h so that the compiler can
include it implicitly at the start of every compilation. It must
not itself include <features.h> or any other header that includes
<features.h> because the implicit include comes before any feature
test macros that may be defined in a source file before it first
explicitly includes a system header. GCC knows the name of this
header in order to preinclude it. */
/* We do support the IEC 559 math functionality, real and complex. */
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
Unicode 6.0. */
/* We do not support C11 <threads.h>. */
subroutine coord(vx,vy,n,d,x,y)
c version : 21.07.2000 16:18
c=======================================================================
implicit none
c*** Calculate the x and y coordinates of a point located on a curve v
c*** at a distance d from the origin of the curve
* arguments
integer n
real*8 vx(n),vy(n),d,x,y
* variables locales
integer i
real*8 dist,distot,eps
parameter (eps=1.e-06)
* procedures
intrinsic sqrt
c========================
c.. n : number of points in the curve
c.. vx,vy: coordinates of the points in the curve
c.. d : required distance along the curve
c.. x,y : coordinates of the found point
c.. dist: distance between 2 consecutive points on the curve
c.. distot: total distance covered
c========================
*..Initialisation.
distot = 0.0
*..Loop over the curve segments
do i=1, n-1 !{
dist = sqrt((vx(i+1)-vx(i))**2 + (vy(i+1)-vy(i))**2)
distot = distot + dist
*..Check whether the distance d is passed
if (distot .ge. d) then !{
x = vx(i+1) - ((distot-d)/dist)*(vx(i+1)-vx(i))
y = vy(i+1) - ((distot-d)/dist)*(vy(i+1)-vy(i))
return
end if !}
end do !}
c*** Check whether the required distance is equal - within tolerance -
c*** to the total curve length
if (abs(distot - d) .lt. eps) then !{
x = vx(n)
y = vy(n)
return
end if !}
*..Error: required distance greater than the total curve length.
print *, 'coord: required distance greater than the total length'
print*,'distot=',distot
print*,'d=',d
call pltend
stop 'Check the target specification'
end
$ifortcoord.f
coord.f(1): error #5149: Illegal character in statement label field [/]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
^
coord.f(1): error #5149: Illegal character in statement label field [*]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
-^
coord.f(1): error #5149: Illegal character in statement label field [C]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
---^
coord.f(1): error #5149: Illegal character in statement label field [o]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
----^
coord.f(1): error #5118: First statement in file must not be continued
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
-----^
coord.f(2): error #5149: Illegal character in statement label field [T]
This file is part of the GNU C Library.
---^
coord.f(2): error #5149: Illegal character in statement label field [h]
This file is part of the GNU C Library.
----^
coord.f(4): error #5149: Illegal character in statement label field [T]
The GNU C Library is free software; you can redistribute it and/or
---^
coord.f(4): error #5149: Illegal character in statement label field [h]
The GNU C Library is free software; you can redistribute it and/or
$ ifort -免费 coord.f
要么
$ ifort coord.f90
coord.f(1): error #5082: Syntax error, found '/' when expecting one of: <LABEL> <END-OF-STATEMENT> ; BLOCK BLOCKDATA PROGRAM MODULE TYPE BYTE CHARACTER ...
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
^
coord.f(16): error #5145: Invalid blank/tab
<http://www.gnu.org/licenses/>. */
----------------------------------^
coord.f(20): error #5145: Invalid blank/tab
include it implicitly at the start of every compilation. It must
-----------------------------------------------------------^
coord.f(29): error #5143: Missing mandatory separating blank
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
--------------------------------^
coord.f(30): error #5145: Invalid blank/tab
Unicode 6.0. */
---------------^
如果这些文件是您正在编译的原始文件,那么您应该删除 C 风格注释。
它们以 /*
开始,以 */
结束。
这些块不是合法的 Fortran。 C 预处理器会丢弃它们,但即使您通过 ifort -fpp
启用预处理,它们也不会被丢弃。只有 C 预处理器会丢弃它们。
另请参阅 了解类似问题。
几乎可以肯定,之前有人使用 C 预处理器创建了这些文件。这是错误的。不要将 C 预处理器单独用于 Fortran 源文件。
并且不要使用 gcc
预处理 Fortran 源代码,它是一个 C 预处理器并且它以错误的模式使用 C 预处理器。您可以通过 Fortran 编译器使用预处理器(gfortran -cpp
或 ifort -fpp
- 注意 cpp 和 fpp 略有不同),但不要直接使用 C 预处理器,也不要使用 C 编译器。
尽管已经回答了这个问题,但我只是 运行 遇到了同样的问题。
有用的是这个胎面还有这个:
https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/293662(即使我在 linux)
.f90 的组合和使用 ifort 而不是 f77 的用法有所帮助。
如果构建系统依赖于设置 FC、F77 等(还有 MPIF77),请确保将它们相应地设置为 ifort(和 mpiifort)。
如果不同的子步骤默认使用不同的工具来处理连续的任务,您通常 运行 会遇到问题,因此根据您的构建系统明确地控制它们。
我尝试使用 ifort 编译 .f 文件。
我收到以下错误:
/.../wreqvr.f(2):错误 #5149:语句标签字段 [h] 中的非法字符 该文件是 GNU C 库的一部分。 ----^
来自以下建议: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/293662 -> 表示将扩展名 .f 更改为 .f90 有效。
还有其他解决办法吗? (我不想更改扩展名,因为代码由 git... 管理)
我在我的旧机器上使用了相同的 ifort 版本,它运行良好,没有错误。
不明白为什么会出现这个错误
我的旧机和新机唯一的区别就是centos版本(老6,新7)
gcc 版本与此错误有关吗?
我添加了部分代码和错误信息。这里:coord.f 文件
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header is separate from features.h so that the compiler can
include it implicitly at the start of every compilation. It must
not itself include <features.h> or any other header that includes
<features.h> because the implicit include comes before any feature
test macros that may be defined in a source file before it first
explicitly includes a system header. GCC knows the name of this
header in order to preinclude it. */
/* We do support the IEC 559 math functionality, real and complex. */
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
Unicode 6.0. */
/* We do not support C11 <threads.h>. */
subroutine coord(vx,vy,n,d,x,y)
c version : 21.07.2000 16:18
c=======================================================================
implicit none
c*** Calculate the x and y coordinates of a point located on a curve v
c*** at a distance d from the origin of the curve
* arguments
integer n
real*8 vx(n),vy(n),d,x,y
* variables locales
integer i
real*8 dist,distot,eps
parameter (eps=1.e-06)
* procedures
intrinsic sqrt
c========================
c.. n : number of points in the curve
c.. vx,vy: coordinates of the points in the curve
c.. d : required distance along the curve
c.. x,y : coordinates of the found point
c.. dist: distance between 2 consecutive points on the curve
c.. distot: total distance covered
c========================
*..Initialisation.
distot = 0.0
*..Loop over the curve segments
do i=1, n-1 !{
dist = sqrt((vx(i+1)-vx(i))**2 + (vy(i+1)-vy(i))**2)
distot = distot + dist
*..Check whether the distance d is passed
if (distot .ge. d) then !{
x = vx(i+1) - ((distot-d)/dist)*(vx(i+1)-vx(i))
y = vy(i+1) - ((distot-d)/dist)*(vy(i+1)-vy(i))
return
end if !}
end do !}
c*** Check whether the required distance is equal - within tolerance -
c*** to the total curve length
if (abs(distot - d) .lt. eps) then !{
x = vx(n)
y = vy(n)
return
end if !}
*..Error: required distance greater than the total curve length.
print *, 'coord: required distance greater than the total length'
print*,'distot=',distot
print*,'d=',d
call pltend
stop 'Check the target specification'
end
$ifortcoord.f
coord.f(1): error #5149: Illegal character in statement label field [/]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
^
coord.f(1): error #5149: Illegal character in statement label field [*]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
-^
coord.f(1): error #5149: Illegal character in statement label field [C]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
---^
coord.f(1): error #5149: Illegal character in statement label field [o]
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
----^
coord.f(1): error #5118: First statement in file must not be continued
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
-----^
coord.f(2): error #5149: Illegal character in statement label field [T]
This file is part of the GNU C Library.
---^
coord.f(2): error #5149: Illegal character in statement label field [h]
This file is part of the GNU C Library.
----^
coord.f(4): error #5149: Illegal character in statement label field [T]
The GNU C Library is free software; you can redistribute it and/or
---^
coord.f(4): error #5149: Illegal character in statement label field [h]
The GNU C Library is free software; you can redistribute it and/or
$ ifort -免费 coord.f 要么 $ ifort coord.f90
coord.f(1): error #5082: Syntax error, found '/' when expecting one of: <LABEL> <END-OF-STATEMENT> ; BLOCK BLOCKDATA PROGRAM MODULE TYPE BYTE CHARACTER ...
/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
^
coord.f(16): error #5145: Invalid blank/tab
<http://www.gnu.org/licenses/>. */
----------------------------------^
coord.f(20): error #5145: Invalid blank/tab
include it implicitly at the start of every compilation. It must
-----------------------------------------------------------^
coord.f(29): error #5143: Missing mandatory separating blank
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
--------------------------------^
coord.f(30): error #5145: Invalid blank/tab
Unicode 6.0. */
---------------^
如果这些文件是您正在编译的原始文件,那么您应该删除 C 风格注释。
它们以 /*
开始,以 */
结束。
这些块不是合法的 Fortran。 C 预处理器会丢弃它们,但即使您通过 ifort -fpp
启用预处理,它们也不会被丢弃。只有 C 预处理器会丢弃它们。
另请参阅
几乎可以肯定,之前有人使用 C 预处理器创建了这些文件。这是错误的。不要将 C 预处理器单独用于 Fortran 源文件。
并且不要使用 gcc
预处理 Fortran 源代码,它是一个 C 预处理器并且它以错误的模式使用 C 预处理器。您可以通过 Fortran 编译器使用预处理器(gfortran -cpp
或 ifort -fpp
- 注意 cpp 和 fpp 略有不同),但不要直接使用 C 预处理器,也不要使用 C 编译器。
尽管已经回答了这个问题,但我只是 运行 遇到了同样的问题。 有用的是这个胎面还有这个: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/293662(即使我在 linux)
.f90 的组合和使用 ifort 而不是 f77 的用法有所帮助。
如果构建系统依赖于设置 FC、F77 等(还有 MPIF77),请确保将它们相应地设置为 ifort(和 mpiifort)。 如果不同的子步骤默认使用不同的工具来处理连续的任务,您通常 运行 会遇到问题,因此根据您的构建系统明确地控制它们。