Scientific Programming
by Bernd Freytag & Nikolai Piskunov
During the last years, one subject not covered by the PhD course curriculum
popped up many times in the discussion with students: programming ... and I do
not mean computer sciences or numerical methods. I mean basic skills in how to
implement a given task (physical model, data analysis, text file sorting,
whatever) on a computer. This will not be a course in Python, Java or C++
although we would need to use some language(s) for the homework.
The goal of the course is
to understand the interaction between you program and your computer and to
answer the question why apparently identical algorithms may show different
performance and even different results
With this introduction the course will cover the following topics:
- Computer and software interaction:
- hardware, memory, bus, registers
- pipelines, threads
- branching, context switching
- memory allocation
- loops
- exceptions
- input/output
- Programming language components:
- constants, variables, arrays, structures, derived data types
- flow control (redirections, conditions, loops)
- subroutines (parameters, global variables, static versus dynamic,
- pointers versus values)
- memory allocation
- I/O, files from a program perspective, creation and opening of files
- formatted, unformatted, sequential, direct, file positioning
- libraries, using and creating dynamic or static library
- combining programming languages
- Programming
- compilers, steps and switches
- general layout (designing a new code)
- structuring
- Debugging ("every code has at least one bug")
- debugging strategy
- using code structure
- "poor-men's" debugging
- using special tools (tracing, exceptions, array boundaries, memory leaks)
- Optimization
- array size and access
- subroutine calls
- loops
- threads
- optimization versus structure and portability
I am planning to use practical examples in various programming languages that
I am familiar with (FORTRAN 77 and 90, IDL, bash) and the students will get lots
of home work in a form of small programs aimed at understanding computer
behavior, and train various programming muscles.
The course will be 10 hp. In order to pass you will need to turn in all
homework some of which you will present in the class.
We will complete the course itself in November/December with the following schedule:
- Part I: November 5-16 (4 lectures and lots of home work)
- Part II: November 23-26 (student presentation of the home work)
- Part III: November 30 - December 17 (concluding 4 lectures with more but smaller home work)
- Part IV: January 2016 (student presentation of the home work)
The schedule looks like this:
- Lecture 1
(Thu 05/11 10:15-12:00, Oseenska rummet Å73121)
Computer hardware characteristics affecting user codes
- Lecture 2
(Mon 09/11 10:15-12:00, Oseenska rummet Å73121)
Elements of programming languages
- Lecture 3
(Thu 12/11 10:15-12:00, Oseenska rummet Å73121)
Compiling and Linking
Home Work Part I.
Your task is
to solve the programming problems given in the exercises
and to write a report including the programs,
the requested output,
and the answers to the questions in some of the exercises
(deadline: before the presentation on 26/11).
Based on the reports, the results will also be presented in the class
(10 minutes per person).
- Lecture 4
(Mon 16/11 10:15-12:00, Oseenska rummet Å73121)
Designing a new code
- Lecture 5
(Mon 23/11 10:15-12:00, Oseenska rummet Å73121)
Style and Structure
- Presentation I
(Thu 26/11 10:15-12:00, Oseenska rummet Å73121)
Presentations of the Home Work Part I
- Lecture 6
(Mon 30/11 10:15-12:00, Oseenska rummet Å73121)
Optimization
- Lecture 7
(Thu 03/12 10:15-12:00 Oseenska rummet Å73121)
Going multi-lingual
Home Work Part II.
The results will be presented in the class (10 minutes per person).
Here are your options:
- If you are starting to work on a new code,
do the analysis described in lecture 4 and present argumentation.
- If you have a code, which is producing dubious results,
try using the debugging techniques described in the course and present the results.
- If you have a working code that may benefit from optimization,
profile it and look for possible optimization options.
- If you have a working code that you would want to parallelize, try it.
- Lecture 8
(Mon 14/12 10:15-12:00 Oseenska rummet Å73121)
Parallel computing
- Presentation IIa
(Mo 18/01/2016 10:15-12:00, meeting room near kitchen in astro corridor, House 6, Floor 3)
Presentations of the Home Work Part II - your own project &
parallel computing
- Presentation IIb
(We 27/01/2016 14:30-15:30, meeting room near kitchen in astro corridor, House 6, Floor 3)
Presentations of the Home Work Part II - your own project &
parallel computing
Good luck!
Bernd Freytag &
Prof. Nikolai Piskunov