Learn Scientific Programming by Examples:
As far as my experience, learning a new programming/scripting language can be much faster by going through examples, particularly if you have already done programming in another language and are familiar with the concepts of programming, such as control structure, loops, data types and so on.
The following is a collection of code examples, some I wrote while I was learning a new language, some are developed as computational tools in my research, some of them are designed by my supervisor Matt Choptuik and used in his popular PHYS210 and PHYS410 computational physics courses in UBC. Lastly, there are few links that I came across on the web and found them to be good examples to learn the features of the programming language they are written in.
Most of the examples are focused on scientific computing. I will hopefully add more examples in C++, Python, Bash scripting and GPU Accelerators (OpenACC).
C Programming:
- Introductory Example Code in C
- Input/Output from/to Files in C
- Handling Arrays/Matrices (Pointers) in C
- Reading Parameters from Text File Using BBHUTIL
- Reading Input Interactively, Harvard's CS50 Simple I/O Library
- Matt's Vector C Library, Scientific Data Format (SDF) I/O Using LIBBBHUTIL
- My Implementation of Single Call SDF Read
- Example of Working with SDF, Simple Implementation of SDF Merger
Matlab:
- Simple Operations in Matlab
- Matt's example of Matlab programming: [1], [2], [3]
- Introductory Programming Structures in Matlab
- Reading 2D Data From SDF/Binary into Matlab
- Simple 1D Interpolation in Matlab
- Linear Multivariable Regression in Matlab
- Weighted Multivariable Regression Using Polynomials, Covariance and Correlation Functions
- Logistic Regression, Simple Classification in Matlab
Parallel Computing, MPI and PAMR:
- Introductory MPI and CPU Communication Code
- Simple 2D Wave Equation Parallel Code Using PAMR See documentation of PAMR [here]
- Example of Reduction/Distribution Between CPUs, Mixed Parallel/Serial Calculation in PAMR
- Collection Operator to a Single Grid Structure in MPI
- LLNL MPI examples: [1] , [2] , [3]
Maple:
- Essential Tools/Operations in Maple
- Introductory Programming in Maple
- Matt's Maple Programming Notes
- Advanced Maple Programming, FD Finite Differencing Toolkit
- Tutorials in Finite Difference Method Using FD Maple toolkit
- 1D wave equation with periodic boundary condition, the driver C code.
- 2D wave equation, parallel-ready, with fixed boundary condition, the driver C code.
- FD: Finite Difference Toolkit in Maple, User Manual
R Programming:
Perl Scripting:
FORTRAN:
HTML/CSS/Markdown: