问题描述
在我使用此命令时,我需要为Fortran代码中的不同文件定义一个变量名
I need to define a variable name for different files inside a Fortran code, while I 'm using this commands
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代码中定义可用名称?谢谢
How I can define the available name inside the Fortran code??Thanks
推荐答案
这两行均不
write(5,"dev postencap" plotname)
write(5,"toplabel LF for",//zbin_str//)
格式正确;那就是编译器试图告诉您的.
is well-formed; that's what the compiler is trying to tell you.
除此之外,我不确定您要尝试做什么,或者如何解决该问题.除非使用关键字,否则您的Fortran编译器将理解write
语句中的第二个参数为您要在其中显示输出的格式说明符.我看不到如何将"dev postencap" plotname
或"toplabel LF for",//zbin_str//
做成有效的格式说明符.也许你想要的是
Beyond that, I'm not sure what you are trying to do or, therefore, how to fix it. Unless you use keywords your Fortran compiler will understand the 2nd argument in a write
statement to be the format specifier in which you want to present the output. I can't see how either "dev postencap" plotname
or "toplabel LF for",//zbin_str//
can be made into a valid format specifier. Perhaps what you want is
write(5,'(a32)') "dev postencap"//plotname
write(5,'(a32)') "toplabel LF for"//zbin_str
其他任何事情都将基于猜测.如果这样不能回答您的问题,请尽可能清楚地解释.
Anything more would be based on guesswork. If this doesn't answer your question explain it more clearly if you can.
这篇关于如何使用“;"定义变量名写在fortran中命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!