当我使用正确的 WRITE DESCRIPTOR 时,以下 Fortran 运行时错误的来源是什么?
What is the source of following fortran runtime error when I have used the correct WRITE DESCRIPTOR?
我只是在制作一个程序,从包含数据的文件中读取值,然后用它来计算一个简单的函数,然后将输出打印到另一个文件。
我不明白为什么当我在这里使用 F 描述符时它显示它有字符。
program doppler_w_data
implicit none
real f
integer i,u,v,n
open(unit=1,file="inputfor_doppler.txt",status="old")
open(unit=2,file="outputfor_doppler.txt",status="old")
do i=1,5
read(1,1001) u,v,n
1001 format(4I5)
f = n*(330+u)/(330-v)
write(2,1002) "the req apparent freq is" ,f
1002 format(F9.4)
end do
endprogram doppler_w_data
错误是:
At line 18 of file doppler_w_data.f90 (unit = 2, file = 'outputfor_doppler.txt')
Fortran runtime error: Expected REAL for item 1 in formatted transfer, got CHARACTER
(F9.4)
^
您没有使用正确的描述符。输出数据为
"the req apparent freq is"
也就是CHARACTER
.
描述符是
F9.4
那是 REAL
数值数据类型。
对 CHARACTER
数据使用 A
描述符。
我只是在制作一个程序,从包含数据的文件中读取值,然后用它来计算一个简单的函数,然后将输出打印到另一个文件。
我不明白为什么当我在这里使用 F 描述符时它显示它有字符。
program doppler_w_data
implicit none
real f
integer i,u,v,n
open(unit=1,file="inputfor_doppler.txt",status="old")
open(unit=2,file="outputfor_doppler.txt",status="old")
do i=1,5
read(1,1001) u,v,n
1001 format(4I5)
f = n*(330+u)/(330-v)
write(2,1002) "the req apparent freq is" ,f
1002 format(F9.4)
end do
endprogram doppler_w_data
错误是:
At line 18 of file doppler_w_data.f90 (unit = 2, file = 'outputfor_doppler.txt')
Fortran runtime error: Expected REAL for item 1 in formatted transfer, got CHARACTER
(F9.4)
^
您没有使用正确的描述符。输出数据为
"the req apparent freq is"
也就是CHARACTER
.
描述符是
F9.4
那是 REAL
数值数据类型。
对 CHARACTER
数据使用 A
描述符。