Printing 1D array in Fortran as 2D array

• Fortran
Delete..

Delete..

Last edited:

minger
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

You can use the semi-colon as an implicit "all" when operating on arrays.

Yes. In C, two-dimensional arrays are simply one-dimensional arrayswhose element type is itself a one dimensional array. Since one-dimensional arrays are required to occupy contiguous storage, itfollows that the same must be true for an array of arrays.

Thanks
__________
Techstore are specialists in a range of http://www.techstore.ie/Design-Print/index.html" Services

Last edited by a moderator:
Mark44
Mentor
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
I don't think you want that first comma after the DO.
You can use the semi-colon as an implicit "all" when operating on arrays.
This character - : - is a colon. This one - ; - is a semicolon.

minger