Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28633 Discussions

A compatibility of POINTER and INTENT

oleglebedev
New Contributor I
314 Views
Good day,
I have coded a test
[fortran]PROGRAM main
    IMPLICIT NONE
    integer, pointer, dimension(:) :: this_ptr
    integer :: i
!
call allocateIt( this_ptr, 1, 5 )
!
this_ptr = (/ (i,i=1,5) /)
write( *, * ) this_ptr
!
!
    CONTAINS
!
subroutine allocateIt(this, from, to)
    implicit none
    integer, intent(IN) :: from, to
    integer, pointer, dimension(:), intent(INOUT) :: this
allocate( this(from:to) )
return
end subroutine allocateIt

END PROGRAM main[/fortran]
I have information that pointer and intent can not bespecified to one variable (see an attachment).
The output is
ifort -g -traceback -check all -openmp allocate.f90 -o xmain
./xmain
1 2 3 4 5
Oleg.
0 Kudos
1 Reply
Steven_L_Intel1
Employee
314 Views
Yes, POINTER and INTENT can be specified as of Fortran 2003. Note that in this case the INTENT applies to the pointer itself, not the data it points to.
0 Kudos
Reply