I have something unexpected happening. I thought it was a compiler bug but
having picked it to pieces I wanted to check here first.
The situation is as follows. I have a derived type T. I declare some scalar
variables of that type. I pass them one by one to a routine sub1 that
modifies them, that is fine.
To simplify things at the calling end I redefined the routine to operate on
an array of type T. My intention was to use "call sub2([x,y,z])" for example
instead of three individual calls. However it turns out that modifications
to the array elements x,y,z are local to sub2, and on exit the structures
revert to their original values. On the other hand, if I work with an array
of type T instead of discrete scalars everything does what I expect.
I can supply source code if it helps.
It seems as if the array constructor [x,y,z] produces an array containing
copies of x,y,z and modifications to these do not affect the originals. Is
that what the problem is? I have been sat here with my Fortran books for
some time trying to find anything that refers to this, to no avail.
Thanks to anyone that can help me out,
Simon.
|