[Fortran] 纯文本查看 复制代码
Program PointTS
Implicit none
! Integer(kind=1)
Integer(kind=4) i, j, k, m
Real(kind=8) EETIME
Real(kind=8) EETIME_1
Integer(kind=4), Allocatable :: KSZ_Global(:,:), KSZ_Global_1(:,:)
Allocate(KSZ_Global(2,3))
Allocate(KSZ_Global_1(2,3))
EETIME = 1
k = 0
Do i = 1, 3
Do j = 1,2
KSZ_Global(j,i) = i+j+k
k = k + 1
End Do
End Do
Open (Unit=32, File="Matrix.bin", Status='Unknown')
Close(Unit=32, Status='DELETE')
Open(Unit=32,File="Matrix.bin",Status="new",Access='sequential',FORM='unformatted')
Do k = 1, 3
Write(32) EETIME
Write(32) ((KSZ_Global(i,j),j=1,3), i=1,2)
EETIME = EETIME + 1.0
KSZ_Global = KSZ_Global + 1
End Do
Close(32)
Open(Unit=32,File="Matrix.bin",Status="old",Access='stream',FORM='unformatted')
Do k = 1, 3
Inquire(32, Pos = m)
Read(32) EETIME_1
Inquire(32, Pos = m)
Write(6,*) EETIME_1
Read(32) ((KSZ_Global_1(i,j),j=1,3), i=1,2)
Inquire(32, Pos = m)
Write(6,*) ((KSZ_Global_1(i,j),j=1,3), i=1,2)
End Do
Close(32)
End Program
上面的代码是为了验证把双精度EETIME, 数组KSZ_Global, 写进Matrix.bin这个二进制文件后,然后再把它正确地读出来,但不知为何,读出来的第1个 EETIME_1 = 3.9525251667299724E-323,KSZ_Global_1 也与原来的 KSZ_Global 不一样,请教大家,问题出在哪儿?