473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 1623
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 this way as our build process does not allow...
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 the array in fortran code, do some filling up 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 version 9.0 and I am getting segmenatation...
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, Christopher Lusardi
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 program. The fortran subroutine statement is ...
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 this way as our build process does not allow...
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++ program that uses ranlux(its actually C code given in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.