Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Carriage return in line endings

mangipus
Beginner
1,519 Views

I have an application in fortran that writes some data into a file which is read by other applications running on platforms like Linux.

My problem is, when I write the content from the application compiled with Intel fortran on Windows, it puts an extra carriage return (a.k.a contro-M) at the end of each line and my Linux applications that read this file get tripped at this point as these don't expect a carriage return at the end of the line. My application is a combination of C and Fortran code and I have tried linking with binmode.obj of MSVC but it did not efffect the behavior at all.

I am giving a sample program here that can reproduce this behavior. Please let me know what I can do at the compiler level or in my program to avoid these carriage returns. Please suggest a simple change as these OPEN calls are spread all over my fortran application and I can't afford to change every such call.


PROGRAM FOPENTEST
open(unit=10, file='test.txt', status='new')
write(10, *) "This is a test message"
write(10, *) "This is the second message"
close(unit=10)
END


I know dos2unix can solve my problem but I would like a better way to deal with it.

I am currently using v7.1 compiler and setting RECORDTYPE = 'STREAM' seems to have no effect on these line endings. I use formatted sequential files so /fpscomp does't seem to have a solution to my problem too.

I realize that setting RECORDTYPE to 'STREAM' works in v8.1 and above but I was wondering if there is a standard way to handle this in v7.1 without having to upgrade.

I see that Absoft fortran has a compiler option -unixeol to handle something like this.

Any help in this regard would be highly appreciated.

Thanks,
Subhash

0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
1,519 Views
Take a look at RECORDTYPE specifier (VF extension) for OPEN statement, as well as "Record Types" page in IVF docs.
0 Kudos
Steven_L_Intel1
Employee
1,519 Views
As best as I can remember, 7.1 doesn't have such a feature.
0 Kudos
mangipus
Beginner
1,519 Views

Thanks for the reply. I guess I have no choice but to upgrade now.

0 Kudos
Reply