3

Sublime Text 3 has a package that links the text editor to Gfortran and it runs without any problems. I would like to know how can I add Intel Fortran as a custom build to Sublime Text 3? From what I understand I need to go on build systems and create a new file with code similar to the one below (this is an example for gfortran).

{
    "cmd": "gfortran ${file} -o ${file_base_name}",
    "selector": "source.modern-fortran, source.fixedform-fortran",
}

How could I do this for Intel Fortran?

Extra:

This was asked before for Linux (I use Windows) here: Sublime Text 2 Build (Ctrl +B) Intel Fortran Compiler . The fix is supposed to be:

"cmd": ["ifort","$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.fortran90"

But it doesn't work on my PC. I get the following message:

[WinError 2] The system cannot find the file specified
[cmd: ['ifort', 'C:\\Users\\username\\Desktop\\fortranfile.f90']]
[dir: C:\Users\username\Desktop]
[path: C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.4.210\windows\mpi\intel64\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\mpirt;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32_win\mpirt;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32_win\compiler;C:\MinGW\bin;C:\cygwin64\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\windows\system32;C:\MinGW\bin]
[Finished]
Sophie
  • 113
  • 10

1 Answers1

5

I managed to run Intel Fortran on Sublime Text 3 by creating a new file in New Build System as follows (I am using Intel 64 Visual Studio 2013 environment):

{
    "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.4.210\\windows\\bin;${path}",
    "variants":
      [  
           {  
              "name": "Run", 
              "cmd": ["cmd", "/e:on", "/v:on", "/c", "ipsxe-comp-vars intel64 vs2013 && ifort ${file} && ${file_base_name}"] 
          }  
     ]  

}
Sophie
  • 113
  • 10
  • 1
    Hey, I was seconds away from posting a similar solution! Glad you got it working. – Matt P Aug 25 '17 at 20:26
  • Matt, how would I be able to run the executable and see the result on sublime? Also, do you know how could I link/run multiple Fortran files that depend on each other? The code shown above works for a single Fortran file, but seems to fail for more than one. – Sophie Aug 25 '17 at 23:55
  • If you want to compile multiple files then substitute " ${file}" by "*.f90" and right below "cmd" add " "shell":true ". How can we run the executable and interact with it though? Say if I have "read*, i" on my fortran file, how can I make that work on Sublime? – Sophie Aug 26 '17 at 01:16
  • Since you have tge variant "Run", you can open the command palette and type in `build`, that should bring up the variant option. It will automatically open the output window (whatever that is called). , – Matt P Aug 26 '17 at 02:17