|
[Sponsors] |
Passing fortran variables to C in mixed programmin |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 9, 2008, 05:45 |
Passing fortran variables to C in mixed programmin
|
#1 |
Guest
Posts: n/a
|
Hi,
I've a subroutine that's written in C. My main program and everything else are in fortran 90. I have a global data module which consist of some variables and it can be assessed globally ie module global_data implicit none save real :: dd(10) end module global_data I would like to pass the values of a variable (e.g. dd) to a C subroutine, do some calculation, and out comes the result of the variable. How can I do this? Is there a sample code somewhere? I tried to find some info on the net but they seem quite complicated... Btw, my environment is visual studio and linux. Thanks in advance! |
|
January 9, 2008, 07:17 |
Re: Passing fortran variables to C in mixed progra
|
#2 |
Guest
Posts: n/a
|
Look in your compiler manual to find out how to mix C and Fortran subroutines. This varies from compiler to compiler. In simple cases it involves little more than knowing the naming convention for Fortran subroutines (common examples are fred_ or fred__) and declaring the C function to be an external C function in Fortran so that the name does not get underscores attached when linking.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to set environmental variables of Intel Fortran +CFX? | Christine MO | CFX | 0 | September 23, 2011 12:11 |
Comparison between C/C++ and Fortran? | rick | Main CFD Forum | 45 | September 6, 2011 01:52 |
CFX11 + Fortran compiler ? | Mohan | CFX | 20 | March 30, 2011 19:56 |
FORTRAN Routine - variable passing | Malcolm | CFX | 1 | August 11, 2005 19:51 |
memory calculation of variables in FORTRAN codes | John | Main CFD Forum | 1 | April 8, 2002 15:13 |