1. Introduction#

This document is intend as reference for anyone just getting into scientific computing and needing some help navigating command line interfaces and C++ guidance/training. You can expect to:

  • become familiar with POSIX system command line tools and tricks

  • Bash shell scripting

  • C++ basics and intermdiates

  • Project set-up, especially version controlling and git/GitHub

  • Use command line to interface with a compute cluster

The vast majority of these notes will be dedicated to familiarizing you the C++ programming language, is it is the standard for high preformance computing. To this end, there will be example projects which are intended to demonstrate how to setup more complicated projects. As a disclaimer, well ahead of time, I am not a fan of inheritance. The coverage of this topic will be minimal so that anyone that stumbles upon is familiar with some of its idioms like “Curiously Recurring Template Parameters”. Lastly, the presentation of topics here, reflects my personal opinion on what is important: C++ is a very big and general purpose language, allowing for lots of freedom of expression and emphasis.

1.1. Chapters and content#

As mentioned in the overview, the primary purpose of these notes are to teach you C++ programming. We will focus on modern C++, relying on language constructs from the 2011 standard and onwards, and a fairly decent review of the capabilities of the standard library (as we might need them) will be included. Has hinted at in the overview, these notes are by know means comprehensive enough to represent the full milieu of C++ language, just the most salient parts for computation and the parts I quite enjoy.

The content is split into four parts: the first is dedicated to familiarizing yoursefl with C++ jargon, syntax, and idioms. The second part will go over structure multi-shource projects; well organized code helps both the development process and project comprehension by others. We will also discuss documentation of code in this section. The third part is dedicated to giving some example projects and to discuss design considerations. Lastly, the fourth part digs into remote computing, bash scripting and slurm.

1.1.1. C++ lessons#

  1. What is a program

  2. Compilation and debugging/debuggers

  3. Variables, types, values and templates

  4. Functions, operators, lambdas (anonymous functions), function overloading, and variadic templates

  5. User-defined types (classes)

  6. Pointers, arrays, references, and smart-pointers

  7. Memory management and memory owndership models

  8. Digression: imperative programming vs object-oriented programming vs functional programming

  9. Move/copy construction/assignment

  10. Our best friend, std::optional, and error handling

  11. More on the standard template library (STL

What we will not cover is:

  1. Macros

  2. Inheritance

  3. Template metaprogamming or concepts

  4. Common data structures and algorithms (such as queues and sort), this is because these are provided by the standard template library

  5. Concurrency computation models

  6. Disributed computation models

Separate notes will be developed for these, beside macros, which I assume the reader can learn on their own. If they are already developed, then the hyperlink above will take you to corresponding notes.

1.1.2. Meat and bones of a project#

  1. Setting up a multi-source file project

  2. Building projects with shell scripts

  3. Building projects with Makefiles

  4. Building projects with CMake

  5. Other build systems available

1.1.3. Example numeical methods and projects#

Some of these programs are inspired by programs that I had to write for research. So the physics may be opaque, but the more important part is the program structure. Where necessary, I will try to ellucidate the physical settings.

  1. Root finding

  2. Numerical integration

  3. Linear algebra (matrix multiplication, vector addition, inner products, matrix reduction)

  4. Interpolation: linear, Delaunay, Lagrange and Hermite

  5. Coupled ordinary differential equation

  6. \(N\)-body simulations

  7. Integral equations

  8. Random number generators

1.1.4. Essentials of high preformance computing#

High preformance computing comes in many shapes: (multiple) graphics card programming, multiple CPU with mesaging passing interfaces, or massively parallel and independent tasks. What they have in common is that they are usually execute remotely, that is not on the computer sitting in front of you. The topics covered here are meant to familiarize yourself with remote computing, and some of the consideration you have to make when designing code for such extreme computing environments.

  1. Command line basics

  2. Connecting to remote servers

  3. Bash scripting

  4. Git and GitHub basics

  5. SLURM and other cluster-computing software