Free Fortran Compiler For Mac
The OS X Fortran compiler supports a full range of project targets including command line programs and GUI based applications. It provides a complete 64 and 32 bit OS X Fortran compiler solution and supports mixed language development by interfacing with Apple’s Xcode C/C compiler. Absoft Pro Fortran Is A Complete Package. Pro Fortran provides a complete 32 or 64 bit Linux Fortran compiler solution and supports mixed language development by interfacing with the GNU GCC C/C compilers. Absoft Pro Fortran 2019 for OS X Mac OS X for Intel Processors Academic. License, Electronic Download. Included FREE! Absoft Pro Fortran 2020 For Windows.
First let me say I’m not a big Fortran user but any blog posts about Fortran always seem to be very popular, and I do get asked regularly about how to compile Fortran applications.
If you have followed the instructions on Cheminformatics on a Mac you already have Xcode, Command Line tools and gfortran installed using Homebrew. Alternatively you can install GCC 8.3 (auto-vectorizing gcc with OpenMP) which includes gfortran (free, open source, GNU Fortran 95 compiler), gcc (GNU C) and g++ (GNU C++) compilers that can perform auto-vectorization (i.e. modify code to take advantage of AltiVec/SSE, automatically) and other sophisticated optimizations like OpenMP. There are detailed instructions here, last updated April 2019 (Mojave).
Portland group also has a commercial fortran compiler as part of their offerings (PGI). Details of compatibility with the latest versions of mac OSX are available here.
The newest update to PGI Fortran, C and C++ compilers & tools for scientists and engineers. Includes Volta support, using CUDA Unified Memory with OpenACC, Open 4.5 CPU support, C++14 lambda and capture support within OpenACC and…. On Intel Haswell CPUs with OpenMP, PGI delivers multicore performance more than 50% faster than the latest GCC compilers. That’s like buying a cluster with 50% more compute nodes. PGI compilers deliver world-class multicore CPU performance and accelerator programming features that can dramatically increase the performance of applications on GPU accelerators. New features include V100 Tensor Core support, full C++17 language support, OpenACC printf(), PCAST directives, LLVM 7.0, Turing support.
There is also a free version of the PGI compiler released April 30, 2019
Absoft Pro Fortran 2019 for MacOSX.
Fully compatible with macOS Mojave, Pro Fortran builds faster code with exclusive Dynamic AP load balancing, SMP analysis, and advanced optimization. The AbsoftTools integrated development environment speeds program development and maintenance. Complete command line development support is also provided. The OS X Fortran compiler supports a full range of project targets including command line programs and GUI based applications. It provides a complete 64 and 32 bit OS X Fortran compiler solution and supports mixed language development by interfacing with Apple’s Xcode C/C++ compile
Pro Fortran for macOS System Requirements
- Intel CPU based system – multi-core suggested for best performance
- macOS Sierra (10.12) through macOS Mojave (10.14)
- OS X Snow Leopard (10.6) through OS X El Capitan (10.11)
- 2 GB RAM – 4 GB recommended for best performance
- 1 GB free disk space for complete installation
Arguably the best fortran compiler for Intel macs are the Intel compilers ifort.
The Intel® Fortran Compiler builds high-performance applications by generating optimized code for Intel® Xeon® Scalable processors and Intel® Core™ processors. Its features allow you to: Boost Single Instruction Multiple Data (SIMD) vectorization and threading capabilities (including for Intel® Advanced Vector Extensions 512 instructions) using the latest OpenMP* parallel programming modelTake advantage of more cores and increased vector register width available in Intel® Xeon® processorsComply with open standards such as Fortran and OpenMPWork with a familiar set of tools on your preferred platform: Windows, Linux, or macOS*
They can build pretty much any fortran code including very old fortran (as far back as fortran 66) and support the latest fortran standards. And in many people’s experience produce the fastest runtime executables. They also integrate directly into Xcode and tend to be the most up to date in terms of compatibility with the apple dev tools. They are also link compatible with both gcc and clang. ifort also includes a fortran version of their MLK library.
They provide redistribute libraries for dynamically linked binaries, but they also support static linking, so in either case binaries can be distributed to people without the compiler installed.They aren't free on Mac (they are free on Linux), but the academic price is relatively inexpensive. Additionally they have a C/C++ compiler suite, but the performance gain over clang is no longer there. They are better than gcc in terms of codgen, however. So if you aren't using MLK there may be no benefit.
NAG Fortran Compiler.
The NAG Fortran Compiler is robust, highly tested, and valued by developers all over the globe for its checking capabilities and detailed error reporting. The NAG Fortran Compiler is available on Linux, Microsoft Windows and Mac OS X. The latest release (6.2) has extensive support for both modern and legacy Fortran features, and also supports parallel programming with OpenMP.
Given the move towards parallel processing it is useful to note that most of the compilers support OpenMP, OpenMP is a specification for a set of compiler directives, library routines, and environment variables that can be used to specify high-level parallelism in Fortran and C/C++ programs.
Compiling Fortran applications on a Mac
If you have Homebrew installed then the easiest way to install gfortran is as part of gcc. I’ve written a page of instructions for setting up a Mac using Homebrew here.
We can check gfortran is installed using, in the Terminal type
and the location
which should be an alias to '/usr/local/Cellar/gcc/4.8.3/bin/gfortran'
An Example
Critic2: A program for real-space analysis of quantum chemical interactions in solids DOI
Download critic2 from: http://gatsby.ucmerced.edu/downloads/critic2/critic2-1.0.tar.gz
Once downloaded:
This compiles and installs:
- critic2, basin2off, off2off, charges.sh executables to /usr/local/bin
- data files to /usr/local/share/critic2
- help files to /usr/local/share/doc/critic2
A couple of Fortran experts have contacted me and suggested I include these flags that are often very useful for developers.
-static-libgcc : includes all necessary system routines in the binary and thus avoids error messages at runtime when some library is missing on the user computer
-mmacosx-version-min=10.1 : generates binaries able to work under several os x versions
-fno-underscoring : supresses the trailing undersore for names of functions and subroutines (but then you must take care about conflicting names)
Jupyter and Fortran
A demonstration of how to use Python, Julia, Fortran and R cooperatively to analyze data, in the same process
More information in this lecture, Project Jupyter: Architecture and Evolution of an Open Platform for Modern Data Science
Useful Fortran Programs
ABINIT is a software suite to calculate the optical, mechanical, vibrational, and other observable properties of materials. Starting from the quantum equations of density functional theory, you can build up to advanced applications with perturbation theories based on DFT, and many-body Green's functions (GW and DMFT) . Compilation/Installation notes are here.
BigDFT a DFT massively parallel electronic structure code (GPL license) using a wavelet basis set. Wavelets form a real space basis set distributed on an adaptive mesh (two levels of resolution in our implementation). GTH or HGH pseudopotentials are used to remove the core electrons. Thanks to our Poisson solver based on a Green function formalism, periodic systems, surfaces and isolated systems can be simulated with the proper boundary conditions. Source code.
Critic2 is a program for the topological analysis of real-space scalar fields in periodic systems
CP2K a quantum chemistry and solid state physics software package that can perform atomistic simulations of solid state, liquid, molecular, periodic, material, crystal, and biological systems. How to compile on a Mac
DALTON two powerful molecular electronic structure programs, Dalton and lsDalton. Together, the two programs provide an extensive functionality for the calculations of molecular properties at the HF, DFT, MCSCF, and CC levels of theory. Many of these properties are ONLY available in the DALTON2013 suite. Speaker enclosure design software for mac.
Dacapo is a total energy program based on density functional theory. It uses a plane wave basis for the valence electronic states and describes the core-electron interactions with Vanderbilt ultrasoft pseudo-potentials. Instructions for compiling on Intel Mac
dftd4 is regularly compiled on MacOSX https://travis-ci.org/dftd4/dftd4. A Generally Applicable Atomic-Charge Dependent London Dispersion Correction DOI.
GAMESS General ab-initio quantum chemistry package.
HORTON HORTON is a Helpful Open-source Research TOol for N-fermion systems. Compile and install under MacOSX
Postg is a program that implements the calculation of the dispersion energy and related quantities using the exchange-hole dipole moment model.
Quantum Expresso is an integrated suite of Open-Source computer codes for electronic-structure calculations and materials modeling at the nanoscale. It is based on density-functional theory, plane waves, and pseudopotentials
Illustrate is a small Fortran program for creating non-photorealistic illustrations of molecules, with cartoony colors and outlines, and soft ambient shadows. It is used to create the RCSB Molecule of the month.
Molecular simulation packages from the Mezei lab
Molpro a complete system of ab initio programs for molecular electronic structure calculations
NWChem aims to provide its users with computational chemistry tools that are scalable both in their ability to treat large scientific computational chemistry problems efficiently, and in their use of available parallel computing resources from high-performance parallel supercomputers to conventional workstation clusters
SIESTA is both a method and its computer program implementation, to perform efficient electronic structure calculations and ab initio molecular dynamics simulations of molecules and solids.
TINKER a general package for molecular mechanics and dynamics.
Photran is an IDE and refactoring tool for Fortran based on Eclipse
Useful Resources
Fortran Standard Library, International Fortran Standards, Fortran Proposals This repository contains proposals for the Fortran Standard Committee in the Issues section. The idea for this repository is to act as a public facing discussion tool to collaborate with the user community to gather proposals for the Fortran language and systematically track all discussions for each proposal
Fortran Course run at ETH
Fortran course run by NAG
Fortran 90 Tutorial from Stanford from 1998
CLFORTRAN – Pure Fortran Interface to OpenCL
FTranProjectBuilder Mac's only native Fortran programming environment (IDE)
More details in this video
Simply Fortran includes the GNU Fortran compiler, an advanced development environment including project management, and an integrated debugger for fast and easy installation, updated August 2019
HPC Mac OSX High performance computing on a Mac
gXXforrtran is available on GitHub This package provides a “pgf77” script that emulates the Portland Group’s PGI fortran 77 compiler, instead using the Free Software Foundation’s GNU gfortran compiler instead. This emulation is sufficient to allow packages such as Gaussian03, that would otherwise require a commercial compiler, to be built using open source tools.
CUDA Fortran for Scientists and Engineers shows how high-performance application developers can leverage the power of GPUs using Fortran
Sourcery Institute a variety of resources for Fortran programmers, Sourcery institute tap for Homebrew formulae not in homebrew/homebrew-core, a Coarray Fortran Jupyter notebook kernel, forks of flang and gcc and OpenCoarrays a transport layer for coarray Fortran compilers.
A parallel Fortran framework for neural networks and deep learning.
Updated 2 January 2020
This page gathers links to all unofficial gfortran binary packages people regularly build, based on the current development gfortran source code.
Windows
MacOS
GNU/Linux
Build GNU Fortran from source
Note: There do not exist any official FSF/GNU/GCC binary builds (only source packages). Most of the builds below come from gfortran maintainers but not all.
Windows
If in doubt, or if you don't know what Cygwin and MinGW are, the package for you is the MinGW ('native Windows') package!
MinGW for Win64: The Mingw-w64 project has regularly updated snapshots of compilers generating 64-bit Windows executables. They provides several compilers, which run on Windows (32-bit and 64-bit Windows), Cygwin, Linux, and Darwin/MacOS - and which generate binaries for 32bit or 64bit Windows. The file name pattern is <target>-<host>-<option-version>-<date>; thus, mingw-w64-bin_x86_64-mingw_20100527.zip is a compiler targeting 64bit Windows (mingw-w64) but also running ('host') on 64bit Windows (xx86-64-mingw); you might search for the file in Toolchains targetting Win64 (Personal Builds or Automatized Builds).
MinGW build ('native Windows' build)
Official MinGW builds (only releases), last seen was 6.3.0 (2017-05-30)
The MinGW for Win64 project has also binaries for 32bit Windows; e.g. mingw-w32-bin_i686-mingw_<date>.zip runs on and generates binaries for 32bit Windows (cf. above); you might search for the file in Toolchains targetting Win32 (Personal Builds or Automatized Builds).
TDM GCC: MinGW/MinGW-W64 Builds
MinGW 32/64bit builds by www.Equation.com (builds were announced at comp.lang.fortran; note - equation.com is not affiliated with any MinGW or GCC developer. Use at your own risk)
Cygwin: The Cygwin project offers up-to-date builds of GCC and gfortran
macOS
The gfortran maintainers offer nice Apple-style installers for macOS: https://github.com/fxcoudert/gfortran-for-macOS/releasesDetailed instructions can be found here.
You just have to force eject and reconnect the USB cable.I was using Mojave, but other people reported the same issue after upgrading from El Capitan to Sierra. Wd my passport for mac stuck on preparing backup.
Other projects packaging GCC (and gfortran) binaries for Mac include:
Homebrew offers the latest stable gfortran release as part of the 'gcc' package.
HPC Mac OS X offers GCC builds, which include gfortran
MacPorts (package name, e.g., 'gcc48') - the fastest way to get a developer version of GCC. MacPorts comes with a packing software, but all software is compiled before installation. For the developer version, the 'Portfile' is updated approx. weekly.
Fink offers GCC packages (all released versions) - similar to MacPorts, but also offers binaries; it does not have the developer versions, just the releases.
GNU/Linux
Most Linux distributions offer gfortran packages, some have also builds for the experimental versions
Nightly builds are available at:
32-bit processors (i686)
Download from gfortran.com
Installation instructions
64-bit AMD-compatible processors (x86_64, AMD64,Intel64, em64t)
Download from gfortran.com (README, nightly builds, 4.3 to 4.9 snapshots)
gcc-4.8-infrastructure package (GCC 4.8 and later; for GCC 4.3 to 4.7 use gcc-infrastructure), which contains required libraries (GMP, MPFR, MPC, etc.) - simply unpack in the 'gcc-trunk' (or 'gcc-4.6' or ..) directory
To unpack .xz files: Use xzcat with tar. It is contained in pre-build xz package, if you don't have it.
Needs to be updated: Installation instructions
Building from Source
See also InstallingGCC and http://gcc.gnu.org/install/
- Obtain the source code either via
subversion
git
Bazaar
unpacking a tarball
You should have the right versions of GMP, MPFR and MPC (and optionally for Graphite: CLOOG and ISL) installed, which you can download from ftp://gcc.gnu.org/pub/gcc/infrastructure/ (They can also be automatically build with GCC.)
Note: You can use ./contrib/download_prerequisites to download them.
Follow the instructions; in a nutshell, you will do
create a build directory, e.g. gcc-build underneath the source directory
go to the build directory and run configure from there; for instance: ./configure --prefix=$HOME/gcc-trunk --enable-languages=c,fortran
run make
run make install
Useful configure options: --enable-checking=release which disables some compile-time checks which slow down the compiler; --disable-bootstrap which speeds up the build but uses the system compiler and disables some consistency checks; --disable-build-poststage1-with-cxx (for 4.7 or higher) avoids building GCC with a C++ compiler, esp. useful if no C++ should be compiled; --disable-libstdcxx-pch speeds up the compilation a bit by not creating pre-compiled header files.