Hello All
I want to read a file that can contain different number of columns of data everytime in Fortran 77. i.e. I dont know the number of columns beforehand.If I know the number of columns,I can read the file like this way
SUBROUTINE varread(TNo,X,Y,Z,VARL)
IMPLICIT NONE
INTEGER NMAX
PARAMETER(NMAX=10000)
Integer N(NMAX),i,j,TNo
double precision X(NMAX),Y(NMAX),Z(NMAX),VARL(NMAX)
OPEN(35,file='exp1.txt')
j = 0
DO WHILE(.true.)
j = j+1
READ(35,600,END=900) N(j),X(j),Y(j),Z(j),VARL(j)
600 FORMAT(I4,1x,E16.7,1x,E16.7,1x,E16.7,1x,E11.4)
END DO
900 continue
TNo = j-1
CLOSE(35)
RETURN
END
In this file exp1.txt,I know that i will always have five columns of data namely N,X,Y,Z,VARL.So I read them easily using the format statement.
But in the file i want to read i know that it can have large number of columns but not how many.
I dont want to store the data in say 50 different variables.Is there a way to read the entire file as an array?.
Can somebody help me read the data?.
Regards
Anbazhagan.
I want to read a file that can contain different number of columns of data everytime in Fortran 77. i.e. I dont know the number of columns beforehand.If I know the number of columns,I can read the file like this way
SUBROUTINE varread(TNo,X,Y,Z,VARL)
IMPLICIT NONE
INTEGER NMAX
PARAMETER(NMAX=10000)
Integer N(NMAX),i,j,TNo
double precision X(NMAX),Y(NMAX),Z(NMAX),VARL(NMAX)
OPEN(35,file='exp1.txt')
j = 0
DO WHILE(.true.)
j = j+1
READ(35,600,END=900) N(j),X(j),Y(j),Z(j),VARL(j)
600 FORMAT(I4,1x,E16.7,1x,E16.7,1x,E16.7,1x,E11.4)
END DO
900 continue
TNo = j-1
CLOSE(35)
RETURN
END
In this file exp1.txt,I know that i will always have five columns of data namely N,X,Y,Z,VARL.So I read them easily using the format statement.
But in the file i want to read i know that it can have large number of columns but not how many.
I dont want to store the data in say 50 different variables.Is there a way to read the entire file as an array?.
Can somebody help me read the data?.
Regards
Anbazhagan.