Subject: Calling FORTRAN FUNCTIONS from a C-Program.

From: [email-masked] (Anil G. Mudholkar)
Date: Thu, 13 Oct 94 09:22:24 CDT

Mr. Hinsen,

	I agree with all of your comments.  I was too quick to just
rattle off the message I wrote.  Also, I had not before seen CFORTRAN,
but I will definitely check it out.  My main point was that f2c isn't
a very good route to take, but that generally something not too
difficult can be done if you have to mix code.  I only resort to this
when I become so completely frustrated in trying but failing to do
some very simple operation with clean Fortran when I am certain I can
do in one line of C code.  For example, dynamic memory allocation for
Fortran is usually only possible by mixing code.

) This might work on one machine, but not on another. It will probably
) work with most Unix machines (except possibly IBM's RS/6000), but

	I have found that the rough guidelines I mentioned off the top
of my head do work on most unix boxes, including RS/6000 under AIX 3.2
and higher, which are our group's main production level machines,
though admittedly, it is not guaranteed to be portable.  This is
neither a part of the description of Fortran-77 nor is there any
universal standard, and I'm sure that most non-unix platforms will
have less similar compiler behavior.  Also, a gentleman from the
Minnesota Supercomputing Center was kind enough to point out to me
yesterday that my prescription (as I stated it) would not work on a
Cray, for example.

	However, this has always been one of the least difficult
aspects of porting code for our group.  We have ports of our
electronic structure code for IBM RS/6000s AIX 3.2 up, SGI IRIX 4.0.5
and IRIX 5.2, Cray UNICOS, and (partially) Sun SunOS 4.1.1.  I have
also done this in some unrelated code from a VAX VMS 5.5 machine, and
the code mixing was the only thing that wasn't a problem in that case,
but that's another story.

	In the future, I will be more careful before recklessly
posting messages.  Or perhaps I should be more careful to avoid
recklessly posting altogether. :^) Thanks.

				Anil Mudholkar
				[email-masked]
				http://rainbow.uchicago.edu/~glump