The Queen's University of Belfast
Parallel Computer Centre

[Next] [Previous] [Top]

1 Introduction


1.1 Programming in general

A program is the tool a user employs to exploit the power of the computer. A program is written in a language which is understood by the computer hardware. A program consists of a sequence of steps which when executed result in a task being carried out. Execution means that the computer is able to interpret each step (instruction), interpretation refers to understanding what is required and instructing the hardware to carry it out. Each instruction might require a calculation to be performed, or a decision to be selected, or some information to be stored or retrieved. The nature of the instruction depends on what programming language is used. Each programming language has its own set of statements.

1.1.1 Available programming languages

There are hundreds of programming languages. A general txonomy of the available programming languages is given below.

1.1.2 Choosing a programming language

The choice of what language to employ depends on two factors:

1.2 History

Fortran (mathematical FORmula TRANslation system) was originally developed in 1954 by IBM. Fortran was one the first to allow the programmer to use a higher level language rather than machine code (0s and 1s) or assembly language (using mnemonics). This resulted in programs being easier to read, understand and debug and saved the programmer from having to work with the details of the underlying computer architecture.

In 1958 the second version was released with a number of additions (subroutines, functions, common blocks). A number of other companies then started developing their own versions of compilers (programs which translate the high level commands to machine code) to deal with the problem of portability (machine dependency).

In 1962 Fortran IV was released. This attempted to standardize the language in order to work independent of the computer (as long as the Fortran IV compiler was available!)

In 1966 the first ANSI (American National Standards Institute) standard was released which defined a solid base for further development of the language.

In 1978 the second ANSI standard was released which standardized extensions, allowed structured programming, and introduced new features for the IF construct and the character data type.

The third ANSI standard was released in 1991, with a new revision expected within 10 years.

1.3 ANSI Standard

Fortran 90 is a superset of Fortran 77. New facilities for array type operations, new methods for specifying precision, free form, recursion, dynamic arrays etc. were introduced. Despite that the whole Fortran77 is included the new ANSI standard proposes that some of the Fortran77 features are obsolete and will be removed in the next version.

In theory a Fortran 77 program should compile successfully with a Fortran 90 compiler with minor changes. This is the last time a reference to Fortran 77 is made and it is recommended that programmers new to Fortran not to consult any Fortran 77 books.

The Fortran 90 version was augmented with a number of new features because previously modern developments were not accommodated. Developments such as the recent importance of dynamic data structures and the (re)introduction of parallel architecture.

Comparing with other languages, and only for number crunching, one can see that Fortran90 scores higher on numeric polymorphism, decimal precision selection, real Kind type etc. Only 90 has data parallel capabilities meaningful for numeric computation which are missing from other languages. Also 90's data abstraction is not as powerful as in C++ but it avoids the complexities of object-oriented programming.

1.4 The Program - Planning

Writing a program is not a floating task. Previous to code writing one has to go through certain stages:

At the end of coding, verification, testing and maintenance are also required.

The stages are iterative and the sooner errors are found the better. These stages though are not discussed in this course but the interested reader can consult any software book for more information. Here, the concentration lies with coding with a brief introduction to design using algorithms.

1.5 The Program - Algorithms

The design phase is one of the most important and usually difficult stage. One tool used to design the program is the algorithm. With an algorithm the steps required to carry out a given task are clearly described. The algorithm will include instructions for how to:

Writing musical score is an algorithm where the notes express tasks. For programming though an algorithm is expressed using English-like instructions. An algorithm is independent of the programming language or the computer hardware to be used, but influenced. A programming language acts like a convenient medium for expressing algorithm and the computer is simply the medium of execution. The solution process expressed as an algorithm can not obviously be executed since computers do not handle well the idiosyncrasies of a natural language or subset of it (but moving towards it)

1.6 The Program - Example of an algorithm

Consider the following algorithm;

  1. Get a number

  2. Save the number

  3. Get a new number

  4. While there is a new number

  5. If the new number is greater than that saved

    Save the new number

    end if

  6. Get a new number

    end while

  7. Print saved number

This is a proposed solution for finding and displaying the greatest number from a given list of numbers. The input terminates when the user enters the blank character.

Notice the English-like expressions. Obviously, one can use Read or Input instead of Get; or store instead of save; or '>' instead of greater than. Notice also the numbering system. This helps towards stepwise refinement. For example, if statement X needed more clarification then the new statements take the value X.1 to X.n. This makes referencing statements easier.

Notice the indentation and the end-if and end-while which make clear where a comparison / loop terminates.

1.7 The minimum program

Consider the following program

PROGRAM nothing

! does nothing

END PROGRAM nothing

This is probably the simplest Fortran90 program. It does nothing. The first statement simply tells the compiler that a program named nothing is to follow. The second statement is a comment (because of the exclamation mark) and it is ignored by the compiler. The third and last statement informs the compiler that the program terminates at that point. Notice that statements between PROGRAM and END are executed in the order that they are written (not strictly true but ok for the moment). Keywords such as PROGRAM and END are written in capitals just for illustration purposes. Small case or a mixture of upper and lower case is acceptable. So PROGRAM, Program, PROgrAM are all acceptable.

Consider the following (more complicated) program

PROGRAM hi

! display a message

WRITE(*,*) 'Hello World!'

END PROGRAM hi

The above program introduces the concept of displaying information to the screen (or other devices). Running this program the message Hello World (without the quotes) will appear on the screen. This is achieved by employing the keyword WRITE and typing the appropriate message between single quotes. One can extend the program to, say, display the name of the current user. Then using in a similar fashion another available keyword (READ) the user can enter his/her name and by changing the WRITE statement he/she can display the name.

1.8 Compilation

Once the program has been designed and entered into a file then the following steps are followed:


[Next] [Previous] [Top]
All documents are the responsibility of, and copyright, © their authors and do not represent the views of The Parallel Computer Centre, nor of The Queen's University of Belfast.
Maintained by Alan Rea, email A.Rea@qub.ac.uk
Generated with CERN WebMaker