Setting Up Your Environment


For users of the University of Virginia’s cluster, first load a compiler module.

module load gcc

This command brings a newer gcc, g++, and gfortran into the current environment. Now load Geany.

module load geany

For personal use, compilers, Geany, and the other cross-platform IDEs are available for all popular Linux distributions and can be installed through the distribution’s package manager or by downloading from the vendor (e.g. the NVIDIA HPC SDK). Most workstation users do not install environment modules, so the module command would not be required.

On Mac and Windows, an IDE can be installed in the usual way for those platforms, either through the application “store” or starting at the package’s home page.

Mac OS

GCC Install Xcode from the App Store. This will install gcc and g++. To use Fortran, download a binary for your version of OS from the binary site. These compilers can be used with any IDE available for Macs. Xcode does not support Fortran directly so another option is recommended, but it can be used for C and C++.

Intel oneAPI Download the Mac version from Intel.

The NVIDIA HPC SDK is not available for Macs.

Geany can be installed from its homepage. Other options, such as VSCode, can be installed similarly.


There are several compiler options for Windows. Visual Studio supports C and C++ but not Fortran, and no Fortran is currently available for it. However, there are several free options.


A popular vehicle for using the Gnu compilers on Windows is Cgwin. Cygwin also provides a large number of other Unix tools. The Gnu compiler suite is installed through the Cygwin installer.

Recently, Microsoft has released the Windows Subsystem for Linux ( WSL). This is not a virtual machine but is a type of Linux emulator. It is a full-featured command-line-only Linux environment for Windows, but the X11 graphical user interface is not supported.

A drawback to both Cygwin and the WSL is portability of executables. Cygwin executables must be able to find the Cygwin DLL and are therefore not standalone. WSL executables only run on the WSL. For standalone, native binaries a good choice is MingGW. MinGW is derived from Cygwin.

MinGW provides a free distribution of gcc/g++/gfortran. The standard MinGW distribution is updated fairly rarely and generates only 32-bit executables. We will describe MinGW-w64, a fork of the original project.

MinGW-w64 can be installed beginning from the MSYS2 project. MSYS2 provides a significant subset of the Cygwin tools. Download and install it.

Once it has been installed, follow the instructions to open a command-line tool, update the distribution, then install the compilers and tools. For Fortran users, the mingw64 repository may be preferable to the ucrt64 repo. To find packages, visit their repository.

A discussion of installing MinGW-64 compilers for use with VSCode has been posted by Microsoft here. To use mingw64 rather than ucrt64, simply substitute the text string. Fortran users should install both the C/C++ and Fortran extensions for VSCode.

Intel oneAPI Download and install the basic toolkit and, for Fortran, the HPC toolkit.

NVIDIA HPC SDK Download and install the package when it is available.

Environment Variables in Windows

To use any of these compilers through an IDE, they must be added to the Path environment variable. You must use the path you chose for the installation. The default is C:\msys64\mingw64\bin for the compilers.

Control Panel->System and Security->Advanced system settings->Environment Variables

Once you open Path, click New to add to the Path

To test that you have successfully updated your path, open a cmd window and type


You should see an error

gfortran: fatal error: no input files

Compiling Your First Program

We will show Geany and VSCode on Windows. Both look similar on the other platforms.

Open Geany (or VSCode). Type in the following

program hello
! My first program
   print *, "Hello world"
end program

Syntax coloring will not be enabled until the file is saved with a file extension that corresponds to the language. Save this file as hello.f90. The coloring will appear.

The appearance is similar in VSCode.

In Geany, click the Build icon (a brick wall). A message confirming a successful compilation should be printed.

Now click the Execute button. A new window will open and the message will be printed.

Executing the Hello World program