Fortran的意图(中) [英] Fortran Intent (in)
本文介绍了Fortran的意图(中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个简单的code的一个问题,给我下面的错误。
不知怎的,它是说,没有与意图(在)
属性冲突。
gfortran -o建立/ lib中/ larsa.o -c -ffree形式-g -J./build/lib的lib / larsa.f
LIB / larsa.f:2701.8: 九月,麦粒肿,SHR和放大器;
1
错误:过程属性与九月的意图属性的冲突在(1)
LIB / larsa.f:2710.17:如果(LEN_TRIM(SEP)大于0)然后
1
错误:(1)必须是字符的LEN_TRIM'内在'串'的说法
这是子程序
子程序write_separator_new&安培;
(安培;
九月,麦粒肿,SHR和放大器;
)字符(LEN = *),意图(中)::月,麦粒肿
整型,意图(中),可选:: SHR字符(LEN = 65)::一,FMT如果(LEN_TRIM(SEP)大于0)然后
一个=重复(SEP(1),60)
其他
写(*,*),
万一结束子程序write_separator_new
解决方案
字符串索引要求:
A =重复(SEP(1:1),60)
编译器假定月
是一个函数,因为你用它作为这样的,而不是作为一个字符串。
I am having a problem with this simple code, giving me the following error.
Somehow it is saying that there is a conflict with the Intent (in)
attribute.
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
This is the subroutine
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
解决方案
Indexing of character strings requires :
a = Repeat (sep(1:1), 60)
The compiler assumed sep
is a a function, because you used it as such and not as a character string.
这篇关于Fortran的意图(中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文