Fortran spacing/coordinate question

  • Context: Fortran 
  • Thread starter Thread starter kevin86
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary

Discussion Overview

The discussion revolves around how to control the placement of printed characters, specifically asterisks, in Fortran. Participants explore methods for formatting output in a way that allows for precise positioning on the output screen, considering both memory efficiency and ease of implementation.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires whether Fortran's write/print command allows for specific placement of characters in a row-column format without manually counting spaces.
  • Another participant suggests creating a character array filled with spaces and asterisks, and printing one row at a time as a potential solution.
  • A participant expresses the need to assign x and y coordinates to each asterisk for precise placement, indicating a preference for this method.
  • It is proposed that using a character variable to hold a format statement could save memory compared to using a character array.
  • One participant questions the relevance of memory space concerns on modern PCs, while another emphasizes that memory issues are significant for their use case.
  • A format statement example is provided, suggesting that it could be more memory-efficient than a character array if certain conditions are met.
  • There is a discussion about the trade-offs between ease of implementation and memory efficiency in the proposed methods.

Areas of Agreement / Disagreement

Participants express differing views on the importance of memory efficiency versus ease of implementation, indicating that there is no consensus on the best approach to the problem.

Contextual Notes

Participants mention varying experiences with memory limitations, which may influence their perspectives on the proposed solutions. The discussion includes assumptions about the efficiency of different methods without resolving these assumptions.

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 ·
Replies
8
Views
4K
  • · Replies 22 ·
Replies
22
Views
5K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 26 ·
Replies
26
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K