Hi,
I'm wondering is the following code is valid.
I'm defining a type bound procedure which has 2 argument:
- the passed-object dummy argument with the attribute 'intent(inout)'
- a integer variable with the attribute 'intent(in)'
If the actual argument associated to the dummy argument n°2 is a component of the passed-object dummy argument and if this component is modified in the TBP, then there is an inconsistency since the argument n°2 is declared as 'intent(in)' but its value is actually changing.
Below, an example which run without any warnings or errors
! ifort main.f90; ./a.out Module MyModule implicit none private public :: MyType Type :: MyType integer :: Var contains procedure ,public :: Do_Something_Inconsistent End Type contains Subroutine Do_Something_Inconsistent( This, Var ) class(MyType) ,intent(inout) :: This integer ,intent(in) :: Var This%Var = Var + 1 End Subroutine End Module Program Main use MyModule ,only: MyType implicit none type(MyType) :: Obj Obj%Var = 1 write(*,"('BEFORE: Obj%Var = ',g0)") Obj%Var call Obj%Do_Something_Inconsistent( Obj%Var ) ! Is this valid write(*,"('AFTER: Obj%Var = ',g0)") Obj%Var End Program
sd