BC2210
- 17
- 0
Delete..
Delete..
Delete..
Last edited:
The discussion focuses on printing a 1D array in Fortran as a 2D array using the WRITE statement. A specific example is provided with a REAL array defined as REAL,DIMENSION(2,3) :: array, and the correct syntax for printing each row is demonstrated using a DO loop. The use of the colon (:) as an implicit "all" operator for array operations is emphasized, clarifying its functionality in Fortran. Additionally, a common mistake regarding the placement of commas in the DO statement is noted.
PREREQUISITESThis discussion is beneficial for Fortran programmers, educators teaching array operations, and developers transitioning from C to Fortran who need to understand array printing techniques.
REAL,DIMENSION(2,3) :: array
DO,i=1,2
WRITE(6,*) array(i,:)
END DO
I don't think you want that first comma after the DO.minger said:They're not crazy, if I want to print all row entries in a column, then:
Code:REAL,DIMENSION(2,3) :: array DO,i=1,2 WRITE(6,*) array(i,:) END DO
This character - : - is a colon. This one - ; - is a semicolon.minger said:You can use the semi-colon as an implicit "all" when operating on arrays.
BC2210,BC2210 said:Delete..