Doing a little online research the other day, I typed in the words "learn FORTRAN", and on page one of the results, someone called Dinho, who I took to be a college student, had posted the following question on a popular forum:
"I've got 2 months to learn fortran programming.Where do I start?!!!!?"
Judging from the bunch of exclamation marks, Dinho sounded desperate.
This was not one of those Internet boards haunted by trolls ready to pounce on the unwary with mindless and scarcely articulate malevolence. Instead, its ethos was, and still is, to provide reasoned answers to all manner of questions. Trollers steer clear as the questioner gets to choose the "best" answer.
Anyhow, Dinho had several responses to his cry from the heart.
One piece of advice, I thought, fell a little short of being helpful "Wow, that sucks. There's a reason Fortran has fallen into disuse. I was able to learn just enough of it by inspection... " Continuing ominously, the expert discloses "but I have 15+ years of programming experience."
Another answer warns "mastering Fortran... should not be expected before several months or even years of intensive coding."
Ouch! And these guys were doing their best to be helpful!
Well, I'd like to reassure Dinho that FORTRAN is alive and kicking and is being used all over the globe. In fact, it's an excellent choice of programming language for any course of study that uses mathematics to express ideas and solve problems. That includes all science and technology subjects. Why? Because FORTRAN has built-in mechanisms for solving difficult problems such as matrices. It also has bolt on goodies that handle advanced topics like:
Curve and surface fitting and interpolationPartial differential equationsNumerical integrationRoots of nonlinear equationsRandom number generationCorrelation and regression analysisI'd also like to put paid to the notion that FORTRAN is hard to learn. As part of 30 years working in computing, I've had 10 years experience teaching programming (including FORTRAN) at a leading UK university. In that time, I've never known anyone not manage to pick up programming in just a few hours study. Of course, like every other skill, the more you do, the better you'll get.
See what you make of this example of a login form. (I've added line numbers to make it easier to talk about). It's written in FORTRAN and in common with any computer program, it's just:
"a set of instructions that the computer executes in sequence"
PROGRAM loginCHARACTER*10 username,passwordPRINT*, "WELCOME!"DOPRINT*, "PLEASE ENTER YOUR USERNAME"READ*, usernamePRINT*, "ENTER YOUR PASSWORD"READ*, passwordIF (username=="dinho".AND.password=="secret") THENPRINT*,"NICE TO SEE YOU DINHO!"STOPEND IFPRINT*, "INCORRECT USERNAME AND PASSWORD COMBINATION"END DOEND
Let's run the program and see what it looks like. The upper case is what is output by the program, and the italicised lower case is what the user types in.
WELCOME!PLEASE ENTER YOUR USERNAME
mikeENTER YOUR PASSWORD
letmein
INCORRECT USERNAME PASSWORD COMBINATION
PLEASE ENTER YOUR USERNAME
dinho
ENTER YOUR PASSWORD
secret
NICE TO SEE YOU DINHO!
Without going into detail, PRINT (lines 3,5,7,10,13) writes to the screen and READ (lines 6 and 8) reads from the keyboard. You'll probably have worked out that the only correct combination of username and password that is allowed is "dinho" and "secret", and this is checked at line 9.
OK, but what's the purpose of the DO and END DO on lines 4 and 14?
This is the crucial feature of this little program and is called a "loop". It's what gives the computer its power. If you think about it, given the definition that a program is just a set of statements executed in sequence, then any substantial application would have to be trillions of statements long unless parts of the code are reused. Reusing code is exactly what a loop does.
The computer executes each line of the program in sequence, reading input and writing output. When it reaches the END DO, the computer jumps back to line 4 and then continues until something tells it to stop. That something, in our example, is the correct entry of the username and password.
If you are comfortable with this, you are already on your way to being able to program.
Dinho posted his question over 2 years ago. I do hope he wasn't discouraged.
If I had the chance, I would have liked to answer his question like this: "There's loads of high quality information on the Internet to help you, and most of it is absolutely free. There has never been a better time to learn coding. And Dinho, it sounds like you're going to have a lot of fun over the next two months!"
Janet A Nicholson has over 10 years experience teaching programming at a leading UK University. Using numerous worked examples, her completely free self-study course http://www.fortrantutorial.com/ teaches programming using the FORTRAN language in 7 lessons.






0 comments:
Post a Comment