469,586 Members | 2,191 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,586 developers. It's quick & easy.

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 1483
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Pakea | last post: by
5 posts views Thread by Christopher M. Lusardi | last post: by
12 posts views Thread by Bigdakine | last post: by
26 posts views Thread by sam | last post: by
4 posts views Thread by rudra | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.