Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran AND C interoperability

Status
Not open for further replies.

Hruod

Programmer
Jan 11, 2006
1
BE
Hi people

I really need a help in this issue. I've got two huge system written in Fortran and C. Now I need to send a Matrix from the Fortran code to the C code where this matrix is represented as a double**
I've tried to find help in internet, but it seems for this very especific case this information is quite rare.
Do you can help me ?
Fortran pass everythins by reference, in case of this matrix I simply don't now how to handle it in the c code!!!
 
Fortran and C are different languages (;-). Linkage of C and Fortran sources in the monolitic module depends on your compilers, so see these implementations manuals (search Fortran/C interface, calling conventions etc in corresponding manuals).

As usually, call by reference is represented in C as type* (pass a pointer but not a pointer to pointer). But your Fortran compiler may pass an array descriptor (not a pointer to the 1st array element). I think in no circumstances Fortran passes type**...
 
Also depends on which version of Fortran. F2003 has a C interface. Also check that the types are the same size: double precision in Fortran may or may not be the same as double in C.

Some variants double the range as well as the precision; others just double the precision but not the range.

If the compilers are from different sources then you may be out of luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top