19-23 August 2013
Europe/Copenhagen timezone

Numerical Codes


The latest copy of the PLUTO source code can be obtained at 

Download the source code (registration required) and unzip and untar it using 
gunzip  pluto-xx.tar.gz
tar xvf pluto-4.0.tar

This will create a directory called PLUTO.

Open the file userguide.pdf, located in the PLUTO/Doc subdirectory.
Python is required to run the PLUTO setup.
For visualisation, gnuplot, IDL, visit, paraview and/or python can be used.
The quickstart chapter will get you started with PLUTO.
Try running a simulation and visualising your results!

To plot you output with VisIt, you will need to modify the pluto.ini file.
Change the line
vtk       -1.0  -1   single_file
to read something like
vtk       1e-3  -1   single_file
which will give you an output in vtk format (readable by VisIt, Paraview and many other tools, every 0.001 time units).


If you have any questions please email us at nbia-phd-school-2013@nbi.dk 
Use the subject line PLUTO: and some keywords describing your problem. We will do our best to help.


The Pencil Code googlecode source code repository page is located at https://code.google.com/p/pencil-code/. The manual can be downloaded at
http://pencil-code.nordita.org/doc/manual.pdf Beware that the manual is a living document, part of a page may be up to date and part of the same page could be out of date. In the end, you must use the source, and in practice it really helps to have a active developer to talk to. The manual often describes multiple ways to do tasks with the code and amongst the user community different people tend to do things differently.

You will need Subversion, a Fortran compiler and MPI library configured for this compiler, Latex, and Perl. If you just want to check out the latest version of the code use:

svn checkout http://pencil-code.googlecode.com/svn/trunk/ pencil-code

It is useful to be aware of the existence of two systems for managing the setup, build, and run of a problem with Pencil Code. The original system is based on a set of csh scripts. A newer system is based on a more set of Perl scripts. Though the idea of both is to automate complicated procedures as much as possible, in practice both require some level of source code modification of the scripts sooner or later. However,  the pc_ system of Perl scripts works well, so these instructions will use these. The following instructions should be supplemented with the manual, but be aware we will follow the pc_ way of doing things.

Pencil Code needs an environment variable set in your shell to point to the location of the SVN repository you have checked out. It is also useful to add the directory with the pc_ scripts to your $PATH. See section 3.1.1 of the manual. After following those steps, you should have an environment variable PENCIL_HOME defined. Do not follow further instructions in the manual beyond section 3.1.1 at this time. To set up a test and run the code, make a separate directory away from the source code to run in. Maybe something like:

mkdir ~/runs
cd ~/runs

Now, we will set up a copy of a sample problem in this directory

pc_newrun $PENCIL_HOME/samples/conv-slab penciltest/

This made a new run setup, using the sample as a template. You can also manually configure a directory for a run by adding some skeleton files and running pc_setupsrc. See the manual.

Now comes the fun part! We need to configure the pc_ scripts to use the right compilers and MPI runtime for your machine. The manual is pretty good for this part. Follow sections 5.1 through 5.1.2. Note that in the "quick Start" section at the top of section 5.1, there is a typo - $PENCIL_HOME/hosts/ should be $PENCIL_HOME/config/hosts/. If things do not work easily, and you need to create a custom configuration for your machine, the option of setting the host manually by creating a file $PENCIL_HOME/host-ID is particularly useful.

To build the code, use the pc_build command. To "make clean" do

pc_build clean

To run the code, first do

pc_run start

This command initializes the run. To actually run the code do


You can Control-C or otherwise kill the processes, and re-issue the pc_run command to continue your run.

Pencil code outputs unformatted Fortran binary data to the data/ subdirectory. If you want to use the Python interfaces to read snapshot and video output files, interactively in ipython you will need to add the python search path. A handy code snippet for doing this is:

import sys
import os
pencil_home = os.getenv('PENCIL_HOME')
if (pencil_home == None): exit()
import pencil as pc

Read the source to figure out the Python interfaces, key routines are pc.read_grid for grid information, pc.read_var for reading snapshot files, and pc.read_slices for reading video slices.

If you have any questions please email us at nbia-phd-school-2013@nbi.dk 
Use the subject line Pencil: and some keywords describing your problem. We will do our best to help.



AMRVAC homepage:

also see: http://homes.esat.kuleuven.be/~keppens/Contents.html

AMRVAC git repository:


The most up-to-date guide to the basic install and running is the "Getting Started Guide" at:

but the manual provides very useful more detailed documentation at  http://homes.esat.kuleuven.be/~keppens/Contents.html

To run AMRVAC, you will need Perl installed. The AMRVAC scripts assume that Perl will be found in


To clone the repository, you will need to install the package for you system which provides Git. These instructions parallel the Getting Started Guide.

To clone the git repository:

git clone git://gitorious.org/amrvac/amrvac.git amrvac

You will need to set a environment variable AMRVAC_DIR, similar to the ones needed for PLUTO and Pencil Code, to point to where your AMRVAC source code is. The AMRVAC getting started guide explains this, and the procedure is the same as for the other codes.

Follow the Getting Started Guide's instructions on "Running a test problem". The guide assume that the machine-dependent commands for compiling and linking Fortran 90 MPI code on your machine. This guide assumes you have a fairly standard configuration - that Frontran 90 code using MPI can be compiled and linked with a command mpif90

If the code fails to build because you do not use the mpif90 wrapper on your system, the set of correct build commands can be specified by creating a new file in AMRVAC_DIR/arch. The relevant variables which are used in the build process are:

F90 Fortran 90 compiler - if you can specify the full command for am mpif90 wrapper here do so.
FFLAGS Arguments needed make the F90 command compile source to object files - usually just -c
F90FLAGS Optimization, include flags needed to compile code using MPI with the F90 compiler
LINK Command and arguments needed to link the object files produced by the F90 compiler, including the MPI library.

The Getting Started Guide instructs on how to run a simple test problem.

If you have any questions please email us at nbia-phd-school-2013@nbi.dk 
Use the subject line AMRVAC: and some keywords describing your problem. We will do our best to help.

Visualization - VisIt

VisIt is a mature package which makes it relatively quick to see your data.

The homepage is at:

You can download a precompiled package for most platforms here:

The documentation is quite polished. See manuals a quick start guides here:

For the codes PLUTO, AMRVAC, and Pencil the strategy used is to produce VTK format output which can be read into VisIt.

For how to output VTK format data from PLUTO, refer to the section at the top of this page.

In AMRVAC, you can output .vtu files by using the autoconvert feature. See: 
The setting goes in the &filelist namelist in the parameter file, and is given with the lines:
The testrho_vac22 in the Getting Started Guide problem already has this setting enabled, so it will output a set of files named data*.vtu.

In Pencil, you will need to use the pc2vtk procedure provided by wither the IDL or Python tools in the Pencil package to convert snapshot files to VTK data files for use with VisIt. This is tractable if you are exoerienced with either IDL or Python, but not so easy if you have not.  We will provide a script which does what is needed for the school exercises.
Your browser is out of date!

Update your browser to view this website correctly. Update my browser now