我需要为Fortran代码中的不同文件定义一个变量名,而我正在使用这个命令
open(unit=5,file="plot.sm")
write(unit=zbin_str,fmt='(f5.2)') zbin
plotname="LF_z"//zbin_str//".ps"
write(5,"dev postencap" plotname)
write(5,"toplabel LF for",//zbin_str//)
我收到这些错误:
Syntax error, found '//' when expecting one of: ( * <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> ...
write(5,"toplabel LF for",//zbin_str//)
error #6355: This binary operation is invalid for this data type. [PLOTNAME]
write(5,"dev postencap" plotname)
An arithmetic or LOGICAL type is required in this context.
write(5,"dev postencap" plotname)
如何在Fortran代码中定义可用名称? 谢谢
答案 0 :(得分:2)
这两行都不是
write(5,"dev postencap" plotname)
write(5,"toplabel LF for",//zbin_str//)
结构良好;这就是编译器试图告诉你的。
除此之外,我不确定你要做什么,或者因此,如何解决它。除非使用关键字,否则Fortran编译器会将write
语句中的第二个参数理解为要在其中显示输出的格式说明符。我无法看到"dev postencap" plotname
或"toplabel LF for",//zbin_str//
如何成为有效的格式说明符。也许你想要的是
write(5,'(a32)') "dev postencap"//plotname
write(5,'(a32)') "toplabel LF for"//zbin_str
任何更多都是基于猜测。如果这不能回答您的问题,请更清楚地解释一下。