[Fortran] 纯文本查看 复制代码
!========================================
! Open file in ANSI mode
open(UNIT = fid, FILE = strFileName,
& ACCESS = 'SEQUENTIAL', ACTION = 'READ',
& FORM = 'FORMATTED', STATUS = 'OLD')
! This is a m X n complex matrix as:
read(fid, *) strBuf, strBuf, strBuf,
& m, strBuf, n, strBuf, strBuf, strBuf
! Memory allocation for A
allocate(A(m,n), STAT = ierr)
! Out of memory
if (ierr .ne. 0) then
close(fid, STATUS = 'KEEP')
print *, 'Out of memory!'
ReadZMatrixFromFile32 = .false.
return
end if
! Read matrix from file in row-major format
! 下一行肯定是错的,但我真心不知道咋整了。。。
read(fid, *) ((A(i,j), j=1,n), i=1,m)
! Close file
close(fid, STATUS = 'KEEP')
!======================================