Pondering God in Fortran

This week, I have to stop avoiding a task at work that I’ve been dreading. I need to learn the inner workings of some software that our group has been developing and using for nearly 20 years.

I’ve been dreading this project, not just because I dislike working with Fortran 77, but also because the code is a mess. The code started as a routine that solved a set of differential equations. Loops were written surrounding that routine to handle different initial conditions. Other routines were written to bring in information about the systems we model. If statements were placed haphazardly to handle special cases. More code was written to produce plots (using our own home-built plotting package, because this all started before commercial ones were able to produce nice results), and that was stuck in the main file. Finally, someone wrote a set of C++ routines that used the output of the original routines as its input, but embedded the new routines within the original convoluted structure of the code.

This type of thing seems to happen often when physicists, applied mathematicians, and engineers develop software over many years, without any input from anyone who has taken a computer science course.

Unfortunately, there are only two people left in the group who know how the code works, and everyone seems to think that I am one of them. I started documenting the code today, because eventually I want to re-design it. We have a script to call the code, because the input is so complex. There are about 50 parameters that need to be set, and I only know what 10 of them do. The output from the code is a similar mess. I counted about 40 output files, of which I’ve only used one in my own work.

All these inputs and outputs, and all of the if statements and loops within the code, were needed at one point. Some of the plots were used to verify that different sub-routines were working properly. Once they served their purpose, however, they were simply left in the middle of the code. A lot of these features were probably implemented for one of the several dozen analysis projects that our group has carried out. They are unlikely to be used again, but are kept around “just in case.”

In a way, this code reminds me of some aspects of our genetic code. Biologists only know the function of about 2% of the DNA in any given plant or animal. Some of the remaining 98% or so of the DNA might have functions that we simply haven’t identified. Like the plots produced by our Fortran code, the DNA might only produce useful products under very specific circumstances, such as when embryonic growth must be regulated. However, a lot of it might just be doing nothing.

The way DNA is arranged seems similarly haphazard. The human genome is arranged into 23 pairs of chromosomes. The Adder’s Tongue Fern, on the other hand, has something like 700 pairs of chromosomes. Why would a fern, which doesn’t need to move, hunt prey, or perform elaborate mating rituals, need all those chromosomes?

However, all of this makes sense in the context of evolution. New features are added to the genetic code that give it more functions, yet there is no reason to take away pieces of code that no longer do anything. Something similar happened with our Fortran code. Now both look like a mess.

I realize that this is a poor analogy, but deconstructing bad analogies can help clarify how something really works. In the context of biology, evolution occurs through natural selection, when random mutations improve the survivability of a species. This is not how our code evolved. If it did evolve through random mutations and natural selection, we would have millions of copies of the code, only a small number of which would work. I’ve only been able to find a few versions of this code.

Perhaps I can think of our code evolving in a way more similar to that which Lamarck imagined, 60 years before Darwin and Wallace came up with the modern idea. Lamarck believed species evolved for two reasons. First, there was a natural tendency for life to get more complex. Second, an organ would become exaggerated as it was used more (like the giraffe’s neck). Neither of this is true in nature, but at first I thought it might do a fair job of describing our code, which acquired new characteristics whenever we decided that we needed them.

In the end, though, the biological analogy works poorly because our code didn’t acquire changes through accidents, or through its own striving, but because we, the authors, added features. So, instead, why don’t I turn the analogy on its head, and consider whether the evolution of our code can be used to develop a new concept for how a biological system might evolve? It should be amusing at least.

Now, I’m not suggesting intelligent design here. After all, our code is barely designed, let alone intelligently so. I see no point in pushing that analogy. Likewise, I see no reason to force the traditional Western conception of a deity as an infallible, all-seeing creator into explaining the messy world of genomics. Instead of relying on ancient texts and the traditions of our forerunners as the basis for inquiry, why not consider what our DNA might say about theological questions?

My (strained) analogy between our Fortran code and DNA suggests that one might think of a creator as an author that learned as it went along. At first, it created cells, at that was good. However, it then thought that the cell should have little hairs help secrete important chemicals, and that seemed better. Then, the creator realized the hairs could be used for propulsion, and flagella appeared. This went on, with experiments in multi-celled life, spinal cords, central nervous systems, and so on. Eventually, we ended up with humans, who are spectacularly good at figuring things out, manipulating their environments, and populating the planet. However, humans are far too often are dogged with detached retinas, mental illness, back pain, and really difficult childbirth. The planet also ended up with a myriad evolutionary dead ends, vestigial appendages, and huge blocks of code that weren’t being used (and haven’t been documented).

If only the creator had taken a good software architecture course in college.

I realize that my analogy is still bad. Theologians probably won’t be happy with the fact that my hypothetical creator is constrained to act — and learn — in time. Time, as we understand it, is connected to space in our theory of gravity, and is therefore a property of this Universe. Can a creator even be contained within its creation? This seems like a paradox to my mind, which is untrained in metaphysics. In any case, I don’t believe that evolution requires a creator to intervene at each step; chance mutations and natural selection seem to be effective on their own. I do think, however, the logic behind using intelligent design to describe biology is equally bad as my initial analogy above. . .

Good design would have produce a code that was modular, that had related information organized into structures, and that output a well-documented data stream (rather than 50 random plots). Fortunately, I get another shot at our group’s code, and I hope to instill a more intelligent design.