【问题标题】:Fortran Intent (in)Fortran 意图(中)
【发布时间】:2014-12-02 15:32:01
【问题描述】:

我对这个简单的代码有问题,给我以下错误。 不知何故,它与Intent (in) 属性存在冲突。

gfortran -o build/lib/larsa.o -c -ffree-form -g -J./build/lib lib/larsa.f
lib/larsa.f:2701.8:

 sep, sty, shr               &
    1
Error: PROCEDURE attribute conflicts with INTENT attribute in 'sep' at (1)
lib/larsa.f:2710.17:

If (Len_trim (sep) > 0) Then
             1
Error: 'string' argument of 'len_trim' intrinsic at (1) must be CHARACTER

这是子程序

Subroutine write_separator_new  &
  (                             &
    sep, sty, shr               &
  )

Character (len=*), Intent(in) :: sep, sty
Integer, Intent(in), Optional :: shr

Character (len=65) :: a, fmt

If (Len_trim (sep) > 0) Then
  a = Repeat (sep(1), 60)
Else
  Write (*,*) ""
End If

End Subroutine write_separator_new

【问题讨论】:

    标签: arguments fortran


    【解决方案1】:

    字符串的索引需要:

    a = Repeat (sep(1:1), 60)
    

    编译器假定sep 是一个函数,因为您将其用作函数而不是字符串。

    【讨论】:

      猜你喜欢
      • 2011-02-22
      • 2018-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多