#############################################################################
#                                                                           #
#                                ftypes V1.0                                #
#                                                                           #
#                   (c) 1996 Mathias Fr"ohlich, T"ubingen                   #
#                                  Germany                                  #
#                                                                           #
#############################################################################

Quick description:

The program ftypes which is compiled by the make command, generates
automatically the C header file "ftypes.h". This file contains some typedef
statements for using FORTRAN77 compiled subroutines from C programs and vice
versa. At the moment only the types which are used in the BLAS and LAPACK
routines are supported.


Problems when calling FORTRAN77 subroutines from C:

* Some f77 compilers append an underscore at the end of a call name of a
  function, and some do not.
* f77 always calls by reference, so we have to know about the length of the
  integer types which are used by f77 (unfortunately there is no "sizeof"
  command and declarations like "INTEGER*4" are not standard).


Strategy to get this information:

First compile a f77 main routine which calls a routine written in C. This C
routine exists in two versions, one has got a name with underscore one
without. Both routines write a C header file "undersc.h" which contains
information whether underscoring is done or not. This information is used for
the second step, getting the variable types from C which are equivalent to
those from f77. The #define macro in "undersc.h" determines which macro for
F77CALL is used (see "cmain.c" for F77CALL), so we can now call f77
subroutines from C. Then a data space is initialized with ones (bitwise ones,
generated by ~0 in C), a f77 routine is called which writes some predefined
values into this data space. The f77 call returns to C and C tries to read
this variables by using pointers of different type. If the predefined values
are found, and if the data space which should not be overwritten by the f77
subroutine is still equal to ~0, this is the variable type we need.


Problems of ftypes:

We __need__ the ANSI C standard. If you have no ANSI C compiler available,
try "gcc -ansi", if gcc works on your system.


How to use "ftypes.h":

Simply type "make". If this does not work try to set CFLAGS to the ANSI option
(gcc: -ansi). "make" will generate the file "ftypes.h" and will remove all
objects, executables and headers which are written during this process except
"ftypes.h".


How to call f77 subroutines form C with "ftypes.h":

If a call of, for example daxpy, looks like that

     call daxpy(10,-4,x,1,y,1)

in FORTRAN 77, the equivalent call form C will than look like this:

integer n=10;
doublereal alpha=-4.0;
doublereal x[10],y[10];
integer inc1=1;

.
.

F77CALL (daxpy) (&n,&alpha,x,&inc1,y,&inc1);
.
.


Reporting Bugs :-( and success :-) :

I have tested ftypes on my own linux machine, on some Sun Sparc Stations, on
HP 712 workstations and on an SGI Indigo II at the moment. If ftypes does not
work on your system, please let me know about it.

Send that to:

        frohlich@na.uni-tuebingen.de
