Thank you!
I was worried, because my Solaris Studio refuses even this simple example
type ptr
integer, pointer :: i
end type ptr
type(ptr) :: a
integer, target :: j
a%i => j
call sub(a,5)
print *,a%i
contains
subroutine sub(p,i)
type(ptr), intent(in) :: p
integer,intent(in) :: i
p%i = i
end subroutine
end
and gfortran-4.6 refuses my real world code, with
subroutine PoisFFT_Solver3D_FullPeriodic(D, Phi, RHS)
type(PoisFFT_Solver3D), intent(in) :: D
.
.
.
forall(i=1:D%nx,j=1:D%ny,k=1:D%nz)&
D%work(i,j,k) = cmplx(RHS(i,j,k),0._RP)
where PoisFFT_Solver3D is
type PoisFFT_Solver3D
.
.
.
complex(CP), dimension(:,:,:),&!contiguous,
pointer :: work => null()
end type PoisFFT_Solver3D
with
D%work(i,j,k) = cmplx(RHS(i,j,k),0._RP)
1
Error: Dummy argument 'd' with INTENT(IN) in variable definition context
(assignment) at (1)
poisfft.f90:95.6:
Best regards,
Vladimir
Dne Tue, 03 Apr 2012 16:42:52 +0200 Steve Lionel
<steve....@intel.invalid> napsal(a):
> On 4/3/2012 8:55 AM, \"Vladimír Fuka <\"name.surname at >> wrote:
>>
>> I have a simple question. Is it allowed to assign to a pointee of a
>> pointer component of a derived type which is a dummy argument with
>> intent IN?
>
> Yes. This was a matter of much debate during the creation of the
> Fortran 2003 standard, but in the end it was agreed that the intent
> applies to the pointer itself, not the data it points to.
>
> The current standard says (5.3.10): A pointer with the INTENT(IN)
> attribute shall not appear in a pointer association context (16.6.8)
>
> and then later:
>
> The INTENT(IN) attribute for a pointer dummy argument specifies that
> during the invocation and execution of the procedure its association
> shall not be changed except that it may become undefined if the target
> is deallocated other than through the pointer (16.5.2.5)
>
--