This is to build RATFIV, which is derived from ratfor (Rational Fortran) but with much more 
enhancements (F77 style, indentation, do while, etc). See "ratfiv.doc".

Source was initially running on VAX/VMS (William WOOD from Institute For Cancer Research in 1981).
It has been adapted on UNIX machines (AIX V3.1 and xlf fortran 2.0, and
DEC-MIPS with DEC Fortran Compiler)
by Nicolas Brouard <brouard@frined51.bitnet>

How to build?
Go to boot subdirectory and try to make xratfiv for FORTRAN files.
Then, if you want to bootstrap from RATFIV files try from the top directory.
Fortran files are output to directory stage1.

On Linux a simple 'make' on top directory should make all.

June-16-2001
Add -mno-cygwin to compile on Windows. N. Brouard
Oct-18-2001
Changed ratfor script in order to work with Linux. N. Brouard

'make install' install ratfiv on /usr/local/bin  (you can change it).
It also installs 'ratfor' which is a script which calls ratfiv. The script varies from
systems. There is a Linux ratfor in subdirectory './r' .
 ratfiv works like this: ratfiv /f77 file1.r file2.r ... filen.r >out.f
 while ratfor uses the unix syntax: ratfor -o out.f file1.r file2.r ... filen.r
 so we use a script. If you use g77  which is a Fortran add-on to gcc you can use
the syntax: gcc -v -o foo foo.r and you will remark
that gcc needs ratfor which needs ratfiv to convert a RATFOR (or FIV) source into FORTRAN
and to compile it in C with gcc.
If you use another FORTRAN compiler it is easy to adapt it.  

OLD OPERATING SYTEMS
--------------------
A file 'symbols' keeps all definitions specific to a system.
define(UNIX) is useful as opposed to define(VAX) (which is VMS)
define(AIX) is specific to AIX 3.1 but could be adapted to other UNIX
machines (like DEC-RISC machines).

% (percent) in first column  keeps line intact in fortran output.
 -function gtarg needs the unix fortran getarg function (gtarg.r)
 -fucntion opn.r is specific to a particular system like AIX.

All routines are now written in ratfiv.
 - ratsrc.r is the main program;
 - macsrc.r gives additional functions for the macro-processor.
 - support.r gives special fucntions.
 - io.r is very system dependent. In particular if getch and putch 
are not available one can use F77 subroutine to emulate them.
 - xitstat.r give a system dependant error status which can be adapted.

The script f77 lets ".r" files transparent. In AIX where f77 does not
exist, it calls xlf.

Remarks
-------

In file symbols.G77 you will remark that Ratfor character is translate
to INTEGER. For some fortran compiler it was sometimes changed to BYTE
or INTEGER which does not exist on some compilers like g77. So most of
strings are passed by reference to INTEGERS, (usually INTEGER*4). Only
for output, like in putch or getch we are using charf77 which is a real
CHARACTER of FORTRAN77. Ratfor was initially compiled on PDP11 with 
fortran IV without the CHARACTER statement. Therefore strings were
converted by ratfor to integer with the ratfor statement:
string cant "can't"
call error(cant)

But when ratfor moved to ratfiv FORTRAN77 was already here on VAX machines.
And some codes are written directly as
call error("can't")

In that case the subroutine error was changed to be able (if byte did
not exist) to read the strings as a real F77 CHARACTER.
So, in symbols, one can find the definition
define(charf77,CHARACTER)

Other remarks
-------------
Ratfor was highly used when C was just starting. Authors of Ratfor where also
involved in C as far as I know. (I lost my book on Ratfor).
And ratfor users, used ratfor in a very similar way of C. But fortran
programmers loved at that time to use ratfor as a RATIONAL FORTRAN, but
keeping some advantage of FORTRAN, like:

do i=32, 128
   print *,'i=',i,'char(i)='//char(i)

instead of using a C syntax of putlin or putchar.

The switch /f77 is not by default but should be used.
To incorporate ratfiv in g77 I needed the switch -o, so instead of changing
ratfiv I wrote a script named ratfor which can use it:
ratfor foo.r -o foo.f

The changes in g77 are experimental only, but it works:

g77 -o foo foo.r

One difficulty is that cpp which works in a similar way for C as
ratfor for G77, does not work completely the same way. In a C program,
macro are included, but in ratfor, macros are usually in the line command:
	ratfiv symbols foo.r
even if they can be included.
So instead of limiting ratfiv to one input file only I used the ratfor script,
keeping ratfiv intact. So the manual is not altered (see ratfiv.man).

For inclusion in g77 which is included in gcc:
- create a subdirectory r of f (gcc/f/r/)
  and copy file r/lang-specs.h (which is included by specs.h in gcc.c).
- recompile g77 (which recompiles gcc).
put ratfor script somewhere like ratfiv.

Sources of ratfiv can be found on ftp://sauvy.ined.fr/pub/

Adaptations to UNIX and AIX by 
	Nicolas Brouard
  Institut national d'\'etudes d\'emographiques
    Paris
Bugs and remarks to  <brouard@ined.fr>
http://sauvy.ined.fr/~brouard


First version was written on september 1991

RATFIV-1.02 Revised in January 1996 and ported to g77.


