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

How can I get ifort to use my lapack libraries?

CCopp
Beginner
3,827 Views
I am trying to install atlas/lapack on my machine. I am running scientitic linux which is just RHEL and I have the latest ifort installed. I also installed atlas and lapack. What I want to do is add those library paths so that ifort knows to look there for functions, but I am not sure how to do that? What do I need to do?
0 Kudos
14 Replies
mecej4
Honored Contributor III
3,827 Views
You will get better performance by using the MKL libraries, which are included with IFort, than by using third party Atlas and Lapack libraries. To get started, look at some of the sample programs in the MKL directories. Compiling the examples (or your own code with simple calls to MKL) needs simply adding the compiler option -mkl.
0 Kudos
CCopp
Beginner
3,827 Views
I am able to compile my program with ifort that way, but when I go to run it, I get the error

"error while loading shared libraries: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory"
Now, the file is there, in/opt/intel/composerxe-2011.3.174/mkl/lib/intel64. The compiler knows that since it seems to compile just fine. I added it to the path in bash_profile but it still won't run. What am I doing wrong?
0 Kudos
TimP
Honored Contributor III
3,827 Views
Among the environment variables set by the compiler setup script is LD_ LIBRARY_PATH, which will include the MKL library directory. You could set it explicitly if you so choose.
0 Kudos
CCopp
Beginner
3,827 Views
I have added the library paths to bashrc, bash_profile, and ifortvars, but I am now getting segmentation faults every time I am able to locate the right files. I am not sure what I am doing wrong.
0 Kudos
mecej4
Honored Contributor III
3,827 Views
You are probably not adhering to the proper argument lists in your calls to MKL.

Instead of attempting one big leap, perhaps you could start with a small example (several are installed under .../mkl/samples), run them successfully and move on to your own application.
0 Kudos
CCopp
Beginner
3,827 Views
Ok, I wrote a test program and I still get the same errors, so I don't think it is with my code, but rather the problem is with my environment variables and/or my compiler.

Here is the error I get running a simple diagonalization routine:
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
TEST 00000000004038CB Unknown Unknown Unknown
TEST 000000000040356C Unknown Unknown Unknown
libc.so.6 0000003021C1D994 Unknown Unknown Unknown
TEST 0000000000403479 Unknown Unknown Unknown
0 Kudos
CCopp
Beginner
3,827 Views
Also, I have tried to compile and run some of the .f90 programs in /opt/intel/mkl/examples, and they do not compile. For example, trying to compile gesvd.f90 with -mkl gives
undefined reference to 'sgesvd_mkl95_'
I am pretty confused about what is going on here.
0 Kudos
mecej4
Honored Contributor III
3,826 Views
It is of little help to diagnose a problem when the information given is insufficient. Now, however, there is something to work with.

The error you got is not a compile-time error, but a link-time error. You are using an example that needs the Lapack95 library. This library is delivered prebuilt with the current compiler releases, but in compiler versions below 12.0, it had to be built from sources (which were supplied, along with a makefile).

Try an example that uses only BLAS or Lapack, since such examples may be built with just the -mkl switch.

To make sure that the proper MKL libraries are used, you may need to use the MKL Link Line Tool .
0 Kudos
CCopp
Beginner
3,826 Views
Ok, I will look into this. But first, how do I know what version of the compiler I have? I thought I had the latest version, so I should be able to use the lapack95 programs...so am I just not linking them properly? Is there some way to just install the latest compiler without having to go through Composer XE on linux? I feel somewhat uncertain that I have the latest version fully installed.
I am not sure abou all the MKL link line tools, I will have to look through that some more. Thanks for the link.
0 Kudos
mecej4
Honored Contributor III
3,826 Views
The XE label is used only with V12.0. You should be all set.

$ ifort -V

will tell you the version number.
0 Kudos
CCopp
Beginner
3,826 Views
Ok, I am following the MKL guide PDF, and when I get to the part where it says to test your compiler by running examples, I get the exact same problem. I can compile them but when I go to run it says it cannot find libiomp5.so. This file is located in the compiler/lib/intel64 directory, but I don't know where I am supposed to record this directory so the compiler will know where to look for it. I ran the ifortvars script and this still does not work. Should I manually edit LD_LIBRARY_PATH? If so, where? That gave me segfaults before...
0 Kudos
mecej4
Honored Contributor III
3,826 Views
At the shell prompt (indicated below by the first '$' on the line), type

$ echo $LD_LIBRARY_PATH

If the echoed string does not contain the directory containing the shared object (.so) in question, add the path as follows:

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:the_missing_path
0 Kudos
CCopp
Beginner
3,826 Views
Adding the path for libiomp5.so in the command line does allow sdia.out to run successfully.
I went back and tried this with my test program, and I had to add a second location to the ld_library_path, but then I encountered the same segfault again. I will try more examples and see if I can find out what is wrong with the code.
Where can I put this ld_library_path so that it will be safe and apply to all ifort compiles? Just my user bash_profile? Or bashrc as well?
0 Kudos
CCopp
Beginner
3,827 Views
Ok, I completely reinstalled my entire OS. I now have Ubuntu and Intel fortran composer XE 12.0.
I have written a simple dsyev test program which I am linking with -mkl. I can compile but still not run this program.
Is there a diagnostic program I could compile and run to find out what is wrong? I am not sure where to begin. I erased everything and reinstalled, so there should not be anything wrong with that. So I am either linking this wrong or I am not setting up my dsyev call correctly, but I am not sure how to fix either of those.
0 Kudos
Reply