How to keep code and output organized? I am having trouble keeping organized the files for the computational component of my research project. In brief, I have written computer code which I use to run computational experiments. For each experiment, I get a set of output files, from which I generate output such as plots and tables.

The trouble stems from the fact that I have multiple experiments (say exp1, exp2 and exp3) and each experiment has multiple output files (say a.txt, b.txt, c.txt). This is further complicated by the fact that I have multiple versions of each experiment (say exp1 2014-01-02, exp1 2014-05-06, etc).

How should I organize the code and the output in a systematic way?
The system should satisfy the following key requirements:


It has to be easy to rerun version X of experiment Y.
I occasionally have to rerun earlier versions of the experiments in order to check the results or to make slight modifications.
It has to record the output for each version of each experiment.
I often have to run many slight variants of a single experiment
to tweak some small aspect of the results,
so it is essential to record the output for each run.
Funny you should ask, because I'm currently answering this question as I take breather from a project involving just such a family of experiments and variations.

In my own self-organization, I typically distinguish two types of such variants.
If some variants are "dead" and would only be referred to on rare occasions for historical purposes, then they get checked into version control and deleted from my working set---they can be exhumed by the powers of SVN/git/Mercurial when needed.

For the "live" versions, some experiments get grouped thematically and some chronologically.  


Thematic is for when I'm it's a purely computer-based experiment (which can be re-run arbitrarily), e.g., "overlay-network", "random-network", "unit-disc-network"
Chronologically is for when my computer-based runs are based on real data from a physical system that can't be regenerated, but only replicated, e.g., "2013-05-09 Alphavirus", "2013-06-09 Alphavirus run #3", "2013-07-02 Repeats of Failed Samples"


I maintain a strong distinction between several types of files, which must never mix:


Core code: there is precisely one version of any core code system, maintained by version control.  If I need to maintain variants, they have to be set by option flags, not by forking the codebase (that way lies madness).
Each thematic/dated directory gets a README file, whatever notes are neecessary and (typically) two subdirectories: experiments and analysis
Experiment scripts for a thematic cluster live in the experiments directory
Each batch of experimental data lives in its own subdirectory of the experiments directory where its script lives.
Analysis contains scripts to process the experimental data.  Often there are two layers: one to process raw data into results, and another to plot the results.  This is because extracting results is often time intensive and figures are frequently tweaked.  If there are a lot of results files, they get their own subdirectory too.
Plots, living in a subdirectory of the analytical scripts directory


I also typically maintain a few master scripts which allow me to re-run large swaths of experiment / analysis when the core code is improved or a bug is found, which happens more frequently than one would like.