Re: Read DOS or Unix files with the same fortran code
- From: ajmf77 <ajmf77@xxxxxxxxx>
- Date: Fri, 30 Nov 2007 10:22:08 -0800 (PST)
On 29 nov, 00:34, "tia...@xxxxxxxxx" <tia...@xxxxxxxxx> wrote:
On Nov 28, 11:58 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:why you willn't use DOS2UNIX utility? This works fine for me :)
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
.
- References:
- Read DOS or Unix files with the same fortran code
- From: feenberg
- Re: Read DOS or Unix files with the same fortran code
- From: tianyf@xxxxxxxxx
- Re: Read DOS or Unix files with the same fortran code
- From: Richard Maine
- Re: Read DOS or Unix files with the same fortran code
- From: tianyf@xxxxxxxxx
- Read DOS or Unix files with the same fortran code
- Prev by Date: Re: Fortran Error Reporting Requirements
- Next by Date: Re: Fortran Error Reporting Requirements
- Previous by thread: Re: Read DOS or Unix files with the same fortran code
- Next by thread: Re: Read DOS or Unix files with the same fortran code
- Index(es):
Relevant Pages
|
|