语句标签字段中的非法字符 - 编译.f扩展名时

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

我尝试使用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

$ ifort coord.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 -free 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.  */
---------------^
annotations fortran intel-fortran
2个回答
0
投票

如果文件是您正在编译的原始文件,则应删除C样式注释。

他们从/*开始,以*/结束。

这些块不是合法的Fortran。 C预处理器会丢弃它们,但即使您通过ifort -fpp启用预处理,它们也不会被丢弃。只有C预处理器丢弃它们。

另请参阅How do I compile this Fortran code with new 2017 ifort?以了解类似问题。

几乎可以肯定,之前有人使用C预处理器创建了这些文件。那是错的。不要将自己的C预处理器用于Fortran源文件。

并且不要使用gcc预处理Fortran源,它是一个C预处理器,它以错误的模式使用C预处理器。您可以通过Fortran编译器使用预处理器(gfortran -cppifort -fpp - 小心cpp和fpp略有不同),但不要直接使用C预处理器而不要使用C编译器。


0
投票

即使已经回答了这个问题,我也遇到了同样的问题。这有什么帮助,这也是:https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/293662(即使我在linux上)

.f90的组合和ifort而不是f77的用法有帮助。

如果构建系统依赖于设置FC,F77等(也是MPIF77),请确保将它们设置为ifort(和mpiifort)。如果不同的子步骤默认为连续任务的不同工具,则通常会遇到问题,因此请根据构建系统明确控制它们。

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