Fortran How many bytes in DIMENSION? - A Fortran Question

AI Thread Summary
In Fortran, the 'dimension' type is used for declaring arrays, with the type of numbers stored in the array determined by how the array is declared. For example, a declaration like "real A" followed by "dimension A(10)" creates a vector of 10 real numbers, while "dimension B(2,2)" creates a 2-by-2 matrix of reals. The memory layout stores these elements in adjacent locations, with column-major order for matrices. The type of the variable can be inferred from its name: if it starts with letters A-J or U-Z, it is a real number; if it starts with I-N, it is an integer. The total memory occupied by the variable is calculated by multiplying the size of a single element by the total number of elements in the array. There was a clarification regarding the integer range, confirming that it is I-N, not I-T, aligning with common mathematical conventions.
dimensionless
Messages
460
Reaction score
1
How many bytes in DIMENSION?? - A Fortran Question

I'm looking at some Fortran code. Some variables are of type dimension. How do I tell if these variables are integers or floating points numbers? How do I know if they are signed or unsigned? How do I tell the number of bytes occupied by the variable?:confused:
 
Technology news on Phys.org
The 'dimension' type is an slightly out-dated way to declaring arrays (vectors, matrices, and higher dimensional arrays). What type of numbers are stored in the array depends on how the name of the array was declared. For example, if I type:

real A
dimension A(10)
real B
dimension B(2,2)

then A will be a vector of 10 reals. These 10 reals will be stored in 10 adjacent memory locations. B will be a 2-by-2 matrix of reals also stored in adjacent memory locations by column ( (1,1) then (2,1) then (1,2) then (2,2) ). And if there is no declaration like 'real A', then remember the fun FORTRAN protocol of automatic typing:

- If the first letter starts with A - J or U - Z, then it's a real
- If the first letter starts with I - T, then it's an integer.

The number of bytes occupied by the variable in memory will be the size of a single element of the array multiplied by the number of elements in the array.

- Jason
 
Unless Fortran has changed since I last used it, intergers are I->N, not I->T.
 
Jeff Reid said:
Unless Fortran has changed since I last used it, intergers are I->N, not I->T.

Good call :blushing: :blushing:

I always try to remember it from the letters in INteger...but occasionally when I'm not thinking (which is surprisingly often) I pick the wrong two letters in InTeger :-p
 
Last edited:
Note that the choice of I->N coincides with common mathematical usage (for example, usually i->n are used as subcripts for series).
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Back
Top