| Fortran Language Reference Manual, Volume 1 - S-3692-51 | ||
|---|---|---|
| Prev Section | Chapter 2. Fortran Concepts and Terms | Next Section |
This section shows the forms of the higher-level components of a Fortran program. The notation used in most of the forms is the same as that used to show the syntax forms in all the remaining sections of this manual. The complete Backus-Naur form (BNF), as given in the Fortran standard, is included in the Fortran Language Reference Manual, Volume 3.
Fortran defines program_unit as follows:
Table 2-1.
| executable_program | is |
| |
| program_unit | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
| main_program | is |
| |
| external_subprogram | is |
| |
|
| or |
| |
| function_subprogram | is |
| |
| subroutine_subprogram | is |
| |
| module | is |
| |
| block_data | is |
| |
| specification_part | is |
| |
| implicit_part | is |
| |
| implicit_part_stmt | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
| declaration_construct | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
| execution_part | is |
| |
| execution_part_construct | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
| internal_subprogram_part | is |
| |
| internal_subprogram | is |
| |
|
| or |
| |
| module_subprogram_part | is |
| |
| module_subprogram | is |
| |
|
| or |
| |
| specification_stmt | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
| executable_construct | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
| action_stmt | is |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
| |
|
| or |
|
Typically, a main program takes the following form:
[ PROGRAM program_name] [ specification_part ] [ execution_part ] [ CONTAINS internal_subprogram [ internal_subprogram ] ...] END [ PROGRAM [ program_name] ] |
Typically, an external subprogram takes one of the following forms:
function_stmt [ specification_part ] [ execution_part ] [ CONTAINS internal_subprogram [ internal_subprogram ] ... ] end_function_stmt |
subroutine_stmt [ specification_part ] [ execution_part ] [ CONTAINS internal_subprogram [ internal_subprogram ] ... ] end_subroutine stmt |
Typically, a module takes the following form:
MODULE module_name [ specification_part ] [ CONTAINS module_subprogram [ module_subprogram ] ... ] END [ MODULE [ module_name ]] |
Typically, a block data program unit takes the following form:
BLOCK DATA [ block_data_name ] [ specification_part ] END [ BLOCK DATA [ block_data_name ] ] |
Typically, an internal subprogram takes one of the following forms:
function_stmt [ specification_part ] [ execution_part ] end_function_stmt |
subroutine_stmt [ specification_part ] [ executable_part ] end_subroutine stmt |
The FUNCTION and SUBROUTINE statements are defined as follows:
|
The END FUNCTION and END SUBROUTINE statements are defined as follows:
|
A specification part generally can contain any of the following. Some program units or subprograms may not allow some of these specification constructs. See the descriptions for each program unit or subprogram description for restrictions.
USE statements
PARAMETER statements
FORMAT statements
ENTRY statements
Derived type definitions
Type alias definitions
Enumeration definitions
Interface blocks
Type declaration statements
Other specification statements
Typically, derived-type definitions take the following form:
TYPE [ [, access_spec] :: ] type_name [ PRIVATE ] [ SEQUENCE ] type_spec [ [, component_attr_spec_list ] :: ] component_decl_list ... [ type_spec [ [, component_attr_spec_list ] :: ] component_decl_list ... ] ... END TYPE [ type_name ] |
Typically, an interface block takes the following form:
INTERFACE [ generic_spec ] [ interface_body ] ... [[MODULE] PROCEDURE procedure_name_list ] ... END INTERFACE |
This section lists the general forms for specification statements. The BNF used here is an abbreviated format and is used only in this section. The specific formats are described in later sections of this manual. The specification statements are as follows:
|
Note: The Fortran standard does not specify the AUTOMATIC, or STATIC statement. BIND, module_nature, PROTECTED, VALUE, and VOLATILE are Fortran 2003 features.
Typically, the type declaration statements take the following form:
|
Section 2.5.12, introduced attr_spec. Typically, attribute specifications take the following form:
|
Note: The Fortran standard does not specify the AUTOMATIC, or STATIC attribute. The BIND, PROTECTED, VALUE, and VOLATILE attributes are Fortran 2003 features.
An execution part can contain the following:
action_statement
case_construct
do_construct
if_construct
where_construct
Typically, action statements take the following form:
|
|
Typically, CASE constructs take the following form:
SELECT CASE (case_expr) [ CASE case_selector block ] ... [ CASE DEFAULT block ] END SELECT |
Typically, DO constructs take the following form:
|
Typically, IF constructs take the following form:
IF (scalar_logical_expr) THEN
block
[ ELSE IF (scalar_logical_expr) THEN
block ] ...
[ ELSE block ]
END IF |
Typically, FORALL constructs take the following form:
FORALL forall_header [ assignment_stmt ] | [ forall_assignment_stmt ] | [ forall_construct ] | [ forall_stmt ] | [ pointer_assignment_stmt ] | [ where_construct ] | [ where_stmt ] END FORALL |
Typically, WHERE constructs take the following form:
[where_construct_name: ] WHERE (mask_expr) [ where_body_construct ] ... [ ELSEWHERE (mask_expr) [ where_construct_name ] [ where_body_construct ] ... ] [ ELSEWHERE [ where_body_construct ] ... ] END WHERE [where_construct_name] |
| Prev Section | Table of Contents | Title Page | Index | Next Section |
| Program Execution | Up one level | Ordering Requirements |