Printing 1D array in Fortran as 2D array

In summary, the conversation is about deleting a post and using a semi-colon as an implicit "all" when operating on arrays. The participants also discuss the difference between a colon and a semi-colon and the importance of not deleting posts as they may be helpful to others.
  • #1
BC2210
17
0
Delete..

Delete..
 
Last edited:
Technology news on Phys.org
  • #2
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.
 
  • #3
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:
  • #4
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.
 
  • #5
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.
 
  • #6


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.
 
  • #7
but why you want to delete the post was it not relevant
 
  • #8
may be it was
 

1. How can I print a 1D array in Fortran as a 2D array?

To print a 1D array in Fortran as a 2D array, you can use a DO loop to iterate through the array and print each element in the desired format. You can also use the RESHAPE function to convert the 1D array into a 2D array before printing.

2. What is the purpose of printing a 1D array as a 2D array in Fortran?

The purpose of printing a 1D array as a 2D array in Fortran is to visualize the data in a more organized and structured format. This can be helpful in understanding the data and identifying any patterns or trends.

3. Can I specify the number of columns when printing a 1D array as a 2D array in Fortran?

Yes, you can specify the number of columns when printing a 1D array as a 2D array in Fortran using the RESHAPE function. This allows you to control the layout of the printed array and make it easier to read.

4. Is it possible to print a 1D array as a 2D array in Fortran without using a DO loop?

Yes, it is possible to print a 1D array as a 2D array in Fortran without using a DO loop by using the RESHAPE function. This function allows you to reshape the array without having to iterate through each element.

5. Can I print a 1D array as a 2D array in Fortran with non-numeric data?

Yes, you can print a 1D array as a 2D array in Fortran with non-numeric data. However, the RESHAPE function may not work for non-numeric data. In this case, you can use a DO loop to iterate through the array and print each element in the desired format.

Similar threads

  • Programming and Computer Science
Replies
20
Views
1K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
1
Views
510
  • Programming and Computer Science
Replies
20
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
32
Views
2K
Replies
7
Views
725
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
Replies
22
Views
6K
Back
Top