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

Fortran 90 array allocation

  1. Nov 20, 2012 #1
    Hello forum,

    I was wondering if there is a way to declare/define arrays depending on some previously defined variable.


    if a=2, then declare/define 2 arrays
    if a=3, then declare/define 3 arrays

    If doable, how does one assign names to these arrays?
  2. jcsd
  3. Nov 20, 2012 #2
    what you can do is declared all 3 arrays as "allocatable", then, depending on a=2 or a=3, you go ahead and allocate as necessary.

    please read up on "allocatable" and take a shot at some Fortran code. Hint: it's very, very simple.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook