- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to keep track of where you are in read input_str after each read.
You also should initialise 'line' to blanks before each read, otherwise reading the last section that is not exactly 80 characters long will leave characters from the previous read in the locations that are not overwritten. One suggestion is, if 'numchars' is the number of characters to be read each time:
integer numchars, len_input, numreads, iread, istart, iend
character*80 line, blankline
blankline=adjustl(adjustr(blankline))
numchars=80
len_input=len_trim(input_str)
numreads=(len_input+numchars-1)/numchars
istart=1
iend=numchars
if(numreads>0) then
do iread=1,numreads
line=blankline
read(input_str(istart:iend), '(80a)',end = 9999) line
callmysub(line)!do something for line
istart=istart+numchars
iend=iend+numchars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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