However, if I declare the device variable inside the same module where it is allocated, then the test succeeds. My system configuration is: Ubuntu 10.04 (64-bit), GeForce GTX 260, original NVIDIA driver packaged by Ubuntu, PGI Accelerator Fortran Workstation 10.5.

Is this a compiler bug? If so, is there workaround while still allocating variables declared in separate modules?

In CUDA Fortran, device module data is only accessible by device routines within the same module or from host code that uses the module. Accessing device data declared from other modules is not allowed. (See the "Variable Qualifier" section of the CUDA Fortran Reference Guide)The problem being that there isn't a linker for device code, hence no way to associate external device symbols.

However, this has been our most requested feature and our engineers have been hard at work trying to find a way to support this. With Fermi and CUDA 3.0, we have found a way to perform this association at run time. The feature is still in development but will be available some time early next year. Full details can be found at http://www.pgroup.com/lit/articles/insider/v2n3a1.htm