cuda fortran about type

 program incrementTestGPU
 use cudafor
 implicit none 
 
 type typea
 integer,a
 integer,pointer :: a_d(:)
 end type
 type(typea),device , allocatable ::type_d(:)
 
 allocate(type_d(2))
 type_d(:)%a=1
 print*,type_d(:)%a

allocate(type_d(1)%a_d(100))

 pause

 end program incrementTestGPU

Such like the code before.
allocate(type_d(1)%a_d(100)),it can compiled but exit the program directly.
I use PGI14.10 and CUDA6.5 with the vs2010 complier.

Hi Wardor,

Yes, you’re trying to dereference a device address on the host, hence the crash.

To get this to work you’d need to put the device attribute on a_d instead of type_d or use managed memory. (See: http://www.pgroup.com/lit/articles/insider/v6n1a2.htm).

Examples:

program incrementTestGPU
 use cudafor
 implicit none

 type typea
 integer,a
 integer,allocatable,device :: a_d(:)
 end type
 type(typea), allocatable ::type_d(:)

 allocate(type_d(2))
 type_d(:)%a=1
 print*,type_d(:)%a

allocate(type_d(1)%a_d(100))

 pause

 end program incrementTestGPU



 program incrementTestGPU
 use cudafor
 implicit none

 type typea
 integer,a
 integer,allocatable,managed :: a_d(:)
 end type
 type(typea), allocatable, managed ::type_d(:)

 allocate(type_d(2))
 type_d(:)%a=1
 print*,type_d(:)%a

allocate(type_d(1)%a_d(100))

 pause

 end program incrementTestGPU

Hope this helps,
Mat