delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/12/09:35:04

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: <3D074C2D.9C5880B6@yahoo.com>
Date: Wed, 12 Jun 2002 09:27:09 -0400
From: Earnie Boyd <earnie_boyd AT yahoo DOT com>
Reply-To: Earnie Boyd <Cygwin AT cygwin DOT com>
X-Accept-Language: en
MIME-Version: 1.0
To: Earnie Boyd <Cygwin AT cygwin DOT com>
CC: Xinan Zhou <zhoux AT lifepredictiontech DOT com>
Subject: [Fwd: fortran read problem]

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


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