How do i 'relabel' variables (in fortran)

  • Context: Fortran 
  • Thread starter Thread starter tothetop
  • Start date Start date
  • Tags Tags
    Fortran Variables
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
tothetop
Messages
2
Reaction score
0
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?
 
Physics news on Phys.org
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:
integer, target::GauntCoefficients
integer, pointer::gc
gc=>GauntCoefficients

I hope this helps.