Raspberry Pi Planet Simulator Cluster
We've just constructed a small cluster of Raspberry Pi single board computers and set it to work simulating the climate of Planet Earth. For further details on the background to this project please see the accompanying blog article.
To do so we referred to Prof. Simon Cox's instructions on how to make a (rather larger!) "Raspberry Pi Supercomputer". One significant difference is that we found we didn't need to build the Message Passing Interface for the Pi, because it's now available off the shelf from Raspbian. Prof. Cox suggests using mpich2, so we tried that first. However the version we installed from the Rasbian repository caused the Planet Simulator (PlaSim for short) to complain about overlapping input and output buffers, so we installed OpenMPI instead. The Planet Simulator is written mostly in Fortran, so we needed to put the GNU Fortran compiler on our master Pi too, but once again we didn't need to build it ourselves. That said, here are our installation notes using a Windows laptop.
We used one 512 Mb Pi running X as our "master", plus two 256 Mb headless "slaves". Assuming the following IP addresses:
- Master – 192.168.2.100
- Slave 1 – 192.168.2.101
- Slave 2 – 192.168.2.102
1. Download the latest Rasbian image from the Raspberry Pi downloads page
2. Install it on an 8 Gb SD card using v0.7 of Win32DiskImager
3. On first use ensure the secure shell is enabled and expand the filesystem to use all the SD card. At this stage ensure the X server is DISABLED. Alternatively this can be done subsequently using:
- sudo raspi-config
4. Login as user pi, then make sure all the basics are up to date:
- sudo apt-get update
- sudo apt-get upgrade
5. Install OpenMPI
- sudo apt-get install openmpi-bin openmpi-dev
6. Shutdown, then turn off the power and remove the SD card
- sudo poweroff
7. Using win32diskimager read the SD card, then write an additional 2 SD cards for the slaves.
8. Put the SD cards in the three Pis and then apply power. On the master Pi only then…
9. Install the X11 development support, plus some standard X fonts for later use:
- sudo apt-get install libx11-dev
- sudo apt-get install xfonts-base
10. Enable the X server using:
- sudo raspi-config
11. After rebooting, start LXTerminal and create a public private key-pair. For additional security specify a passphrase. For ease of use later don't!
- ssh-keygen -t rsa
- cat ~/.ssh/id_rsa.pub | ssh email@example.com "mkdir .ssh;cat >> .ssh/authorized_keys"
- cat ~/.ssh/id_rsa.pub | ssh firstname.lastname@example.org "mkdir .ssh;cat >> .ssh/authorized_keys"
12. Install GNU Fortran and tcsh:
- sudo apt-get install gfortran
- sudo apt-get install tcsh
13. Use Midori to download the Planet Simulator from GitHub
14. Unpack the PlaSim source. In our case we had version 16.022, so:
- tar -zxvf most16.022.tgz
- cd most16.022
15. The Planet Simulator needs a little tweak to use a cluster. Skip to step 17 if you only want to experiment on a single Raspberry Pi. Download our most16.diff, then:
- patch -o most.new most.c most16.diff
- mv most.c most.old
- cp most.new most.c
16. Create a suitable "machinefile" for your cluster:
- leafpad plasim/dat/machinefile &
which should contain something along the lines of:
17. Configure everything for the Raspberry Pi environment:
18. Run the Model Starter and design your first climate experiment. Finish by using the "Save & Exit" option:
19. Only if you are using a cluster:
- scp plasim/run/*.x email@example.com:~
- scp plasim/run/*.x firstname.lastname@example.org:~
20. At long last you should be able to simulate the climate of Planet Earth!
- cd plasim/run
21. Experiment at your leisure! Try the following, then go back to step 18:
- touch Expert