Parse Fortran String Like A File -


i want pass string c fortran , process line-by-line if reading file. possible?

example string - contains newlines

file description: file contains stuff 3 values   1     description   2     description   3     more text 

then, parse string line-by-line, file. similar this:

subroutine read_str(str, len) character str(len),desc*70  read(str,'(a)') desc read(str,*) n 10 i=1,n read(str,*) parm(i) 10    continue 

not without significant "manual" intervention. there couple of issues:

  • the newline character has no special meaning in internal file. records in internal file correspond elements in array. either need first manually preprocess character scalar array, or use single read skipped on newline characters.

  • if did process string array, internal files not maintain file position between parent read statements. need manually track current record yourself, or process entire array single read statement accessed multiple records.

if have variable width fields, writing format specification process in single read problematic, though depends on details of input.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -