Help in Converting Fortran90 Code to C/C++

apv@sify.com (Vijay)
22 Mar 2003 16:39:15 -0500

          From comp.compilers

Related articles
Help in Converting Fortran90 Code to C/C++ apv@sify.com (2003-03-22)
| List of all articles for this month |
From: apv@sify.com (Vijay)
Newsgroups: comp.compilers
Date: 22 Mar 2003 16:39:15 -0500
Organization: http://groups.google.com/
Keywords: Fortran, C, translator, comment
Posted-Date: 22 Mar 2003 16:39:15 EST

Dear Sir / Madam,
We are working on a project, which is about "converting a legacy
code, written in Fortran90/95, to C++." Since we could not find any
tool, which directly converts code written in Fortran90/95 to C++, we
decided to first convert the code into C and then the resulting C code
into C++.
We made some progress in this direction but got stuck on "Accessing
Module data from C code". We are using Intel Fortran Compiler version
7.0 for compilation. We also referred to the section on "Mixed
Language programming" of the pdf help but were unable to find any
relevant solution.
         While looking for the solution we came across a code snippet in
which Fortran90 module data was directly being accessed from C code.
We found it in Compaq Visual Fortran compiler help.


The code snippet is as follows:


The Fortran code:


! F90 Module definition
MODULE EXAMP
REAL A(3)
INTEGER I1, I2
CHARACTER(80) LINE
TYPE MYDATA
SEQUENCE
INTEGER N
CHARACTER(30) INFO
END TYPE MYDATA
END MODULE EXAMP


The C code:


/* C code accessing module data */
extern float EXAMP_mp_A[3];
extern int EXAMP_mp_I1, EXAMP_mp_I2;
extern char EXAMP_mp_LINE[80];
extern struct {
int N;
char INFO[30];
} EXAMP_mp_MYDATA;


Is the above method of directly accessing Module Data supported by any
compiler? If it is, please let us know the procedure and if it is not
possible please specify an alternative solution for the same.


We will be highly grateful if you could please help in addressing our
problem.


Thanking You
Vijay


[Most C compilers can access data defined in Fortran compilers on the
same system, but there is absolutely no consistency in the naming or
other details. Better read the documentation again. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.