To: J3 J3/19-223 Subject: Edits for Conditional form From: Van Snyder Date: 2019-September-29 Reference: 18-274 Edits pursuant to specs and syntax in 18-274 ============================================ [48:12- 6.2.5 Statement Labels-] Before subclause 6.2.5 Statement Labels, insert a subclause "6.2.4a Conditional forms A conditional form allows to select one of several entities. R611a <> IF ( ) THEN ( ) [ ELSE IF ( ) THEN ( ) ] ... [ ELSE ( ) ] END IF R611b <> <> <> <> <> <> C602a (R611a) If is not an actual argument that corresponds to an optional dummy argument, or is not a that appears within a that is an actual argument that corresponds to an optional dummy argument, ELSE ( ) shall appear. C602b (R611b) shall not be . {For syntax disambiguation} R611c <> C602c (R611c) Every within shall be . R611d <> C602d (R611d) Every within shall be . R611e <> C602e (R611e) Every within shall be . R611f <> C602f (R611f) Every within shall be a . R611g <> C602g (R611g) Every within shall be a . C611h <> C602h (R611h) Every within shall be a . R611i <> C602i (R611i) Every within shall be . R611j is C602j (R611j) Every in shall be . R611k is C602k (R611k) Every in shall be a that is a . Evaluating a conditional form consists of evaluating the s in the order they appear until the value of one is true or all have been evaluated. When the value of one is true, the corresponding is selected, and no further s are evaluated. If none is true, the in the ELSE ( ) part, if it appears, is selected. If ELSE ( ) part does not appear and no is true, no is selected. If the selected is , the foregoing process is repeated. The attributes of a conditional form are those of the selected , if any is selected. In a constraint that requires a certain attribute, or one of several attributes, or prohibits an attribute, the constraint applies to each individually. Where normative text requires a certain attribute, or one of several attributes, or prohibits an attribute, the requirement applies to each individually. NOTE For example, in a that is a , each in is required to be a . [123:9+] Add a right-hand side for R901 <> ... " <> [124:1- 9.3 Constants-] Before 9.3 Constants, add a subclause " 9.2a Selector A selector is either an expression or a variable. R907a <> R907b <> <> If is , it allows to select one of several variables or expressions. As an actual argument that corresponds to an optional dummy argument, it allows to specify whether an actual argument is present. A conditional selector is a variable if and only if every is a variable. Otherwise it is an expression. C907b (R907b) Each in shall have the same declared type, kind type parameter values, and rank. C907c (R907b) In a reference to a generic procedure, each in shall have the same corank, and if any in a has the ALLOCATABLE or POINTER attribute, each shall have that attribute. In a constraint that requires a certain attribute, or one of several attributes, or prohibits an attribute, the constraint applies to each selection individually. Where normative text requires a certain attribute, or one of several attributes, or prohibits an attribute, the requirement applies to each selection individually. [132:11 R932 9.7.1.1 Form of the ALLOCATE statement] Replace R929 "R929 <> " [132:15-16 R932 9.7.1.1 Form of the ALLOCATE statement] Replace the definition of with "R932 <> [132:21 after in 9.7.1.1 Form of the ALLOCATE statement] insert a constraint: "C931b (R932) Every in shall be a or a that is a . " [136:6-8 R939 9.7.2 NULLIFY statement] Replace R939 "R939 <> <> <> [138:13 9.7.4 STAT specifier] Replace R942 "R942 <> [154:12- 10.1.7p2- Evaluation of operands] Insert a paragraph: If an operand is a conditional form, only the selected is evaluated. [158:29+ 10.1.12 Constant Expression] Insert a list item after (4)(b)(iii): " (4') a in which every and every is a constant expression," [164:29-30 10.2.2.2 Syntax of the pointer assignment statement] Replace R1034 "R1034 <> C1014a (R1034) Every within shall be a or a that is a and every shall be . " [165:21-22 10.2.2.2 Syntax of the pointer assignment statement] Replace R1038 "R1038 <> C1026a (R1038) Every within shall be or . " [174:13-14 11.1.3.1p1 Purpose and form of the ASSOCIATE construct] Delete R1105 because it's replaced above by R907a. [174:19 11.1.3.1p1 Purpose and form of the ASSOCIATE construct] Delete C1104 because it's replaced above by C602b. [180:24 11.1.7.2 Form of the DO construct] Replace R1124 "R1124 <> C1120a (R1124) Every within shall be . " [204:4-6 11.6.7 EVENT POST statement] Replace R1171 and C1176: "R1171 <> C1176 (R1171) Every within shall be a scalar variable of type EVENT_TYPE from the intrinsic module ISO_FORTRAN_ENV (16.10.2). " [205:2 11.6.9 FORM TEAM statement] Replace R1177 "R1177 <> " [206:5 11.6.10 LOCK and UNLOCK statements] Replace R1182 and C1182 "R1182 <> C1182 (R1182) Every within shall be a scalar variable of type LOCK_TYPE from the intrinsic module ISO_FORTRAN_ENV (16.10.2). " [216:32 12.5.1 Referring to a file] Replace R1203 "R1203 <> C1200a (R1203) Every within shall be a . " [220:11 12.5.6.2 Syntax of the OPEN statement] the NEWUNIT= right-hand side of R1205 " <> NEWUNIT = " [220:19 12.5.6.2 Syntax of the OPEN statement] Replace R1207 "R1207 <> " [225:15 12.6.2.1 Syntax] Replace the ID= right-hand side of R1213 " <> ID = " [225:23 12.6.2.1 Syntax] Replace the SIZE= right-hand side of R1213 " <> SIZE = " [225:24 12.6.2.1 Syntax] Delete R1214 because it's no longer used [246:15 12.10.1 Forms of the INQUIRE statement] Replace the IOLENGTH specifier part of R1230 " <> INQUIRE ( IOLENGTH = ) \smudge " [246:23-247:29 12.10.2.1 Syntax] Replace "" with "" everywhere it appears within the right-hand side of R1231 . [247:5:17 12.10.2.1 Syntax] Replace "" with ". [247:13-26 12.10.2.1 Syntax] Replace "" with ". [301:19-20 15.5.1p4 R1524] Replace | with : "R1524 <> " [301:19-20 15.5.1p4 C1535] Replace C1535, whose only purpose was syntax disambiguation, which is not needed because R611b has the same constraint (C602b). "C1535 (R1524) Where is , each shall conform to the requirements of the corresponding dummy argument. " [302:3+ 15.5.1p4 C1537+] Insert a constraint: "C1537a (R1524) Where is , a that is a coindexed object shall not have a pointer ultimate component. " [310:30 15.5.2.12 Argument presence and restrictions on arguments not present] Remove "or" from the second item in the list, and add a third item: o corresponds to a conditional form in which no is selected, or " [404:25 16.9.152 PRESENT (A)] After "PRESENT function appears" append ", or a conditional form in which every selection is the name of such a dummy argument". [404:27 16.9.152 PRESENT (A)] After "A is present (15.5.2.12)" insert ", or if A is a conditional form in which a selection is selected and the selection is present". [536:1+ C.4+ Clause 9 notes] Insert a new subclause "C.4.1 Conditional forms (9.2a) Conditional forms have many uses. Within an expression, one useful application is to select between the value of an optional argument, and a default value: {\cf myFormat = if ( present ( formatArg ) ) then & & ( "(" // formatArg // ")" ) & & else ( "(f10.4)" ) end if } The MERGE intrinsic function could not be used for this purpose because when a function is invoked, all of its argument expressions are evaluated. If {\cf formatArg} is not present, it cannot be evaluated. Another application is within the declaration of an automatic variable: {\cf ! We don't need the WORK variable if B is not present: real :: Work ( if ( present(b) ) then ( size(b) ) else ( 0 ) end if ) } Another application is to compute whether actual arguments are present: {\cf call AbsorptionCrossSection ( beta, & & if ( wantTemperatureDeriv ) then ( temperatureDeriv ) end if, & & if ( wantLineCenterDeriv ) then ( lineCenterDeriv ) end if, & & if ( wantDopplerWidthDeriv ) then ( dopplerWidthDeriv ) end if, & & if ( wantTempSensitivDeriv) then ( tempSensitivityDeriv) end if ) } Expressing this statement using an IF construct would require sixteen s to enumerate all possible combinations of requested derivatives.