0

次のファイルを でコンパイルするf2cと、有益でない構文エラー メッセージが表示されて失敗します。

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

gfortranエラーなしでコンパイルします。何が原因なのか考えていますか?f2cas に厳密で、適切なエラー メッセージが表示される Fortran コンパイラを知っていますか?

問題のファイル:

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

f2cFORTRAN77と行を読むことを期待していると思います

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

Fortran 90 で導入されたトークン ( ie ) を使用します。行を次のように変更してみてください。 <=

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

これで問題が解決した場合、次はどちらが Fortran 90 の導入であるかf2cについて文句を言うことになると思います。==

のファンの方は読み進めないでくださいf2c

f2c のように厳密で、適切なエラー メッセージが表示される Fortran コンパイラを知っていますか? 冗談ですよね? f2cは時代遅れの山であり、中程度から重度の不承認のお気に入りの用語をここに挿入します。これは、最初に発行された1990年にはおそらく悪い考えでした. Fortran と C の間の相互運用性が (a) 標準化され、(b) これまで以上に簡単になった今、それを使用する正当な理由はないと思います。

于 2013-11-25T15:43:42.077 に答える