compiling OpenMPI & HDF5 with Fortran support

Fortran…why on Earth would I want something with Fortran support? Apparently it’s fast; and when something is fast people still use it. I’m currently looking into the radiative transfer code Hyperion and it requires both MPI and HDF5 to be compiled with fortran support. It’s fairly simple to do, but can be a pain in the neck to find the syntax if you don’t know exactly where to look. Let’s start with OpenMPI which is currently on version 1.6.5.
?> ./configure --prefix=/Users/bob/local/openmpi-1.6.5 F77=gfortran FC=gfortran
?> make
?> make install
For HDF5 the syntax is similar:
?> ./configure CC=mpicc --enable-fortran --enable-hl --prefix=/Users/bob/local/hdf5-1.8.11 FC=gfortran
?> make
?> make install
And that should do it. To get hyperion to see these you just add the /bin dirs to your $PATH and the lib dirs to your $LD_LIBRARY_PATH. To check if the MPI-fortran bindings worked you can type mpif90 and mpi77 at the terminal and gfortran should error out saying that there are no input files.
Lastly once you recompile OpenMPI you may have to reconfigure/recompile/reinstall mpi4py if you’re using it. This is also super simple, but on OSX it can be troublesome. Before the compilation you have to redirect it to the proper SDK directory; the install should look like so:
?> export SDKROOT=/
?> python setup.py build
?> python setup.py install
I usually end up with an error at the end, but it installs and seems to run without any problems.

check executable library dependencies

When compiling a C code it often requires certain libraries be present. To check which libraries the executable depends on there is a handy linux and OSX command that can show you where the executable thinks these libraries reside:
 ## LINUX ##
 ldd executable\_name

## OSX ##
 otool -L executable\_name
very handy when working on remote machines where things might be a little nutty.

backing up my wordpress SQL database

Along the lines of using this as a sort of lab journal for my experiments and thoughts, I think it is important to keep these things backed up. Crontab again comes to the rescue by executing a small snippet of code that will backup the database in case something nutty happens. The script for such an action looks something like so:
#!/bin/bash
/usr/bin/mysqldump -u root -pPASSWORD wordpress | gzip > /home/bob/RAID5/Backups/MYSQL/wordpress_`date +%m-%d-%Y`.sql.gz
I set this to run in the crontab at 5am daily. This will create a new file each time, but I may have it perform this task once a week and have the daily backup overwrite the previous dump.

bash math!

In doing some Kelvin-Helmholtz comparisons I have been trying to cook up a script that can stitch two movies together with ffmpeg. In order to determine how many frames I need I must do a simple subtraction in bash, but how?! Easy apparently…you just:

#!/bin/bash
BEG=10
END=400
NUM=$((END-BEG))
echo $NUM

and it will return the value 390. So how about that ffmpeg script?!

#!/bin/bash

FPS=12

BEG=10
END=50

DIR1=.
DIR2=.

PREFIX1=splash\_%04d.png
PREFIX2=splash\_%04d.png

MOV1=1.mov
MOV2=2.mov
FINAL=SIDEBYSIDE.mov

NUM=$((END-BEG))

if [ $END -gt 0 ]
  then
  PARAM="-vframes $NUM"
  else
  PARAM=""
fi

ffmpeg -start\_number $BEG -r $FPS -i $DIR1/$PREFIX1 $PARAM -vcodec qtrle $MOV1
ffmpeg -start\_number $BEG -r $FPS -i $DIR2/$PREFIX2 $PARAM -vcodec qtrle $MOV2

## SIDE BY SIDE ##
ffmpeg -i $MOV2 -vf "movie=$MOV1 [in1]; [in]pad=iw\*2:ih:iw:0[in0]; [in0][in1] overlay=0:0 [out]" -vcodec qtrle $FINAL
Here’s the end result:

auto-login followed by auto-lock

I’m heading away for a while and will need continued access to my server. Usually that means via ssh, but occasionally I have to VNC into the machine. The problem is - if the server goes down for any reason, when it comes back up the VNC server does not start until I login. So is there a way to set automatic login and lock the screen at the same time? Yes! This is linux, of course there is! Simply create a new file

/home/USERNAME/.config/autostart/screen_lock.desktop

and add the contents

[Desktop Entry] Type=Application Name=Lock Screen Exec=gnome-screensaver-command -l

and that was that, works like a charm. Courtesy of AskUbuntu.


Aquarium webcam

I’m headed out of town for a bit and I’d like to keep an eye on my tank. Luckily linux has software that can do that called motion (obtained via apt-get install motion). You can do all sorts of things with it like time lapse photography, stream at whatever fps you like, auto adjust brightness, etc etc. Had to remove the filter from my ps3eye so a little too much IR is showing through, but it should be sufficient to make sure everything isn’t dying, here’s a live picture (refresh to get a new one):

Aquarium!

[iframe src="http://192.168.1.18:8083/?action=stream"]

edit: something to check out in the future for a more permanent solution - zoneminder


the beauty of crontab

I’ve never really understood the linux startup process (and still don’t), so it’s always been difficult to figure out how start things on every reboot.  Luckily, crontab is a beautiful thing that allows one to do just this and more!  Say I have a script that I’d like to run as admin on every reboot.  All I have to do is:

> sudo crontab -e

then add the line:

@reboot /home/bob/local/scripts/something.sh

and on upon every reboot the script will run.  What’s even cooler is that there are separate crontabs for each user.  So instead of using sudo in the above command if you simply use ‘crontab -e’ you will edit the current user’s crontab. For instance I have two entries in my server’s current crontab that periodically deletes a huge log file, and starts my ipython notebook server:

# m h  dom mon dow   command
10 06 * * * /home/bob/local/scripts/delxsessionerrs.sh
@reboot /home/bob/local/scripts/ipynotebook.sh

The first command tells the system to run delxsessionerrs.sh at 6:10am every day, the second line launches ipynotebook.sh on every reboot. Now I imagine one could insert the commands directly into the crontab, but I prefer the above script method.