Subject: C to Fortran

From: Richard Gillilan <[email-masked]>
Date: Mon, 27 Sep 1999 09:37:22 -0400

I may be wrong, but I suspect C and Fortran interconversion 
is a "one-way street". The man page for the f2c conversion
says:

"Some things are impossible to express in Fortran 77 or are harder to
express in
Fortran than in C (e.g. storage management, some character operations,
arrays of functions, heterogeneous data structures, and calls that
depend on the operating system) ..."

C++ is even less likely to be convertable because its object-oriented
nature would be awkward or even impossible to replicate in Fortran.

It is possible to call Fortran routines from C programs (I have done it
in the past). It is also possible to call C from Fortran. On SGI
platforms,
there is a program called "mkf2c" to create the appropriate wrappers
for C code.

 Hope this helps

   Richard Gillilan
   Cornell Theory Center

---

From: Iraj Daizadeh <[email-masked]>
Date: Mon, 27 Sep 1999 13:04:11 -0400 (EDT)

Why in the world would someone want to perform this absurd transformation?
Is this a problem with the obtainment of compilers or simply a lack of
programming knowledge about C/C++. [BTW; it would be impossible to convert
C++ to fortran77; maybe 90 but this would take some effort.]

Simply use multi-language compiling tricks which are well known to the
CCL. That is, compile the fortran code, compile the C/C++ code and ligate
the object files together.[There are some fine points, however--such as
passing variables to functions (Since fortran always passes via `pointers'
by default-thus, when you call a fortran subroutine from within C/C++ code
you need to pass the variable address (&) -which can be easily introduced
even in large coding projects. ] There was a post some time ago (by me)
that dealt with multi-language compilation issues in a most pragmatic
way--the post even contained a small tutorial-like example.]

Also, if speed is what is sought-for here--optimized C is just as fast as
fortran.

Iraj.

Iraj Daizadeh, Ph.D.
Harvard University
Department of Cellular and Molecular Biology
The Biological Laboratories
16 Divinity Avenue
Cambridge, MA 02138
Phone:   (617) 495-0783
         (617) 495-0560
Fax:     (617) 496-4313
Email:   [email-masked]
WebPage: http://mcb.harvard.edu/gilbert/daizadeh

---

From: Matt Challacombe <[email-masked]>
Date: Mon, 27 Sep 1999 14:07:48 -0600

> Why in the world would someone want to perform this absurd transformation?

One reason for performing this transformation is to ensure portability 
for fortran-c and c-fortran interfaces where strings are passed.  

--Matt

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ Matt Challacombe, Ph.D.           http://www.t12.lanl.gov/~mchalla/ +
+ Los Alamos National Laboratory    email: [email-masked]       + 
+ Theoretical Division              vmail:   (505) 698-4112           +
+ Group T-12, Mail Stop B268        phone:   (505) 665-5905           +
+ Los Alamos, New Mexico  87545     fax:     (505) 665-3909           +
+                                                                     +
+ "The secret to mountain biking is pretty simple. The slower you go  +
+  the more likely it is you'll crash." -- Julie Furtado              +
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+