- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
I can't seem to understand why iostat is behaving the way it does when it compiles. Here is the program:
-------------------------------------------------
PROGRAM ERROR
IMPLICIT NONE
INTEGER :: x,k
DO
read (*,*, iostat=k ) x
write (*,*) k, 'this is the iostat value'
if ( k == 0 ) exit
END DO
write (*,*) 'Now out of loop'
END PROGRAM
-------------------------------------
All I want to be able to do is to be able to tell when the user does not enter in an integer and to give him a second chance to enter in a valid number.
This iostat method above seems to do the job for all non integer values except the letters " f ", " t ", " , " , " / ", and all real values. Why is this the case? Can anyone explain what's going on? Or if there is another method to achieve what I set out to do.
Thanks,
-Jason.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not use list-directed input to "validate" user input. You can get closer to what you want by reading with an I5 format or somethng similar - this will be much less accepting of non-integer values. Or read into a string and scan it for valid characters.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page