How to get FORTRAN 95 Compiler• Write FTN silverfrost in google and download it for free
History• One of the oldest programming languages, the FORTRAN was developed by a team of programmers at IBM led by John Backus, and was first published in 1957.• The name FORTRAN is an acronym for FORmula TRANslation, because it was designed to allow easy translation of math formulas into code.• Often referred to as a scientific language, FORTRAN was the first high-level language, using the first compiler ever developed.• Prior to the development of FORTRAN computer programmers were required to program in machine/assembly code, which was an extremely difficult and time consuming task, difficult to debug the code.
Significant Language Features• Simple to learn• Machine Independent - allows for easy transportation of a program from one machine to another.• More natural ways to express mathematical functions - FORTRAN permits even severely complex mathematical functions to be expressed similarly to regular algebraic notation.• Problem orientated language• Remains close to and exploits the available hardware• Efficient execution - there is only an approximate 20% decrease in efficiency as compared to assembly/machine code.
Areas of Application• Number crunching - due to the more natural (like its true algebraic form) way of expressing complex mathematical functions and its quick execution time, FORTRAN is easy and efficient at processing mathematical equations.• Scientific, mathematical, statistical, and engineering type procedures -due to its rapid number-crunching ability FORTRAN is a good choice for these type of applications.
Basic Elements of Fortran ProgramThe Fortran Character SetThe following are valid in a Fortran 90/95 program:alpha-numeric: a-z, A-Z, 0-9, and _ (the underscore);arithmetic symbols: +, -, *, /, **miscellaneous symbols: e.g. , comma . decimal point < less thanetc
Structure of a FORTRAN Statement A program consists of a series of statements designed to accomplish the goal. There are two basic types of statements: Executable statements describe the actions taken by the program (additions, subtractions, multiplications, divisions). Non-executable statements provide information necessary for proper operation of the program.
Rules on Fortran statements:Each line may be up to 132 characters long.A statement too long to fit in a single line may be continued on the next line by ending the current line with an & (ampersand). e. g.output = input1 + input2 ! sum the inputsCommenting your code is very important. To comment in FORTRAN, one uses the exclamation point (!)All comments after the ! are ignored by the compiler
Structure of a Fortran ProgramA FORTRAN program can be divided into three sections:Declarations - This section consists of a group of non-executable statements at the start of the program.Execution - This section consists of one or more statements describing the actions to be performed by the program.Termination - This section consists of a statement (or statements) telling the computer to stop/end running the program.
The program reads two numbers as input, multiplies them, and prints out the resultPROGRAM my_first_program! Purpose:! To illustrate some of the basic features of a Fortran program.!! Declare the variables used in this program.INTEGER :: i, j, k ! All variables are integers! Get two values to store in variables i and jWRITE (*,*) Enter the numbers to multiply: READ (*,*) i, j
Continued…! Multiply the numbers togetherk=i*j! Write out the result.WRITE (*,*) Result = , k! Finish up.STOPEND PROGRAM my_first_program
Discussion of Program AboveThe first statement of this program begins with the word PROGRAM. This is a non-executable statement that specifies the name of the program to the FORTRAN compiler.The name may be up to 31 characters long and be any combination of alphabetic characters, digits, and the underscore.The first character must be a letter.The PROGRAM statement must be the first line of the program.
The Declaration SectionThis section begins with a comment stating that variable declarations are to follow.The declaration begins with the data type (INTEGER) followed by two colons and then the variable name.A comment follows the variable name. Every variable must be commented as to its purpose in the program.These statements are non-executable.
The Execution SectionThe first statement in this section is the WRITE statement that tells the user to enter the input.The second statement will read the input and assign the values to the corresponding variables.The third statement multiplies the two variables and the product is assigned to a third variable.The last executable statement prints the product to the screen.
The Termination SectionThe STOP statement tells the computer to stop running the program.The use of the STOP command is optional here.The END PROGRAM statement informs the compiler that no more statements exist.
Compiling and Executing the FORTRAN ProgramBefore a program can be run (executed) it must be compiled into an executable program.In this process the code may also be linked to various system libraries.
Variables and the IMPLICIT NONEChecking a constant (e.g.7, 3.14156, John), it is easy to determine which type it may be. However, for a variable, we must assign a type to that variable.Assigning a type reserves the memory needed to store the data expected (e.g.4 bytes for: 7 , 3.14156 and 2 bytes/letter for: John).