- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I am facing issues I don't seem able to resolve. Hopefully someone here will have an answer or a hint.
Here's the context. I have to couple two software pieces via Python:
Piece 1:
- fortran 90 code built into shared libraries
- built with openmpi 1.6.4 / ifort 15.0.2
- uses mpi, openmp and some legacy libs that can not be rebuilt
- a python interface to the main routine is created via f2py
Piece 2:
- C++ code with Python interface generated by Swig
- uses mpi and some routines from Pièce 1's shared libraries
- compiled with distutils => the default linker is g++ as Python has been compiled with
Python:
- python 2.7, built with GNU (no intel C/C++ compiler on my machine)
- the main script must execute some ops from "Piece 2" then some ops from "Piece 1"
Today, I am able to execute Piece 1 or Piece 2 code through a python script. However the environment is different. My problem is to be able to call both in the same script. I have read here that I have to link everythin with ifort. Well, as Python has been compiled with GNU, it'll need a hack to change the linker but I am not even sure it is the solution.
What would be your roadmap if you had to set up a coupling like this?
Best regards,
Ekaterina.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, you don't have to link everything with ifort. If you are mixing Fortran and C++ code, it's best if you link with ifort but you could link with gcc if you get the libraries right.
Since you seem to have two executables being called from Python, I don't see what the problem is. Are you having a problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Steve and thanks a lot for your answer. Surely, I am not getting the libraries right. Maybe I should give more details on my "pieces".
Piece 1
---------------------------------------
#if defined (LIBRARY)
subroutine main()
#else
program main
#endif
integer i
#if defined (LIBRARY)
call get_piece2(i)
#else
call read_file(i)
#endif
call compute(i)
end
---------------------------------------
subroutine read_file (i) [read data from file] end
---------------------------------------
Static library lib1.a (external) defines compute(), I have no source code for it.
---------------------------------------
I generate:
- without -DLIBRARY: lib2.a (main + file) + executable linked to both lib1.a and lib2.a
- with -DLIBRARY: lib3.so (main)
- lib1.a converted to lib1.so (extract with ar + build lib with ld)
- python interface uses lib3.so
Piece 2
I generate:
- lib4.so: a shared library using get (=> link to lib2 is required for read_file)
- lib5.so: another shared library defining get_piece2
Triggering script
from piece2 import lib4 [initialize piece2 data using lib4] [launch piece1 via lib3]
When importing lib4, I get unresolved symbol errors (mpi, openmp, intel, ... ), symbols coming from lib1 and lib3. I have tried to resolve them by adding libs to the piece 2 library generation step (like -lirc), I have stopped at _f90_dope_vector_init saying myself it was probably not a good way to go.
Ekaterina.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's difficult to provide the best advice when you are not showing actual code or commands. Adding libraries with -l when building a .a is not helpful, as that doesn't do anything.
You will not only need to add the appropriate libraries -lifcore -lirc, -letc., -liomp5, but also add -L to give the path to where the Intel Fortran libraries are provided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
Thanks for your help, I have finally redone the whole legacy compilation process and now mixing goes well. The issue is resolved.
Regards.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page