我想从文本文件中读取我的测量数据。数据具有例如以下形式:
0 0.0531139
0.000157095 0.306123
0.000314191 0.133868
0.000471286 0.29799
0.000628381 0.0182098
0.000785477 0.121222
0.000942572 0.32111
0.00109967 0.0267326
0.00125676 0.49554
0.00141386 0.433729
我的代码如下:
SUBROUTINE test(name)
implicit none
character :: name*(*)
real*8,allocatable, dimension(:,:) :: measMatrix
integer :: i,
& nrcols
nrcols = 2
nrrows = 10
allocate(measMatrix(nrcols,nrrows))
open(unit = 20, file = Dateiname, status = 'old', action = 'read')
do i = 1, nrrows
read(20,*) measMatrix(i,1:nrcols)
end do
close(20)
open(unit = 10, file = 'Test4.txt')
do i = 1,nrrows
write(10,777) (measMatrix(i,j), j = 1,nrcols)
end do
close(10)
777 format(F12.9,4X,F12.9)
deallocate(measMatrix)
END
但是,输出是错误的:
0.000000000 0.000314191
0.000157095 0.000471286
0.000314191 0.000628381
0.000471286 0.000785477
0.000628381 0.000942572
0.000785477 0.001099670
0.000942572 0.001256760
0.001099670 0.001413860
0.001256760 0.495540000
0.001413860 0.433729000
我究竟做错了什么 ?:(
在此先感谢您的帮助。