Friday, November 6, 2009

F77 Column Indentation Rules -- المسافات

When writing the F77 source code you have to follow some rules, so that the compiler understand the written code, and therefore it will be translated in the right way. In FORTRAN 77 each specific statements are inserted in specific columns, the following rules summarizes these rules.

            Here is a simple example program before getting into the rules:


  • Column 1: This column designates comments, when you insert a (C) or a (!) or any other character the rest of this line is ignored. C & ! are the ISO, other characters may be used as well. Comments are very important when writing large blocks of codes, if you write more than 100 lines of code, I bet you will forget why you wrote some instructions after about one month. SO a neatly commented code surely helps the programmer and those who help him.

  • Column 2-5: This block is reserved for inserting numerical labels these labels are used to mark this line, so that you can jump back to it, via GOTO statements, or after finishing a DO loop, or even in subroutines. Some experienced programmers follow a neat sequence of multiples of 10. For example 100, 110, 120, 130, 140, 150, ... and so on.

  • Column 6: This column is reserved for inserting a character usually a (+), which is the continue notation for F77 . For example sometimes you may need to write a long line in F77 and you can't exceed column 73, so you insert a + in column 6 and continue writing your code.

  • Column 7-73: This block is where you write your instruction source code and statements that are translated by the compiler.
Why such limited width ? Well, Fortran was born many years ago when the final stage of coding was always punching a card which contained binary instruction code for nu-merically controlled devices. The standard punched card had 80 columns, numbered 1 to 80 from left to right. Each column could hold one character, encoded as some combination of punches in the 12 rows of the card; more on this at Although many modern compilers can read your code beyond the 73th character, we will strictly cut our source code to appear within column 7 and 73. If your line would extend beyond the 73th character, you
have to break it and place the symbol + in column 6 of each continuation line.(Taken from Roman Gro ger's tutorial)

Saturday, October 24, 2009

FOTRAN 77, Getting Started

Big Hand for our civil colleagues
         First of all welcome to my place, so You are probably a Civil undergraduate, like me -for now- at the Structural Division of the  Faculty of Engineering, Alexandria University

  What is Fortran?

 Fortran is a general purpose programming language, mainly intended for mathematical computations in e.g. engineering. Fortran is an acronym for FORmula TRANslation, and was originally capitalized as FORTRAN. However, following the current trend to only capitalize the first letter in acronyms, we will call it Fortran. Fortran was the first ever high-level programming language.
Copyright © 1995-7 by Stanford University. All rights reserved.

 That was the first part of a nice tutorial on the web, Fortran 77 tutorial at Stanford University. Just an Introduction.

 This is the link to the tutorial online >> Fortran 77 Tutorial

 Our beloved Professors at Alexandria University also provided us with an online tutorial for 1st Year Civil Undergraduates >> FORTRAN 77. Along with lectures, sheets + their answers, and some useful links.

 Software compilers

  The Force 2.0.9 IDE on Windows is available for download here. --=it uses g77 compiler as well=--

  To those of you who are using Linux my number 1option for programming (Ubuntu or any other flavor) try to compile the old package g77, or try using the available fortran 90 (gfortran) and see if it works well with fortran 77 code. --= or just contact me and I'll help you for both, i.e Linux and g77=--

I think we are now ready to start with fortran 77.

That was a brief gentle introduction to getting started, take a look at the tutorial and try out your first program, then leave a comment or e-mail me if you got a problem.

You are also welcomed to ask about linux, I guess I can help you... -=1.5 Years of experience in linux is not that bad, huh?=-