Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29030 Discussions

Different results when using a shared library in an executable and in python

raf3
Beginner
148 Views

Hello,

I encountered a strange behavior when using the compiler options -fPIC and -fp-model=strict with ifx (IFX 2025.1.0 20250317).

I’ve attached a minimal reproducible example to this message.

I use the followings bash script to compile and launch two different cases:


#!/bin/bash
opt1='-O2 -fPIC '
opt2='-O2 -fPIC -fp-model=consistent'
opt3='-O3 -fPIC -fp-model=strict'
#
opt=$opt3
#
echo "Result in direct launch (dynamic)"
rm -rf test *.o *.so
ifx -shared $opt my_function.f90 -o my_function.so
ifx $opt test_main.f90 my_function.so -o test
export LD_LIBRARY_PATH=".":$LD_LIBRARY_PATH
./test
#
echo "Result in python"
rm -rf test *.o *.so
ifx -shared $opt my_function.f90 -o my_function.so
python3 launch.py

 

In the first case, a shared library is created and used by an executable.

In the second case, the same shared library is used in Python.

The results differ between the two cases, I get the following results:

Result in direct launch (dynamic)
dval real = 5823048.334457053, hexa = 415636921567BE8E
calc real = 233.2397881329337, hexa = 406D27AC58299D6A
Result in python
dval real = 5823048.334457053, hexa = 415636921567BE8E
calc real = 233.2397881329337, hexa = 406D27AC58299D6B

Can you reproduce this behavior? Is it expected, or is it a bug?
If relevant, please note that I’m using ifx on a Red Hat 8 Linux system.

Best regards,

Raphaël

0 Kudos
0 Replies
Reply