delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/13/08:45:48

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 12:44:18 GMT
Message-ID: <017001c212d7$874a7e70$050202ca@apple>
From: "Xinan Zhou" <zhoux AT lifepredictiontech DOT com>
To: <tprince AT computer DOT org>
Cc: <cygwin AT cygwin DOT com>
References: <3D074C2D DOT 9C5880B6 AT yahoo DOT com> <20020613042819 DOT 415632CC32 AT inet1 DOT ywave DOT com>
Subject: Re: [Fwd: fortran read problem]
Date: Thu, 13 Jun 2002 08:40:41 -0400
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

Hi, Tim, thank you for your response.

What I want to do is to port worked program on Linux to cygwin. In the
ported program, the input file needs to be parsed and one entire line is
read in each time. The input file has the following format:

*HEADING
Model: beam
*NODE
1,0.,0.,0.
2,1.,0.,0.
......
*ELEMENT, TYPE=C3D20R
1,1,2,3,4,13,14,15,16,5,6,
  7,8,17,18,19,20,9,10,11,12
......

being able to read in one entire line each time will make parsing terse.

It did pass the compile and give the executable with g77 testRead.f. And the
same test program gives correct results  on MS Fortran.

Could you tell me how to fix the incompatible mixture of fixed and free
format input or your
modified one? Can your modified one read the entire line?

Thank you very much!
Have a nice day!

Xinan

----- Original Message -----
From: "Tim Prince" <tprince AT computer DOT org>
To: "Earnie Boyd" <Cygwin AT cygwin DOT com>
Cc: "Xinan Zhou" <zhoux AT lifepredictiontech DOT com>
Sent: Thursday, June 13, 2002 12:28 AM
Subject: Re: [Fwd: fortran read problem]


> On Wednesday 12 June 2002 06:27, Earnie Boyd wrote:
> > Asking me directly, even though you have difficulty is not your best
> > option.  I've forwarded to the list, this time, and have set the
> > Reply-To to the list.
> >
> > Earnie.
> >
> > -------- Original Message --------
> > Subject: fortran read problem
> >    Date: Wed, 12 Jun 2002 08:59:05 -0400
> >    From: "Xinan Zhou" <zhoux AT lifepredictiontech DOT com>
> >      To: <earnie_boyd AT yahoo DOT com>
> >
> > hi, Earnie, sorry to send you mail directly. I registered
> > cygwin AT cygwin DOT com mailing list, and got the confirm message. But I tried
> > 2 days, failed to send the message to cygwin AT cygwin DOT com. Could you tell
> > me whom should I contact about this? I searched mailing list and found
> > you had message about fortran read.I conpile on bash console with g77
> > testRead.f. I found fortran read(1, '(a40)') did not behave properly on
> > cygwin.
> >
> > the input file has
> > 1,1,2,3,4,5,6,7,ELEMENT,TYPE
> >
> > but it cannot read it correctly.
> >
> > any suggestions are appreciated.
> >
> > thank you and have a nice day!
> >
> > Xinan
> > PS: test code attached.
> >
> >       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
> > !
> >       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(*,*)'text = '
> >       write(*,'(a40)') text
> >    write(*,*)'n = ',n
> >    write(*,*)'textpart1=',textpart(1)
> >    write(*,*)'textpart2=',textpart(2)
> >    write(*,*)'textpart3=',textpart(3)
> >    write(*,*)'textpart4=',textpart(4)
> >    write(*,*)'textpart5=',textpart(5)
> >    write(*,*)'textpart6=',textpart(6)
> >    write(*,*)'textpart7=',textpart(7)
> >    write(*,*)'textpart8=',textpart(8)
> >    write(*,*)'textpart9=',textpart(9)
> >    write(*,*)'textpart11=',textpart(10)
> >    write(*,*)'textpart11=',textpart(11)
> >    write(*,*)'textpart12=',textpart(12)
> >
> >
> > !
> > !     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
> >
> >    in = 1
> >
> >    call openfile()
> >
> >    call getnewline(istat, in, n, key)
> >
> >   END PROGRAM TEST_READ
> You shouldn't be able to compile this without fixing the incompatible
mixture
> of fixed and free format input.  My cygwin g77 versions had no difficulty
> with this, when I used binary/unix files, and fixed the source code
format.
> I still wouldn't trust libf2c I/O library to read DOS text format files,
and
> I can't tell if that was what you wished to do.
> --
> Tim Prince
>
> --
> 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/
>
>
>



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