Fortran Fortran spacing/coordinate question

  • Thread starter Thread starter kevin86
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
The discussion centers on the limitations of the Fortran write/print command for positioning output on the screen, specifically regarding the placement of asterisks or other characters in a grid format. Participants explore the idea of creating a character array filled with spaces and asterisks to control output placement without manually counting spaces. The conversation highlights the use of a character variable to hold a format statement, which can optimize memory usage compared to using a character array, although some participants express that memory constraints are not a significant concern on modern PCs. The efficiency of using a single format string for multiple lines and a coordinate array for asterisks is also discussed, with considerations for both implementation ease and memory efficiency. Overall, the thread emphasizes strategies for managing output formatting in Fortran while balancing memory considerations.
kevin86
Messages
20
Reaction score
0
Since the graphing idea is not available. Does the fortran write/print command let me choose where a number or * is printed at. Like a row column thing if I want to print say a * on the page.

Code:
*                                *                              *

*             *                                *                *

Something like that. Can I make sure it ends where I want it to end up without counting how many spaces it takes to display something.
 
Last edited:
Technology news on Phys.org
Create a character (text) array the size of a print line. Fill it with spaces and asterisks., then print it. You could create a matrix, then print out one row at a time.
 
I suppose this is the way to do it. I actually needed to give each asterisk an x and y coordinate value, so I can print them out anywhere I choose. But I try this.
 
You can use a character variable to hold a format statement. That would save you some memory space over jeff's method.
 
how do i do that, please help, point me in the right direction
 
franznietzsche said:
You can use a character variable to hold a format statement. That would save you some memory space over jeff's method.
I don't think memory space is an issue on a PC in this case. Also if the plot is an alternating pattern of asterisks and spaces, then the character variable for the format statement would be longer than just character array.
 
I don't really need *, I am happy to use 0 and 1 etc
 
Jeff Reid said:
I don't think memory space is an issue on a PC in this case. Also if the plot is an alternating pattern of asterisks and spaces, then the character variable for the format statement would be longer than just character array.

Well, memory is always an issue for me, on every machine I've used (No 4 GB of RAM isn't really enough. Nor is 500 GB of disk storage), so i thought I'd suggest it.

A format statement of the form:

'(1A, NX, 1A, NX,...)'

will be shorter than the array if N is on average greater than 4.

Also, if you have many lines, it will be more efficient to have one format string that the program creates, and a single array holding coordinates for each *.

On the other hand, I'm used to dealing with 3-D data arrays that have more than 8 million cells, and needing to store a half dozen arrays with that many cells in double precision. So my concern may be unwarranted. I do think your method would be easier to implement, just less memory efficient.
 

Similar threads

Replies
8
Views
4K
Replies
22
Views
5K
Replies
19
Views
6K
Replies
13
Views
3K
Replies
5
Views
3K
Replies
8
Views
4K
Replies
6
Views
3K
Replies
13
Views
4K
Back
Top