Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How many bytes in DIMENSION? - A Fortran Question

  1. Jun 25, 2007 #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:
     
  2. jcsd
  3. Jun 25, 2007 #2
    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
     
  4. Jun 25, 2007 #3

    rcgldr

    User Avatar
    Homework Helper

    Unless Fortran has changed since I last used it, intergers are I->N, not I->T.
     
  5. Jun 25, 2007 #4
    Good call :blushing::surprised: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 :tongue2:
     
    Last edited: Jun 25, 2007
  6. Jun 25, 2007 #5

    rcgldr

    User Avatar
    Homework Helper

    Note that the choice of I->N coincides with common mathematical usage (for example, usually i->n are used as subcripts for series).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: How many bytes in DIMENSION? - A Fortran Question
  1. Fortran question (Replies: 2)

  2. Fortran Question (Replies: 32)

Loading...