-1
array這是我的代碼:讀1D和2D從文件
Program Reading_from_file
Implicit none
Integer::i,j
Integer,dimension(3)::Type_SNDM
Integer,dimension(2,3)::Type_NNDM
Real,dimension(3)::Lenght_SNDM
Real,dimension(2,3)::Lenght_NNDM
Character(350),parameter::fmtA_1_5='(2x,3(f4.2,2x,i1,3x))'
Character(350),parameter::fmtA_1_6='(/,/,/,2x,4(f5.3,2x,i1,3x))'
Open(Unit=15,File='Input.txt',Status='Unknown',Action='Readwrite')
Read(15,trim(adjustl(fmtA_1_5)))(Lenght_SNDM(j),Type_SNDM(j),j=1,3)
Do concurrent(i=1:2)
Read(15,trim(adjustl(fmtA_1_6)))(Lenght_NNDM(i,j),Type_NNDM(i,j),j=1,3)
End Do
Close(Unit=15,Status='Keep')
Open(Unit=15,File='Output.txt',Status='Unknown',Action='Readwrite')
Write(15,trim(adjustl(fmtA_1_5)))(Lenght_SNDM(j),Type_SNDM(j),j=1,3)
Do concurrent(i=1:2)
Write(15,trim(adjustl(fmtA_1_6)))(Lenght_NNDM(i,j),Type_NNDM(i,j),j=1,3)
End Do
Close(Unit=15,Status='Keep')
End Program Reading_from_file
這是Input.txt
內容:
|2.50||2| |2.50||2| |2.50||2|
|0.250||3| |0.250||3| |0.250||3|
|0.250||3| |0.250||3| |0.250||3|
我特林從Input.txt
文件中讀取一些值。接下來的目的是在Output.txt
文件中寫入該值。 Afther程序執行的消息是:Fortan runtime error: End of file
。 代碼或閱讀格式有什麼問題?
你的'Input.txt'中的第一個字符缺失,我猜它應該是一個空格,這只是一個轉錄錯誤。你爲什麼使用併發做I/O? – Ross