How To Make A Great Program In FORTRAN

Posted on - Last Modified on

Many people think FORTRAN is an antique or primeval programming language which has ceased to exist. To the dismay of many, most engineering and scientific code is written using FORTRAN, so it remains a pivotal programming language for every technical PHP programmer.

The latest releases of the language, i.e., 2003, 2008, and 2015, permit every programmer to write highly effective code using minimal effort, while making use of the recent language features that include object-oriented programming (OOP). FORTRAN is an acronym that stands for “Formula Translation.” It is mainly used for numerical and mathematics applications, as opposed to database and graphic applications. Most of the FORTRAN codes receive text from a command line or a file, rather from a Graphical User Interface (GUI) or a menu.

FORTRAN is an ancient programming language whose existence is credited to John Backus, and a team of programmers in IBM. It was designed to help in easing the translation of mathematics formulas into readable code. Many people refer to it as a scientific language since it is a high-level language that was among the first ones to use the compiler. Before it came into existence, PHP developers had to program in assembly or machine code, which was time-consuming and tiring even before the dreaded task of debugging the entire code.

FORTRAN was created with the sole purpose of having a programing language that would be run easily, understood easily, independent from machines, fit for an array of applications, and one that would allow complex mathematical formulas to be stated similarly to algebraic notations. It was thought to have all these characteristics, and also be efficient in the execution of code like any other assembly language. Since it was such an easy program to code, PHP developers and programmers could manage to code five times faster than before, but the efficiency in execution went down by 20 percent. Therefore, a programmer could focus more on the internal models of a solving a problem and write fewer lines of code.

FORTRAN was such an innovative language, not only because it was the original high-level language, but also due to its excellent compiler. Its compiler was instrumental in the rise of a popular branch of computer science referred to as the compiler theory. Many years after it was released, FORTRAN helped to develop various dialects - which were enabled by its special tweaking by PHP developers and programmers - who wanted to change it to suit their needs. Developers and programmers, therefore, had a hard time trying to transfer programs from one machine to another. Such challenges prompted the American National Standards Association (previously known as American Standards Association) to release the first standard for a programing language. The initial standardized version was called FORTRAN IV.

Features of FORTRAN programming language

The main features of FORTRAN are:

  • Machine independent - makes it easy to transfer a program from one machine to another.

  • Allows more freedom in its code layout - unlike machine/assembly language, its code does not have to be defined in columns rigidly. However, it must remain within the precincts of the FORTRAN code form.

  • It is a problem-oriented programming language.

  • It is easy to learn - the original intention of designing it was to have a program that was easy to learn, code, and comprehend.

  • It is close to and makes use of the readily available hardware.

  • It controls storage allocation - PHP developers and programmers could easily control storage allocation (though this is a dangerous practice these days, it used to be essential sometimes due to the limited memory).

  • FORTRAN has more natural ways to express complex mathematical functions - it allows complex mathematical functions to be expressed algebraically.

  • It has an efficient execution of code.

There are numerous PHP jobs on freelancer.com which you can use to practice.

Editing FORTRAN

There is no FORTRAN window in which a user can type a FORTRAN program. Instead, one types and saves the program in an editor (word processor), and a FORTRAN compiler helps to turn the program into an executable file. You need to open an editor when you want to create a FORTRAN program. It is better to use a simple editor such as a DOS editor or Notepad since more advanced processors may add extraneous formatting and make the FORTRAN program hang.

It is important to note that FORTRAN is not sensitive to case - i.e. it cannot tell the difference between small and capital letters. Therefore, “A” and “a” prompt the same variable. Most PHP developers use small letters, but it is at your discretion to use any case you prefer. Also, after you code up to the sixth column, the FORTRAN code will not recognize spaces (apart from spaces found inside certain quotations such as print statements). Spaces make code more readable.

If you have a WordPress site, and you need to know how to apply custom CSS, visit freelancer.com.

FORTRAN has various declaration statements which are used to state the variables that are used in a particular program. A variable name has characters chosen from the letters of the alphabet and digits 0 to 9. As a rule of thumb, a letter should be the first character of a name. You cannot use your FORTRAN program name as a variable; neither can you use words which have been reserved for the FORTRAN programming language, which include “end”, “real”, and “program”. FORTRAN has various variable types which include:

  • Logical variable (logical)

  • Single precision real variable (real)

  • Complex variable (complex)

  • Integer (ranging from roughly -2 billion to +2 billion)

  • Double precision real variable (double precision)

  • String variable (character)

For instance, the declaration statements:

Double precision x, y

Interger P, Q

Real g, make;

declare that “g” and “make” are single precision variables, P and Q are integers, and “x” and “y” are double precision variables. If you are programming in FORTRAN and you fail to declare the type of variable, FORTRAN will make an integer by default if it begins with one of the letters from “i” to “n”; otherwise it will make a single precision variable. As a good practice in programming, you are obliged to declare every type of variable to avoid making mistakes.   

How do you program in FORTRAN?

  • Understand what your program should do. You should have a rough idea of what data you need for the input, how you will structure the output, and your intended method of monitoring the progress of the calculation. If your calculation will take some time, this will be critical.

  • If you are aware of another programming language, just learn the syntax, and focus on the equivalents to the commands on FORTRAN.

  • Learn how to compile and run your first program. It should display the words “Hello World” and exit. The minor details should not worry you, but you should focus on running and compiling.

  • Understand the variable types, i.e. logical, character, real, and integer.

  • Learn the concepts of subroutines, functions, arrays, and variables. Arrays are certain groups of variables, subroutines and functions are pieces of executable codes, and variables are the stores of information.

  • Learn how to use conditional statements such as “SELECT CASE” and the “IF” statements. You will use the “IF” statements mainly. A code will be executable if a certain condition is true or false.

  • Learn “CYCLE”, “EXIT”, and loops.

  • Understand FUNCTIONS and SUBROUTINES.

  • Learn F90 and later (Recursion) and other cutting-edge topics.

  • Find and read books about Scientific Programming - for instance, “Numerical Recipes in FORTRAN” is a good book for an introduction on how to compile codes, and a perfect one on scientific programming. The recent edition has chapters on parallel programming, and a guide on programing in mixed languages. You could also read Modern FORTRAN in Practice whose author is Arjen Markus. It is a classical book that explains how you can apply the latest FORTRAN standards to a program.

If you have further information on how to program in FORTRAN, give your suggestions in the comment section below.

 

Posted 18 November, 2017

LucyKarinsky

Software Developer

Lucy is the Development & Programming Correspondent for Freelancer.com. She is currently based in Sydney.

Next Article

Top 10 CRM Software Solutions For Freelancers