- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I need to read a line of data (the number is unknow), I have the following code, which runs OK in Debug mode, however, in Release mode, it displays 'error in reading file':
character*512::line
integer::readtype
integer::length
integer::n,inum,i
integer::data(n)
open(1,file='data.txt')
read(1,'(a)')line
line=adjustl(adjustr(line))
length=len_trim(line)
read(line(1:length),*,end=1,err=10)(data(i),i=1,n)
10 &
stop 'error in reading data'
1 &
inum=i-1 ! data is saved in data(1:inum)
end
The data file can be as follows:
1 2 3 4 5
or
1,2,3,4,5
or
1, 2, 3, 4, 5,
and so on.
Can anyone give me some suggestion?
Thanks,
Zhanghong Tang
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For a start, in the code you posted you have not defined a value for n. There should normally be a warning from the compiler if you are ..'using a variable that has not yet been defined'.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page