Search code examples
linuxrfortranldintel-mkl

Does Rscript change LD_LIBRARY_PATH?


I am running a version of R (which was not compiled with intel parallel studio) and am attempting to load an intel compiled shared Fortran library that I compiled myself. In the script I am using to run, I include the LD_LIBRARY_PATH and then use Rscript to run the R script (which calls dyn.load("My_Fortran.so"), compiled using ifort and mkl).

When I run the script, however, it fails with Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so. Is it possible that Rscript undoes my setting of LD_LIBRARY_PATH? If not, is it possible that since this version of R was not compiled with intel parallel studio, that it cannot load the shared libraries?

Here is how I am running the R script and loading the path:

#!/bin/bash
module load R/3.1.0
LD_LIBRARY_PATH=/path/to/intel_parallel_studio/xe_2015_u3/install/mkl/lib/intel64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
Rscript myRscript.r

The R script fails with:

Running R code
Attempting to load Fortran compiled shared library ... Done!
Calling Fortran subroutine from within R ... 
MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so

Solution

  • You could look at the shell script source code of both R and Rscript.

    In general such PATH settings (for executables as well as shared libraries) are generally only added to and not overwritten. So you may have another problem.

    Can you edit /etc/ld.so.conf ?

    Edit Also consider setting LD_LIBRARY_PATH before you do module load R/3.1.0.