2

I am trying to define a subroutine which allocates different types of arrays. Here is a simplified version of the code:

subroutine Allocation1(Vec)
    class(*), allocatable, intent(out)      :: Vec(:)

    select type(Vec)
    type is(real(8))
        allocate(Vec(10)); Vec = 0.D0
    type is(complex(8))
        allocate(Vec(10)); Vec = (0.D0,0.D0)
    type is(integer)
        allocate(Vec(10)); Vec = 0
    endselect
endsubroutine Allocation1

But I got three error messages that I don't understand:

error #8306: Associate name defined in ASSOCIATE or SELECT TYPE statements doesn't have ALLOCATABLE or POINTER attribute   [VEC]

As you can see VEC is an allocatable array, so I don't think this error make sense. What does it mean, and how do I make this work?

I am using IVF XE 14.0.1.139.

4

2 回答 2

2

Seems like a compiler bug, works with Gfortran and with the Solaris Studio. I recommend you to contact your official Intel support.

As IanH points out, it is possible the other compilers are in error to compile that. Anyway, be it standard conforming or not, the procedure would still be useless, because for the select type to work the variable would still have to be already allocated, because the actual argument to your procedure must be polymorphic. You cannot just pass real, allocatable there.

于 2014-10-09T17:30:56.950 回答
0

未分配具有 intent(out) 属性的变量,因此 Vec 将没有类型并且 SELECT TYPE(VEC) 是无法定义的。

于 2014-10-10T09:21:57.950 回答