problem with using Fortran routine in C.

P

Pavan Zope

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
 
J

Jack Klein

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.
 
D

Dik T. Winter

> 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top