Printing 1D array in Fortran as 2D array

Click For Summary

Discussion Overview

The discussion revolves around printing a one-dimensional array in Fortran as if it were a two-dimensional array. Participants explore the syntax and methods for achieving this, including the use of specific operators and the structure of arrays in Fortran.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants suggest using the WRITE statement with array slicing to print all row entries in a column format.
  • One participant notes that in C, two-dimensional arrays are essentially arrays of one-dimensional arrays, which implies certain storage characteristics.
  • There is a correction regarding the syntax of the DO loop, with emphasis on the correct use of commas and colons in array operations.
  • Participants express confusion over terminology, such as misidentifying a colon as a semicolon, indicating a potential mix-up with other programming languages.
  • Some posts are deleted, leading to questions about the relevance of those contributions and the practice of deleting posts in the forum.

Areas of Agreement / Disagreement

Participants generally agree on the method of printing array entries but express differing views on the syntax details and the relevance of deleted posts. The discussion remains somewhat unresolved regarding the implications of deleting posts.

Contextual Notes

There are limitations in the clarity of syntax corrections and the potential confusion arising from mixing programming languages, which may affect understanding.

BC2210
Messages
17
Reaction score
0
Delete..

Delete..
 
Last edited:
Technology news on Phys.org
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:
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
I don't think you want that first comma after the DO.
minger said:
You can use the semi-colon as an implicit "all" when operating on arrays.
This character - : - is a colon. This one - ; - is a semicolon.
 
Right-o, as far as the comma, I occasionally get f90 and ANSYS APDL mixed up a bit. Also can't believe I called a, ':', a semi-colon. 1:11pm, perhaps, I was in a lunch daze.
 


BC2210 said:
Delete..
BC2210,
Although it's possible for you to delete your own post, it's not a good idea to do so. Other people can possibly learn from your question.
 
but why you want to delete the post was it not relevant
 
may be it was
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
64
Views
10K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K