Operators

Implicit none statement, Operators

By default, Fortran allows variables to be used without declaration. One undesirable side effect of this behaviour is that spelling errors in variable names may not be found by the compiler. As a result, difficult-to-find runtime errors can occur. Therefore, it is considered good programming practice to include the implicit none statement at the start of each source file. This forces the programmer to explicitly declare all variables.

Operators

The arithmetic operators available in Fortran are summarised in the following table:

Operator Description
a+b Add a and b
a-b Subtract b from a
a*b Multiply a and b
a/b Divide a by b
a**b Raise a to the power of b

Logic operators are also available, the result of which is .true. or .false. depending on the values of their operands:

Operator Description
a .EQ. b Equal to
a .NE. b Not equal to
a .GT. b Greater than
a .GE. b Greater than or equal to
a .LT. b Less than
a .LE. b Less than or equal to

 

Supported By

File Browser Reference
Department FHERIS
University of Galway
HEA Logo