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



On Nov 28, 11:58 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
tia...@xxxxxxxxx <tia...@xxxxxxxxx> wrote:
I used Fortran to read/write ASCII files in FreeBSD, Solaris, and
Windows. There seems no problems. I suppose that the line-ending
difference between DOS and Unix sytles does not matter.

Then your experience is limitted. This kind of thing depends on the
particular compiler and its run-time libraries. I assure you that there
have existed compilers on those systems for which is *DOES* matter.

In fact, I'm somewhat surprised at the comment because in my experience
it very often matters. We have certainly helped many people in this
newsgroup who had problems with this.

In particular, although some (but not all) DOS compilers can handle the
Unix line endings, my experience is that very few Unix-based compilers
directly handle DOS line endings. The problem there is that a DOS text
file is also a valid Unix text file, but with a different
interpretation. On Unix, the CR character counts as part of the data
instead of part of the line terminator. If a Unix compiler handled DOS
text files, then that would mean there were legitimate Unix text files
that it could not handle correctly. Of course, there could be some kind
of selectable option, but it is hard to imagine how this could be made
to "just work" without user intervantion of some sort.

Depending on how you read the files, you might not notice the problem.
For example, if you always read fixed-length fields, then extra "junk"
at the end of each record might not matter.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain

I only used g77 in Cygwin (Windows XP) and FreeBSD, and Sun Studio
(f77) in Solaris. My text file is a NROW*NCOL numerical array, like:

1 11 111
2 22 222
3 33 333
....

The code I used is,
do i=1,nrow
read(fid,*,end=900) (data(i,j),j=1,ncol)
enddo

It works.


Cheers,
Tian
.



Relevant Pages

  • Re: Read DOS or Unix files with the same fortran code
    ... have existed compilers on those systems for which is *DOES* matter. ... although some DOS compilers can handle the ... Unix line endings, my experience is that very few Unix-based compilers ...
    (comp.lang.fortran)
  • Re: "Thinking in C++" ; which compiler?
    ... I don't know anything about Unix...does that matter? ... The first thing the installer asks is "Default text type: DOS or UNIX" ...
    (alt.comp.lang.learn.c-cpp)
  • 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: 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)