Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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" To: References: <62835D8790DBD111981100805FA7E4C4036C8DFC AT EXPRESS1> Subject: Re: [Fwd: fortran read problem] Date: Thu, 13 Jun 2002 15:39:24 -0400 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01C1_01C212F0.7E910740" 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 RE: [Fwd: fortran read problem]
Hi, Mark, thank you very much for your=20 message.
 
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.
 
It seems fortran read on cygwin = interpret the end=20 of line differently for data files edited by cat and = Notepad.
 
Mark's code and test files are=20 attached.
 
Again, thanks for Mark's = help.
 
Xinan
----- Original Message -----
From:=20 Stucky, Mark B. UTRC
To: 'Xinan Zhou' ; cygwin AT cygwin DOT com=20
Sent: Thursday, June 13, 2002 = 1:23=20 PM
Subject: RE: [Fwd: fortran read = problem]



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


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

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

--Mark

------=_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--