- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
My Windows IVF application is creating text files, which in turn are used as input to my customers' applications. Now, these customer codes either run on Windows or Unix machines. The problem is of course the difference in CR/LF characters at the end of each line of these files.
Is there a way to turn a flag in my code that would help these WRITE statements be interpreted eitheras a *Windows* WRITE, or a *UNIX* WRITE? Or maybe an easy workaround?
Short of this I have to postprocess my output file to remove the extra ^M charactersthat Unix applications are not expecting.
Thanks,
Olivier
My Windows IVF application is creating text files, which in turn are used as input to my customers' applications. Now, these customer codes either run on Windows or Unix machines. The problem is of course the difference in CR/LF characters at the end of each line of these files.
Is there a way to turn a flag in my code that would help these WRITE statements be interpreted eitheras a *Windows* WRITE, or a *UNIX* WRITE? Or maybe an easy workaround?
Short of this I have to postprocess my output file to remove the extra ^M charactersthat Unix applications are not expecting.
Thanks,
Olivier
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OPEN the file with RECORDTYPE="STREAM_LF".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve,
I am sure you pointed me in the right direction - but I don't see any difference yet between the STREAM_LF and STREAM_CR options. When Iexecut a 'cat -v my_file.txt' on a Unix machine I still see the ^M characters for both.
Here is how I open my file, and perform write operations:
[fortran]OPEN(UNIT=MY_UNIT,FILE=MY_FILE,STATUS='REPLACE',IOSTAT=IO_ERROR,RECORDTYPE='STREAM_LF') WRITE(MY_UNIT,'(A)',IOSTAT=IO_ERROR,ERR=100) 'TEST 1' WRITE(MY_UNIT,'(A)',IOSTAT=IO_ERROR,ERR=100) 'TEST 2'
[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know everything you did - you may be looking at an old file. But when I try it, I get only LF delimiters. It is also possible you are using a very old version of the compiler - this feature did not work correctly for a while, but it has been fixed for a couple of years now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thanks to your pointer I was able to sort things out. I am using IVF 10.1 (which probably qualifies as old). The documentation of RECORDTYPE is a bit all over the place (depending on whether you look at the page "Record Types" in "Building Applications", or "OPEN: RECORTYPE Specifier" in "Language Reference" you might not come to the same interpretation of STREAM_LF, for instance).
Anyway, the answer to produce a text file where each line only ends with the LF character (the UNIX/LINUX standard) is:
STREAM_LF writes CR+LF. STREAM_CR writes CR only. STREAM (with CARRIAGECONTROL = 'LIST', which is the default I think) writes LF only. STREAM (with CARRIAGECONTROL = 'NONE') writes nothing.
Maybe this has been clarified in the documentation of newer compiler versions (I couldn't check). If not, may I suggest a slight rewrite to better explain?
Anyway - problem solved; thanks Steve for your help and forbeing always so available to answers this forum users' questions.
Olivier
Thanks to your pointer I was able to sort things out. I am using IVF 10.1 (which probably qualifies as old). The documentation of RECORDTYPE is a bit all over the place (depending on whether you look at the page "Record Types" in "Building Applications", or "OPEN: RECORTYPE Specifier" in "Language Reference" you might not come to the same interpretation of STREAM_LF, for instance).
Anyway, the answer to produce a text file where each line only ends with the LF character (the UNIX/LINUX standard) is:
[fortran]OPEN(UNIT=MY_UNIT,FILE=MY_FILE,STATUS='REPLACE',IOSTAT=IO_ERROR,RECORDTYPE='STREAM',CARRIAGECONTROL='LIST')[/fortran]
STREAM_LF writes CR+LF. STREAM_CR writes CR only. STREAM (with CARRIAGECONTROL = 'LIST', which is the default I think) writes LF only. STREAM (with CARRIAGECONTROL = 'NONE') writes nothing.
Maybe this has been clarified in the documentation of newer compiler versions (I couldn't check). If not, may I suggest a slight rewrite to better explain?
Anyway - problem solved; thanks Steve for your help and forbeing always so available to answers this forum users' questions.
Olivier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that's a buggy version with the interdependence on CARRIAGECONTROL. It is fixed in newer versions.
The current documentation says:
STREAM_CRLF is the default on Windows, STREAM_LF is the default on Linux and Mac OS. CARRIAGECONTROL has no effect on this.
You will probably find that the behavior changes if you update the compiler.
The current documentation says:
'STREAM' |
Indicates stream-type variable length data with no record terminators. |
'STREAM_LF' |
Indicates stream-type variable length records, terminated with a line feed. |
'STREAM_CR' |
Indicates stream-type variable length records, terminated with a carriage return. |
'STREAM_CRLF' |
Indicates stream-type variable length records, terminated with a carriage return/line feed pair. |
STREAM_CRLF is the default on Windows, STREAM_LF is the default on Linux and Mac OS. CARRIAGECONTROL has no effect on this.
You will probably find that the behavior changes if you update the compiler.

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