Re: Read DOS or Unix files with the same fortran code



On 28 nov, 00:15, Terence <tbwri...@xxxxxxxxx> wrote:
On Nov 27, 11:54 am, feenb...@xxxxxxxxx wrote:



I would like my fortran program to be able to read text files with
either Unix or DOS line endings..

The read is free format. (read(*,*) (x(i),i=1,22).
The compiler is gcc version 3.4.6 [FreeBSD] 20060305
The OS is FreeBSD 6.2
Code is standard F77

Is there an option I could set or another compiler that I could use
that would allow the stray contol-Ms in DOS formatted files without
getting upset? I understand that I could preprocess DOS files with
dos2unix, but that adds complications I would prefer to avoid.

Thank you
Daniel Feenberg
National Bureau of Economic Research
feenberg at nber dotte org

Whenever I meet this problem I use Wordstar in text mode to read the
file and then change
^M^J to ^J for unix, or
^J to ^M^J for DOS
It's one single operation. Wordstar may pause on very large files, but
there is a control to "write-to-cursor" (what is current) and
"continue reading" (to get some more) which allows unlimited size
files, unlike EDIT and many other editors.

Just another idea : when I exchange a lot of files from Windows to
Unix and vice versa, I generally use a Zip format because the command
unzip has a funny option -a which automatically solves the "end of
line" trouble in text files only (it automatically detects binary
files and does not change them).

unzip -a myfile.zip

.



Relevant Pages

  • Re: Big Mikey --- Your (sic) Not Choking On US, Are You?
    ... This class is a basic UNIX beginners one day UNIX course, Steve Highly ... DOS is far from Antiquated. ... Many A+ students, ...
    (alt.vacation.las-vegas)
  • Re: Unix connection to a Windows Server
    ... > that interpet other scripting languages but no DOS, ... > What Unix, version, and hardware? ... The Linux DOS Emulator DOSEMU is a PC Emulator ... And there's always Samba: ...
    (comp.unix.shell)
  • Re: 8-bit unzip utility
    ... Rename some binary Apple DOS file to "UNZIP ZIPFILE.ZIP". ... The comma is here important - it informs the CLI that the filename ends after ...
    (comp.sys.apple2)
  • Re: Review of my performance analysis
    ... DOS vs Unix really tells you little as very disk op in DOS will ... And SCSI vs MFM - and the ability of SCSI to do many ops [depending ... Frragmentation isn't nearly the problem in Unix system as it is ...
    (comp.unix.sco.misc)
  • Re: Flaw in install script for nasm v0.98.39?
    ... that the DOS world was pretty painless. ... Windows and it's registry and the DLL hell and with Linux and the ... Aspects of DOS and UNIX are troublesome ...
    (alt.lang.asm)