fortran90 - Using array member as the control variable of do loop in fortran -


I was surprised that you can not keep the array member in the loop as a control variable for the loop: < / P>

  Program testing integer, dimension (2) :: I do (1) = 1, do 3 (2) = 1, 3!  

Edit: > Or is it allowed but am I doing wrong?

There is an error message from ifort v 11.1:

  test.f90 (4): Error # 5082: The syntax error, while expecting one of the identifier 'I' Found: (%:. = = & Gt; I (1) = 1, 3 ------- ^ test.f90 (4): Error # 5082: Syntax error, found ',' when these There is no hope: & lt; END-OF-STATEMENT & gt; I (1) = 1, 3 --------------- ^ test.f90 (5): Error # 5082: Syntax error, while identifying 'I' found one: (%:. = = & Gt; I (2) = 1, 3 ------- ^ test.f90 (5): Error # 5082: Syntax error, found ',' when one of these It is: & lt; END-OF-STATEMENT & gt; I (2) = 1, 3 --------------- ^ Test .f90 (4): Error # 6535: This The variable or component must be derived or structure type [DO] I (1) = 1, 3 ---- ^ test.f90 (4): error # 6460: This is not a field name, defined in the surroundings ING structure [I] I (1) = 1, 3 ------- ^ test.f90 (8): Error # 6099: An EDDO ​​statement happened without a related DO or DO WHILE statement. End - --- ^ test.f90 (9): Error # 6099: Without any related DO or DO WHILE statement of an ENDDO statement Happened. Ending ---- ^  

error message from Goffron V4.5.1; 4.8.3:

  test.f90: 4.4: I (1) = 1, 3 error: Unclassifiable statement (1) test.f90: 5.4: i (2) = 1, 3 1 Error: (1) Unclassified Statement on test.f90: 8.7: End 1 Error: (1) test.f90: 9.7 Expect the details of the end program: End 1 Error: Expecting the End Program Statement (1 < / B> 

Sorry for the wrong answer before me.

According to restriction language rules:

FORTRAN 2008 (ISO / IEC 1539-1: 2010) 8.1.6.2:

R818 Loop-control RANGE is , two-variable = ...

R819 two-variable , Scalar -Inti-Variable-Name

C812 (R819) will be a variable of two types of integers.

< P> So, only one scalar variable name is allowed in the position of the loop control variable.

If you ask why the rule language is this way, you can use standard, SC 22 / WG5 and X3 J. 3 has to ask the author, but I think that as a fixed-source Syntax is related to the necessity of nonconformity. Spaces are not important as a fixed source and it is difficult to come up with a clear grammar.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -