- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Q control edit descriptor is a nifty feature... but it's not standard-compliant.
A standard-compliant workaround I can think of is to use a loop of non-advancing IO read statements with EOR to catch the end of the record... but this is rather unwieldy...
Any other suggestions?
PROGRAM P
IMPLICIT NONE
INTEGER :: I
CHARACTER(LEN=1) :: S
OPEN(FILE='Test.txt',UNIT=10,FORM='FORMATTED',STATUS='REPLACE')
WRITE(10,FMT='(A10)') 'A 1'
REWIND(10)
READ(10,'(A1,Q)') S,I
WRITE(*,'(A,I4)') S,I
CLOSE(10)
END PROGRAM P
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure what you really want to do here, but I'd lean towards this approach:
PROGRAM P
IMPLICIT NONE
INTEGER :: I
CHARACTER(LEN=1) :: S
CHARACTER(100) :: LINE
OPEN(FILE='Test.txt',UNIT=10,FORM='FORMATTED',STATUS='REPLACE')
WRITE(10,FMT='(A10)') 'A 1'
REWIND(10)
READ (10,'(A)') LINE
READ(LINE,'(A1)') S
I = LEN_TRIM(LINE)-1
WRITE(*,'(A,I4)') S,I
CLOSE(10)
END PROGRAM P

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