472,353 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

problem with using Fortran routine in C.

Hello
I am facing a weired problem in calling a fortran routine from
c. The fortran function in question is like this:-

subroutine fortran_fun(idtab, nx, x, nf, nh, nhd, info, rinfo, fa,
ga, ha, stats,iusr_size, iusr,rusr_size, rusr )
implicit none
external usrfgh
external foo
integer :: idtab, nx, nf, nh, nhd, info(20),itno
integer :: iusr_size, rusr_size
integer :: iusr(iusr_size)
doubleprecision :: x(nx), rinfo(20+nx+nf)
doubleprecision :: fa(nf), ha(nhd), stats(50)
doubleprecision :: ga(nf,nx)
doubleprecision :: rusr(rusr_size)
character*128 :: fn
............
............

While calling this function from another c with debugger
attached, gdb output is:-

fortran_fun (idtab=13, nx=2, x=(), nf=1, nh=0, nhd=1, info=(0, 0, 0,
1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), rinfo=(), fa=(),
ga=(), ha=(), stats=Cannot access memory at address 0x0
) at isat_wrap.f90:8

the varible *stats* is a pointer of _double_(fortran real*8 =
c double) type and points to 50 valid blocks of memory allocated in C.
(i have checkd it in c side and it is not NULL). It seems that the
satck gets corrupted while calling the fortran function. How can I
proceed? I am using gcc 3.2 and intel fortran compiler.
Any help is welcome.

Thanks in advance
Pavan
Nov 14 '05 #1
2 1554
On 2 Feb 2004 01:41:09 -0800, pa****@yahoo.com (Pavan Zope) wrote in
comp.lang.c:
Hello
I am facing a weired problem in calling a fortran routine from
c. The fortran function in question is like this:-
The C language standard does not define or require a compiler to
provide linkage to any other language, not assembly language, not C++,
not FORTRAN.

If you are on a platform and using C and FORTRAN compilers that
provide this interface, all of the details about it are completely
compiler specific, not anything at all to do with the C language per
se.

[snip]
While calling this function from another c with debugger
attached, gdb output is:-


[snip]

Given your debugger, I'd suggest one of the gnu.* groups, or one of
their mailing lists. It's off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #2
In article <9e**************************@posting.google.com > pa****@yahoo.com (Pavan Zope) writes:
....
the varible *stats* is a pointer of _double_(fortran real*8 =
c double) type and points to 50 valid blocks of memory allocated in C.
(i have checkd it in c side and it is not NULL). It seems that the
satck gets corrupted while calling the fortran function. How can I
proceed? I am using gcc 3.2 and intel fortran compiler.


The calling interface gcc is using is probably different from the calling
interface the intel fortran compiler is using. Look in the documentation
of the compilers how to proceed, it is off-topic here.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #3

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

Similar topics

1
by: Pakea | last post by:
Dear all, I'm trying compile MSV .NET with IFC v8. In my c++ source I write .... extern "C" void _stdcall ROUTINE (...) ... main {....
6
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of...
5
by: NM | last post by:
Hi All, I am having a peculiar problem. I used to link between intel fortran 7.0 and g++ without any problem. Now the intel compiler is upgraded to...
5
by: Christopher M. Lusardi | last post by:
Hi, I know about the convention of appending "_" to c routine names, but how do I access Fortran global variables in c? Thank you,...
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...
26
by: sam | last post by:
Hi, Can anyone help me find a software that can convert a code in 'C' to 'Fortran77/90' automatically? Thanks in advance. Sam.
5
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it...
4
by: rudra | last post by:
dear friends, i am new to C/C++ and i need to call ranlux routine from my fortran code...here is a toy fortran code, which is calling the C++...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.