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

How do i 'relabel' variables (in fortran)

  1. Jun 26, 2009 #1
    Suppose I have a global variable like "GauntCoefficients".. and I want to use it in a formula in the next block of code. In C++, I might do something like this to make the code more readable:

    const int* gc = GauntCoefficients;
    (then write some nasty formula with "gc" rather than "GauntCoefficients" everywhere)

    Since "gc" is declared here as a constant, the compiler should just delete it (I think). And since "gc" id declared locally.. it doesn't pollute the namespace.

    Can I do something like that in Fortran?
     
  2. jcsd
  3. Jun 28, 2009 #2
    Hey
    In Fortran 90 and newer pointers are possible to use. But they are more restrictive than in e.g. C/C++.
    You can therefore do something like this:
    Code (Text):
    integer, target::GauntCoefficients
    integer, pointer::gc
    gc=>GauntCoefficients
    I hope this helps.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How do i 'relabel' variables (in fortran)
Loading...