0

I'm using the fortran read function to analyze some input I've read from a file. I take a line, which is defined as,

character(len=128) :: line

And a valid input is if said line contains exactly 3 floating point numbers, divided by some separator. For example, line='0.1 0.1 0.1'. An invalid input would be line='0.1 0.1' or line='0.1 0.1 0.1 0.1' and so on.

To convert this string into numbers, I have used:

double precision :: nline(3)
read(line,*,iostat=err) nline

However, this successfully executes even if the original line contains more than 3 floats. Is there a simple way to know if this input string exceeds the limit?

A nontrivial way would be to try and count separators in line, with something like COUNT, but I was hoping to avoid that.

Thank you very much!

0 Answers0