473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How To Get To Fortran Common Variables Within a C Code

Hi,

I know about the convention of appending "_" to c routine names, but
how do I access Fortran global variables in c?

Thank you,
Christopher Lusardi
Nov 14 '05 #1
5 2757
cl********@aol.com (Christopher M. Lusardi) wrote in
news:d5**************************@posting.google.c om:
I know about the convention of appending "_" to c routine names, but
how do I access Fortran global variables in c?


Sadly, the C language does not specify how to do this (e.g. no help here).

--
- Mark ->
--
Nov 14 '05 #2
# I know about the convention of appending "_" to c routine names, but
# how do I access Fortran global variables in c?

You need to verify the details with your compiler vendors, but the
general idea is that
common /abc/ x,y,z
real x
integer y
complex z
corresponds to the global variable declaration
struct {
double x;
int y;
struct {double re,im;} z;
} abc;
with details varying with the system and compilers.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
Death is the worry of the living. The dead, like myself,
only worry about decay and necrophiliacs.
Nov 14 '05 #3
Christopher M. Lusardi wrote:
I know about the convention
of appending "_" to [Fortran] routine names,
but how do I access Fortran global variables [from] C?
Fortran 77 does not support "global" variables.
cat file.f program main
common/structure/i, x
integer i
real x
end
g77 -c file.f
nm file.o

00000000 T MAIN__
U s_stop
00000008 C structure_

The common block named structure is identified by the symbol structure_.
In your C program, define a global variable

struct {
int i;
float x;
} structure_;

so that you can reference the data members of the common block

structure_.i

and

structure_.x

Nov 14 '05 #4
"E. Robert Tisdale" wrote:
Christopher M. Lusardi wrote:
I know about the convention
of appending "_" to [Fortran] routine names,
but how do I access Fortran global variables [from] C?
Fortran 77 does not support "global" variables.
> cat file.f

program main
common/structure/i, x
integer i
real x
end
> g77 -c file.f
> nm file.o

00000000 T MAIN__
U s_stop
00000008 C structure_

The common block named structure is identified by the symbol
structure_. In your C program, define a global variable


C doesn't have global variables. Get your terms straight.

struct {
int i;
float x;
} structure_;

so that you can reference the data members of the common block

structure_.i

and

structure_.x


Fortran is NOT on topic in c.l.c. Are you doing this just to
avoid having people around who know that language criticize your
statements?

*** WARN WARN WARN ***
Anything Trollsdale posts is usually wrong.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #5
Christopher M. Lusardi wrote:

I know about the convention of appending "_" to c routine names, but
how do I access Fortran global variables in c?


The actual methods tend to be system dependent, but the
most obvious one is that a COMMON corresponds to an
extern struct.

One complication is that C allows padding and Fortran
does not.

-- glen

Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
5
by: Al | last post by:
I am about to start rewriting a fortran program to ansi C++. Would it be best to convert the variables that are 'real' to float? double? long double?
6
by: Santosh | last post by:
Hello all, I am trying to interface c++ and fortran, the fortran code is already there and I was successful in calling the subroutines and functions, but was not able to send the fortran module...
11
by: John Smith | last post by:
Ok, I know this is a common topic, but I didn't find any post that solves my current problem. I'm using Microsoft Visual C++ 6.0 (SP5), and Intel Fortran 7.1 Compiler for Windows. I'm trying to...
5
by: google | last post by:
first, a little background... i have a C program which preprocesses some data, and then outputs the results into a text file. that text file, in turn, is used as input to a FORTRAN...
12
by: Bigdakine | last post by:
I don't know if this is the right forum for this, and if not please suggest one which fits. I have to call a fortran sub routine from a C main program. The fortran subroutine statement is ...
2
by: | last post by:
Help! I'm new to c++, and am breaking my teeth on MS Visual C++ (bundled within Visual Studio .NET 2003). Am trying to link simple c++ code to fortran dlls created in Compaq Visual Fortran (v6.1)....
52
by: Nomad.C | last post by:
Hi I've been thinking of learning Fortran as number crunching kinda language for my Physics degree......but then looking around the internet, people are saying that the libraries/ Algorithms once...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.