Jump to content

Fortran

From Encyc
(Redirected from FORTRAN)

Fortran was an early and influential computer language. It was widely described as being intended for "scientific" programming.

It was written before computer scientists deprecated the GOTO statement, and many early Fortran programs made extensive use of it. Any statement in the program could be preceded by a label, and these labels were potential targets for GOTO statements.

It did provide an IF statement, but it did not work like a modern IF. It included an "arithmetic if", where the IF was followed by an arithmetic expression, and then three labels, the programs flow of control would go-to the first of those labels if the expressions value was less than zero. Flow of control would go to the second label if the expressions value was zero; and flow of control would go to the third label if the expression's value was greater than zero. Alternately the expression that followed the IF could be followed by a single Fortran statement. In practice that was often a GOTO statement.

Fortran did provide a DO statement, which incremented an integer variables value, until a limit was reached.

Since original Fortran programs were intended to be written on punch cards, that were only 80 characters wide, original programs were not written using indentation to make them more readable.

However, researchers, at Bell Labs, developed a pre-processor for Fortran they called ratfor, for rational Fortran, that allowed programmers used to the C language used to write Unix to write programs that looked like C programs on more primitive computer systems. The ratfor preprocessor would turn the beautiful ratfor into primitive Fortran. Variables they used that dd not comply with Fortran limited variable namespace would be translated to standard Fortran variable names. Modern if-then-else constructs would be rewritten to use IF and GOTO statements.

Fortran used two variable types, an integer type, and a "real" or floating point type. Programmers were not required to declare the type of their variables. They could just use them, and the compiler would assign them a type based on the the first letter. Variables that began with an I, J, K, L, M, N would automatically be type integer. All other undeclared variables would be a floating point type.