0

当我用 编译以下文件时f2c,它会失败并显示非信息性语法错误消息

f2c  < ../../libcruft/blas-xtra/ddot3.f >ddot3.c
   ddot3:
Error on line 37: syntax error

gfortran编译它没有任何错误。你知道是什么原因造成的吗?你知道任何 fortran 编译器会很严格f2c并且有很好的错误信息吗?

有问题的文件:

c Copyright (C) 2009-2012  VZLU Prague, a.s., Czech Republic
c
c Author: Jaroslav Hajek <highegg@gmail.com>
c
c This file is part of Octave.
c
c Octave is free software; you can redistribute it and/or modify
c it under the terms of the GNU General Public License as published by
c the Free Software Foundation; either version 3 of the License, or
c (at your option) any later version.
c
c This program is distributed in the hope that it will be useful,
c but WITHOUT ANY WARRANTY; without even the implied warranty of
c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c GNU General Public License for more details.
c
c You should have received a copy of the GNU General Public License
c along with this software; see the file COPYING.  If not, see
c <http://www.gnu.org/licenses/>.
c
      subroutine ddot3(m,n,k,a,b,c)
c purpose:      a 3-dimensional dot product.
c               c = sum (a .* b, 2), where a and b are 3d arrays.
c arguments:
c m,n,k (in)    the dimensions of a and b
c a,b (in)      double prec. input arrays of size (m,k,n)
c c (out)       double prec. output array, size (m,n)
      integer m,n,k,i,j,l
      double precision a(m,k,n),b(m,k,n)
      double precision c(m,n)

      double precision ddot
      external ddot


c quick return if possible.
      if (m <= 0 .or. n <= 0) return

      if (m == 1) then
c the column-major case.
        do j = 1,n
          c(1,j) = ddot(k,a(1,1,j),1,b(1,1,j),1)
        end do
      else
c We prefer performance here, because that's what we generally
c do by default in reduction functions. Besides, the accuracy
c of xDOT is questionable. Hence, do a cache-aligned nested loop.
        do j = 1,n
          do i = 1,m
            c(i,j) = 0d0
          end do
          do l = 1,k
            do i = 1,m
              c(i,j) = c(i,j) + a(i,l,j)*b(i,l,j)
            end do
          end do
        end do
      end if

      end subroutine
4

1 回答 1

2

我相信f2c期望阅读 FORTRAN77 和行

if (m <= 0 .or. n <= 0) return

使用Fortran 90 中引入的令牌 ( ie )。尝试将行更改为 <=

if (m .le. 0 .or. n .le. 0) return

我希望如果这能解决问题f2c,接下来会抱怨==这也是 Fortran 90 的介绍。

如果您是f2c.

至于您是否知道任何像 f2c 一样严格并具有良好错误消息的 fortran 编译器?你在开玩笑吧? f2c是一堆过时的插入你最喜欢的中度到重度不赞成的术语,这在 1990 年首次出版时可能是一个坏主意。现在 Fortran 和 C 之间的互操作性(a)标准化并且(b)比以往任何时候都更容易,我认为没有充分的理由使用它。

于 2013-11-25T15:43:42.077 回答