[1502] in Athena Bugs

home help back first fref pref prev next nref lref last post

F77 rename bug or is it?

daemon@ATHENA.MIT.EDU (adtaiwo@ATHENA.MIT.EDU)
Fri Dec 9 10:16:33 1988

From: <adtaiwo@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Date: Fri, 09 Dec 88 10:15:32 EST
The following is a piece of code that should work, unfortunately it does not
this is because rename, at least called by the fortran libraries, is broken.
Funny it returns a zero value on exit, but I do not think it does anything.

Please tell me what I am doing wrong.

c************************************************************************
      subroutine lopen(iunit,fname,knew,ktype)
c************************************************************************
c     LOPEN  opens disk files
c     iunit:   fortran unit number
c     fname:   disk file name
c     knew:    'OLD' for existing files
c     'NEW' for files to be created
c     ktype:   'TEXT' for a text file
c     'SEQ' for a sequential binary file
c***********************************************************************
      character fname*(*), a, ktype*(*), knew*(*)
      character cp*100
      external rename
      logical isthere, onefound
c
      cp = ' '
      inquire(file=fname,exist=onefound)
      if (knew.eq.'old'.or.knew.eq.'OLD') then
         if(onefound) then
            open(unit=iunit,file=fname,status=knew)
         else
            write(6,9010) fname
            call exit(1)
         end if
      else
         cp = fname
         l = index(cp,' ')
         cp(l:l) = '-'
         a = 'a'
         if (onefound) then
            do 10 i=1,26
               cp(l+1:l+1) = a               
               inquire(file=cp,exist=isthere)
               if(.not.isthere)go to 11
               j = ichar(a)+1
               a = char(j)
 10         continue
 11         continue
            i = rename(fname,cp)
            if(i .ne. 0) then
               write(6,*)'Can not rename file',fname
               call exit(1)
            end if
         end if
         open(unit=iunit,file=fname,status=knew)
         if(onefound) write(6,9000)fname,cp
      end if
 9010 format(/5('*'),' file not found! ',a, /'Run Terminated'/)
 9000 format(/5('*'),' file ',a,' found, was renamed to ',a)
      return
      end

      Thank you.		-adtaiwo

home help back first fref pref prev next nref lref last post