[gnu.gcc] Linking gcc and Sun f77 code?

rich@Rice.edu (Carey R. Murphey) (09/25/89)

I hope this is of general interest to others who use gcc and link in
fortran subroutine libraries. (I could not reach Alan Bair directly.)

There is a discussion on how to call fortran subroutines from C code
in the Unix Programmers Manual Volume 2, published by Holt, Rinehart
and Winston, ISBN 0-03-061743.  The section `Inter-Procedure
Interface' pp 407-409 describes how to call fortran subroutines from C
language code.

Here's an example of a C language declaration for a linpack subroutine
which does singular value decomposition:

int dsvdc_( double *x, int *ldx, int *n, int *p, double *s, double *e,
	  double *u, int *ldu, double *v, int *ldv, double *work,
	  int *job, int *info);

Where the fortran language definition is:

 subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info)
 integer ldx,n,p,ldu,ldv,job,info
 double precision x(ldx,1),s(1),e(1),u(ldu,1),v(ldv,1),work(1)


Note that there is an underscore appended to fortran subroutine names
by Sun's f77 but this varies between other fortran compilers.

Good Luck!
Rich

--
Richard-Murphey@Rice.edu       Electrical & Computer Engineering Dept.