# Allocatable derived types

**URL:** <https://forums.developer.nvidia.com/t/allocatable-derived-types/132804>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [March 2, 2012, 2:27am UTC](https://forums.developer.nvidia.com/t/allocatable-derived-types/132804 "2012-03-02T02:27:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![t-san](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@t-san](https://forums.developer.nvidia.com/u/t-san)\
**Post date:** [March 2, 2012, 2:27am UTC](https://forums.developer.nvidia.com/t/allocatable-derived-types/132804/1 "2012-03-02T02:27:53Z")

</div>

Hi,

I’ve found a problem on allocatable derived types with device attribute.  
The test code is attached.

Compiling the code with CUDA Fortran from PGI Workstation 11.10 and CUDA4.0  
the output of the executable is:

cudaSetDevice: istat = 0  
allocate: istat = 0  
3.141592653589793  
3.141592653589793  
3.141592653589793  
3.141592653589793

However, compiling the code with CUDA Fortran from PGI Workstation 12.2 and CUDA4.0,  
the output of the executable is:

cudaSetDevice: istat = 0  
allocate: istat = 0  
3.141592653589793  
3.141592653589793

* * *

* * *

It seems that the arrays are not correctly allocated using v12.2.

The situation is the same both in Windows(64-bit) and Linux(64-bit).

Tetsuo

```nohighlight
program TEST
use cudafor
implicit none
integer, parameter :: KRSZ = selected_real_kind(15)

type :: yield_
  real(KRSZ) :: x_fin(1:10) = acos(-1.0_KRSZ)
end type yield_

type(yield_), allocatable, device :: yield(:)

real(KRSZ) :: rtmp

integer :: istat

istat = cudaSetDevice(0)
write(*,*) 'cudaSetDevice: istat =', istat

allocate( yield(1:2), STAT=istat )
write(*,*) 'allocate: istat =', istat
rtmp = yield(1)%x_fin( 1) ; write(*,*) rtmp
rtmp = yield(1)%x_fin(10) ; write(*,*) rtmp
rtmp = yield(2)%x_fin( 1) ; write(*,*) rtmp
rtmp = yield(2)%x_fin(10) ; write(*,*) rtmp

end program TEST

```

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [March 2, 2012, 7:30pm UTC](https://forums.developer.nvidia.com/t/allocatable-derived-types/132804/2 "2012-03-02T19:30:25Z")

</div>

Hi t-san,

Thank you for the report. This does appear to be a compiler error and we have begun to investigate. This is being tracked as TPR#18511.

Best Regards,  
Mat
