fortranfortran95

Same value assignment of multiple variables in a single statement


Is there a way where I can assign the same value for different variables without constructing an array in a single statement?

For example, if I have variables a,b,c,d, and e, can I assign something like

a=b=c=d=e=10.0 

?

I know that I can do in a single line:

a=10.0; b=10.0; c=10.0; d=10.0; e=10.0

But that is not I want since if I want to change the value 10.0 later to something else, I have to make the change everywhere.


Solution

  • Come on Fortranners, you know you want to ...

    equivalence(a,b,c,d,e)
    

    Now all those rascals are going to have the same value at all times.