Link to News items about Fortran on a Mac
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.
NAG Fortran compiler Fortran compiler for Apple Silicon Macs now available to download
NAG announce the latest NAG Fortran Compiler for the new Apple platform running natively, without emulation, on Apple Silicon, an Arm v8 processor. 29 years after developing the world’s first Fortran-90 compiler NAG has released the first commercially available Fortran compiler for Apple Silicon Macs.
Apple Arm Mac
64-bit
macOS version 11.0 or compatible
gfortran for ARM Big Sur (macOS 11 +) and Apple Silicon, .
(gfortran only), updated June 2022 (Monterey — M1 Apple Silicon).
(gfortran only), updated May 2023 (Ventura — M1 and M2 Apple Silicon)
Absoft Pro Fortran 2022 For macOS
Apparently Absoft have ceased operations
Fully compatible with macOS Monterey (12.0) and supports Apple M1 systems through Rosetta 2 translation
Simply Fortran Integrated Development Environment
GNU Fortran and C Compilers Version 12.1.0
Aplot Two-Dimensional Plotting LibrarySimply Fortran for Apple Silicon does not support debugging at this time
LFortran is a modern open-source (BSD licensed) interactive Fortran compiler built on top of LLVM. It can execute user’s code interactively to allow exploratory work (much like Python, MATLAB or Julia) as well as compile to binaries with the goal to run user’s code on modern architectures such as multi-core CPUs and GPUs.
LFortran is in development (alpha stage), we have released a Minimum Viable Product (MVP) version at the end of the summer 2021, see the MVP announcement for more information.
Main repository at GitHub: https://github.com/lfortran/lfortran
Try LFortran in your browser using WebAssembly: https://dev.lfortran.org/
LFortran can be used as a Jupyter kernel, allowing Python/Julia-style rapid prototyping and an exploratory workflow (conda install jupyter lfortran). It can also be used from the command-line with an interactive prompt (REPL).
I suspect this will be of interest.
Fortran Package Manager (fpm) is a package manager and build system for Fortran. Its key goal is to improve the user experience of Fortran programmers. It does so by making it easier to build your Fortran program or library, run the executables, tests, and examples, and distribute it as a dependency to other Fortran projects. Fpm’s user interface is modeled after Rust’s Cargo, so if you’re familiar with that tool, you will feel at home with fpm. Fpm’s long term vision is to nurture and grow the ecosystem of modern Fortran applications and libraries.
Available on GitHub https://github.com/fortran-lang/fpm
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.
1 2 |
brew update brew install gcc |
We can check gfortran is installed using, in the Terminal type
1 2 |
man -k fortran gfortran(1) - GNU Fortran compiler |
and the location
1 2 |
which gfortran /usr/local/bin/gfortran |
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:
1 2 3 4 |
cd critic2-1.0 ./configure make install |
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)
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)
HPC Mac OSX High performance computing on a Mac
Fortran Tools, Libraries, and Application Software
Installing the GNU compilers on Mac OS X
Installing Open MPI on Mac OS X
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.
f90wrap is a tool to automatically generate Python extension modules which interface to Fortran libraries that makes use of derived types. It builds on the capabilities of the popular f2py utility by generating a simpler Fortran 90 interface to the original Fortran code which is then suitable for wrapping with f2py, together with a higher-level Pythonic wrapper that makes the existance of an additional layer transparent to the final user. f90wrap has been used to wrap a number of large software packages of relevance to the condensed matter physics community, including the QUIP molecular dynamics code and the CASTEP density functional theory code.
The full paper is here https://iopscience.iop.org/article/10.1088/1361-648X/ab82d2
Install using PIP
1 2 |
pip install f90wrap |
Source code is on GitHub https://github.com/jameskermode/f90wrap.
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.
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.
Michel Petitjean / softwares / freewares
Photran is an IDE and refactoring tool for Fortran based on Eclipse