Writing formatted files from Win2000 to Linux

Writing formatted files from Win2000 to Linux

Apologies if this shows up twice.

I am developing a program that will run on a Win2000 machine, writing results to a file on a Linux machine (using Samba). A program on the Linux box will then read this file. However, I am having an issue with the line termination characters. Is it possible, on the Linux side, to compile the program such that it will treat a CR-LF as terminating a record in a formatted file, or, conversely, is it possible to write the file (using Compaq Visual Fortran 6) such that it will terminate a record in a formatted file with a LF. As the Linux box needs to read the file as soon as it is created, and the files are updated regularly I can't use FTP to transfer the files in ASCII mode.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

No doubt you've considered this, but you could use shell script commands on the linux side to strip the '
' characters, either running your program from the script, or running a script from your program, like
call system("tr -d '
' .....")
before opening it. I don't fill in the file redirection stuff, because I don't know how to get it past the posting filter on this site.
On the Windows side, you could try simply writing char(10) into the output stream, using ADVANCE=NO to avoid terminating the record each time. No doubt there's a limit to the number of characters you could write before record termination. Or, you could write an unformatted sequential file, putting in char(10) characters.

There is not an option in either Intel Fortran or CVF to change the terminator used. But Tim is on the right track. If you are using formatted output on Linux, append CHAR(13) - CR - to the end of each record. Then Fortran will add the LF. Or use FORM='BINARY' and use unformatted writes, adding whatever terminator you want (this works on either platform.)

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today