I have a compiled Fortran program (lets say in ~/codedir
) linked against Intel MKL, which I want to run with a Python script in a certain directory (lets say calculationdir
).
I can navigate to calculationdir
and execute ~/codedir/code
, where code is the name of the executable. Everything works. But if I try to start the code from the below Python script:
import subprocess
command = '~/codedir/code'
with open('job.out', 'a') as f:
process = subprocess.Popen(command.split(), stdout=f, shell=True)
output, error = process.communicate()
I get the following error:
/home/codedir/code: error while loading shared libraries: libmkl_intel_lp64.so.1: cannot open shared object file: No such file or directory
I suspect that this might have something to do with the environment variables. I configured my shell that every time I start a shell, the script setvars.sh
of Intel One API is executed which sets a lot of things. Could it be case that these variable are not set if I use python's subprocess? Do I have to tell subprocess in some way to execute also the setvars-script
?