Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Problem with nested ASSOCIATE constructs

$
0
0

Hi,
   I get an error with the attached code which I think is due to a
problem within the compiler. The error appears when using two nested
associate constructs:

$ ifort -c test.f90
test.f90(20): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [VALS]
   allocate( xdt%vals( sum(ydt) ) ) ! error
-----------------^
compilation aborted for test.f90 (code 1)

Notice that all the three equivalent constructs included in the
example compile without problem, and notice that gfortran accepts also
the problemtaic version.

$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0 Build 20140723

module m
 implicit none

 type :: t1
  integer, allocatable :: vals(:)
 end type t1

 type :: t2
  type(t1) :: dat
 end type t2

contains

 pure subroutine s(x,y)
  type(t1),         intent(in)  :: y
  type(t2), target, intent(out) :: x

   associate( xdt => x%dat  )
   associate( ydt => y%vals )
   allocate( xdt%vals( sum(ydt) ) ) ! error
   !allocate( x%dat%vals( sum(ydt) ) ) ! works
   end associate
   end associate

   ! This works
   !associate( xdt => x%dat  )
   !allocate( xdt%vals( sum(y%vals) ) )
   !end associate

   ! ... as well as this
   !associate( xdt => x%dat , ydt => y%vals )
   !allocate( xdt%vals( sum(ydt) ) )
   !end associate

 end subroutine s

end module m

Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>