By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,995 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,995 IT Pros & Developers. It's quick & easy.

problem with using Fortran routine in C.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.