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!

fortran 90 from 1d array to 2d

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
program pr2
implicit none
integer:: i,j
real, dimension(21,80) :: istat
open(7,file='sens.dat',status='old',action='read')
read(7,*)((istat(i,j),i=1,21),j=1,80)
write(*,*)istat
end

Where is the problem?Input file has 1680 values.But I get this:

1.3598419E-08 4.9547498E-19 -2.3852840E-09 1.1903219E-04 4.6582014E-07
-8.6184544E-18 -9.3819693E-08 1.3887561E-02 -8.2534843E-06 -1.7656002E-16
-3.4295390E-08 8.9485317E-02 -1.4944331E-03 -4.6679033E-15 5.9263188E-05
0.4140495 -5.5463272E-03 3.7684741E-15 1.6822672E-04 -0.2041877
 
Are you sure that the program opens file then reads data w/o errors?
Use err=label in the open stmt and eof=label, err=label in the read stmt.
It seems istat is not initialized after read...
 
Yo should look at your data file, how much lines it has and how much values are at 1 line.
 
My data file has 1680 lines.It is written this way:
1.3829832E-06
1.4455666E-09
2.6437375E-21
2.1257034E-11
1.2414082E-05
1.3598419E-08
4.9547498E-19
-2.3852840E-09
1.1903219E-04
4.6582014E-07
-8.6184544E-18
-9.3819693E-08
1.3887561E-02
-8.2534843E-06
-1.7656002E-16
-3.4295390E-08
 
May be there is problem at reading in the first place?
 
Since you are printing as write(*,*)istat, it will print whatever fits on a line of up to 80 characters.

How do you want it printed?

If you want one per line, either provide a format or, if you do not wish to provide a format, do not use an implied loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top