![]() |
||
|
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大的 |
|||||||
|
|
|
Elite Member
![]() ![]() ![]() ![]() ![]() 加入日期: Jul 2003 您的住址: Großdeutschland
文章: 6,997
|
推文章,希望你能得到解答.
|
||
|
|