- #1
fluidistic
Gold Member
- 3,957
- 266
I have a program that makes a histogram from data taken in a file but it only works if the data is an array (nx1 matrix).
I've downloaded a data file which is a 159663x12 matrix but only the 8th column contains numbers I'm interested it. The other columns contain either letters and/or numbers.
So I cannot read the data file and assignate, say, a(i) to values in the first column for example because these values might not even be numbers.
What I want is something like
where I don't want to read the blancked values.
I'm sure there's a way to do this, but despite reading what I could find in google it's not clear at all to me how to do.
I'll ask other questions related to allocatable probably further.
Thanks for any help.
Edit: To complicate things, some if not most columns have no values for a particular row. For example here is how the file starts:
Here is my code:
It compiles but when I execute it, I get the error
I've downloaded a data file which is a 159663x12 matrix but only the 8th column contains numbers I'm interested it. The other columns contain either letters and/or numbers.
So I cannot read the data file and assignate, say, a(i) to values in the first column for example because these values might not even be numbers.
What I want is something like
Code:
read(11,*) , , , , , , ,x_i, , , ,
I'm sure there's a way to do this, but despite reading what I could find in google it's not clear at all to me how to do.
I'll ask other questions related to allocatable probably further.
Thanks for any help.
Edit: To complicate things, some if not most columns have no values for a particular row. For example here is how the file starts:
Code:
10207538 A E M, Doshtagir BAN M 1864 0 30 0000 i
10206612 A K M, Sourab BAN M 1714 0 30 0000 i
5045886 A K, Kalshyan IND M 1943 9 15 1964
8605360 A La, Teng Hua CHN F 1915 0 30 1993 wi
5031605 A, Akshaya IND F 2014 0 15 1994 w
5080444 A, Sohita IND F 1447 0 30 1995 wi
5706068 A. Nashir, Mohd Khairul Nazrin MAS M 1878 0 30 0000 i
10201971 A.f.m., Mahfuzul Haque BAN M 1758 0 15 0000
10202650 A.k. Azad, Akand BAN M 1692 0 30 0000 i
10210997 A.K.M. Mehfuz BAN M 2015 0 30 0000 i
24663832 Aab, Manfred GER M 1758 0 15 1963
1701991 Aaberg, Anton SWE M 2372 0 10 1972
1513966 Aabid, Ryaad NOR M 1698 0 15 1958
1407589 Aabling-Thomsen, Jakob DEN M FM 2336 7 15 1985
12524670 Aadeli, Arvin IRI M 2037 5 15 0000
5072662 Aadhityaa, M IND M 1893 0 15 1999
25034677 Aadish S IND M 1528 0 15 1999
25088955 Aadit Bhatia IND M 1544 0 30 2002
5086183 Aaditt, M K IND M 1610 0 30 1996 i
25083821 Aaditya jain IND M 1297 0 30 2000
5027942 Aaditya, Jagadeesh IND M 1811 0 15 1998
25011952 Aadityan G IND M 1627 0 15 2001
5063485 Aadityan, N. IND M 1758 0 15 1996
1431692 Aae, Jesper DEN M 1881 0 30 1954
1427024 Aagaard, Gert DEN M 2049 7 15 1966
1401815 Aagaard, Jacob DEN M GM FST 2519 0 10 1973
Here is my code:
Code:
program histogram
implicit none
real :: mean
integer :: x_i ,i ,k
integer, dimension(0:3000) :: icount
character (5):: a,b,c,d,e,f,g,h,j,l,m
i=1
open(12,file='histchess.txt',status='old')
open(11,file='crat.txt', status='old')
icount=0
do while (i.le.159663)
read(11,*)a,b,c,d,e,f,g,x_i,h,j,l,m
icount(x_i)=icount(x_i)+1
i=i+1
end do
do k=0,3000,1
write(12,*)k,icount(k)
end do
close(11)
close(12)
end program
Code:
At line 15 of file chesshistogram.f90 (unit = 11, file = 'crat.txt')
Fortran runtime error: Bad integer for item 1 in list input
Last edited: