Ratfor (short for ''Rational Fortran'') is a
programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
implemented as a
preprocessor
In computer science, a preprocessor (or precompiler) is a program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which is often used by so ...
for
Fortran 66. It provides
modern control structures, unavailable in Fortran 66, to replace
GOTO
GoTo (goto, GOTO, GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code; in contrast a function ca ...
s and statement numbers.
Features
Ratfor provides the following kinds of flow-control statements, described by Kernighan and Plauger as "shamelessly stolen from the language
C, developed for the
UNIX
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
operating system by
D.M. Ritchie" ("Software Tools", p. 318):
* statement grouping with braces
* if-else, while, for, do, repeat-until, break, next
* "free-form" statements, i.e., not constrained by Fortran format rules
* <, >, >=, ... in place of .LT., .GT., .GE., ...
* include
* # comments
For example, the following code
if (a > b) else
might be translated as
IF(.NOT.(A.GT.B))GOTO 1
MAX = A
GOTO 2
1 CONTINUE
MAX = B
2 CONTINUE
The version of Ratfor in ''Software Tools'' is written in Ratfor, as are the sample programs, and inasmuch as its own translation to Fortran is available, it can be ported to any Fortran system. Ratfor source code file names end in .r or .rat.
History
Ratfor was designed and implemented by
Brian Kernighan
Brian Wilson Kernighan (; born 1942) is a Canadian computer scientist.
He worked at Bell Labs and contributed to the development of Unix alongside Unix creators Ken Thompson and Dennis Ritchie. Kernighan's name became widely known through co-au ...
at
Bell Telephone Laboratories
Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984),
then AT&T Bell Laboratories (1984–1996)
and Bell Labs Innovations (1996–2007),
is an American industrial research and scientific development company owned by mul ...
in 1974, and described in ''Software—Practice & Experience'' in 1975. It was used in the book "Software Tools" (
Kernighan and
Plauger, 1976).
In 1977, at
Purdue University
Purdue University is a public land-grant research university in West Lafayette, Indiana, and the flagship campus of the Purdue University system. The university was founded in 1869 after Lafayette businessman John Purdue donated land and money ...
, an improved version of the Ratfor preprocessor was written. It was called Mouse4, as it was smaller and faster than Ratfor. A published document by Dr.
Douglas Comer
Douglas Earl Comer is a professor of computer science at Purdue University, where he teaches courses on operating systems and computer networks. He has written numerous research papers and textbooks, and currently heads several networking resear ...
, professor at Purdue, concluded "contrary to the evidence exhibited by the designer of Ratfor, sequential search is often inadequate for production software. Furthermore, in the case of lexical analysis, well-known techniques do seem to offer efficiency while retaining the simplicity, ease of coding and modularity of ad hoc methods." (CSD-TR236).
In comparison to the Ratfor preprocessor on a program of 3000 source lines running on a
CDC 6500 The CDC 6000 series is a discontinued family of mainframe computers manufactured by Control Data Corporation in the 1960s. It consisted of the CDC 6200, CDC 6300, CDC 6400, CDC 6500, CDC 6600 and CDC 6700 computers, which were all extremely rapi ...
system took 185.470 CPU seconds. That was cut by 50% when binary search was used in the Ratfor code. Rewriting the ad hoc lexical scanner using a standard method based on finite automata reduced run time to 12.723 seconds.
With the availability of
Fortran 77, a successor named
Ratfiv
Ratfor (short for ''Rational Fortran'') is a programming language implemented as a preprocessor for Fortran#FORTRAN 66, Fortran 66. It provides Structured programming, modern control structures, unavailable in Fortran 66, to replace GOTOs and stat ...
(Ratfor=rat4 => rat5=Ratfiv) could, with an option /f77, output a more readable Fortran 77 code:
IF (A .GT. B) THEN
MAX = A
ELSE
MAX = B
ENDIF
Initial Ratfor source code was ported to C in 1985 and improved to produce Fortran 77 code too. A
git
Git () is a distributed version control system: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data in ...
tree has been set in 2010 in order to revive ratfor
.
Although the
GNU C compiler
The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free software ...
had the ability to directly compile a Ratfor file (.r) without keeping a useless intermediate Fortran code (.f) (
gcc foo.r
), this functionality was lost in version 4 during the move in 2005 from
f77 to
GNU Fortran
GNU Fortran or GFortran is the GNU Fortran compiler, which is part of the GNU Compiler Collection (GCC).
It includes full support for the Fortran#Fortran 95, Fortran 95 language, and supports large parts of the Fortran#Fortran 2003, Fortran 2003 an ...
.
Source packages, .
deb or
src.rpm package are still available for users who needs to compile old Ratfor software on any operating system.
Ratfiv
Ratfiv is an enhanced version of the
Ratfor programming language, a
preprocessor
In computer science, a preprocessor (or precompiler) is a program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which is often used by so ...
for
Fortran designed to give it
C-like capabilities. Fortran was widely used for scientific programming but had very basic
control-flow
In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an ''imp ...
primitives ("do" and "
goto
GoTo (goto, GOTO, GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code; in contrast a function ca ...
") and no "
macro" facility which limited its expressiveness.
The name of the language is a pun (''Ratfor'' (RATional FORtran) -> "Rat Four" -> "Rat Five" -> ''RatFiv'').
Ratfiv was developed by Bill Wood at the
Institute for Cancer Research,
Philadelphia
Philadelphia, often called Philly, is the largest city in the Commonwealth of Pennsylvania, the sixth-largest city in the U.S., the second-largest city in both the Northeast megalopolis and Mid-Atlantic regions after New York City. Sinc ...
, PA in the early 1980s and released on several
DECUS
The Digital Equipment Computer Users' Society (DECUS) was an independent computer user group related to Digital Equipment Corporation (DEC). The Connect User Group Community, formed from the consolidation in May, 2008 of DECUS, Encompass, HP-I ...
(Digital Equipment Users Group) SIG (Special Interest Group) tapes. It is based on the original Ratfor by
B. Kernighan and
P. J. Plauger
Phillip James (P.J. or Bill) Plauger (; born January 13, 1944, Petersburg, West Virginia) is an author, entrepreneur and computer programmer. He has written and co-written articles and books about programming style, software tools, and the C ...
, with rewrites and enhancements by David Hanson and friends (U. of Arizona), Joe Sventek and Debbie Scherrer (
Lawrence Berkeley National Laboratory
Lawrence Berkeley National Laboratory (LBNL), commonly referred to as the Berkeley Lab, is a United States Department of Energy National Labs, United States national laboratory that is owned by, and conducts scientific research on behalf of, t ...
).
Ratfiv V2.1 was distributed on the DECUS RSX82a SIG tape.
Ratfiv V2.1 archive
/ref>
See also
* Fortran
* EFL
References
{{reflist, 30em
External links
Ratfor
Ratfor90
History of Programming Languages: Ratfor
Purdue summary
Ratfor90
Fortran programming language family
Programming languages created in 1976