On February 16, 2026, this repository underwent a major restructuring and is not backward-compatible with earlier clones.
If you cloned the repository before February 16, 2026, clone it again. A
simple git pull is not enough for that transition.
This repository contains source code and documentation for examples and exercises used in the PACS course (Programmazione Avanzata per il Calcolo Scientifico, Advanced Programming for Scientific Computing) and in the AMSC course (Advanced Methods for Scientific Computing) at Politecnico di Milano.
For the AMSC course, only a subset of the material is typically used in lectures and labs, but interested students are encouraged to explore the full collection.
The material for the AMSC course is in the AMSC branch, not in master.
The master branch is the main branch for the APSC/PACS course.
You may of course create your own branches for experiments.
This repository uses Git submodules, so it should be cloned with:
git clone --recurse-submodules https://github.com/HPC-Courses/AMSC-CodeExamples.gitor, if you use SSH,
git clone --recurse-submodules git@github.com:HPC-Courses/AMSC-CodeExamples.gitIn the latter case, your SSH keys must already be registered with GitHub.
To keep your local repository up to date, use:
git pull --recurse-submodulesor, from the root of this repository,
./update.shYou need a reasonably recent C++ compiler with solid C++20 support, and some
examples also require C++23 features. In practice, the current configuration in
Examples/Makefile.user defaults to c++23.
As a rule of thumb, use at least:
gcc13 or newer, orclang18 or newer.
To check your compiler version, run for example:
g++ -vCompiler support tables are available here.
The course environment may use the mk module system provided in
this repository. This is unrelated to Git
submodules.
Using that module system is convenient, but not strictly required if you have a recent Linux installation and install the required packages yourself.
The script load_modules.sh contains one example of a module setup used in the
course environment.
You may want to use an IDE. Common choices are:
CLion and Visual Studio Code can be integrated with AI-assisted coding tools.
At the top level, the most relevant directories and scripts are:
Examples/: the main collection of examples and their build instructions.Extras/: third-party or auxiliary material used by some examples.shared_files/: additional shared material.load_modules.sh: helper script for environments that use themkmodule system.install-git-submodules.sh: initializes and updates submodules if you did not clone with--recurse-submodules.change_submodules_url_https.sh: switches submodule URLs to HTTPS.change_submodules_url_ssh.sh: switches submodule URLs back to SSH.update.sh: pulls the repository and its submodules, then runs theExamples/setup.shhelper.
If you use the mk module system, you may load the main modules with:
source load_modules.shor equivalently:
. ./load_modules.shThis loads the main toolchain and several libraries used by the examples.
hdf5 is left commented out because it is only needed by a small subset of the
code.
If you cloned the repository without --recurse-submodules, you can initialize
the submodules afterwards with:
./install-git-submodules.shThe file submodule_commands.txt also contains a few useful reminders for
working with submodules.
- Go to
Extras/and read its localREADME.md. - Go to
Examples/and follow the instructions in its localREADME.md.
If you also want the repository used for the course laboratories, see:
The examples are intentionally organized as relatively independent pieces of software that still share some common infrastructure. In this setting, plain Makefiles remain simple and practical.
Migrating the repository to CMake is possible, but it is not currently
planned. However, there is an experimental branch, called cmake that contains a
previous version of these examples, ported to cmake. Have a try if you wish.
This repository is a collection of teaching examples. Some parts are small and illustrative; others are more complete and may serve as a starting point for further work.
You are free to use the code, but please give credit where appropriate and keep in mind that no warranty is provided regarding correctness, suitability, or absence of bugs.
Luca Formaggia (lformaggia on GitHub)