当我在 Gnuplot 中使用变量更改 Fortran 代码中的输入文件的名称时收到错误
I receive an error when I use a variable in Gnuplot to change the name of the input file within a Fortran code
我用 Fortran 编写了一段代码,允许我使用 gnuplot 直接从文件中绘制数据。
write(10,*) 'plot "Test18.Stop.TXT" u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
每次编译都想改数据文件的名字。问题是我不知道如何将文件名作为变量输入。我做了一些尝试,比如:
open(11,file=Filename)
write(10,*) Filename
write(10,*) 'plot '<Filename>' u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
close(11)
和
open(11,file=Filename)
write(10,*) Filename
write(10,*) 'plot "'Filename'" u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
close(11).
Filename是一个字符,里面有文件数据的名字,应该画出来。当我编译它时,我总是得到这个错误 Error: Write statement at <1> Syntax error (i.e. at File name).
评论再次作为答案,根据 Whosebug 规则:"no answers in comments"。
您必须连接字符串。
不知道 Fortran 但做了一个简短的搜索,我想它应该是这样的:
write(10,*) 'plot "' // Filename // '" u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
我用 Fortran 编写了一段代码,允许我使用 gnuplot 直接从文件中绘制数据。
write(10,*) 'plot "Test18.Stop.TXT" u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
每次编译都想改数据文件的名字。问题是我不知道如何将文件名作为变量输入。我做了一些尝试,比如:
open(11,file=Filename)
write(10,*) Filename
write(10,*) 'plot '<Filename>' u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
close(11)
和
open(11,file=Filename)
write(10,*) Filename
write(10,*) 'plot "'Filename'" u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'
close(11).
Filename是一个字符,里面有文件数据的名字,应该画出来。当我编译它时,我总是得到这个错误 Error: Write statement at <1> Syntax error (i.e. at File name).
评论再次作为答案,根据 Whosebug 规则:"no answers in comments"。
您必须连接字符串。 不知道 Fortran 但做了一个简短的搜索,我想它应该是这样的:
write(10,*) 'plot "' // Filename // '" u 1:8 title "Force" lt -1 lc rgb "#808080" w lines'