Fork Me on GitHub

Fusion by Peter

my little presence on the web

Graphing Fortran Projects

Currently, I am refactoring the code that I work on and I wanted to see how the different modules depend on each other. Doxygen generates graphs of how individual functions and routines call each other, which is pretty nifty, but it doesn’t seem to do it for the modules. Looking into how doxygen generates these graphs, I found out it uses the graphviz package, in particular dot.

Dot is a very simple language used to describe graphs. Wikipedia has some nice examples.

I wrote a short python function to crudely extract the module dependencies from my code and put them into a dot graph:

Writing the output of this function to a file and running dot on it produces lovely images like this:

messy graph

…I’m not sure if my refactoring is making it better or worse.

Posted on

Finding variables across a project

Quite often, I want to find a variable across the whole project I’m working on. I have progressed through a few different methods of doing so. When I was new to emacs and ran it in a terminal, I would flick to another tab in my terminal and just run grep.

Then I learnt about grep -n, which also displays the line numbers. I could then flick back to my emacs session and M-g M-g to go to that line. This is a bit of a pain, as I had to keep switching between tabs to find the next search result.

This year, I started using emacs in its gui, as I was mostly working locally, rather than on remote machines. Now I had to switch between emacs and my terminal, which was getting annoying. I discovered the wonders of M-x eshell - a terminal inside emacs! Using grep from eshell opens a new buffer with the grep results. From this buffer, you can use n and p to move between search results, which automatically displays the relevant section in a different buffer.

Then this week I came across M-x occur (shortcut: M-s o). This searches the current buffer for a regexp and displays the results in a new buffer. You can search across multiple buffers with M-x multi-occur, however you have to specify each buffer manually. A better command is M-x multi-occur-in-matching-buffers, which searches buffers that match a regexp.

So here is how I’ve started searching for variables across projects:

  1. First, I open all the project files (C-x C-f *.[fF]90, for example)
  2. Run M-x multi-occur-in-matching-buffers with the first argument as an elisp regexp (e.g. .*\.[fF]90)
  3. Switch to the *Occur* buffer and run M-x next-error-follow-minor-mode (this can actually be toggled with C-c C-f, same as in compilation-mode)
  4. Use C-n and C-p to move between search results, displaying the result in a different window

Posted on

Building a blog

I have made various short-lived websites over the years, using sundry template sites - geocities and their ilk. This one was built using a bunch of free tools and templates too, but it’s the only one where I have actually laid down money for a domain name. In getting this one off the ground, I have learnt how little I actually knew about hosting a site. Fusionplasma.co.uk is hosted on GitHub Pages, the domain name came from Vidahost, and the backend is done in Jekyll (which in turn is written in Ruby).

Messing about with projects on GitHub, I discovered that projects can have their own website, hosted on GitHub, very simply. In fact, users can have their own pages too. I had been thinking for some time about having some little space on the web to put little snippets of code, and so on. At the same time, I had also been thinking about getting a slightly more professional personal email address. This seemed like the perfect spur to action, so I started a new project on GitHub with the name “ZedThree.GitHub.io” (ZedThree being my GitHub username). A project named like this becomes your user page, accessible from http://ZedThree.github.io

The next step was to get my own domain name. As all variations on my name were already taken, I decided to go with something related to my job - a researcher in fusion. There are two steps to actually using this domain name as the url for the GitHub user-page. This first is to put the domain name into a file named CNAME in the repo. This tells GitHub to serve your pages from that domain, instead of username.github.io. Next, you need to point your domain name to GitHub’s servers. This is done using a nameserver. Nameservers translate the natural-language domain name into a numeric IP address. Your registrar might provide a nameserver; if not, there are free ones available.

Well, it took me a while to actually finish writing this post. I guess I’ve not got into the habit yet.

Posted on

Finally!

I finally got round to converting the Github Pages Merlot theme into a Jekyll theme, and so I have finally commenced my blog! The idea behind this blog is for it to be a place where I can share useful bits of python, emacs, Fortran, etc. that I have picked up; and moreover, a place where I can dump all those useful bits so I can find them later! I also intend to write some posts about my work and the various half-finished github projects I’ve started (case in point: this Jekyll theme).

I’m going to attempt to force myself to update this site pretty often, which means just getting on and writing posts and publishing them, so I imagine the first few will be fairly scrappy.

First up, how I created this site…

Posted on