Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

IOSTAT in READ

Mike896
Beginner
383 Views
Hi

I have a file like this:

0.5715 0.2378-1416.9485

It should have at least one space between the second and third data. But the number(3rd one) is too large.
I'd like to detect this kind of file from several files, if this error happens.

I used
read(....,IOSTAT=ios) a,b,c
I print ios values for every file including the above example.
I find every ios is 0, i.e. success reading.

How to detect the above file as a failed one?
If I neglect "IOSTAT=ios" in READ, then I get "list-directed i/o syntax error...."
Thanks
Mike
0 Kudos
1 Reply
Les_Neilson
Valued Contributor II
383 Views
Mike,
The "usual" way to do this is to read the data into a character string [read (lu,'(a)') string] and parsethe stringyourself, that way you have full control over error handling etc.

Les
0 Kudos
Reply