How many bytes in DIMENSION? - A Fortran Question

Click For Summary

Discussion Overview

The discussion revolves around understanding the 'dimension' type in Fortran, specifically regarding how to determine the data type of variables declared with this type, whether they are integers or floating-point numbers, and how to calculate the number of bytes they occupy in memory.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant notes that the 'dimension' type is an outdated method for declaring arrays and that the type of numbers stored depends on how the array was declared.
  • Another participant provides examples of declarations, explaining that the number of bytes occupied by the variable can be calculated by multiplying the size of a single element by the number of elements in the array.
  • There is a correction regarding the automatic typing rules in Fortran, with one participant asserting that integers are designated by the letters I to N, not I to T.
  • A later reply acknowledges the correction and humorously reflects on the common mistake of confusing the letters used for integer designation.
  • Another participant mentions that the choice of I to N aligns with common mathematical conventions, where these letters are often used as subscripts in series.

Areas of Agreement / Disagreement

Participants express some agreement on the automatic typing rules in Fortran, but there is a correction regarding the specific letters used for integers, indicating a lack of consensus on the original claim.

Contextual Notes

There are unresolved assumptions regarding the specific version of Fortran being discussed and whether any changes have occurred in the language's typing rules.

dimensionless
Messages
461
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).
 

Similar threads

Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 5 ·
Replies
5
Views
2K