The difference between inout and pointer-pointer arguments

What is the practical difference in

subroutine fillName(person)
   type(PersonType), intent(inout) :: person

   person%name = "Name"
end subroutine

or following

subroutine fillName(person)
   type(PersonType), pointer :: person

   person%name = "Name"
end subroutine
+3
source share
2 answers

pointerhas specific requirements for arguments that are not in the simple description. Basically a dummy argument personshould be associated with a pointer-pointer. This may be due to allocation or simple assignment of a pointer ( =>). It is important to note that any changes to the association of the dummy argument pointer personduring subroutine execution will be reflected in the actual argument passed. An immediate description will pass the actual argument by reference, but not an association of pointers.

+2
source

, , , , intent(inout) .

, , intent(inout) . , intent(inout) .

pointer, intent(inout), , .

+1

Source: https://habr.com/ru/post/1789453/


All Articles