CLASS model fork: headless CLI + Python bindings for the Chemistry Land-surface Atmosphere Soil Slab model https://classmodel.github.io/
  • C++ 93%
  • Python 4.8%
  • Nix 0.6%
  • C 0.6%
  • Just 0.4%
  • Other 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Niccolò Zanotti f6e12fbaf5
Fix Qt platform plugin discovery for the GUI in the nix shell
Qt5 in nixpkgs keeps the platform plugins (libqcocoa.dylib) in the bin
output, and nothing pointed Qt at them.  The dev shell now exports
QT_PLUGIN_PATH and QT_QPA_PLATFORM_PLUGIN_PATH, and just gui-run starts the
app binary directly instead of using open, so the process inherits the shell
environment and finds the cocoa plugin (open goes through launchd, which does
not inherit it).
2026-09-27 19:55:29 +02:00
cli Add full commented configuration template 2026-09-27 18:43:10 +02:00
python Add LaTeX publication plotting preset to classmodel.plot 2026-09-27 18:58:55 +02:00
.gitignore Build class-cli as an installable package and ignore nix results 2026-09-27 19:52:45 +02:00
CHANGES.md Fix Qt platform plugin discovery for the GUI in the nix shell 2026-09-27 19:55:29 +02:00
CMakeLists.txt Build class-cli as an installable package and ignore nix results 2026-09-27 19:52:45 +02:00
COPYING Added GPL licence 2013-11-28 12:32:29 +01:00
defaultinput.cpp Extract shared model defaults from the GUI into Qt-free defaults.{h,cpp} 2026-09-27 18:30:08 +02:00
defaults.cpp Initialize r09 (OH + ISO) reaction type 2026-09-27 18:30:17 +02:00
defaults.h Extract shared model defaults from the GUI into Qt-free defaults.{h,cpp} 2026-09-27 18:30:08 +02:00
flake.lock Add Nix flake and just recipes for the C++/Python workflow 2026-09-27 19:53:32 +02:00
flake.nix Fix Qt platform plugin discovery for the GUI in the nix shell 2026-09-27 19:55:29 +02:00
justfile Fix Qt platform plugin discovery for the GUI in the nix shell 2026-09-27 19:55:29 +02:00
landsoil.cpp Extract shared model defaults from the GUI into Qt-free defaults.{h,cpp} 2026-09-27 18:30:08 +02:00
landsoil.h Revert "Added the non-linear water stress response for A-Gs to the model" 2016-11-02 13:53:38 +01:00
main.cpp For some reason, pre-processing should be done after the other includes 2013-11-28 17:05:17 +01:00
mainwindow.cpp Revert "Added the non-linear water stress response for A-Gs to the model" 2016-11-02 13:53:38 +01:00
mainwindow.h Added additional soil types 2014-04-08 18:46:03 +02:00
mainwindow.ui Revert "Added the non-linear water stress response for A-Gs to the model" 2016-11-02 13:53:38 +01:00
mlmodel_main.pro Extract shared model defaults from the GUI into Qt-free defaults.{h,cpp} 2026-09-27 18:30:08 +02:00
model.cpp Fix out-of-bounds profile timestep read and output error handling in run2file 2026-09-27 18:30:21 +02:00
model.h Revert "Added the non-linear water stress response for A-Gs to the model" 2016-11-02 13:53:38 +01:00
modelchem.cpp Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
modelchem.h Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
modelchemtypes.h Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
modelinput.cpp Add include guard and initialize chemistry fields in modelinput 2026-09-27 18:30:25 +02:00
modelinput.h Add include guard and initialize chemistry fields in modelinput 2026-09-27 18:30:25 +02:00
modeloutput.cpp Added "1"s to indicate top soil layer like in book 2014-04-10 17:47:57 +02:00
modeloutput.h Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
modelrun.cpp Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
modelrun.h Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
plotwindow.cpp Double potential solution for not automatically closing docks on OSX 2013-12-02 14:12:49 +01:00
plotwindow.h Some more cleanup of deprecated stuff 2013-11-29 12:29:20 +01:00
plotwindow.ui fine tuning of interface for OS X; axis range labels were slightly too small 2014-07-08 09:30:54 +02:00
README.md Fix Qt platform plugin discovery for the GUI in the nix shell 2026-09-27 19:55:29 +02:00
subplot.cpp Removed axis settings and model runs from view menu, set MacOS switch by 2013-12-02 18:42:35 +01:00
subplot.h For some reason, pre-processing should be done after the other includes 2013-11-28 17:05:17 +01:00
subplot.ui Changed directory structure 2010-05-31 11:53:12 +02:00
switches.cpp Added licence information to all .cpp and .h files 2013-11-28 12:30:47 +01:00
todolist.txt Added closing dialog 2011-07-11 15:23:12 +02:00

CLASS model

CLASS: Chemistry Land-surface Atmosphere Soil Slab model

This repository is a fork. It is based on classmodel/modelgui and adds a headless command line interface and a Python interface on top of the original graphical application. See CHANGES.md for the detailed list of changes and cli/README.md for the command line documentation.

Book

CLASS is part of a book (soon to be) published at Cambridge University Press: "Atmospheric boundary layer: Integrating chemistry and land interactions" by Jordi Vila-Guerau de Arellano, Chiel C. van Heerwaarden, Bart J.H. van Stratum and Kees van den Dries.

Obtaining the CLASS software

CLASS can be downloaded as precompiled binaries for Windows and OS X.

For information on compiling CLASS on Linux / OS X, see the notes below.

Note for OS X users

On recent versions of OS X, opening CLASS for the first time will result in a warning: "CLASS can’t be opened because it is from an unidentified developer". To circumvent this problem, right click the application and select "open" and again "open" in the dialog instead of double clicking the application. This step is only needed once.

Alternatively, remove the quarantine attribute from the command line:

xattr -dr com.apple.quarantine /path/to/CLASS.app

For the locally built app this happens automatically with just gui-run (or manually with just macos-unquarantine).

Bugs

Bugs can be reported at https://github.com/classmodel/modelgui/issues?state=open

In order to reproduce and fix the bug, we will most likely need:

  • Information on the operating system you are using (Windows or OS X version, Linux distribution)
  • The git-hash, shown in the 'about CLASS' window (e.g. git-hash: v1.0_beta2-6-g49b7603)
  • A description of the exact steps needed to reproduce the problem.

Compiling CLASS

The source code of CLASS can be downloaded manually from GitHub or (preferably) using GIT:

git clone https://github.com/classmodel/modelgui.git

Both methods will always provide you the most recent (stable) version of CLASS. There are two ways of compiling CLASS: using QtCreator or using the command line.

QtCreator

After installing QtCreator, open the CLASS project file (mlmodel_main.pro) in QtCreator and select "build" > "run". This should compile and start CLASS.

Command line

Without QtCreator installed, some additional packages are needed, e.g.

  • Ubuntu (20.04 LTS) or Mint (21): g++ qt5-qmake qtbase5-dev

After installing the required packages, calling:

qmake
make

from the source directory of CLASS should compile the model.

In order to build the code on OS X without creating an Xcode project, call:

qmake -spec macx-g++
make

Headless command line interface

The physics core (model.cpp, modelinput.cpp, modeloutput.cpp, modelchem.cpp) has no Qt dependencies. A headless class-cli and a Python package are provided for running experiments from a TOML configuration:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

./build/class-cli --config python/examples/standard_case.toml --out runs --name standard
./build/class-cli --help
./build/class-cli --dump-config -    # all settings, defaults and names

Full option and configuration reference: cli/README.md. A commented boilerplate with all settings is cli/config.example.toml. Python interface: python/README.md.

Nix development shell

flake.nix provides every dependency (cmake, ninja, uv, just, Python and Qt5 for the GUI):

nix develop                  # interactive shell
nix develop --command just test
nix build                    # builds ./result/bin/class-cli (runs ctest)

A justfile with the common tasks is included:

just --list                  # all recipes
just build                   # configure + build class-cli
just test                    # ctest + python tests
just run case.toml mycase    # run the model
just gui                     # build the Qt GUI with qmake
just gui-run                 # run the Qt GUI (clears macOS quarantine)
just plot                    # Python example figure

The dev shell exports QT_PLUGIN_PATH (Qt5 keeps its plugins in the bin output), and just gui-run starts the binary directly instead of using open, so the app inherits that environment and finds the cocoa platform plugin.