To: J3 J3/19-248 From: Van Snyder Subject: Formal specifications for conditional form Date: 2019-October-16 Reference: 18-274 Three conditional forms are described in 220-wvs-006. 1. One selects among several subexpressions. 2. One selects among variables that can appear in statement specifiers or as input items in input lists. 3. One selects among several actual arguments. They all have similar syntax. In principle, a conditional form can be viewed as "if ( logical expression 1 ) then ( selection 1 ) [ else if ( logical expression 2 ) then ( selection 2 ) else if ( logical expression 3 ) then ( selection 3 ) ] ... [ else ( selection n ) endif ]" A. A conditional form shall have at least one logical expression and allow an indefinite number of additional logical expressions. B. Each logical expression corresponds to a selection. C. A selection may be a subexpression, a variable, or a conditional form. (i) If a conditional form is an actual argument, and the corresponding dummy argument has INTENT(OUT) or INTENT(INOUT), every selection, including those within a nested conditional form, shall be a variable or a conditional form. (ii) If a conditional form is an expression that is an actual argument, and the corresponding dummy argument has unspecified or unknown intent, and execution of the procedure assigns a value to the dummy argument or causes it to become undefined, each selection, including those within a nested conditional form, shall be a variable or a conditional form. (iii) If a conditional form corresponds to a statement specifier that produces a value and therefore requires the corresponding entity to be a variable, each selection, including those within a nested conditional form, shall be a variable or a conditional form. (iv) Otherwise, each selection, including those within a nested conditional form, may be a subexpression, a variable, or a conditional form. D. Form (1) and form (2) shall contain a final additional selection. E. If form (3) corresponds to a non-optional dummy argument, the conditional form, and every selection within it that is a conditional form, shall contain a final selection that does not correspond to any logical expression. If it corresponds to an optional dummy argument, it is permitted not to include a final selection, and a nested conditional form is permitted not to include a final selection. F. Every subexpression or variable that is a selection within a conditional form, including within a nested conditional form, shall have the same type, kind type parameter values, and rank. G. If a conditional form is an actual argument that corresponds to a dummy argument that has the ALLOCATABLE attribute, every selection, including those within a nested conditional form, shall have the ALLOCATABLE attribute. If a conditional form is an actual argument that corresponds to a dummy argument that has the POINTER attribute, every selection, including those within a nested conditional form, shall have the POINTER or TARGET attribute. H. The logical expressions are evaluated in the sequence they appear until one is found to be true, or none remain. I. If one of the logical expressions is found to be true, no further logical expressions are evaluated, and the corresponding selection is selected. J. If no logical expression is true, and there is a final selection, that selection is selected. K. No part of a selection that is not selected shall be evaluated. L. If a selection is selected (i) If it is a variable, expressions necessary to identify the variable, such as subscripts and substring selectors, are evaluated. If the conditional form corresponds to a dummy argument, the variable, not its value, is the actual argument. (ii) Otherwise, if it is a subexpression, it is evaluated. (iii) Otherwise, it is a conditional form; steps H-M are repeated. M. If no selection is selected, the conditional form must necessarily correspond to an optional dummy argument (specification E), and the actual argument is considered not to be present.