- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a program that scans a text file and finds strings in a certain column that look like numbers, ie 100.3, it grabs these strings and prints them out.Now I want to use the same routine, but once the character string is found, ie 100.3, I would like to assign it to a real variable so I can use it in a math expression.. Can this be done?
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This could be as simple as
READ(charstr,*)realval
The "rules and restrictions" in Adams, Brainerd et al are in the section titled "Data Transfer on Internal Files."
Examples of Internal File I/O appear in the Intel compiler .pdf manual.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And what do I do If I want do to exactly the opposite?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
WRITE (STRING,*) variable....
The * can be an explicit format as well.
This is called "Internal I/O" and is a standard language feature of Fortran. You can read about it in the Intel Fortran Language Reference.
The * can be an explicit format as well.
This is called "Internal I/O" and is a standard language feature of Fortran. You can read about it in the Intel Fortran Language Reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, but with opposite I meant read a real variable and pass its value to a string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I understood - that's what I described above.
The way one does this sort of thing in Fortran is to pretend you are writing to or reading from a file, except that the character variable takes the place of the unit number.
The way one does this sort of thing in Fortran is to pretend you are writing to or reading from a file, except that the character variable takes the place of the unit number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Got the idea! Thanks very much!

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