473,804 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Intel Compiler 8.1] C++ calling Fortran Routine


Hi!

I have desperately searched google and its groups in vain. Hope you can
help with my problem. I need to call some ancient Fortran objects by
C++-main program with the latest Intel Compiler V8.1 on Linux 2.6.x.

Compilers are properly installed and working, means, LD_LIBRARY_PATH and
PATH is set correctly.

Calling Fortan (example.f) from C (main.c) works fine using
icc -c main
ifort -o main main.o function.f -nofor_main
However, C++ seems to have some problems. Here are the codes:

----- FORTRAN: function.f -----

SUBROUTINE fortrantest()
IMPLICIT NONE
PRINT *, "Simple test o.k."
END

----- C++: main.C ----------

#include<iostre am>
using namespace std;

extern "C"
{
extern void fortrantest_();
}

int main()
{
cout << "Testing call" << endl;
fortrantest_();
}

----------------------

using
icpc -c main.C
ifort -c function.f -nofor_main
works without errors, but linking with
ifort -o main function.o main.o -nofor_main main.o
produces lots of undefined refs. icpc produces different
and fewer error-messages
icpc -o main function.o main.o

function.o(.tex t+0x36): In function `fortrantest_':
: undefined reference to `for_write_seq_ lis'
Any suggestions welcome!

Thanx

ST

Jul 23 '05 #1
3 8975
Sascha T. wrote:
Hi!

I have desperately searched google and its groups in vain. Hope you can help with my problem. I need to call some ancient Fortran objects by
C++-main program with the latest Intel Compiler V8.1 on Linux 2.6.x.

Compilers are properly installed and working, means, LD_LIBRARY_PATH and PATH is set correctly.

Calling Fortan (example.f) from C (main.c) works fine using
icc -c main
ifort -o main main.o function.f -nofor_main


However, C++ seems to have some problems. Here are the codes:

----- FORTRAN: function.f -----

SUBROUTINE fortrantest()
IMPLICIT NONE
PRINT *, "Simple test o.k."
END

----- C++: main.C ----------

#include<iostre am>
using namespace std;

extern "C"
{
extern void fortrantest_();
}

int main()
{
cout << "Testing call" << endl;
fortrantest_();
}

----------------------

using
icpc -c main.C
ifort -c function.f -nofor_main


works without errors, but linking with
ifort -o main function.o main.o -nofor_main main.o


produces lots of undefined refs. icpc produces different
and fewer error-messages
icpc -o main function.o main.o

function.o(.tex t+0x36): In function `fortrantest_':
: undefined reference to `for_write_seq_ lis'
Any suggestions welcome!

Thanx

ST


Looks like you're missing some libraries used by your fortran compiler.

-shez-

Jul 23 '05 #2

"Sascha T." <dj************ @spammotel.com> wrote in message
news:pa******** *************** *****@spammotel .com...

Hi!

I have desperately searched google and its groups in vain. Hope you can
help with my problem. I need to call some ancient Fortran objects by
C++-main program with the latest Intel Compiler V8.1 on Linux 2.6.x.

Compilers are properly installed and working, means, LD_LIBRARY_PATH and
PATH is set correctly.

Calling Fortan (example.f) from C (main.c) works fine using
icc -c main
ifort -o main main.o function.f -nofor_main


However, C++ seems to have some problems. Here are the codes:

----- FORTRAN: function.f -----

SUBROUTINE fortrantest()
IMPLICIT NONE
PRINT *, "Simple test o.k."
END

----- C++: main.C ----------

#include<iostre am>
using namespace std;

extern "C"
{
extern void fortrantest_();
}

int main()
{
cout << "Testing call" << endl;
fortrantest_();
}

----------------------

using
icpc -c main.C
ifort -c function.f -nofor_main


works without errors, but linking with
ifort -o main function.o main.o -nofor_main main.o


produces lots of undefined refs. icpc produces different
and fewer error-messages
icpc -o main function.o main.o

function.o(.tex t+0x36): In function `fortrantest_':
: undefined reference to `for_write_seq_ lis'
Any suggestions welcome!

If the compiled objects make calls to a run-time library which came with a
Fortran compiler earlier than ifort 8.0, you will need that library, and you
will not be able to use ifort. You will need also a great deal of luck, and
avoidance of file usage conflicts between your code and the invisible
Fortran. If the objects are actually compatible with ifort, you could link
with ifort, but you need to know the additional libraries involved in icpc
linkage. This will depend on several factors, including whether you are
running 32-bit or one of the 64-bit versions of linux, and whether your icpc
was installed on top of a working g++. For example, I have a project which
requires
ifort *.o -lstdc++ -lunwind -lcxa
on one of those linux versions.
Jul 23 '05 #3


OF COURSE! Dump me, thanks for the hint!

I recompiled the .f-object and, using icpc for linking, I added

-L[ifort8.1path]/lib -lifcore

ending up in a successful binary.

Thank you!

Cheers

Am Wed, 16 Feb 2005 14:39:34 +0000 schrieb Tim Prince:
For example, I have a project which
requires
ifort *.o -lstdc++ -lunwind -lcxa
on one of those linux versions.


Jul 23 '05 #4

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

Similar topics

1
2591
by: Jeff Hagelberg | last post by:
I'm trying to create a python module which can be used by a python interpreter embedded inside a fortran program I have. To do this, I first created python wrappers for all the functions in my fortran program using f2py. I then start an embedded python interpreter in c code which I link against the fortran program. I invoke the fortran program with a filename containing python code. This file is passed to the c code which passes it on...
0
1059
by: Ryan Mitchley | last post by:
Hi all Before I go chasing ghosts - has anyone encountered any difficulties using the Move Constructor (Mojo) approach with the Intel compiler (7.1 or higher). I am finding that functions that take temporaries as parameters are never being called, and function returns are causing references to invalid memory. I was previously using gcc without any problems.
0
1130
by: Ryan Mitchley | last post by:
Hi all The Intel compiler generates a #383 remark: "value copied to temporary, reference to temporay used", for both of the following lines: const complex<FTYPE> CBase::m_cfZero = complex<FTYPE>(0.0f, 0.0f); const complex<FTYPE> CBase::m_cfOne(1.0f, 0.0f); Should I not worry about this remark, or is there a better way to initialise a static const complex member variable without these remarks being
2
2982
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the Intel compiler it has stopped working. I think the singleton pattern static instance thing may be at the root of the problem, but I'm not sure. I had to add calls to instance() in regCreateFn, which gets the behaviour more in line with what I was...
4
4533
by: merlevo | last post by:
I am trying to set up the intel compiler. I have no trouble when I #include <stdio.h> but if I #include (iostream> using namespace std; I get an error "could not open source file "iostream" When I use gcc I don't get this error.
2
1653
by: Pavan Zope | last post by:
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
12
2909
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 wload(starttime, duration, station, component, dataray, nsamp, calib, srate, samplength, datadir)
2
1479
by: tomamil | last post by:
does anyone has an idea how to do it?
5
4940
by: rembremading | last post by:
Hi All, I want to use intels LibM math library for my c program under Linux with intel compiler 10.1. I tried to follow the steps in http://software.intel.com/en-us/articles/implement-the-libm-math-library and the Linux compiler reference, respectively. I added #pragma function(exp)
0
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9171
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.