Sorry for all the posts on equivalence but each time I complete 1, the next one creates a slightly different issue.
I am down to the final one in my old code. I have an included file that defines the following…
integer, parameter :: mj = 4000
integer, parameter :: mh = 4
integer, parameter :: me = 9
double precision :: element(mj, me)
double precision :: velement(mj, me)
double precision :: hydrogen(mj), vhydrogen(mj)
equivalence (element,hydrogen) , (velement,vhydrogen)
If I then search the actual file that uses this include file, I have 55 for element
, 14 for velement
, 66 for hydrogen
and no matches for vhydrogen
.
That tells me that I am only interested in the equivalence (element,hydrogen)
If I look at some of the element
lines I get this such as…
element(j, k) = velement(j, k)
element(i, k) = element(mj, k)
element(j + 1, k) = element(j, k)
And so on.
Considering there are 55 for element and 66 for hydrogen (though many of them are not assignments that affect either variable’s contents), I feel I need to add the following…
element(j, k) = velement(j, k)
hydrogen(j) = velement(j,k)
element(i, k) = element(mj, k)
hydrogen(i) = element(mj, k)
element(j + 1, k) = element(j, k)
hydrogen(j + 1) = element(j, k)
The only issue is that each of those lines are within a loop that alters k, whilst hydrogen does not vary by this index; so I am assuming I could just as easily do this…
hydrogen(j) = velement(j, 1)
hydrogen(i) = element(mj, 1)
hydrogen(j + 1) = element(j, 1)
Again, my only thought is that it shouldn’t be for (2) = 1 but for (2) = k, where k is at it’s maximum value (which is me
). So…
hydrogen(j) = velement(j, me)
hydrogen(i) = element(mj, me)
hydrogen(j + 1) = element(j, me)
Am I right in my thinking here?