delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/13/18:17:02

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <03f801c21327$4f658220$9c140944@ri.cox.net>
From: "mstucky5" <mstucky5 AT cox DOT net>
To: "Xinan Zhou" <zhoux AT lifepredictiontech DOT com>, <cygwin AT cygwin DOT com>
References: <62835D8790DBD111981100805FA7E4C4036C8DFC AT EXPRESS1> <01c501c21312$06178920$050202ca AT apple>
Subject: Re: [Fwd: fortran read problem]
Date: Thu, 13 Jun 2002 18:11:46 -0400
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

----- Original Message -----
From: "Xinan Zhou" <zhoux AT lifepredictiontech DOT com>
To: <cygwin AT cygwin DOT com>
Sent: Thursday, June 13, 2002 3:39 PM
Subject: Re: [Fwd: fortran read problem]


> RE: [Fwd: fortran read problem]Hi, Mark, thank you very much for your
message.
>
> I tried your code with 3 data files that contain the same two line
data but
> edited with cat, vi, and Notepad respectively. And found that only the
data
> file edited by vi gives the correct results for two lines. The other
two only > give the correct results for the last line. I did not hit the
'return key' at > the end of last line for all 3 data files.
>
> It seems fortran read on cygwin interpret the end of line differently
for data > files edited by cat and Notepad.
>
> Mark's code and test files are attached.
>
> Again, thanks for Mark's help.
>
> Xinan

I generated that version of the code at work and would almost
bet money that it worked correctly for me with a Notepad generated
file...   I'll have to check when I get back to work tomorrow...

Meanwhile...

If you apply the following fix to the code, it should
fix your problem...

The "trick" is to check for the problem character at
the end of the line :

       if(ICHAR(text(i:i)).NE.13) then


--Mark


stuckymb [522] > diff orig_test_read.f test_read.f
33a34
>       integer ic
36a38
>       character*1 ch
89c91,101
<             if(j.le.40) textpart(n)(j:j)=text(i:i)
---
>             if(j.le.40) then
>                if(ICHAR(text(i:i)).NE.13) then
>                   textpart(n)(j:j)=text(i:i)
>                else
>                   ch = text(i:i)
>                   ic = ICHAR(ch)
>                   write(*,'('' text('',I2,'') : ICHAR = '',I3,
>      :                      2x,'' J = '',I3)')
>      :              i,ic,j
>                endif
>             endif



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019