I am trying to allocate an array on the device which can have zero length.
integer :: i
real, device, allocatable :: arr(:)
i = 0
allocate(arr(i))
deallocate (arr)
The compilation returns no errors; however, when I run the code I get the following message:
0 : ALLOCATE: 0 bytes requested; statu = 0 (no error)
and the program stops.
I tryed adding stat = istat to the allocation, e.g. allocate(arr(0), stat = istat). This time the program runs but istat = 1, denoting an error in the allocation.
Can anyone tell me what’s going on? Allocating zero-length arrays on the host has never been a problem.