fortran77 question

silverpig

Lifer
Jul 29, 2001
27,703
12
81
So I'm reading in some real*8 numbers from stdin and want to make sure the user is actually putting in numbers and not letters. How do I check the datatype easily? Is there an intrinsic function that does something like:

if( TYPE(inputdata) .eq. real*8 ) then
yay!

What's the best way to do this?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
My *guess* is that if the input read in contains letters and you try to read it into a real*8 it will corrupt stdin and you'll be fvcked. You probably want to read it into a string and look for the equivalent of atof()

But I/O is what I hate most about FORTRAN and I do it as little as possible. I've been known to write C/C++ drivers for FORTRAN code just so I don't have to do file or user I/O in FORTRAN :p
 

silverpig

Lifer
Jul 29, 2001
27,703
12
81
Thanks. It seems as though it's smart enough to figure out what it needs anyways. Taking the sin of the letter a manages to trigger one of my error checks anyways so it all seems to work out fine. :)