[comp.sys.hp] Fortran Libraries ???

greg@cityzoo.acs.umbc.edu (Greg Sylvain,Lib 007,3929,4376834) (12/20/89)

	Hello again,

	Another unrelated question for you all.  I'm trying to build some 
fortran packages, and I was having some linking errors.  So I looked in the
archived library where the funcions are supposed to be.  And the functions
were there, except they had an underscore ( _ ) after the function name.  So
I looked on a SGI machine and a DEC machine, they all had the underscore. 
Except on these machines the package was built with no problem.  And I looked
on the machine (DEC) that had the sources to some of the math fortran
libraries, and, in the comments, they showedthe function name with a underscore
and how it should be called from fortran.  The call was WITHOUT the underscore?
Does the fortran compiler (on some machines) append the underscore to the call?
What is the purpose of the underscore - to distinguish between <C-function> 
and <FORTRAN-equivalent-C-Function>_ ????


	Any clues ???  Thanks alot, Greg

				Greg Sylvain
				Academic Computing Services
				Systems Programmer
			
	UUCP:           	...{uunet}!umbc3!greg
	Internet (Arpa) :	greg@umbc3.umbc.edu
 	BITNET :		GREGS@UMBC

peter@mit-amt.MEDIA.MIT.EDU (Peter Schroeder) (12/21/89)

In article <2644@umbc3.UMBC.EDU>
greg@cityzoo.acs.umbc.edu (Greg Sylvain,Lib 007,3929,4376834) asks
how to link C and Fortran.

I've done this on the 800 machines. The compiler (or linker) will not
screw around with function names. So, `dsvdc()' from linpack can be
called in C as `dsvdc()', no mucking around. Some companies think
they do you some sort of favor by mucking around... I have seen underscores
prepended, appended, names all CAPITALIZED, etc. You will probably want
to isolate yourself from this in some header file.

Also remember that on some machines to include a fortran function call
in a C program forces you to do the final link edit from f77. Luckily on
the HPs (I only tried this on 800 type machines) you only have to do
what you would expect, that is link in -lcl for the Fortran runtime support.

I am happily using linpack and blas from withing C++, I love it!!!

On a related note, what corresponds to stderr in Fortran? I am using lsode
and every once in a while it prints some error message to stdout which
is not so nice since I am using it in a heavily pipe oriented environment.
Subsequent parsers tend to choke on that stuff.

Peter
peter@media-lab.media.mit.edu

mike@hpfcso.HP.COM (Mike McNelly) (12/22/89)

> ...
> On a related note, what corresponds to stderr in Fortran? I am using lsode
> and every once in a while it prints some error message to stdout which
> is not so nice since I am using it in a heavily pipe oriented environment.
> Subsequent parsers tend to choke on that stuff.

> Peter
> peter@media-lab.media.mit.edu

If I understand your question correctly, all HP-UX Fortran
implementations preconnect logical unit 5 to stdin, unit 6 to stdout,
and unit 7 to stderr.  Thus

	write(7,*)"hello world"

will go to stderr.  This preconnection can be overridden with an
explicit OPEN statement to the unit in question.

It's also possible to use shell input/output redirection (i.e.  <, >)
and piping facilities to redirect stdin, stdout and stderr to the
locations of your choice.

Mike McNelly
mike%hpfcla@hplabs.hp.com