Skip to content

Instantly share code, notes, and snippets.

@sestelo
Last active April 1, 2024 14:44
Show Gist options
  • Save sestelo/6b01e1405c1d0fa7f0ecdc951caaa995 to your computer and use it in GitHub Desktop.
Save sestelo/6b01e1405c1d0fa7f0ecdc951caaa995 to your computer and use it in GitHub Desktop.
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) 
@tanim26072000
Copy link

hi there, i followed the instruction above, but i m getting "The system cannot find the path specified.", what should i do??

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