Is that illegal f77 or an f2c problem? 
Author Message
 Is that illegal f77 or an f2c problem?

Hallo, I have had a problem with a fortran program which runs on
unix (Sun, f77), IBM3090, VAX: When I use f2c and gcc on my PC
running os/2 I get trapped in an endless loop doing file acces:
The offending subprogam is this one:

      subroutine append(i)           ! i is either 1 or 3
      implicit real*8(a-h,o-z)
 1    read(i,*,end=2)
      write(6,*)'Am I trapped here in append?'
      go to 1                        ! here I get trapped with f2c/gcc
 2    backspace(i)
      return
      end

I have no clue what it is supposed to do. Commenting out the calls to
it make me lose output. Getting trapped means that I go in this infinite
loop. What can I do? Cheers. Stefan
--
===============================================================================

                                                    home^    UTK^     ORNL^
===============================================================================



Fri, 29 Aug 1997 09:29:47 GMT  
 Is that illegal f77 or an f2c problem?

         subroutine append(i)           ! i is either 1 or 3
         implicit real*8(a-h,o-z)
    1    read(i,*,end=2)
         write(6,*)'Am I trapped here in append?'
         go to 1                        ! here I get trapped with f2c/gcc
    2    backspace(i)
         return
         end

   I have no clue what it is supposed to do. Commenting out the calls to
   it make me lose output. Getting trapped means that I go in this infinite
   loop. What can I do? Cheers. Stefan

Offhand it seems like the code is trying to skip over all records
until it finds end-of-file, then backspace back over the EOF record.

Maybe it's a compiler bug that's showing up here, but it seems like
your OS/2 compiler doesn't actually advance the file position when
reading using list-directed formatting with no input items.  I say
"compiler bug" only because of the wording of 12.9.4.1 of the F77
standard -- "On input, the file is positioned at the beginning of
the next record.  This record becomes the current record." -- I'd
conclude that the next sequential input must then treat the record
_after_ the current record as the "next record", but I might be wrong
about this.

Anyway, try replacing the "*" in the READ statement with "'()'",
which the standard explicitly (in 13.3, lines 47-51 on p 13-3)
indicates would skip an input record.

If that doesn't work, maybe the compiler is really broken and cannot
detect end-of-file properly or doesn't ever advance unless it actually
reads things.  If using "'(A1)'" and including a single READ I/O list
item of an otherwise unused CHARACTER variable doesn't work, it's
the former -- if it does, it's the latter.  Either way, you should
report the bug to your vendor.
--




Fri, 29 Aug 1997 21:03:08 GMT  
 Is that illegal f77 or an f2c problem?
Thank you again, Craig. I forgot to state here again that I am using
f2c and gcc 2.6.3. Roger Fearick sent email to me already pointing out that
things would work once I actually read something in a dummy variable,
like you also suggested. He thinks it is a problem with f2c and suggested I
inform the maintainers of f2c. I will do this and take the liberty to send
them this post, too.
You are right with your idea about the function of the code: I could get a
hold of the author, and I was told that this code was written in the old days
to run on a PDP-11, which sometimes would crash. Closing the files after
every write was the way to keep the output up to the crash time.
So probably it isn't needed anymore this way. However, I tried to show
someone how well f2c works, and sure enough -- Murpheys law ...

Cheers again.  Stefan


:        subroutine append(i)           ! i is either 1 or 3
:        implicit real*8(a-h,o-z)
:     1    read(i,*,end=2)
:        write(6,*)'Am I trapped here in append?'
:        go to 1                        ! here I get trapped with f2c/gcc
:     2    backspace(i)
:        return
:        end

:    I have no clue what it is supposed to do. Commenting out the calls to
:    it make me lose output. Getting trapped means that I go in this infinite
:    loop. What can I do? Cheers. Stefan

: Offhand it seems like the code is trying to skip over all records
: until it finds end-of-file, then backspace back over the EOF record.

: Maybe it's a compiler bug that's showing up here, but it seems like
: your OS/2 compiler doesn't actually advance the file position when
: reading using list-directed formatting with no input items.  I say
: "compiler bug" only because of the wording of 12.9.4.1 of the F77
: standard -- "On input, the file is positioned at the beginning of
: the next record.  This record becomes the current record." -- I'd
: conclude that the next sequential input must then treat the record
: _after_ the current record as the "next record", but I might be wrong
: about this.

: Anyway, try replacing the "*" in the READ statement with "'()'",
: which the standard explicitly (in 13.3, lines 47-51 on p 13-3)
: indicates would skip an input record.

: If that doesn't work, maybe the compiler is really broken and cannot
: detect end-of-file properly or doesn't ever advance unless it actually
: reads things.  If using "'(A1)'" and including a single READ I/O list
: item of an otherwise unused CHARACTER variable doesn't work, it's
: the former -- if it does, it's the latter.  Either way, you should
: report the bug to your vendor.
: --


--
===============================================================================

                                                    home^    UTK^     ORNL^
===============================================================================



Sat, 30 Aug 1997 07:51:32 GMT  
 Is that illegal f77 or an f2c problem?
The problem turned out to be a bug in the f2c libraries rather than in
the f2c compiler. I append the reply from the maintainers here:



re- libI77 bug (f2c)

Thanks for the example of a read statement with empty input list
not detecting end-of-file.  That was a bug in libI77 rather than
in f2c itself.  Fixed.  Corrected source for libI77 is now available

by ftp (ftp://netlib.att.com/netlib/f2c/libi77.Z).

B.t.w., I don't have time to read netnews...

-- dmg

: Hallo, I have had a problem with a fortran program which runs on
: unix (Sun, f77), IBM3090, VAX: When I use f2c and gcc on my PC
: running os/2 I get trapped in an endless loop doing file acces:
: The offending subprogam is this one:

:       subroutine append(i)           ! i is either 1 or 3
:       implicit real*8(a-h,o-z)
:  1    read(i,*,end=2)
:       write(6,*)'Am I trapped here in append?'
:       go to 1                        ! here I get trapped with f2c/gcc
:  2    backspace(i)
:       return
:       end

: I have no clue what it is supposed to do. Commenting out the calls to
: it make me lose output. Getting trapped means that I go in this infinite
: loop. What can I do? Cheers. Stefan
: --
: ===============================================================================

:                                                     home^    UTK^     ORNL^
: ===============================================================================

--
===============================================================================

                                                    home^    UTK^     ORNL^
===============================================================================



Sun, 31 Aug 1997 11:45:26 GMT  
 Is that illegal f77 or an f2c problem?

Quote:

> Hallo, I have had a problem with a fortran program which runs on
> unix (Sun, f77), IBM3090, VAX: When I use f2c and gcc on my PC
> running os/2 I get trapped in an endless loop doing file acces:
> The offending subprogam is this one:
>       subroutine append(i)           ! i is either 1 or 3
>       implicit real*8(a-h,o-z)
>  1    read(i,*,end=2)

Given that you read nothing, it is perhaps f2c-gcc avoiding this instruction and not
skipping a line of input as you want? Try instead:

   1    read (i,'(a1)',end=2) ch

with

        character*(1) ch

defined above.

Quote:
>       write(6,*)'Am I trapped here in append?'
>       go to 1                        ! here I get trapped with f2c/gcc
>  2    backspace(i)
>       return
>       end
> I have no clue what it is supposed to do. Commenting out the calls to
> it make me lose output. Getting trapped means that I go in this infinite
> loop. What can I do? Cheers. Stefan
> --
> ===============================================================================

>                                                     home^    UTK^     ORNL^
> ===============================================================================

--
+--------------------------------------------+  +---^---/    /
!               Victor Lua~na                !  |   ~       / Just in case
! Departamento de Quimica Fisica y Analitica !  |           | you don't
! Universidad de Oviedo, 33006-Oviedo, Spain ! <            / remember

!          phone: (34)-8-5103523             !  |____  ___/   is  ;-)
!           fax: (34)-8-5103480              !       \/
+--------------------------------------------+


Sun, 07 Sep 1997 19:51:39 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. problem compiling f77 with f2c or gcc on redhat 7.0

2. Problems including libraries with Linux f77/f2c

3. Problem with f77 script calling f2c and gcc

4. f2c,f77 on Linux

5. DEC F77 on Ultrix 4.3a and OSF 1.2 vs f2c on Linux 1.1.x

6. f77 & f2c numbers under os/2

7. Performance of f2c + gcc under Linux vs SunOS F77

8. Performance of f2c + gcc under Linux vs SunOS F77

9. Symbol names under POSIX, f77, and f2c

10. Conversion F77 to C with f2c

11. LINUX f77 (f2c+gcc) Script

12. f77 shell script for f2c (wanted)

 

 
Powered by phpBB® Forum Software