PCDVD數位科技討論區
PCDVD數位科技討論區   註冊 常見問題 標記討論區為已讀

回到   PCDVD數位科技討論區 > 其他群組 > 疑難雜症區
帳戶
密碼
 

回應
 
主題工具
marstse
Amateur Member
 

加入日期: Jan 2004
您的住址: Kent.edu
文章: 41
急問,fortran 90

小弟有fortran 90的作業,但有一段不支是哪裡錯,
要用array 讀數字:

...

IMPLICIT NONE
!arrays
REAL, DIMENSION(:,: ), ALLOCATABLE :: A, B, C

!VARIABLES
INTEGER :: length, I, J

!main program

!intro message
PRINT "(A)", "this program will solve equations using arrays"
PRINT "(A)", "in form of B=A*C"
PRINT "(A)", "the program will read values from matrix_a.dat"
PRINT "(A)", "and matrix_c.dat to calculate B"
PRINT "(A)", "where users can adjust the size of the matrix"
PRINT "(A)", "pess 'enter' to continue"

!pause till user ready to start
READ *

!ask user to input the size of the array
!and to check if the number is between 1 and 4
DO
PRINT "(A)", "enter the number of equations used:"
READ *,length
IF (length>=1.AND.length<=4) then
EXIT
ELSE
PRINT "(A)", "input error!!!, must between 1 and 4!!!"
END IF
END DO

!setup arrays
ALLOCATE(A(length, length), B(length, 1), C(length, 1))


!open files matrix_a.dat
OPEN (UNIT=10, FILE="matrix_a.dat", STATUS="OLD", ACTION="READ", POSITION="REWIND", IOSTAT=I)
!check to see if matrix_a.dat is open correctly
IF (I/=0) THEN
PRINT "(A)", "error in opening file"
STOP
ELSE
PRINT "(A)", "file open successfully"
PRINT "(A,I1,A,I1,A)", "matrix A has dimensions (", length, ",", length, ")"
END IF

READ *
!read values into arrays A
!outer loop for rows
DO I=1, length
!iner loop for columns
DO J=1, length
READ (UNIT=10, FMT="(F4.2)") A(I,J)
END DO
END DO


...

在做後一段會出現:
end of file on unit 10
program terminated by fatal I/O errer



大家救救我吧。
     
      
__________________
先借ben_chien大的
舊 2004-05-05, 11:15 AM #1
回應時引用此文章
marstse離線中  
AMD-Ti
Elite Member
 
AMD-Ti的大頭照
 

加入日期: Jul 2003
您的住址: Großdeutschland
文章: 6,997
推文章,希望你能得到解答.
 
舊 2004-05-08, 07:15 PM #2
回應時引用此文章
AMD-Ti離線中  


回應


POPIN
主題工具

發表文章規則
不可以發起新主題
不可以回應主題
不可以上傳附加檔案
不可以編輯您的文章

vB 代碼打開
[IMG]代碼打開
HTML代碼關閉



所有的時間均為GMT +8。 現在的時間是03:12 AM.


vBulletin Version 3.0.1
powered_by_vbulletin 2026。