CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

Passing fortran variables to C in mixed programmin

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 9, 2008, 05:45
Default Passing fortran variables to C in mixed programmin
  #1
Quarkz
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!
  Reply With Quote

Old   January 9, 2008, 07:17
Default Re: Passing fortran variables to C in mixed progra
  #2
andy
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.

  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 11:11
Comparison between C/C++ and Fortran? rick Main CFD Forum 45 September 6, 2011 00:52
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
FORTRAN Routine - variable passing Malcolm CFX 1 August 11, 2005 18:51
memory calculation of variables in FORTRAN codes John Main CFD Forum 1 April 8, 2002 14:13


All times are GMT -4. The time now is 14:57.