X3J3/96-068 Date: April 5, 1996 To: X3J3 From: David Epstein Subject: The Full CoCo Definition INTRODUCTION This is a separate part of the standard that defines a conditional compilation language. References to Part 1 refer to the Fortran 95 standard. The rest of the introduction to be completed for electronic distribution. RATIONALE Conditional compilation is a programming language feature which permits selected blocks of code to be ignored by the processor. There are many uses for conditional compilation. Writing portable code is one of the popular uses of conditional compilation. The rest of the rationale to be completed for electronic distribution. ------------------------------------------------------------------------ THE CONDITIONAL COMPILATION LANGUAGE DEFINITION Section 1 Conditional Compilation The conditional compilation language definition for Fortran consists of nine directives and three options. When used together, the conditional compilation directives and options offer the power to select blocks of code for compilation without modifying the source text. Section 2 High level syntax This section introduces the terms associated with the conditional compilation (CoCo) program. (For brevity, throughout this text the term conditional compilation is appreviated as CoCo. We may decide to use CC or the full spelling before the final draft.) A Fortran statement is considered a CoCo-comment. R201 CoCo-program is CoCo-directive [ CoCo-directive ] ... R202 CoCo-directive is CoCo-type-decl-directive or CoCo-executable-construct or INCLUDE line or CoCo-comment R203 CoCo-executable-construct is CoCo-action-directive or CoCo-if-construct R204 CoCo-action-directive is CoCo-assignment-directive or CoCo-error-directive Section 3 Constants, source form and including text 3.1 CoCo constants R301 CoCo-constant is CoCo-literal-constant or CoCo-named-constant R302 CoCo-literal-constant is CoCo-int-literal-constant or CoCo-logical-literal-constant R303 CoCo-int-literal-constant is digit-string R304 CoCo-logical-literal-constant is .TRUE. or .FALSE. R305 CoCo-char-literal-constant is ' [ rep-char ] ... ' or " [ rep-char ] ... " R306 CoCo-named-constant is name 3.2 CoCo source form A CoCo program is a sequence of one or more lines, organized as CoCo directives, CoCo comments and INCLUDE lines. A CoCo directive is a sequence of one or more complete or partial lines. A line is a sequence of zero or more characters. A CoCo character context means characters within a CoCo character literal constant (R305). A CoCo comment may contain any character that may occur in any CoCo character context. In CoCo source form, each source line may contain from zero to 132 characters and there are restrictions on where a CoCo directive (or portion of a CoCo directive) may appear within a line. However, if a line contains any character that is not of default kind (part1:4.3.2.1), the number of characters allowed on the line is processor dependent. In CoCo source form, blank characters shall not appear within CoCo lexical tokens other than in a CoCo character context. Blanks may be inserted freely between CoCo tokens to improve readability. A sequence of blank characters outside of a CoCo character context is equivalent to a single blank character. A blank shall be used to separate CoCo names, or CoCo constants from adjacent keywords, CoCo names, or CoCo constants. 3.2.1 CoCo directive and comment start R307 CoCo-dir-start is ?? R308 CoCo-comment-start is ?> or ?* Constraint: The characters "??", "?>" or "?*" shall be in character positions 1 and 2 of the source line. 3.2.2 CoCo commentary A line that is not a CoCo directive or a partial CoCo directive is called a CoCo comment line. Within a CoCo directive, the character "!" in any character position initiates a CoCo comment except when it appears within a CoCo character context. The comment extends to the end of the source line. If the first nonblank character on a line after character position 2 is an "!", the line is also a CoCo comment line. Lines containing only blanks after character position 2 or containing no characters after character position 2 are also CoCo comment lines. Lines with the CoCo-comment-start in character positions 1 and 2 are also CoCo comment lines. Note 3.1 Examples of CoCo comment lines are: gender = GetRabbitGender(a_rabbit) ! a Fortran statement? ! a Fortran comment ?? ! set "system" to "system_A" ?? ?> OPEN(UNIT=6, FILE="system.dependent.name") ?* OPEN(UNIT=6, FILE="sysdpnt.nam") ENDNote 3.1 3.2.3 CoCo directive continuation The character "&" is used to indicate that the current CoCo directive is continued on the next line. CoCo comment lines shall not be continued; an "&" in a CoCo comment has no effect. When used for continuation, the "&" is not part of the CoCo directive. No line shall contain a single "&" as the only nonblank character after character position 2 in a CoCo-noncomment line or as the only nonblank character before an "!" that initiates a comment. 3.2.3.1 CoCo-noncharacter context continuation If an "&" not in a CoCo comment is the last nonblank character on a line or the last nonblank character before an "!" that initiates a comment, the CoCo directive is continued on the next line. If the first nonblank character after character position 2 on the next CoCo-noncomment line is an "&", the CoCo directive continues at the next character following the "&"; otherwise, it continues with the first character position after character position 2 of the next CoCo-noncomment line. If a CoCo lexical token is split across the end of a line, the first nonblank character after character position 2 on the first following CoCo-noncomment line shall be an "&" immediately followed by the successive characters of the split token. Note 3.2 An example of CoCo-noncharacter context continuation is: ?? LOGICAL :: too_good& ??&_to_be_& ??&true = & ?? .FALSE. ! These four lines contain 1 CoCo directive ENDNote 3.2 3.2.3.2 CoCo character context continuation If a CoCo character context is to be continued, the "&" shall be the last nonblank character on the line and shall not be followed by CoCo commentary. An "&" shall be the first nonblank character after character position 2 on the next line and the CoCo directive continues with the next character following the "&". Note 3.3 An example of CoCo character context continuation is: ?? error *, "de& ?? &f& ?? &inately choosing Fortran" ! 3 lines, 1 CoCo directive ENDNote 3.3 3.2.4 CoCo directives A CoCo directive shall contain the characters "??" in character positions 1 and 2. A CoCo directive shall not have more than 39 continuation lines. Note 3.4 Examples of CoCo directives are: ?? INTEGER, PARAMETER :: system_A = 1 ?? ERROR *, "system_A = ", system_A ?? IF (.FALSE.) THEN ?? endif ENDNote 3.4 3.3 Including source text Additional text may be incorporated into the source text of a CoCo program during processing. This is accomplished with the INCLUDE line, which has the form INCLUDE char-literal-constant The INCLUDE line is specified in part 1, section 3.4 of this standard. An INCLUDE line in a CoCo FALSE block (6.2.2) is not expanded. The CoCo directives that are part of a CoCo IF construct (6.2) shall not be split across included source text. Section 4 CoCo type declaration directives R401 CoCo-type-declaration-directive is CoCo-dir-start CoCo-type-spec [ , PARAMETER ] :: CoCo-entity-decl-list R402 CoCo-type-spec is INTEGER or LOGICAL R403 CoCo-entity-decl is CoCo-object-name [ CoCo-initialization ] Constraint: A CoCo-object-name shall not be the same as any other CoCo-object-name. R404 CoCo-initialization is = CoCo-initialization-expr CoCo-initialization-expr is defined in R512. Note 4.1 Examples of CoCo type declaration directives are: ?? integer, parameter :: F77 = 1, F90 = 2, F95 = 3 ?? integer :: fortran_level = F90 ?? logical :: debug_procedure_entry_exit ENDNote 4.1 Section 5 CoCo variables, expressions and assignment directive 5.1 CoCo variables R501 CoCo-variable is CoCo-scalar-variable-name Constraint: CoCo-scalar-variable-name shall not have the PARAMETER attribute. Constraint: CoCo-scalar-variable-name shall appear as an object-name in a CoCo-type-declaration-directive before appearing elsewhere in a CoCo program. 5.2 CoCo expressions 5.2.1 CoCo primary R502 CoCo-primary is CoCo-constant or CoCo-variable or ( CoCo-expr ) Constraint: A CoCo-variable shall be defined (8.2) before appearing as a CoCo-primary. 5.2.2 Level-1 expressions R503 CoCo-add-operand is [ CoCo-add-operand mult-op ] primary R504 CoCo-level-1-expr is [ [ CoCo-level-1-expr ] add-op ] CoCo-add-operand 5.2.3 Level-2 expressions R505 CoCo-level-2-expr is [ CoCo-level-1-expr rel-op ] CoCo-level-1-expr 5.2.4 Level-3 expressions R506 CoCo-and-operand is [ not-op ] CoCo-level-2-expr R507 CoCo-or-operand is [ CoCo-or-operand and-op ] CoCo-and-operand R508 CoCo-equiv-operand is [ CoCo-equiv-operand or-op ] CoCo-or-operand R509 CoCo-level-3-expr is [ CoCo-level-3-expr equiv-op ] CoCo-equiv-operand 5.2.5 General form of a CoCo expression R510 CoCo-expr is CoCo-level-3-expr 5.3 Data type of a CoCo expression The data type of a CoCo expression is either Integer or Logical. R511 CoCo-logical-expr is CoCo-expr Constraint: CoCo-logical-expr shall be type logical. 5.4 CoCo initialization expression R512 CoCo-initialization-expr is CoCo-expr Constraint: A CoCo-initialization-expr shall be an initialization expression (need forward reference to Part 1.) The one place in the CoCo language where an intialization expression is used is the CoCo type declaration directives. 5.5 CoCo assignment directive A CoCo variable may be defined or redefined by execution of a CoCo assignment directive. R513 CoCo-assignment-directive is CoCo-dir-start CoCo-variable = CoCo-expr where CoCo-variable is defined in R501 and CoCo-expr is defined in R510. In a CoCo assignment directive, the types of CoCo-variable and CoCo-expr shall either both be integer or both be logical. Note 5.1 Examples of CoCo assignment directives are: ?? debug_level = debug_level + 1 ?? is_company_x_machine = (system == sysE) .OR. (system == sysF) ?? project_level = foo_version + latest_release ENDNote 5.1 Section 6 CoCo execution control and conditional compilation The execution sequence and conditional compilation are controlled by CoCo if constructs. Note 6.1 A CoCo program is not required to contain any CoCo if constructs, CoCo error directives or INCLUDE lines. Execution of such a CoCo program has no effect. END Note 6.1 6.1 CoCo blocks A CoCo block is a sequence of CoCo directives that are treated as a unit. R601 CoCo-block is [ CoCo-directive ] ... CoCo executable constructs may be used to control which CoCo blocks of a CoCo program are executed. 6.2 CoCo IF construct The CoCo IF construct selects for execution no more than one of its constituent CoCo blocks. This CoCo block is called the CoCo TRUE block. The remainder of the CoCo blocks in a CoCo IF construct, if any, are selected to be ignored by the processor. These CoCo blocks are called CoCo FALSE blocks. 6.2.1 Form of the CoCo IF construct R602 CoCo-if-construct is CoCo-if-then-directive CoCo-block [ CoCo-else-if-directive CoCo-block ] ... [ CoCo-else-directive CoCo-block ] CoCo-end-if-directive R603 CoCo-if-then-directive is CoCo-dir-start IF ( CoCo-scalar-logical-expr ) THEN R604 CoCo-else-if-directive is CoCo-dir-start ELSE IF ( CoCo-scalar-logical-expr ) THEN R605 CoCo-else-directive is CoCo-dir-start ELSE R606 CoCo-end-if-directive is CoCo-dir-start END IF Note 6.2 An example of two CoCo if constructs (one nested within the other) is: ?? if (is_company_x_machine) then ?? if (fortran_level == F95) then pure function GetRabbitWeight(a_rabbit) result(weight) type (rabbit), intent(in) :: a_rabbit ?? elseif (fortran_level == F90) THEN function GetRabbitWeight(a_rabbit) result(weight) type (rabbit) :: a_rabbit ?? else ?? ERROR *, "We do not have a FORTRAN 77 product from company X" ?? endif ! (fortran_level == ... ?? else function GetRabbitWeight() result(weight) ! Only have Fortran 90 derived types with company X, so ! return a weight of 1 for now ?? endif ! (is_company_x_machine) ENDNote 6.2 6.2.2 Execution of an IF construct At most one of the CoCo blocks in the CoCo IF construct is executed. If there is a CoCo ELSE directive in the construct, exactly one of the CoCo blocks in the construct will be executed. The CoCo scalar logical expressions are evaluated in the order of their appearance in the construct until a true value is found or a CoCo ELSE directive or CoCo END IF directive is encountered. If a true value or a CoCo ELSE directive is found, the CoCo block immediately following is executed and this completes the execution of the construct. The CoCo scalar logical expressions in any remaining CoCo ELSE IF directives of the CoCo IF construct are not evaluated. If none of the evaluated expressions is true and there is no CoCo ELSE directive, the execution of the construct is completed without the execution of any CoCo block within the construct. Execution of a CoCo END IF directive has no effect. 6.2.2.1 Execution of a CoCo TRUE block Source lines contained in a CoCo TRUE block are selected as possible Fortran statements for the processor and are handled according to the rules in Section 11. 6.2.2.2 Execution of a CoCo FALSE block Source lines contained in a CoCo FALSE block are selected as lines to be ignored by the processor and are handled according to the rules in Section 11. Section 7 CoCo error directive R701 CoCo-error-directive is CoCo-dir-start ERROR * [ , CoCo-output-item-list ] R702 CoCo-output-item is CoCo-expr or CoCo-char-literal-constant Execution of a CoCo ERROR directive informs the processor that an error has occurred during CoCo processing. Note 7.1 Examples of the CoCo error directive are: ?? ERROR *, "system shall be set to 'sys1' or 'sys2'" ?? ERROR *, "system = ", system ?? ERROR * ENDNote 7.1 Section 8 Scope and definition of CoCo variables 8.1 Scope of CoCo variables CoCo variables have the scope of the CoCo program in which they are declared. 8.2 Events that cause CoCo variables to become defined CoCo variables become defined as follows: (1) Execution of a CoCo assignment directive causes the CoCo variable that precedes the equals to become defined. (2) Execution of a CoCo initialization in a CoCo type declaration directive causes the CoCo variable that precedes the equals to become defined. (3) Execution of the CoCo-set-option (10.2) causes the CoCo variable to become defined. Section 9 CoCo program conformance 9.1 A conforming CoCo program A CoCo program shall contain CoCo directives that abide by the syntax and semantics rules previously described in this part of the standard. A processor shall accept CoCo programs, CoCo options (Section 10), and be capable of creating the CoCo file (Section 11). 9.2 A nonconforming CoCo program A processor shall have a mechanism to report a nonconforming CoCo program (erroneous CoCo syntax or erroneous CoCo semantics). In the case of a nonconforming CoCo program, it is processor dependent whether or not the processor will recover and continue with the CoCo program, ignore the rest of the CoCo program and continue processing the Fortran source, or cease processing completely. Section 10 CoCo options There are three CoCo options - the CoCo-on-option, the CoCo-set-option, and the CoCo-file-option. A processor shall supply at least one method of recognizing CoCo options separate from the CoCo program. For example, the invocation line may be the chosen method of communicating CoCo options to the processor. Note 10.1 A second example would be a CoCo input file which could supply all the values for the desired CoCo options. ENDNote 10.1 10.1 The CoCo ON option The CoCo-on-option is a method to specify whether or not the processor is to recognize CoCo programs. Note 10.2 Since it may be desirable to apply conditional compilation only for certain situations, the Fortran programmer is able to specify when the CoCo program is recognized by using the CoCo-on-option. For example, the CoCo program may only be recognized when moving a source program from one operating system to another operating system or when starting or ending debugging sessions. ENDNote 10.2 10.2 The CoCo SET option The CoCo-set-option is a method of either (1) documenting the value of a CoCo PARAMETER or (2) assigning an initial value to a CoCo variable (R501) or (3) overriding the initial value assigned to a CoCo variable in a CoCo initialization expression (R512) without editing the CoCo program. Note 10.3 Recall that a CoCo variable shall not have the PARAMETER attribute. ENDNote 10.3 R1001 CoCo-set-option is CoCo-set-option-variable=CoCo-set-option-literal-constant R1002 CoCo-set-option-variable is CoCo-variable R1003 CoCo-set-option-literal-constant is CoCo-literal-constant Constraint: The CoCo-set-option-variable must be a CoCo variable declared in the CoCo type declaration directive. Constraint: The type of the CoCo-set-option-variable shall match the type of the CoCo-set-option-literal-constant. Constraint: If the CoCo-set-option-variable has the PARAMETER attribute, the value of the CoCo-set-option-literal-constant shall match the value supplied in the CoCo type declaration directive. Constaint: If the CoCo-set-option-variable appears in the CoCo program as the CoCo variable in a CoCo assignment directive, it shall appear at least once in a previous CoCo executable construct. The CoCo-set-option minimally consists of a CoCo-set-option-variable and a CoCo-set-option-literal-constant. A processor may supply additional representations for the CoCo logical literal constant; for example, the characters 'T' or 'F' could be used to represent .TRUE. or .FALSE. respectively. In this case it is as if .TRUE. or .FALSE. were specified as the CoCo-set-option-literal-constant. The CoCo-set-option acts as if a CoCo assignment directive (R513)-- which consists of the CoCo-set-option-variable as the CoCo variable and the CoCo-set-option-literal-constant as the CoCo expression (R510)--were placed immediately following the CoCo type declaration directive that declared the CoCo-set-option-variable. Note 10.4 The value assigned to a CoCo variable with the CoCo-set-option shall not override the value assigned to a CoCo variable with the CoCo assignment directive. ENDNote 10.4 The CoCo-set-option may or may not appear if the CoCo-on-option specifies that the CoCo program is to be recognized by the processor. 10.3 The CoCo FILE option The CoCo file (Section 11) may be created as output from CoCo in order to show exactly which blocks of code, if any, are selected to be ignored by the processor based on the conditional compilation specified with CoCo if constructs. There are different sorts of the CoCo file; each serves to feed a different personal style of Fortran source input or different uses of conditional compilation. The CoCo-file-option is a method of specifying which sort of the CoCo file is desired. The CoCo-file-option minimally consists of a method to specify which sort of the CoCo file is to be generated by the CoCo program--either the CoCo-short-file (11.2), the CoCo-expand-file (11.3), the CoCo-shift-file (11.4), or the CoCo-overwrite-file (11.5). Whether or not the name of the CoCo file may be specified in the CoCo-file-option is processor defined. Note 10.5 The CoCo file need not be generated in order to achieve conditional compilation as executing the CoCo program may result in direct communication to the processor as to which blocks of source text are to be ignore. ENDNote 10.5 If the CoCo-file-option specifies the CoCo-shift-file as the sort of CoCo file, the CoCo program shall not contain a CoCo-overwrite- comment-line (11.1.3) within a CoCo if construct (R602). If the CoCo-file-option specifies the CoCo-overwrite-file as the sort of CoCo file, the CoCo program shall not contain a CoCo-shift- comment-line (11.1.1) within a CoCo if construct. If the CoCo-file-option specifies the CoCo-short-file as the sort of CoCo file, the CoCo program shall not contain both CoCo-shift-comment-lines and CoCo-overwrite-comment-lines within the CoCo if constructs. A processor may require that the CoCo-file-option appear if the CoCo-on-option specifies that the CoCo program is to be recognized by the processor. Section 11 The CoCo file The CoCo file may be created by the execution of CoCo programs. There are three sorts of the CoCo file - the CoCo-short-file, the CoCo-shift-file and the CoCo-overwrite-file. Creating the CoCo file requires recognizing four forms of a CoCo comment line (3.2.2) - the CoCo-shift-comment-line, the CoCo-unshift-comment-line, the CoCo-overwrite-comment-line, and the CoCo-unoverwrite-comment-line. Note 11.1 By creating either the CoCo-shift-file or the CoCo-overwrite-file, it is possible to replace the input source with the CoCo file without losing information. ENDNote 11.1 11.1 CoCo comment lines CoCo comment lines are all source lines that are not CoCo directives or partial CoCo directives. Execution of an CoCo if construct in CoCo programs requires the recognition of two forms of CoCo comment lines -- CoCo shift comment lines and CoCo overwrite comment lines. CoCo comment lines that are CoCo shift comment lines or CoCo overwrite comment lines may be modified by the execution of CoCo TRUE blocks and CoCo FALSE blocks. 11.1.1 CoCo shift comment lines The CoCo-shift-comment-line is a CoCo comment line that has the characters "?>" in character positions 1 and 2 A CoCo comment line that is not a CoCo-shift-comment-line becomes a CoCo-shift-comment-line by shifting its contents 2 character positions to the right and placing the characters "?>" in character positions 1 and 2. If a CoCo comment line becomes a CoCo-shift- comment-line, the length of the CoCo-shift-comment-line shall be equal to two plus the length of the CoCo comment line. The length of the CoCo-shift-comment-line, not including trailing blanks, shall be less than or equal to 132. Note 11.2 For example, these two lines are CoCo comment lines that are not CoCo shift comment lines: !234567890123456789012345678 line_len = 23 .OR. 28 These two lines, turned into CoCo shift comment lines, would become: ?>!234567890123456789012345678 ?> line_len = 23 .OR. 28 ENDNote 11.2 11.1.2 CoCo unshift comment lines The CoCo-unshift-comment-line is a CoCo shift comment line that has been shifted to the left 2 character positions. The length of the CoCo-unshift-comment-line is equal to the length of the CoCo shift comment line minus two. Note 11.3 For example, these two lines are CoCo shift comment lines: ?>!234567890123456789012345678 ?> line_len = 23 .OR. 28 These two lines, turned into CoCo unshift comment lines, would become: !234567890123456789012345678 line_len = 23 .OR. 28 ENDNote 11.3 11.1.3 CoCo overwrite comment lines The CoCo-overwrite-comment-line is a CoCo comment line that has the characters "?*" in character positions 1 and 2. A CoCo comment line that is not a CoCo-overwrite-comment-line becomes a CoCo-overwrite-comment-line by replacing the characters in character positions 1 and 2 with the characters "?*". The replaced characters shall be " " (two blanks). Note 11.4 For example, these two lines are CoCo comment lines that are not CoCo overwrite comment lines (each lines starts with 2 blanks): !78901234567890123456 line_len = 18 These two lines, turned into CoCo overwrite comment lines, would become: ?*!78901234567890123456 ?*line_len = 18 ENDNote 11.4 11.1.4 CoCo unoverwrite comment lines The CoCo-unoverwrite-comment-line is a CoCo overwrite comment line that has replaced the characters "?*" in character positions 1 and 2 with the characters " " (two blanks). The length of the CoCo-unoverwrite-comment-line is equal to the length of the CoCo overwrite comment line. Note 11.5 For example, these two lines are CoCo overwrite comment lines: ?*!78901234567890123456 ?*line_len = 18 These two lines, turned into CoCo unoverwrite comment lines, would become (each lines starts with 2 blanks): !78901234567890123456 line_len = 18 ENDNote 11.5 11.2 The CoCo short file The CoCo-short-file shall consist of all the CoCo comment lines, possibly modified, in the order in which they appear in the CoCo program except those that are in a CoCo FALSE block. There are no CoCo directive lines in the CoCo-short-file. The CoCo-short-file shall have at most the same number of lines as the source text. Included source text from any INCLUDE lines is not expanded in the CoCo-short-file. Execution of a CoCo TRUE block changes each CoCo shift comment line contained in the CoCo TRUE block to a CoCo-unshift-comment-line in the CoCo-short-file according to 11.1.2. Execution of a CoCo TRUE block changes each CoCo overwrite comment line contained in the CoCo TRUE block to a CoCo-unoverwrite- comment-line in the CoCo-short-file according to 11.1.4. Note 11.6 For example, consider the following CoCo program: ?? integer, parameter :: vendorA = 1, vendorB = 2 ?? integer :: using_vendor = vendorA ?? if (using_vendor == vendorA) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER If the CoCo-file-option specifies the CoCo-short-file and the CoCo-set-option is not specified, the following CoCo short file would be created by executing the above CoCo program. INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER ENDNote 11.6 11.3 The CoCo expand file The CoCo-expand-file differs from the CoCo-short-file only by expanding any included source text from any INCLUDE lines. The INCLUDE line is replaced with the included source text. 11.4 The CoCo shift file The CoCo-shift-file shall consist of all the CoCo comment lines, possibly modified, and all the CoCo directive lines in the order in which they appear in the CoCo program. The CoCo-shift-file shall have the same number of lines as the source text. Included source text from any INCLUDE lines is not expanded in the CoCo-shift-file. Execution of a CoCo FALSE block changes each CoCo comment line that is not a CoCo shift comment line contained in the CoCo FALSE block to a CoCo shift comment line in the CoCo-shift-file according to 11.1.1. A processor shall not change a CoCo shift comment line that appears in a CoCo FALSE block. Execution of a CoCo TRUE block changes each CoCo shift comment line contained in the CoCo TRUE block to a CoCo unshift comment line in the CoCo-shift-file according to 11.1.2. Note 11.7 For example, consider the following CoCo program: ?? integer, parameter :: vendorA = 1, vendorB = 2 ?? integer :: using_vendor = vendorA ?? if (using_vendor == vendorA) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then ?> INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER If the CoCo-file-option specifies the CoCo-shift-file and the CoCo-set-option specifies that the value of CoCo variable "using_vendor" shall be "vendorB", the following CoCo shift file would be created by executing the above CoCo program. ?? integer, parameter :: vendorA = 1, vendorB = 2 ?? integer :: using_vendor = vendorA ?? if (using_vendor == vendorA) then ?> INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER ENDNote 11.7 11.5 The CoCo overwrite file The CoCo-overwrite-file shall consist of all the CoCo comment lines, possibly modified, and all the CoCo directive lines in the order in which they appear in the CoCo program. The CoCo-overwrite-file shall have the same number of lines as the source text. Included source text from any INCLUDE lines is not expanded in the CoCo-overwrite-file. Execution of a CoCo FALSE block changes each CoCo comment line that is not a CoCo overwrite comment line contained in the CoCo FALSE block to a CoCo overwrite comment line in the CoCo-overwrite-file according to 11.1.3. A processor shall not change a CoCo overwrite comment line that appears in a CoCo FALSE block. Execution of a CoCo TRUE block changes each CoCo overwrite comment line contained in the CoCo TRUE block to a CoCo unoverwrite comment line in the CoCo-overwrite-file according to 11.1.4. Note 11.8 For example, consider the following CoCo program: ?? integer, parameter :: vendorA = 1, vendorB = 2 ?? integer :: using_vendor = vendorA ?? if (using_vendor == vendorA) then ?* INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER If the CoCo-file-option specifies the CoCo-overwrite-file and the CoCo-set-option is not specified, the following CoCo overwrite file would be created by executing the above CoCo program. ?? integer, parameter :: vendorA = 1, vendorB = 2 ?? integer :: using_vendor = vendorA ?? if (using_vendor == vendorA) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then ?* INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif INTEGER (KIND=FOUR_BYTE_INT) :: ACCOUNT_NUMBER ENDNote 11.8 11.6 Replacing the input file with the CoCo file The above definitions of CoCo shift comment lines, CoCo overwrite comment lines, the CoCo shift file, and the CoCo overwrite file permits replacing the input source file with the CoCo file. Replacing the input source file with the CoCo short file, however, would result in deleting the CoCo program and possibly CoCo comment lines. Note 11.9 For example, consider the CoCo if construct: ?? if (using_vendor == vendorA) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif If the CoCo-file-option specifies the CoCo-overwrite-file and CoCo variable "using_vendor" is set to "vendorA", the following would appear in the CoCo overwrite file created by executing the above CoCo if construct. ?? if (using_vendor == vendorA) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then ?* INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *,"Set 'using_vendor' correctly on the CoCo-set-option" ?? endif If the CoCo-file-option specifies the CoCo-overwrite-file and CoCo variable "using_vendor" is set to "vendorB", the following would appear in the CoCo overwrite file created by executing the above CoCo if construct. ?? if (using_vendor == vendorA) then ?* INTEGER, PARAMETER :: FOUR_BYTE_INT = 1 ?? elseif (using_vendor == vendorB) then INTEGER, PARAMETER :: FOUR_BYTE_INT = 4 ?? else ! error with the value of using_vendor on CoCo-set-option ?? error *, "CoCo variable 'using_vendor' shall be set to 1 or 2" ?? error *, "Set 'using_vendor' correctly on the CoCo-set-option" ?? endif If the CoCo-file-option specifies the CoCo-overwrite-file and CoCo variable "using_vendor" is set to the value 3, the contents of the CoCo overwrite file created by executing the above CoCo if construct is processor defined. ENDNote 11.9 ------------------------------------------------------------------------ EXAMPLES The following are examples of CoCo programs and CoCo files that result from CoCo processing. The examples to be completed for electronic distribution.