linking "C" and FORTRAN functions together
Anthony Mutiso
anthony at alberta.UUCP
Sun Mar 5 10:38:10 AEST 1989
In article <1599 at aucs.UUCP>, 850181p at aucs.UUCP (STEVEN E. PARKER) writes:
> I am trying to find out how to link a fortran library
> subroutine "SVD" into a "C" program.
> I know that you have to compile the souce
> to .o files but what do you do next???
Have a look at your Unix programmers manual "Fortran and Friends". It
does say something about how to solve your problem, if memory serves.
In general here is what you need to understand:-
(1) Fortran data types are passed to functions by default in
a manner that is different to the default C manner (especially
text string, which have to include a byte length).
(2) The f77 compiler will compile fortran code to names with
two underscores. e.g.. the fortran procedure "map" will
compile to the identifier "__map", while the C name "map"
will compile to the identifier "_map". So to access the
fortran subroutine in a C file the name "_map" will have
to be used to reach the fortran name "map". Watch out of
course for subroutine naming conventions, ie. calling a C
function from the fortran program.
I hope this is sufficient to get you going.
Anthony.
--------------------------------------------------------------------------------
Anthony Mutiso Email
Department of Computing Science. anthony at UAlberta.AB.CA
University of Alberta or anthony at alberta.UUCP
Edmonton, Alberta
CANADA
Tel: (office) 403-432-2821
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Disclaimer:
...... angle and ministers of grace defend us all......
...... lord protect the foolish.....
--------------------------------------------------------------------------------
More information about the Comp.unix.questions
mailing list