PCDVD數位科技討論區

PCDVD數位科技討論區 (https://www.pcdvd.com.tw/index.php)
-   疑難雜症區 (https://www.pcdvd.com.tw/forumdisplay.php?f=34)
-   -   急問,fortran 90 (https://www.pcdvd.com.tw/showthread.php?t=330922)

marstse 2004-05-05 11:15 AM

急問,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



大家救救我吧。

AMD-Ti 2004-05-08 07:15 PM

推文章,希望你能得到解答.


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

vBulletin Version 3.0.1
powered_by_vbulletin 2026。