Lecture summary: Programming Techniques for Scientific Simulations

During the autumn semester of 2017 I took the course “Programming Techniques for Scientific Simulations” as part of my BSc course in Computational Science and engineering at ETH Zürich. This is a summary of the course’s contents I wrote and used during the actual exam. Some things are missing, as it was an open-book exam

Setting up passwordless SSH access on Linux

SSH stands for Secure Shell Host. It effectively allows you to access the terminal (shell) on a remote machine – securely. There are two ways to validate your identity when attempting to access a server via SSH: password, or SSH key pair. Password authentication is the default method: you run a command similar to ssh

Accelerating build processes with multithreading

Building (compiling) large projects can take a long time. Build systems like Make and SCons do a really good job of reusing resources that don’t need recompiling because we didn’t change anything, but compiling a large project for the first time can still take a while. One solution to this issue, especially with multicore and

gnuplot revisited

Here is a more sophisticated example of using gnuplot: set terminal png size 1920, 1080 enhanced font ‘Verdana,15’ # Different log scales set logscale x 2 set logscale y 10 # %L is the exponent of the current log scale set format y “%g” set format x “2e%L” # Move the legend to the top

Cmake basics

We already know make, a powerful tool to automate all kinds of building sequences. But if you are using it to compile large C++ projects, you will quickly find that it’s tedious to maintain, and that you’re often repeating the same commands over and over again. This, of course, opens up the door to mistakes

A simple gnuplot example

gnuplot is a very easy-to-use tool allowing us to quickly plot data we generated with, for instance, a C++ program. Here is a sample gnuplot script – see a brief explanation of the commands below: set terminal png size 900,675 enhanced font ‘Verdana,9’; set output ‘error_plot.png’; set logscale xy; show logscale; set format xy “%g”;

Compiling C++ libraries

If you use C++, you’ve almost certainly already used a library of some kind. Even the classic “Hello world” program requires one: #include <iostream> // include the iostream library int main() { std::cout << “Hello world!”; return 0; } But what if we wanted to write our own? This has several advantages. First off, if