Calling C from FORTRAN under Unix

Charles Packer packer at amarna.gsfc.nasa.gov
Tue May 21 00:31:57 AEST 1991


I received 15 e-mail replies to my query, (two since I started
writing this followup) -- thanks to everyone! Almost all of
them, with varying degrees of certainty,  suggested appending
an underscore to the subroutine name in the C source module and
compiling and linking as usual. This included one reply from an
Ultrix 4.1 user. 

But we have Ultrix 4.0, (on a VAXStation) and buried in its
manual is material that tells how to call C from FORTRAN. It
requires an intermediate language they call "JBL." Underscores
are irrelevant. 

To prove that I'm not making this up, below is an excerpt from
the source I used to test the scheme by filling an image array 
in Fortran and passing it to C, which in turn called a display
routine. 




FORTRAN------------------------------

	BYTE IMGDAT(0:511,0:511)
	.
	.
	.
	CALL LTEST(IMGDAT,J)


JBL (in it's entirety)------

LTEST(ref:ref,ref:val);


C-----------------------------------

void ltest_(Img,InVal)
unsigned char Img[512][512];
int InVal;
	{
	.
	.
	.

THE BUILD COMMAND--------------------

	fort aa.for c.jbl csubr.c

[OR, if modules compiled separately,]

	fort aa.o c.jbl csubr.o



More information about the Comp.unix.questions mailing list