Running Intel Fortran on Sublime Text 3 - fortran

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]

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}"]
}
]
}

Related

Sublime Text 3 intel oneAPI Fortran build system

Has anyone figured out how to write the build system for the oneAPI Fortran compiler?
Previously, i was using Parallel Studio XE ifort, and i managed to get it working using the solution here:
{
"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}"]
}
]
}
I tried changing the paths to the new ones but it doesn't work. I get the following error:
"ipsxe-comp-vars" is not recognized as an internal or external command,
program o executable.
I found the answer. Explanation below. Posting the working build system here for visibility.
This should be the build system:
{
"cmd": ["cmd", "/e:on", "/v:on", "/S", "/k", "C:\\\"Program Files (x86)\"\\Intel\\oneAPI\\setvars.bat intel64 vs2022 && 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)\\Intel\\oneAPI\\compiler\\latest\\windows\\bin\\intel64;${path}",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/e:on", "/v:on", "/s", "/c", "C:\\\"Program Files (x86)\"\\Intel\\oneAPI\\setvars.bat intel64 vs2022 && ifort ${file} && ${file_base_name}"]
}
]
}
Why the problem happens
For starters, ipsxe-comp-vars is a batch file which when run, sets up environment variables required to execute the intel compilers. This file is specific to Intel Parallel Studio XE (IPSXE). Now, when installing IPSXE, it would add this batch file to your PATH, meaning you could simply call ipsxe-comp-vars from any directory to set up the required environment variables.
Intel oneAPI has a differently named file, that essentially does the same thing, called setvars.bat. This file is stored in:
C:\Program Files (x86)\Intel\oneAPI\setvars.bat
So, at first it seems that calling ipsxe-comp-vars fails because the file is named differently. However, unlike IPSXE did with ipsxe-comp-vars, oneAPI does not add setvars to PATH, so you cannot simply call setvars, you have to usethe full path.
How to solve it
With IPSXE, you could call ipsxe-comp-vars and it would run the batch file that sets up environment variables, but with oneAPI either you add the file to PATH (not reccomended because it has a generic name), or you use the full path when calling it (same as above):
C:\Program Files (x86)\Intel\oneAPI\setvars.bat
Now, because you have to plug this in into the build system config, you need to format it correctly. ST runs the commands in a cmd.exe, so you have to use the correct options and format the path in a way that cmd can understand it:
options (you can get a full list by opening a cmd prompt, typing cmd /? and hitting return):
- /e:on Enables command extensions
- /v:on Enables extension of environment variables
- /s Modifies how the string following a /c or /k is read
- /k Executes the string command and continues
The path to the setvars.bat file must be formatted as follows:
C:\\\"Program Files (x86)\"\\Intel\\oneAPI\\setvars.bat
Each \ separating dirs needs to be escaped (using \ as well)
needs to be enclosed in double quotes, since it contains a whitespace. Each double quote needs to escaped as well (once again with )
The following options are specific to the setvars.bat file:
- intel64 specifies 64-bit configuration
- vs2022 specifies Visual Studio 2022 as the developer cmd or
powershell version to use
Finally, ifort is called on the current file with ifort ${file}
Additionally, the build system is completed with a variant "Run". This variant runs the output file once it has been compiled(&& ${file_base_name}), and will show the output in the Sublime Text 3 console (does not accept inputs, if anyone knows how to setup up sublimeREPL for Fortran please tell me)

unable to run c++ program in sublime text 3(build system works!!!)

I am trying to set up sublime text 3 for compiling and running c++ programs.
I am on a Windows machine(x64).
My build system looks like this:
{
"cmd": ["g++.exe", "-o", "$file_base_name", "$file"],
"variants": [
{
"cmd": ["start", "cmd", "/k", "$file_base_name"],
"shell": true,
"name": "Run"
}
]
}
When I choose build, it shows me no error. I can then run the .exe file from the directory.
When I choose build and run option, the problem begins. It shows me:
[WinError 2] The system cannot find the file specified
[cmd: g++ "C:\Users\***\Documents\c++\new.cpp" -o
"C:\Users\***\Documents\c++/new" &&
"C:\Users\***\Documents\c++/new"]
[dir: C:\Users\***\Documents\c++]
[path: C:\Program Files (x86)\NVIDIA
Corporation\PhysX\Common;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;
C:\Program Files\Python37\Scripts;C:\Program Files `(x86)\CodeBlocks\MinGW\bin\;
c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;
c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;
C:\TDM-GCC-64\bin;C:\Program Files\mingw-w64\mingw64\bin;
C:\TDM-GCC-64\bin;C:\Program Files\mingw-w64\mingw64\bin;]
[Finished]
My question is how can I overcome this problem? I am repeating that MY BUILD SYSTEM WORKS, PROBLEM BEGINS ONLY WHEN I TRY TO RUN THE FILE FROM SUBLIME TEXT

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.
Intel Fortran compiler flag /Qmkl adds MKL libraries.
Changing "ifort ${file}" to "ifort /Qmkl ${file}" should work for you.

Sublime Text no build output

Using build option does not give any output except of
[Finished in 0.4s]
I didn't configure any c++.sublime-build file, I just installed C++ compiler and added it to the system path. It should work out of the box, but it is not. I also use Pawn language very often, but I had to configure my pawn.sublime-build file in order to work. There is a similar problem, after building if there are some errors it says:
[Finished in 0.4s]
But if the code has no errors, it says:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team
Header size: 836 bytes
Code size: 5048 bytes
Data size: 2148 bytes
Stack/heap size: 16384 bytes; estimated max. usage=883 cells (3532 bytes)
Total requirements: 24416 bytes
Done.
[Finished in 0.1s]
It would by nice if sublime could just show the output from compiler.
Here's my Pawn.sublime-build
{
"cmd": ["amxxpc.exe", "$file"],
// "cmd": ["compile.exe"],
// "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"file_regex": "(.*)\\((\\d+)\\)\\s*:\\s*()(.*)",
"selector": ["source.pwn", "source.pawn", "source.sma", "source.inc"],
"path": "Extensions\\pawn\\"
}
I tried diffrent versions of the "file_regex" and also without it, just like in tutorials, but it just doesn't show output if code has an error.
On the other hand, Python shows up an output, like this:
print"test")
^
SyntaxError: invalid syntax
[Finished in 0.2s with exit code 1]
[shell_cmd: python -u "C:\Users\Michał\OneDrive\Documents\test.py"]
[dir: C:\Users\Michał\OneDrive\Documents]
[path: C:\Program Files (x86)\ActiveState Komodo Edit 9\;C:\Python34\;C:\Python34\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\MinGW\bin]
And here's output with corrected code:
test
[Finished in 0.1s]
How can I get output from C++ and Pawn files?
What I am doing wrong?
I use MinGW for C++ and amxxpc.exe (AMX MOD X COMPILER) for pawn.
Thank you in advance for any solution and sorry for my english. I'm from Poland.
Open up Sublime Text 2 and go to Tools -> Build System -> New Build System...
Enter the following:
{
"cmd": ["pawncc.exe", "-i includes", "$file", "-;+"],
"path": "C:/path/to/pawno/folder"
}
Of course you need to replace the path
Save this file and close Sublime Text 2
Now navigate to AppData/Roaming/Sublime Text 2/Packages/User
Open up the .sublime-keymap file based on your operating system
Enter the following (this example is for the Windows file):
[
{ "keys": ["f5"], "command": "build" }
]
You can change f5 to another key if you wish
Save and reopen Sublime Text 2
Now go to Tools -> Build System
Click on the name of the build you created
`

How to build and run c++ programs in Sublime Text 2, Windows 8?

I installed Codeblocks with mingw, chose default compiler, and could build and run a simple hello program without errors.
I installed Sublime Text 2, copy pasted the same hello world program:
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Upon building, I get the error message:
[Error 2] The system cannot find the file specified
[cmd: [u'bash', u'-c', u"g++ '' -o '/' && '/'"]]
[dir: C:\Windows\system32]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\]
[Finished]
What do I need to do in order to build and run a simple program using Sublime Text 2?
First, make sure you save the file you're working on, wherever on your drive, before building and running.
Sublime Text 2 needs g++, bash, etc in order to compile. These packages need to be installed on your computer, as per the instructions on this page:
http://mjiang.com/mec/cs244/files/Installing%20c++_g++_on_Windows.pdf
For WINDOWS:
If you have Dev C++ (Bloodshed) then,
OPEN SUBLIME TEXT 2 and creat a new file to write your code (change build system to c++ through Tools> Build System> C++ as SublimeText2 doesn't come with build-system for c)
After that, you save that file to bin folder contained in Dev-Cpp folder and press ctrl+b
If your code is correct (bug free) then you'll found a corresponding file (in .exe format) on same directory which will show you
Hello World!
REMEMBER: SUBLIME TEXT 2 is an Editor, not a COMPILER
You could use my working C++.sublime-build file for Windows:
https://gist.github.com/trietptm/4950038
just create new Build-system (TOOLS->BUILD SYSTEM->NEW BUILD SYSTEM)
{
"windows":
{
"cmd": ["g++", "$file_name","-o", "${file_base_name}.exe", "-lm", "-Wall", "&","start", "${file_base_name}.exe"]
},
"selector": "source.c++",
"shell": true,
"working_dir": "${file_path}"
}
and save it as (name_you_can_provide).sublime-build and use that build system. :)
(I assume you already have installed MingW in your computer.)
You need to go to
Preferences->Browse Packages->C++ folder->C++.sublime-build;
bring this C++.sublime build file into the sublime text editor and now paste this code :
{ "cmd": ["g++", "$file", "-o", "$file_base_name"], "selector": "source.c++", "working_dir": "$file_path", "variants": [ { "name": "Run", "cmd": ["g++", "$file", "-o", "$file_base_name", "&&", "$file_path/$file_base_name"], "shell": true } ]
}
Hope this helps you.
You must install MinGW, then add path to MinGW to PATH variable.