I am running Fortran 90 in DOS and trying to read one-dimensional arrays from an input file. These are the first few lines in the file.
Sample Influent Effluent
Date BOD (mg/l) BOD (mg/l)
01/22/88 203.1 7.6
01/31/88 159.0 15.1
02/05/88 214.1 17.5
In the code, the variable X is for the Influent column and Y is for the Effluent column. I don't know how many rows of data are in the file, so the arrays need to be automatic. When I run it, I get this error message:
"The instruction at address 4534636 attempted to read from an illegal location
00560982IO_process_[void][+006c]
00508eaeCH_RSF [02F0]
00041001 main [+0141]"
I have code for an interface, which calls a function, before the OPEN statements. But the function is used for calculation, which it can't do until I can get the data from the file, so I decided not to paste that part of the code.
The compiler complains when I put more than one variable name in the read statement. Like this:
It says a "Read statement can have a maximum of 2 non-keyword specifiers."
Why can't I read this arrays? Thank you - Zemm
Sample Influent Effluent
Date BOD (mg/l) BOD (mg/l)
01/22/88 203.1 7.6
01/31/88 159.0 15.1
02/05/88 214.1 17.5
In the code, the variable X is for the Influent column and Y is for the Effluent column. I don't know how many rows of data are in the file, so the arrays need to be automatic. When I run it, I get this error message:
"The instruction at address 4534636 attempted to read from an illegal location
00560982IO_process_[void][+006c]
00508eaeCH_RSF [02F0]
00041001 main [+0141]"
Code:
PROGRAM Lab3c
! ----------------------------------------------------------------
! This program computes a linear correlation coefficient to find a
! linear correlation between waste input and waste output at a
! waste treatment plant.
! Data: Input from file
! ----------------------------------------------------------------
IMPLICIT NONE
INTEGER :: N, Sum, EOF, NMax
! DOUBLE PRECISION :: Cin, Cout, CinMean, CoutMean, Rho
CHARACTER, DIMENSION(:), ALLOCATABLE :: Char
INTEGER, DIMENSION(:), ALLOCATABLE :: X, Y
OPEN (UNIT=14, FILE="bodinout.dat", STATUS="OLD")
OPEN (UNIT=16, FILE="bodinout.out", STATUS="OLD")
N = 1
SUM = 0D0
DO
READ(14, Char, IOSTAT = EOF)Char(N), X(N), Y(N)
write (16,*) "In the do loop before eof if statement and N = ", N, " Char = ", Char(N) !, " X = ", X(N)
IF(EOF /= 0) THEN
write (16,*) "In the if check before exit "
EXIT
END IF
IF(N == Nmax + 1) THEN
WRITE(*,*) "Too many data points", Nmax
STOP
END IF
Sum = Sum + X(N)
N = N+1
WRITE (16,*) "X = ", X(N), "and sum = ", Sum
END DO
N = N-1 ! because N is one step ahead the whole time
END PROGRAM Lab3c
The compiler complains when I put more than one variable name in the read statement. Like this:
Code:
READ(14, Char, X, IOSTAT = EOF)Char(N), X(N), Y(N)
Why can't I read this arrays? Thank you - Zemm