Search code examples
fortransublimetext3intel-fortranintel-mkl

Link with Intel MKL library when compiling Fortran in Sublime Text 3?


With the help of this great site, I was able to compile my Fortran code in Sublime Text 3 using a "new build system" as suggested in this answer like this.

{
    "cmd": ["cmd", "/e:on", "/v:on", "/k", "ipsxe-comp-vars intel64 vs2013 && ifort ${file}"],  
    "file_regex": "^.*\\\\([0-9A-Za-z_]+\\.[A-Za-z0-9]+)\\(([0-9]+)\\):[ ]+error[ ]+#([0-9]+):[ ]+(.*)$",  
    "working_dir":"${file_path}",   
    "selector":"source.f ,source.for ,source.ftn ,source.f90 ,source.fpp ,source.i ,source.i90",
    "encoding":"cp936",
    "path":"C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2017.2.187\\windows\\bin;${path}",
    "variants":
      [  
           {  
              "name": "Run", 
              "cmd": ["cmd", "/e:on", "/v:on", "/c", "ipsxe-comp-vars intel64 vs2013 && ifort ${file} && ${file_base_name}"] 
          }  
     ]  

}

Now, I want to link against the MKL library to benefit from its highly optimized routines. I want to include LAPACK routines, FFTs from mkl_dfti, random numbers from mkl_vsl, etc. I tried to add these libraries to the compile command as follows without success.

"cmd": ["cmd", "/e:on", "/v:on", "/c", "ipsxe-comp-vars intel64 vs2013 && 
        ifort ${file} && ${file_base_name} mkl_lapack95_lp64.lib mkl_intel_lp64.lib
        mkl_intel_thread.lib mkl_core.lib libiomp5md.lib"]

I use Windows 10 and can access these libraries in Visual Studio 2013. I need help configuring Sublime Text to use the same libraries.


Solution

  • Intel Fortran compiler flag /Qmkl adds MKL libraries. Changing "ifort ${file}" to "ifort /Qmkl ${file}" should work for you.