Pages

21 May 2014

Evolutionary Rates - Kimura

Preamble

In his paper, "Evolutionary rate at the molecular level", Kimura (1968) discusses the rate of evolution as found in comparing various contemporary, at the time, studies with respect to nucleotide substitutions. Kimura began with the assumption that most mutations are neutral or nearly neutral, whereas the thinking at time was that most mutations were usually either harmful or helpful. It was Kimura's work that led to Neutral Theory becoming the Null Hypothesis in modern Molecular Evolution.

Kimura, according to my H-Index Calculator, has been cited over 39169 times, has an h-index >10 and a g-index >10.

Methodology

Kimura begins by looking at the paper by Zuckerkandl and Pauling (1965) who compared studies of hemoglobin molecules who found, among mammals, in a chain of about 140 amino-acids there was a change in one amino-acid in a 107 year period. Then Kimura compares Buettner-Janusch and Hill's (1965) study on primate hemoglobin who found a substitution rate of 45x106 years. The study by Kaplan (1965) between were also compared and found a rate of 2.7x106 years.

Here, Kimura makes the assumption that nuclear DNA is similar among most mammals and that the GC content in mammalian DNA is uniform withing a value of 40-44%. Then Kimura assumes that 4x109 of nucleotide pairs are haploid chromosome complements. From this Kimura estimates a substitution rate within the population of ~2 years.

Compared to the 300 generations rate predicted by Haldane's paper (1957), this is a huge contrast. Kimura concluded, Haldane's erroneous fitness factor aside, that this could be accounted for if most mutations were in fact neutral or at least nearly neutral.

Thus the very high rate of nucleotide substitution which I have calculated can only be reconciled with the limit set by the substitutional load by assuming that most mutations produced by nucleotide replacement are almost neutral in natural selection. (Kimura, 1968, p. 625)

The next paper Kimura looks at is the work by Lewontin and Hubby (1966) who studied genetic variation in the fruit fly species Drosophila psseudoobscura and estimated in each individual that 12% of each loci are heterozygous. Kimura assumes that the heterozygosity would be much higher in nucleotide sequences. Since it is evident that the mutation rate in Drosophila is ten times that of humans, Kimura calculates a mutation rate of 1.5x10-5 and checks his calculation by looking at Drosophila neutral mutations, neucleotide pair mutation per generation the fact that the Drosophila genome is 1/20 the size of the human genome to get the same result.

Finally, Kimura looks at Kimura and Crow (1964) who found that for neutural mutations the probability that an individual in a population is heterozygous and if the individual is homozygous differ.

Looking at Watson's work (1965) Kimura finds that in gamete production substitution in base pairs could be 200-2000 and is reduced to ~2 by natural selection.

Conclusions

Firstly, as in my last post, it must be said that Kimura was in no way finding fault in evolution. In fact, Kimura was proposing a new idea to explain why organisms appear to change so quickly with low cost when calculations such as the one by Haldane say it would take a long time and be costly. In fact, Kimura has been proven correct with Neutral Theory being the Null Hypothesis, with Nearly Neutral Theory taking up much of the slack.

Secondly, Kimura has shown that evolution occurs at a even a faster rate than had previously been supposed. Once again, this supports not defeats evolution. This paper in no way shows that genomes are decaying.

Kimura sums up by stating that each generation is producing neutral or nearly neutral mutations that have been largely ignored and are occurring at a very high rate making random drift an important factor of evolution.

Questions to My Opponent

  • Did you actually read the paper before posting it?
  • If yes to the previous question; did you think neutral or nearly neutral mutations indicated that genomes are decaying?
  • Do you think "random drift" indicated genomic decay?
  • What on earth made you think that this paper demonstrated that the evolution of one species to another is impossible when it is a keystone to the modern understanding of evolution?

Bibliography

20 May 2014

Genome Decay Claim

Prelude

Recently, a Creationist on Google+ presented a list of papers that he felt demonstrated that genomes are decaying and, therby, evolution of species from one form into another is impossible. The thread where this discussion occurred was a post titled Evolution: How it Works and How to Teach it. The articles cited by the Creationist are listed as follows:
  • J.B.S. Haldane. 1957. The cost of natural selection. J. Genetics55: 511-524
  • Kimura, M. 1968. Evolutionary rate at the molecular level. Nature 217:624-626
  • Muller, H.J. 1950. Our load of mutations. Amer. J. Human Genetics 2:111-176
  • Muller, H.J. 1964. The relation of recombination to mutational advance. Mutation Research 1:2-9
  • J.V. Neel, et al. 1986. The rate with which spontaneous mutation alters the electrophoretic mobility of polypeptides. PNAS 83:389-393
  • A.S. Kondrashov. 1995. Contamination of the genome by very slightly deleterious mutations: Why have we not died 100 times over? J. Theor. Biol. 175:583-594
  • S. Kondrashov. 2002. Direct estimates of human per nucleotide mutation rates at 20 loci causing Mendelian diseases. Human Mutation 21:12-27
  • M.W. Nachman and S.L. Crowell. 2000. Estimate of the mutation rate per nucleotide in humans. Genetics 156: 297-304
  • A. Eyre-Walker and P. Keightley. 1999. High genomic deleterious mutation rates in Hominids. Nature 397:344-347
  • J.F. Crow. 1997. The high spontaneous mutation rate: is it a health risk? PNAS 94:8380-8386
  • J.F. Crow. 1958. Genetic effects of radiation. Bulletin of the Atomic Scientists 14:19-20
  • M. Lynch, J. Conery, and R. Burger. 1995. Mutation accumulation and the extinction of small populations. The American Naturalist 146:489-518
  • K. Higgins and M. Lynch. 2001. Metapopulation extinction caused by mutation accumulation. PNAS 98: 2928-2933
  • F. Hoyle. 1999. Mathematics of Evolution. Acorn Enterprises, LLC, Memphis, TN.
  • Howell et al. 1996. Evolution of human mtDNA. How rapid does the human mitochondrial genome evolve? A. J. Hum. Genet. 59: 501-509
  • Loewe, L. 2006. Quantifying the genomic decay paradox due to Muller’s ratchet in human mitochondrial DNA. Genet. Res., Camb 87:133-159
The conditions are that responses must be from credible, scientific journals. He cannot use apologist websites such as Answers in Genesis or Journal of Creations and the like. In turn I have agreed not to use sites like Talk Origins though I did correct him with his claim of Talk Origins being an "atheist apologist" website that rejects Creationist studies out-of-hand.

I don't see why you're arguing this point, I've agreed to only use scientific journals. To belabor the point; if you could show, scientifically, that Creationism is true, that the God of the Bible is the God of Creation and that the God of the Bible exists then most of the scientists on TO would be on the side of Creationist (though many would choose not to worship this God). AiG and the like, well they've stated on their webpage that they will not be swayed. Ken Ham said so quite bluntly in a recent debate that he wouldn't change his mind.

That's the difference.

Program

I shall address each article as they appear in the list. The rate at which I post will be subject to numerous variables such as my ability to acquire an article, how busy I am in my family and work life and how motivated I am when I do have the time. Any claim by my Creationist opponent that suggests I am answering in a particular order, or rate, just to avoid dealing with challenging papers will be treated in the same vein as Godwin's Law. I shall try to determine several things.
  • If the author(s) is(are) actually challenging the validity of Evolutionary Theory, or disputing a detail of Evolutionary Theory.
  • If the conclusion of the article means what the Creationist thinks it says.
  • If the research is refuted, improved upon or verified by other research.

Haldane's Dilemma

Preamble

The paper by Haldane (1957) discusses and attempts to quantify the rate at which otherwise harmful genetic mutations become fixed within an animal population due to natural selection by way of environmental change which favours individuals possessing the mutation. Based on his calculations, Haldane determined that an animal population can only fix this mutation in the population at a rate of 300 generations, at best, and avoid the collapse of the species. The implication being, by my opponent, that there would not be enough time for certain species (ie. humans from the other great apes) to have successfully diverged in the time frame mainstream science says that they have.

The Haldane (1957) paper, according to my H-Index Calculator, has been cited 5613 times and has an h-index >10 and a g-index >10.

Methodology

Haldene first begins by looking at Haploid, Clonal or Self-Fertilizing organisms, or Maternally passed cytoplasmic traits. Stating that if A and a represent allalomorphic genes in these populations then for the representative nth population, prior to selection, we have the frequencies:

pnA, qna where pn + qn = 1.

The cost incurred to fix a gene in the population of such organisms is calculated to be:

The deaths over all generations for the species in question which Haldane calculated to be between 5-15 times the number of species members of a population each generation, 10 being typical.

Then Haldane looks at autosomal locus with pairs A and a in diploids giving their fitness as:

AA frequency: pn2 fitness: 1

Aa frequency: 2pnqn fitness: 1-k

aa frequency: qn2 fitness: 1-K

For the members of these species the total deaths over all generations was calculated to be between 10-100 times the number of members each generation with 30 being typical.

Haldane then examines autosomal locus in inbreeding diploids with the following frequency table:

AA frequency: pn2+fpnqn

Aa frequency: 2(1-k)(1-f)pnqn

aa frequency: (1-K)(fpnqn+qn2)

Here the deaths of heterozygotes can be ignored if the organisms employ full inbreeding and the cost is similar to that of in the first group of organisms. If there is partial inbreeding then the cost is slightly less than the first group and the breeding coefficient f is introduced where f>0. The cost is not significantly reduced unless A is recessive.

After this Haldane looks sex-linked characteristics in diploids. The frequency and fitness table produced is:

AA frequency: pn2 fitness: 1

Aa frequency: pnqn fitness: 1-k

aa frequency: qn2 fitness: 1-K

A frequency: pn fitness: 1

a frequency: qn fitness: 1-l

For this group Haldane calculates the death rate over all generations to carry a cost of 10-40 times the population of a generation where 20 is typical.

Lastly Haldane examines the cost to heterozygotes.According to Haldane's calculations the cost to heterozygotes is small and therefore little fixation can occur.

Discussion

Haldane then concludes that the rate of change, for adapting a previously harmful gene to survive, over 300 generations is reasonable because if change occurred over too few generations this would render the gene unstable and the population would languish and collapse.

Interestingly, Haldane makes the assertion that multiple mutations would take the same amount to fix simultaneously as if they were fixed in sequence. Literally, Haldane claims that three mutations being selected for will take three times as long.

Can this slowness be avoided by selecting several genes at a time? I doubt it, for the following reason. Consider clonally reproducing bacteria, in which a number of disadvantageous genes are present, kept in being by mutation, each with frequencies of the order of 10-4. They become slightly advantageous through a change of environment or residual genotype. Among 1012 bacteria there might be one which possessed three such mutants. But since the cost of selection is proportional to the negative logarithm of the initial frequency the mean cost of selecting its descendants would be the same as that of selection for the three mutants in series, though the process might be quicker. The same argument applies to mutants linked by an inversion. Once several favourable mutants are so linked the inversion may be quickly selected. But the rarity of inversions containing several rare and favourable mutants will leave the cost unaltered. (Haldane, 1957, p. 522)

However, aside from mentioning the negative logarithm Haldane offers no good reason why multiple mutations could not be fixed any faster than one mutation. In his example, Haldane cites bacteria that reproduce clonally. Organisms that utilize sexual reproduction multiple mutations can be selected simultaneously, via sexual recombination, and likely have those traits fixed in the population sooner.

Furthermore, there is a problem in Haldane's calculations. In his paper, Haldane uses 1-k to represent the fitness of gene a. If k = 0.01 then the fitness j of gene a works out to be, by Haldane's calculations, j = 1 + 0.01 = 1.01. Using Haldan's equation with this fitness value, if population N = 100 000, the frequency that A is passed to next generations is p = 1/N = 1e-5 and the frequency that a is passed to the next generations q = 1 - p = 0.99999 we get the following value for deaths.

(q^2/j)*N = ((0.99999)^2)/1.01)*100 000 = 9.90e4

So a bit over 99 000 individuals need to die to pass a to the next generations and eventually cause fixation, 99 009 with better precision. To put that into perspective; 99 009/100 000 * 100 =~ 99%! Haldane perpetuates this error throughout his paper. The point is, there is no reasonable expectation that individuals carrying A have to die, particularly at such rates, but Haldane kept doing so because he normalized his fitness factor incorrectly by counting the previously killed off carriers of A in the calculation for the next generation.

Fixing a gene in a population is not restricted to adopting a previously harmful mutation either. Here, again, the fixation could possibly occur at a higher rate without destabilizing the population as noted by Valen (1963).

Dodson (1962) seized on this estimate of 300 generations, applied it to evolution within the genus Homo, and needless to say for this case, found a poor fit with observed and inferred facts. The most probable interpretation of this difference is that much of the evolution of this genus has been such to present no dilemma to the populations. The most commonly noted difference between successive species, and one that is probably responsible for some of the other differences, is the increase in brain size and presumably intelligence. There is no reason to believe that the part of this increase that occurred in the transition from H. erectus to H. sapiens was a direct adaptation to middle Pliestocene environmental changes (that is, would not have been valuable to the environments of Homo erectus), although it is conceivable that environmental changes (such as possible changes in predators and food) increased the selective advantage for greater intelligence or lowered a threshold of disadvantage for the cocomitant structural disturbance of the skull. The other functional complex known to have changed importantly is posture (and presumably locomotion); it is very possible that the only difficulties in the change of this complex also, were the reorganizations of the anatomy and the genome and not a greater than previous loss of individuals with the ancestral genotype. (Valen, 1963, p. 186-187)

Conclusions

It must first be said that Haldane was not presenting any fault with evolution, nor was he in any way defending Creationism or its poorly disguised brother Intelligent Design. Haldane, in his paper, was trying to come up with a means to calculate how quickly a population evolves if survival meant adopting a previously harmful gene. Nor is there any discussion or other indication about genomes decaying.

Secondly, Haldane's estimate of 300 generations was falsified by Dodson when he compared changes in genus Homo. There is no empirical grounds to accept 300 generations as sacrosanct and suggests that there is no dilemma.

Thirdly, Haldane's calculations are erroneous because he did not properly normalize his fitness factor correctly. Why should individual carrying gene A need to die in such large numbers to fix gene a? Clearly, the empirical evidence suggests that this does not happen on the norm and yet evolution proceeds unabated.

Lastly, although much more can probably yet be said, Haldane was a scientist and admitted that his work probably was not without error. His efforts, nonetheless, helped scientists better understand the evolutionary process. This is how science works!

To conclude, I am quite aware that my conclusions will probably need drastic revision. But I am convinced that quantitative arguments of the kind here put forward should play a part in all future discussions of evolution. (Haldane, 1957, p. 523)

Questions to my Opponent

How did you reach the conclusion that this paper supported a decaying genome?

What is it about the 300 generations estimate that you find significant seeing that it is evidently incorrect?

Did you actually spend time reading the paper?

Bibliography

  • Haldane's Dilemma, Evolutionary Rates, and Heterosis Valen, 1963
  • 28 July 2013

    the nature of evidence or dafuq?

    When having online arguments it is often customary to back up your claims with links to supporting evidence. Depending on the level of the argument this evidence may be a newspaper article, a digitized photograph or even a blog posting. For ordinary arguments this works very well and the issue of evidence is quick and easily obtainable.

    When the argument involves topics of science then articles from reputable, peer reviewed scientific journals are typically used as evidence. Often, all parties involved in the argument will have access to the same article, or the one with access will read out the relevant portions so that all parties can analyze and judge for themselves what the authors were actually saying, the quality of the author's methodology and whether the author's conclusions were in line with the evidence discovered in the author's research and what the readers themselves actually know.

    In addition to this going over the paper itself other papers that verify the findings of a paper's authors are searched for. The more papers in independent research that verify the findings of the originally disputed paper's conclusions the more weight is given to the original paper.

    This is how grown up, scientifically minded people argue about science. They go to the source, the research of the scientists themselves.

    Arguing with Creationists

    Before I dive into this, there are some rational theists, none of whom are Creationists, out there and I wish to acknowledge them and not smear them with the same paintbrush as their more irrational peers.

    When arguing with Creationists the nature of evidence often gets called into dispute. Now it's interesting because Creationists want to debate the science of evolution which they often feel is an evil plot, or at best misguided due to human frailties. Science always falls back onto what can be verified and is empirical and often when debating Creationists I insist upon such evidence, preferably from reliable scientific sources. However, it occurs to me that Creationists often do not know what I mean when I say "verfiable", "empirical" or "reliable scientific sources", or they do not wish to know and therein lies the problem.

    So, as a service to my Creationist friends, I will provide the following the definitions so that the meanings of these words and phrase are clear to them.

    Verifiable

    : capable of being verified

    Oopsie, it appears that we've run into a once of those problems of using a dictionary. We've been referred to another definition. Alright then.

    Verified

    : to establish the truth, accuracy, or reality of <verify the claim>

    So, when I'm asking for verifiable evidence I'm not asking you to assert that your claim is true. I'm asking you to give me the evidence so that I can establish for myself if the claim is true, accurate or in keeping with what is known about reality. If you're asking me to believe that some sky Djinn "did it" but you can't point the Djinn out to me or show me where scientists have found it in their research then I can't verify it. If I can't verify your claim then your claim is unverifiable and, for lack of a better word, worthless. Sorry.

    Empirical

    1. : originating in or based on observation or experience
    2. : relying on experience or observation alone often without due regard for system and theory <an empirical basis for the theory>
    3. : capable of being verified or disproved by observation or experiment <empirical laws>
    4. : of or relating to empiricism

    If your evidence comes from a book, well that's fine, but books by themselves aren't evidence. I'm sorry, but no matter how many time you tell me your book is correct because your sky Djinn says it is doesn't make your book any truer. Besides, then we're back to having to verify the existence of your sky Djinn and if you can't point it out to me or where scientists have discovered your sky Djinn then your book fails as empirical evidence.

    Sadly, the same thing goes for prophetic predictions, or claims of scientific foreknowledge. Unless, for prophecy, you can show me where you holy book makes a prediction that is clear and testable and not actually a prophecy for the people living at that time in that holy book then your claims of prophetic evidence fail. Claims of scientific foreknowledge also have to be clear and testable. I mean, why did the bible, for example, only predict Hitler after he started persecuting Jews and Homosexuals? In the same vein, why did the bible only reveal dinosaurs (it doesn't, but that's another topic) only after scientists started digging up and classifying their fossilized remains?

    Reliable Scientific Sources

    Okay, I don't have a dictionary definition for this one so I'll have to do my best to carefully explain what I mean by this phrase. When I say "reliable scientific sources" I'm saying several things:

    1. Articles from reputable, peer reviewed scientific journals
    2. Reputable science magazines

    So the first thing you need to do is try to find a supporting article in a reputable, peer reviewed scientific journal...oh dear. By the blank looks on my Creationist friend's faces I seem to have uttered more words that they don't seem to understand. Alright then, let's try some more definitions.

    "Reputable

    1. : enjoying good repute : held in esteem
    2. : employed widely or sanctioned by good writers

    If you have some claim that birds aren't related to dinosaurs and you pass me off an article from Answers in Genesis: Answers Research Journal, well that's just not a reputable journal. No scientist that has any value in their field publishes their work in Answers Research Journal. There are a couple of reasons for this 1) if you go to Answers about page the publishers quite clearly state that the bible is the ultimate authority and all scientific research must conform to the bible, 2) Answers rarely publishes any research, mostly just rebuttals of science research that they don't agree with, and the odd actual research they do publish is third rate.

    Peer Reviewed

    : a process by which something proposed (as for research or publication) is evaluated by a group of experts in the appropriate field

    Again, if you hand me Creation Ministries International's Journal of Creation claiming I should read it because it's peer reviewed well I'm not. In a reputable journal peer review is carried out by experts that have been selected to perform the review of a particular paper that has been submitted. The more reputable the paper the more experts they have to draw on. In a journal of low repute, such as Journal of Creation, there are very few experts in any scientific field that are associated with them that they can draw on. Also, as in Answers Research Journal, Journal of Creation states on their about page that the bible is the ultimate authority and thereby limits, if not eliminates, the usefulness of any peer review except to perhaps grammar and spelling.

    A good source to look for reputable, peer reviewed scientific journals is PAIS.

    Carrying Onward

    Now, where was I? Oh yes, I was saying the first thing you should do is try to find if there are any articles in any of the reputable, peer reviewed scientific journal that support your claim. Then read it, not just the abstract, but the whole paper, try to understand it, to absorb it. Try to get inside the heads of the scientists and try to see things the way they saw them. Look at their methodology, did they do things correctly? If you don't understand their methodology, ask for help. Try to get a feel for the equations they're using and the graphs they're displaying. Go over the conclusion, does it fit their premise and does it make sense in light of their research?

    Do all of this and you might be able to win points against people who accept evolution, be they theist or atheist. In the process you might learn something new about the world around you too.

    21 July 2013

    agnosticism and atheism

    For some reason most theists and even some atheists seem to have trouble with the concepts of agnosticism versus atheism. In this article, I'm going to try to address the apparent confusion around these two terms. With any luck this will be a useful resource for theists and atheists alike.

    Agnosticism

    The root of agnosticism is gnosis. According to Merriam-Webster's Online Dictionary gnosis is:

    : esoteric knowledge of spiritual truth held by the ancient Gnostics to be essential to salvation
    

    Therefore, to be agnostic is to be without this special knowledge. Again, according to Merriam-Webster's Online Dictionary agnostic is:

    : a person who holds the view that any ultimate reality (as God) is unknown and probably unknowable; broadly : one who is not committed to believing in either the existence or the nonexistence of God or a god
    

    Atheism

    The root of atheism is theos from which theism is derived. According to Merriam-Webster's Online Dictionary theism is:

    : belief in the existence of a god or gods; specifically : belief in the existence of one God viewed as the creative source of the human race and the world who transcends yet is immanent in the world
    
    Then an atheist is someone who does NOT believe in the existence of deities. From Merriam-Webster's Online Dictionary atheism is:
    : a disbelief in the existence of deity
    

    Discussion

    Most atheists will naturally fall into the agnostic camp. There being no verifiable, empirical evidence of deities means that one cannot know for certain about the actual existence of said deities. So while an atheist may not believe in the existence of any deities, without searching all space-time they cannot know for absolute certain that one does not exist. However, given the improbable likelihood of ever being able to perform such a search it is not necessary to do so in order to show that no deities exist. If there are deities in the Universe and they are not in anyway observable within the space we search then we can infer that they do not affect us and are as good as nonexistent. That said, given the complete lack of evidence of deities up to this point some atheists believe that such a lack of evidence is compelling enough evidence to positively conclude that there are no deities.

    It is interesting to note that most theists are actually agnostics as well. They, much like atheists have no verifiable, empirical evidence of the existence of their particular or any other deities. While a theist may actually believe in the existence of a certain set of deities they cannot know for certain that any actually do exist. Theists that say they actually know that deities exist is either deluded or lying. Unfortunately for the theist making a positive claim, as no verifiable, empirical evidence of deities has yet been found, it falls on them to prove the existence of the deities they say exist.

    Naturally, some theists object to this and claim that atheists that make a positive claim of the absence of deities also bear the burden of proof. However, this is not true. Given the fact that up to this date no deities have been found the Null Hypothesis is that there are no deities. As a result, the atheist making the positive claim is not really obligated to prove that deities don't exist because the view of these particular atheists are in line with the Null Hypothesis. Since the theist has, through making a positive claim, constructed an Alternative Hypothesis he or she now bears the burden of collecting the evidence and seeing which hypothesis is supported by this evidence.

    Bear in mind that this does not get the atheists off "Scott Free". Should a theist actually find any verifiable, empirical evidence of the existence of deities and this evidence passes scrutiny then the Null Hypothesis may change and the atheists will now have to reevaluate their beliefs, or lack thereof as the case may be. However, until that happens atheists can rest assured that theists will spend a long time looking for the existence of their deities which started at the dawn of religion.

    13 May 2013

    we're all cranks-in-waiting

    So I read this article, linked to on this Slashdot article which prompted me to post this on my G+ account.

    Easy to Crank

    Earlier this morning it occurred to me that I was behaving in the manner of a crank. I was acting as if my inexpert opinion counted as much as the opinions of those who've studied and practiced computer programming much of, if not most, of their careers.

    Additionally, it doesn't seem to take much to turn one into a crank.

    Aside:

    I still can't stop futzing with the code.

    
    
    #include <stdio.h>
    
    int fizz_buzz(int num)
    {
            int m1 = 3, m2 = 5, f = 0;
    
            if (num % m1 == 0) {
                    f = 1;
            }
    
            if (num % m2 == 0) {
                    f = f + 2;
            }
    
            return(f);
    }
    
    int main() 
    {
            int max = 100, n = 1;
            char s1[] = "fizz", s2[] = "buzz";
    
            while (n <= max) {
                    switch (fizz_buzz(n)) {
                            case 1:
                                    printf("%s", s1);
                                    break;
                            case 2:
                                    printf("%s", s2);
                                    break;
                            case 3:
                                    printf("%s%s", s1, s2);
                                    break;
                            default:
                                    printf("%d", n);
                                    break;
                    }
                    
                    printf("\n");
                    n++;
            }
            return 0;
    }
    

    30 March 2013

    learning fortran

    I've decided that a person with a science degree is probably lacking if s?he doesn't know a bit of Fortran, so I've taken the liberty of teaching myself by following the tutorial available a Fortran Tutorial. I ran into a bit of a snag on Exercise 6.3 on the Subroutines and Functions lesson. For some reason I couldn't get the subroutine to work the way I wanted. I knew the algorithm for the finite difference matrix itself was correct, but it kept crashing on me

    I'm using gfortran on both my workstation and on my android device, but they both seem to work differently when it comes to arrays and fortran procedural programming and I think gcc on my android is broken. This only made things more frustrating for me, so I began to do a lot of reading on Fortran 95 and how it handles arrays, functions and the like while trying things out.

    Happily, I was able to figure it out but it only works on my workstation. It's too bad the gcc android port I'm using is broken, I'll have to find a replacement. Anyhow, here is the code I was able to cobble together. Try not to be too critical.

    
    program exercise6_3
        !print out a finite difference matrix using a function
        implicit none
        integer :: row, col, length
        integer, allocatable, dimension(:,:) :: matrix 
        print *, 'How big is your nxn matrix?'
        read *, length
    
        allocate(matrix(length, length))
        call d_matrix(length, matrix)
    
        do row = 1, length
              write(*, 10) (matrix(row, col), col = 1, length)
        end do
    
        10 format(100i2)
    
        deallocate(matrix)
    
        end program exercise6_3
    
        subroutine d_matrix(count, array)
        !finite difference matrix
            implicit none
            integer :: count, m
            integer, dimension(count,count) :: array
            !array dimensions must be specified
    
            array = 0
            do m = 1, count
                  array(m, m) = 2
                  if ( m /= count ) then
                        array(m, m + 1) = -1
                        array(m + 1, m) = -1
                    end if
            end do
    
            end subroutine d_matrix