- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an application that reads a user-generated text file for input -- virtually all of it is numeric. To relax the formatting requirements for the user I'm using list-directed read statements [ read(2,*) . . . ]. Files from Europe often usea comma to delimit the whole and fractional part of a real number. Assuming I can detect the origin of the file, is there a way to change the assumption made by the list-directed read statement about the delimiter?
David
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK you cannot alter the read statement to catch a , as a delimiter. So you have to read it as a string and convert every numeric step by step. There you have to replace the , with a .
character*255 codeinteger*4 npos
npos=index(code,',')
if (npos.ne.0) code(npos:npos)='.'
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the IFNLS library routines to set and get the LOCALE settings, which includes which character is used for the decimal.
The NLSFormatNumber function can be used to output numbers in the correct format, but unfortunately no way to handle on reading. If your application is to be used in multiple LOCALES, I would recommend modifying Markus' code to get the local decimal character rather than assume that it is ",".
Regards,
David
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page