Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3d array problem

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
Well I am trying to read a file and make it rank3 array.
forrtl: severe (24): end-of-file during read, unit 5, file /home/milenko/ircg/test_res1.dat

program praviar
implicit none

integer*4 k,n,m
integer,dimension(3) ::s
real,dimension(57,57,57) :: x
open(5,file='test_res1.dat',status='old')
do m=1,57
read(5,100)((x(k,n,m),n=1,57),k=1,57)
100 format(i7,f6.2,i5)
end do
close(5)
s=shape(x)
write(*,*)s
end
Input file:
2 1.00 0
3 1.80 0
4 63.69 0
5 472.97 0
6 801.43 0
7 3.71 0
8 35.07 0
9 15.63 0
10 6.15 0
11 170.03 0
12 1.96 1
13 47.99 0
14 55.85 1
15 268.35 0
16 59.79 1
17 34.29 0
18 426.48 0
19 966.75 1
20 150.88 0
21 794.58 1
22 7.79 0
23 18.97 0
24 499.75 1
25 90.99 0
26 506.33 1
27 766.85 1
28 3.27 1
29 374.94 0
30 525.45 0
31 7.62 0
32 643.81 1
33 17.54 0
34 8.27 1
35 35.05 0
36 15.36 0
37 234.07 0
38 116.79 0
39 42.94 0
40 59.87 0
41 1.93 1
42 67.37 0
43 19.81 0
44 62.90 0
45 342.80 1
46 30.00 0
47 208.50 1
48 1.70 1
49 3.76 1
50 4.88 1
51 219.32 1
52 1.88 1
53 3.50 0
54 70.81 0
55 54.88 1
56 165.17 0
57 8.76 0
58 21.45 1
 
You try to read a 3D cube of values 57x57x57=185193 values to be read, while you only provide 57 values.

Declare x as DIMENSION(57,3) (or 2,57 if you're a purist in memory menagament) and then read

DO i=1,57,1
READ(5,*)(x(i,j),j=1,3,1)
END DO

ie, 57 times 3 values, which is actually what you give in the file

BTW, your file has mixed integers and reals, while they're all stored as real, are you sure it wouldn't be better to separate them? I suspect that what you want to read actually is x(i) in which i is the counter on the first column
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top