Menu Close

Keywords and Identifiers | Fortran

Fortran has a number of predefined keywords that have special meaning in the language and cannot be used as user-defined identifiers. These keywords include:

  • PROGRAM: used to define the start of a program block
  • END: used to define the end of a program block or statement
  • IF: used to execute a block of code conditionally
  • THEN: used in conjunction with IF to specify the block of code to be executed
  • DO: used to create a loop
  • WHILE: used to create a loop that continues as long as a condition is true
  • FORALL: used to create a loop that iterates over all elements of an array

In addition to these keywords, Fortran also has a number of built-in functions that can be used to perform common tasks, such as mathematical calculations, input/output operations, and string manipulation. These functions include SIN, COS, TAN, LOG, EXP, ABS, MAX, MIN, and many others.

User-defined identifiers, such as variable names and subroutine names, must follow certain rules. They must begin with a letter and can contain letters, digits, and underscores, but they cannot contain special characters or be the same as a Fortran keyword. Identifiers are case-sensitive, which means that x and X are considered to be different variables.

More Related Stuff