# CUDA - Call device subroutine

**URL:** <https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [March 22, 2010, 4:01pm UTC](https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637 "2010-03-22T16:01:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JensWiese95812](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@JensWiese95812](https://forums.developer.nvidia.com/u/JensWiese95812)\
**Post date:** [March 22, 2010, 4:01pm UTC](https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637/1 "2010-03-22T16:01:58Z")

</div>

Hi,

sorry for my many question, but i hope you will help me anyway.

I tried to call a “device” subroutine in a “global” subroutine. In the emulation mode erverthing works fine, but if i want to built my code (without the emulation mode) i get a windows message “cudafe.exe does not longer works”.

My compute capability is 1.0 and i program with the CUDA Fortran Compiler 10.3.

Here is a sample:

module m\_test

use cudafor

contains

attributes(global) subroutine k\_test(i,adev)

integer,value :: i  
integer :: adev(1)

i=i+threadidx%x

adev(1) = i+100

Call k\_test2(i,adev)

end subroutine k\_test

attributes(device) subroutine k\_test2(i,adev)

integer :: adev(1)  
integer,value :: i

adev(1) = adev(1)+111+i

end subroutine k\_test2

subroutine h\_test(i,a)

integer :: i  
integer :: a(1)  
integer,device,allocatable,dimension(:) :: adev  
type(dim3) :: dimGrid,dimBlock

dimGrid = dim3(1,1,1)  
dimBlock = dim3(1,1,1)

allocate(adev(1))

i=10

call k\_test\<\<\<dimGrid,dimBlock\>\>\>(i,adev)

a(1)=adev(1)

end subroutine h\_test

end module m\_test

program prog

use m\_test

implicit none

integer :: i  
integer :: a(1)

Call h\_test(i,a)

write(_,_)a(1)

pause

end program prog

---

<div class="post-metadata">

**Author:** ![JensWiese95812](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@JensWiese95812](https://forums.developer.nvidia.com/u/JensWiese95812)\
**Post date:** [March 23, 2010, 4:08pm UTC](https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637/2 "2010-03-23T16:08:11Z")

</div>

I tried the same at an other PC. There has the graphic board a compute capabilty of 1.1. On both PCs is windows 2007 installed.  
In my last post i predicate i am working with CUDA Fortran 10.3. Sorry but this is wrong. I am working with CUDA Fortran 10.2.  
I need to work with different subroutines. So i hope you can help me.

Does Cuda Fortran work on Linux more stable?

---

<div class="post-metadata">

**Author:** ![JensWiese95812](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@JensWiese95812](https://forums.developer.nvidia.com/u/JensWiese95812)\
**Post date:** [March 23, 2010, 4:24pm UTC](https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637/3 "2010-03-23T16:24:45Z")

</div>

Okay,

i have found the problem. The module has to start with the device subroutine. That is stupid!

---

<div class="post-metadata">

**Author:** ![JensWiese95812](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@JensWiese95812](https://forums.developer.nvidia.com/u/JensWiese95812)\
**Post date:** [March 23, 2010, 5:31pm UTC](https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637/4 "2010-03-23T17:31:50Z")

</div>

But I get an ICE if i call a device subroutine with more than 4 arguments.

error F0000 : Internal compiler error. pgnvd job exited with nonzero status code 0

---

<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 29, 2010, 7:53pm UTC](https://forums.developer.nvidia.com/t/cuda-call-device-subroutine/131637/5 "2010-03-29T19:53:37Z")

</div>

Hi JensWiese95812,

I think you’re hitting a compiler error that was resolved with the 10.3 release. I’m able to successfully compile the code as is with 10.3 but get the same pgnvd error with 10.2.

Hope this helps,  
Mat
