All,

I have been doing some language exploration in v7/4.3bsd and came across Software Tools (not the pascal version). It's written using ratfor, which I had seen in the v7 UPM. I fired up v7 and tried my hand at the first example:

# copy - copy input characters to output
        integer getc
        integer c

        while(getc(c) != EOF)
                call putc(c)
        stop
        end

The first thing I noticed was that it read more like C than Fortran (I know C quite well, Fortran just a smidge)... awesome, right? So I ran the preprocessor on it and got the following f77 code:
c copy - copy input characters to output
      integer getc
      integer c
c     while
23000 if(.not.(getc(c) .ne. eof))goto 23001
         call putc(c)
         goto 23000
c     endwhile
23001 continue
      stop
      end
Cool. The way it translated the EOF test is weird, but ok. Trying to compile it results in complaints about missing getc and putc:
$ f77 copy.f
copy.f:
   MAIN:
Undefined:
_getc_
_putc_
_end

Ah well, no worries. I know that they're in the c lib, but don't about fortran libs... Meanwhile, over on 4.3BSD, it compiles without issue. But running it is no joy:
$ ./a.out
This is a test
$

I remembered that the authors mentioned something about EOF, so I tweaked the code (changed EOF to -1) and rebuilt/reran:
$ ./a.out
This is a test
This is a test
$
Fascinating. Dunno why no complaints from F77 about the undefined EOF (or maybe mis-defined), but hey, it works and it's fun.

I'm curious how much ratfor was used in bell labs and other locations running v6, v7, and the BSD's. When I first came across it, I was under the impression that it was a wrapper to make f66 bearable, but the manpage says it's best used with f77, so that's not quite right. As someone coming from c, I totally appreciate what it does to make the control structures I know and love available, but that wasn't the case back then, was it? C was pretty new... Was it just a temporary fix to a problem that just went away, or is there tons of ratfor out there in the wild that I just haven't seen? I found ratfor77 and it runs just fine on my mac with a few tweaks, so it's not dead:

ratfor77 -C copy.r | tee copy.f
C Output from Public domain Ratfor, version 1.0
C copy - copy input characters to output
      integer getc
      integer c
23000 if(getc(c) .ne. eof)then
      call putc(c)
      goto 23000
      endif
23001 continue
      stop
      end


What's the story? Oh, and in v6 it looks like it was rc - ratfor compiler, which is not present in v7 or 4.3BSD - is there a backstory there, too?

Will