This is a question that has probably been asked here before.
What does intent(in) mean for a pointer component of a
derived type dummy argument? My reference says that the
intent(in) applies to all subobjects, but a pointer object
can't have the intent attribute. Is it allowed that the
target of the pointer be modified as long as the pointer
itself is not?
I usually sidestep the issue by declaring it inout whenever
there is a question, but in my current case it is an argument
to a defined assignment procedure which must be intent(in).
Some background for those interested: I have a derived type
type :: box
type(boxcore), pointer :: contents
end type box
and a pair of procedures link/unlink which do things like
"box1%contents => box2%contents" together with updating a
reference counter component of the "contents" variable.
This allows the contents to be deallocated when it is no
longer referenced by any other "box". Unfortunately,
intrinsic assignment, box1 = box2, is automatically
available which is equivalent to box1%contents => box2%contents
and breaks the reference counting procedure. In order to
make it robust, I want to disable intrinsic assignment
by providing a defined assignment that prints an error
message, or better, just performs the link(box1,box2)
procedure. But in this case the reference counter in
the contents of the rhs (box2) is updated. So can box2
be intent(in)?
Thanks!
Neil
--
Neil N. Carlson [log in to unmask]
Motorola Computational Materials Group [log in to unmask], [log in to unmask]
Los Alamos National Laboratory Voice: 505-665-1220
Mailstop B221, Los Alamos, NM 87545 FAX: 505-665-5757
|