delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/13/15:43:28

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
X-Sent: 13 Jun 2002 19:43:01 GMT
Message-ID: <01c501c21312$06178920$050202ca@apple>
From: "Xinan Zhou" <zhoux AT lifepredictiontech DOT com>
To: <cygwin AT cygwin DOT com>
References: <62835D8790DBD111981100805FA7E4C4036C8DFC AT EXPRESS1>
Subject: Re: [Fwd: fortran read problem]
Date: Thu, 13 Jun 2002 15:39:24 -0400
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

------=_NextPart_000_01C1_01C212F0.7E910740
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_01C2_01C212F0.7E910740"


------=_NextPart_001_01C2_01C212F0.7E910740
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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
  ----- Original Message -----=20
  From: Stucky, Mark B. UTRC=20
  To: 'Xinan Zhou' ; cygwin AT cygwin DOT com=20
  Sent: Thursday, June 13, 2002 1:23 PM
  Subject: RE: [Fwd: fortran read problem]





  > -----Original Message-----=20
  > From: Xinan Zhou [mailto:zhoux AT lifepredictiontech DOT com]=20
  > Sent: Thursday, June 13, 2002 12:38 PM=20
  > To: cygwin AT cygwin DOT com=20
  > Subject: Re: [Fwd: fortran read problem]=20
  >=20
  >=20
  > Hi,=20
  >=20
  > Can I safely say that it is a bug that fortran read(1,=20
  > '(a132)') on cygwin=20
  > cannot read an entire line properly from a data file edited=20
  > by Notepad or=20
  > vi?=20
  > Or it is my mistake that I miss setting up something?=20
  >=20
  > Thank you and have a nice day!=20
  >=20



  No, it isn't a problem with cygwin and g77...=20

  It is a problem with your source code.  I sent you=20
  more info in a separate email...=20

  --Mark=20


------=_NextPart_001_01C2_01C212F0.7E910740
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>RE: [Fwd: fortran read problem]</TITLE>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, Mark, thank you very much for your=20
message.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I tried your code with 3 data files =
that contain=20
the same two line data but edited with cat, vi, and Notepad =
respectively. And=20
found that only the data file edited by vi gives the correct results for =
two=20
lines. The other two only give the correct results for the last line. I =
did not=20
hit the 'return key' at the end of last line for all 3 data =
files.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>It seems fortran read on cygwin =
interpret the end=20
of line differently for data files edited by cat and =
Notepad.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Mark's code and test files are=20
attached.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Again, thanks for Mark's =
help.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Xinan</FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:StuckyMB AT UTRCCT DOT res DOT utc DOT com"=20
  title=3DStuckyMB AT UTRCCT DOT res DOT utc DOT com>Stucky, Mark B. UTRC</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20
  href=3D"mailto:zhoux AT lifepredictiontech DOT com"=20
  title=3Dzhoux AT lifepredictiontech DOT com>'Xinan Zhou'</A> ; <A=20
  href=3D"mailto:cygwin AT cygwin DOT com" =
title=3Dcygwin AT cygwin DOT com>cygwin AT cygwin DOT com</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Thursday, June 13, 2002 =
1:23=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> RE: [Fwd: fortran read =

  problem]</DIV>
  <DIV><BR></DIV><BR><BR>
  <P><FONT size=3D2>&gt; -----Original Message-----</FONT> <BR><FONT =
size=3D2>&gt;=20
  From: Xinan Zhou [<A=20
  =
href=3D"mailto:zhoux AT lifepredictiontech DOT com">mailto:zhoux AT lifepredictiont=
ech.com</A>]</FONT>=20
  <BR><FONT size=3D2>&gt; Sent: Thursday, June 13, 2002 12:38 PM</FONT> =
<BR><FONT=20
  size=3D2>&gt; To: <A=20
  href=3D"mailto:cygwin AT cygwin DOT com">cygwin AT cygwin DOT com</A></FONT> =
<BR><FONT=20
  size=3D2>&gt; Subject: Re: [Fwd: fortran read problem]</FONT> =
<BR><FONT=20
  size=3D2>&gt; </FONT><BR><FONT size=3D2>&gt; </FONT><BR><FONT =
size=3D2>&gt;=20
  Hi,</FONT> <BR><FONT size=3D2>&gt; </FONT><BR><FONT size=3D2>&gt; Can =
I safely say=20
  that it is a bug that fortran read(1, </FONT><BR><FONT size=3D2>&gt; =
'(a132)')=20
  on cygwin</FONT> <BR><FONT size=3D2>&gt; cannot read an entire line =
properly=20
  from a data file edited </FONT><BR><FONT size=3D2>&gt; by Notepad =
or</FONT>=20
  <BR><FONT size=3D2>&gt; vi?</FONT> <BR><FONT size=3D2>&gt; Or it is my =
mistake=20
  that I miss setting up something?</FONT> <BR><FONT size=3D2>&gt;=20
  </FONT><BR><FONT size=3D2>&gt; Thank you and have a nice day!</FONT> =
<BR><FONT=20
  size=3D2>&gt;</FONT> </P><BR>
  <P><FONT size=3D2>No, it isn't a problem with cygwin and g77...</FONT> =
</P>
  <P><FONT size=3D2>It is a problem with your source code.&nbsp; I sent =
you</FONT>=20
  <BR><FONT size=3D2>more info in a separate email...</FONT> </P>
  <P><FONT size=3D2>--Mark </FONT></P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_001_01C2_01C212F0.7E910740--

------=_NextPart_000_01C1_01C212F0.7E910740
Content-Type: application/octet-stream;
	name="test_read.f"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test_read.f"

      subroutine openfile()
!
      implicit none
!
      logical exi
      character*132 jobname,fnin,fndat,fnfrd,fnsta
      integer i

      write(*,*) 'please enter input file name'
      read(*,*) fnin
!
      inquire(file=fnin,exist=exi)
      if(exi) then
         open(1,file=fnin,status='old')
      else
         write(*,*) '*ERROR in openfile: input file',fnin
         write(*,*) 'does not exist'
         stop
      endif
!
      return
      end


      subroutine getnewline(istat,in,n,key)
!
      implicit none
!
!     parser for abainput
!
!     n = # comma's +1,
!
      integer istat,in,n,key,i,j,k
!
      character*40 textpart(16)
      character*132 text
!
!     reading a new line
!
      do
         text=''
         read(in,'(a40)',iostat=istat) text
         if(istat.lt.0) then
            if(text.eq.'') then
               if(in.ne.1) then
                  close(2)
                  in=1
                  cycle
               else
                  return
               endif
            else
               istat=0
            endif
         endif
         if((text(1:8).eq.'*include').or.
     &          (text(1:8).eq.'*INCLUDE')) then
!           call include(text,in)
            write(*,*)'should not have include'
         elseif(text(1:2).eq.'**') then
         else
            exit
         endif
      enddo
!
      key=0
!
!     only free format is supported
!
      if((text(1:1).eq.'*').and.(text(2:2).ne.'*')) then
         key=1
      endif
!
!     initialize all textpart fields...
!
      do i=1,16
         textpart(i)='                                        '
      enddo

      
      n=1
      j=0
      do i=1,40
         if(text(i:i).ne.',') then
            if(j.eq.0) then
               if(text(i:i).eq.' ') cycle
            endif
            j=j+1
            if(j.le.40) textpart(n)(j:j)=text(i:i)
         else
            do k=j+1,40
               textpart(n)(k:k)=' '
            enddo
            n=n+1
            j=0
         endif
      enddo
      if(j.eq.0) n=n-1
      write(*,*) '----------------------------------------'
      write(*,*)'n = ',n
      write(*,'('' n = '',I5,''  text = '',a40)') n,text
      do i = 1, n
        write(*,'('' textpart('',I2,'') = '',A40)') i,textpart(i)
      enddo

!
!     clearing all textpart fields not used
!
      do i=n+1,16
         textpart(i)='                                        '
      enddo
!
      return
      end


      PROGRAM TEST_READ
      IMPLICIT NONE

      integer istat, in, n, key
      integer i
      
      in = 1

      call openfile()

      do i = 1, 10
        call getnewline(istat, in, n, key)
      enddo

      END PROGRAM TEST_READ

------=_NextPart_000_01C1_01C212F0.7E910740
Content-Type: application/octet-stream;
	name="test.vi"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="test.vi"

1,1,2,3,4,5,6,7,ELEMENT,TYPE=0A=
1,1,2,3,4,5,6,7,ELEMENT,TYPE=0A=

------=_NextPart_000_01C1_01C212F0.7E910740
Content-Type: text/plain;
	name="test.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test.txt"

1,1,2,3,4,5,6,7,ELEMENT,TYPE
1,1,2,3,4,5,6,7,ELEMENT,TYPE
------=_NextPart_000_01C1_01C212F0.7E910740
Content-Type: application/octet-stream;
	name="testcat.dat"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="testcat.dat"

1,1,2,3,4,5,6,7,ELEMENT,TYPE
1,1,2,3,4,5,6,7,ELEMENT,TYPE

------=_NextPart_000_01C1_01C212F0.7E910740
Content-Type: text/plain; charset=us-ascii

--
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/
------=_NextPart_000_01C1_01C212F0.7E910740--


- Raw text -


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