- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to read an ASCII file with MPI_FILE_READ. I found out that I need first of all to read the entire file and put it on a character string.
The problem is that I didn't found how to split this string on a lines because I don't know how to detect a new line in a character string with fortran.
In some way I'm searching the equivalent of this C++ code in Fortran :
nlines = 0;
for (int i=0; i<file_size;i++)
if (data == '\n') (*nlines)++;
Thanks,
Ines
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the char function char(10) is linefeed LF and char(13) is carriage return CR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for the answer. It works with CHAR(10).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are a little paranoid, ACHAR(10) is better - this is a little more robust to the default character kind not being ascii. The NEW_LINE standard intrinsic is even more robust.
There's also the C_NEW_LINE and C_CARRIAGE_RETURN constants from the ISO_C_BINDING module for kind C_CHAR characters.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page