Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to configure Sublime text for working with Fortran code

First steps

Note: I'm supposing you have the gfortran compiler installed. If not, for example:

curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /

To fortran color sintaxis (choose one, for me the first one). Shift + CMD + P/ Install packages:

Build systems. Go to Tools/Build System/New Build System…

Code for Build: (Fortran_Build)

{
"cmd" : ["/usr/local/bin/gfortran ${file_name} -o ${file_base_name}.out"],
"selector" : "source.f90",
"working_dir" : "${file_path}",
"shell" : true
}

Code for Build and Run: (Fortran_Build_Run)

{
"cmd" : ["/usr/local/bin/gfortran ${file_name} -o ${file_base_name} && ./${file_base_name}"],
"selector" : "source.f90",
"working_dir" : "${file_path}",
"shell" : true
}

Code for Build in parallel with OpenMP: (Fortran_Build_openMP)

{
"cmd" : ["/usr/local/bin/gfortran -fopenmp ${file_name} -o ${file_base_name}.out"],
"selector" : "source.f90",
"working_dir" : "${file_path}",
"shell" : true
}

Code Fortran (.f90). In order to recognize directly the working directory:

character*200::cwd,wd
integer len

CALL GETARG(0,cwd)
len=index(cwd,'/',back=.true.)-1
wd=cwd(:len)
wd=trim(wd)
CALL CHDIR(wd) 
@ghylander

This comment has been minimized.

Copy link

@ghylander ghylander commented Aug 24, 2021

is this transferable to windows?
i have gfrotran from mingw64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment