Instructions for installing SUMMA on Mac OS X
The following has been tested on a MacBook Pro and iMac, both using OS X v. 10.12.6 (Sierra) and with MacPorts as the OS X package manager. It should also work on older versions of OS X or with other package managers such as fink or homebrew, but you will undoubtedly need to make some modifications.
This document is mainly for people who want to use SUMMA in their modeling project, rather than contribute or change the SUMMA source code. If you want to contribute to SUMMA, , please see the following documents:
Using MacPorts
In the following I will assume that you don't have a Fortran compiler or NetCDF installed. If you do, just scroll down.
-
Install MacPorts. This is a package manager for OS X (Darwin), which will let you install many software packages that are typically used in a Unix-like environment (which is what your Mac provides). MacPorts has detailed instructions on how it should be installed for various versions of OS X. Just follow the instructions (you will be asked to install Xcode, etcetera). If you know nothing about Unix/Linux/Darwin, now is the time to learn.
-
Open a terminal (Applications --> Utilities --> Terminal.app)
-
Use MacPorts to install NetCDF by typing the following on the command-line
sudo port install netcdfYou will be asked to provide your password. Note that you can only
sudo(execute a command as a superuser) if you have administrative privileges for your machine (i.e., you can install software, etc.). If you do not have administrative privileges, talk to the person who maintains your computer. A whole bunch of other packages (dependencies) will be installed as well. Just let MacPorts do its work, this is why you are using a package manager. It may take a while the first time you do this. Make sure that the NetCDF is compiled usinggcc6or higher. You can specify different variants of the package to be installed. See the MacPorts documentation for details. -
Install the Fortran version of the NetCDF library
sudo port install netcdf-fortranNote what version of
gccwas used to compile the NetCDF Fortran library. If you did not see it, typesudo port info netcdf-fortranThe gcc compiler will be listed under
Build Dependencies. For example,gcc6, which is what I'll assume for now. However, make sure to use the correct version of gcc (i.e. the one used to compile the netcdf-fortran library) when you compile SUMMA. -
Install the correct version of gcc (here we'll assume gcc6)
sudo port install gcc6 -
Note that MacPorts typically installs everything in the
/opt/localdirectory. Make sure you now have NetCDF and gfortran installed:ls /opt/local/lib/*netcdf*You should have one or more
libnetcdf.*(C-version of NetCDF library) andlibnetcdff.*(Fortran version of NetCDF library) filesls /opt/local/bin/*fortran*You should have one or more
gfortran-*files. If you installedgcc6, the gfortran executable will be/opt/local/bin/gfortran-mp-6. Since MacPorts will have modified your path so that/opt/local/binis part of that, you should be able to invoke the compiler by typinggfortran-mp-6and the results should be
gfortran-mp-6: fatal error: no input filescompilation terminated.Note that you may also have a symbolic link named
/opt/local/bin/gfortran. Make sure that that link points to the correct executable (e.g./opt/local/bin/gfortran-mp-6). If so, then you should be able to invoke the correct version of the fortran compile by simply typinggfortran. -
While you are at it, there are a number of other packages that would be useful to install, in particular
sudo port install ncview: to visualize NetCDF filessudo port install nco: to manipulate NetCDF files, see the NCO homepagesudo port install cdo: to manipulate NetCDF files, see the CDO homepage
Using Homebrew
Note: This was tested on an Apple machine with silicon M3 Pro chip that is running MacOS Sonoma (14.4.1) with homebrew (4.2.20). 1. Install Homebrew by opening the terminal and running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install NetCDF library and the Fortran version of the NetCDF library
brew install netcdf netcdf-fortran 2. Install gcc and gfortran
brew install gcc 4. Install other NetCD utilities
brew install nco cdo ncview 5. Install LAPACK
brew install lapack
Download and compile the source code
-
Now obtain the SUMMA source code from the SUMMA source code repository. You may just want to download the latest tagged release. Unless you are planning to contribute to the source code, there is no need to clone or fork the repository.
-
Untar or unzip the archive, then go to the
summa/builddirectory and follow the instructions in the SUMMA installation page. -
If you are using MacPorts, the
FC_ENVcan be set togfortran-6-macports. -
If you are using Homebrew, then use the following entries in Part 0 of Makefile:
Note: change x.x.x with the exact version number in both the INCLUDE and LIBRARIES variables.
This can be done by using ls /opt/homebrew/Cellar/netcdf-fortran/ and then using tab button to find the current version installed on your machine.
Do the same for lapack. Currently, the most up-to-date netcdf-fortran version is 4.6.1 and lapack is 3.12.0.
FC = gfortran
FC_EXE = gfortran
INCLUDES = -I/opt/homebrew/Cellar/netcdf-fortran/x.x.x/include -I/opt/homebrew/Cellar/lapack/x.x.x/include
LIBRARIES = -L/opt/homebrew/Cellar/netcdf-fortran/x.x.x/lib -lnetcdff -L/opt/homebrew/Cellar/lapack/x.x.x/lib -lblas -llapack