overlap of INTENT(IN) and INTENT(OUT) arguments
- From: "Beliavsky" <beliavsky@xxxxxxx>
- Date: 20 Feb 2007 12:08:09 -0800
For the code
module foo_mod
contains
subroutine set_alloc(ii,jj)
! allocate jj and set it to ii
integer, intent(in) :: ii(:)
integer, intent(out), allocatable :: jj(:)
integer :: ni
ni = size(ii)
allocate (jj(ni))
jj = ii
write (*,*) "jj =",jj
end subroutine set_alloc
end module foo_mod
program xset_alloc
use foo_mod, only: set_alloc
implicit none
integer, allocatable :: ii(:)
allocate (ii(3))
ii = (/10,20,30/)
call set_alloc(ii([1,3]),ii)
call set_alloc(ii(1:1),ii)
call set_alloc(ii,ii)
end program xset_alloc
gfortran says at compile time
In file xxset_alloc.f90:23
call set_alloc(ii,ii)
Warning: Same actual argument associated with INTENT(OUT) argument
'jj' and INTENT(IN) argument 'ii' at (1)
and crashes at run time at line 23. G95 and Intel Fortran do not
complain at compile time and run to completion.
Are all three calls to set_alloc nonstandard? If they are, I can see
how warning about the 3rd case would be much easier than warning about
the first two.
.
- Follow-Ups:
- Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- From: Tobias Burnus
- Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- From: Richard Maine
- Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- From: glen herrmannsfeldt
- Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- From: Craig Powers
- Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- Prev by Date: Re: pictures as comments
- Next by Date: Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- Previous by thread: pictures as comments
- Next by thread: Re: overlap of INTENT(IN) and INTENT(OUT) arguments
- Index(es):
Relevant Pages
|