CLASS array patch latest
Paul Richard Thomas
paul.richard.thomas@gmail.com
Sun Nov 13 20:26:00 GMT 2011
or you can use SOURCE=extended_type (99, 100) or
SOURCE=[(extended_type (i*10, i*100), i=1,...)] etc., etc..
Paul
On Sun, Nov 13, 2011 at 9:08 PM, Arjen Markus <arjen.markus895@gmail.com> wrote:
> Hello,
>
> 2011/11/13 Paul Richard Thomas <paul.richard.thomas@gmail.com>:
>
>> subroutine reallocate (a)
>> class(base_type), dimension(:), allocatable, intent(inout) :: a
>> class(base_type), dimension(:), allocatable :: tmp
>>
>> allocate (tmp (2 * size (a))) ! how to alloc b with same type as a ?
>>
>> ! This is one way how!
>> ! select type (a)
>> ! type is (base_type); allocate (base_type :: tmp (2 * size (a)))
>> ! type is (extended_type); allocate (extended_type :: tmp (2 * size (a)))
>> ! end select
>>
>
> You can use the source= keyword, can't you?
>
> allocate( tmp(2*size(a), source = a(1) )
>
> (I think the a(1) is required, as the contents of a are copied)
>
> Regards,
>
> Arjen
>
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy
More information about the Fortran
mailing list