Errors in this Code

Hi
I am a student trying to learn CUDA Fortran in Visual Studio. Unfortunately, the following code refuses to work. Could someone point me in the right direction in order to know what is wrong with it?

!
! ConsoleApp.f90
!
! Fortran Console Application
! Generated by PGI Visual Fortran®
! 6/2/2010 5:43:41 PM
!

!
! ConsoleApp.f90
!
! Fortran Console Application
! Generated by PGI Visual Fortran®
! 6/1/2010 5:52:04 PM
!

!pgf90 -Bstatic -Mcuda=cc13 -ta=nvidia -o cuda.exe cuda.cuf -Minfo
!pgf90 -Mcuda=cc13 -ta=nvidia -o cuda.exe cuda.cuf -Minfo
!pgf90 -ta=nvidia -o cuda.exe cuda.cuf -Minfo
subroutine sum( a, b, c, n)
real*4 a(10,10), b(10,10), c(10,10)
integer i,j,n
!$acc region
do i=1,n !line7
do j=1,n !line8
c(i,j) = a(i,j)+ b(i,j)
enddo
enddo
!$acc end region
end

program main
use cudafor
type(cudadeviceprop):: prop
integer i, j, n
real4 input_a(10,10), input_b(10,10), output_c(10,10)
j=cudaGetDeviceProperties( prop, 0)
write(
,)" name=",trim(prop%name)
write(
,)" totalGlobalMem=",prop%totalGlobalMem
write(
,)" sharedMemPerBlock=",prop%sharedMemPerBlock
write(
,)" regsPerBlock=",prop%regsPerBlock
write(
,)" warpSize=",prop%warpSize
write(
,)" memPitch=",prop%memPitch
write(
,)" maxThreadsPerBlock=",prop%maxThreadsPerBlock
write(
,)" maxThreadsDim=",prop%maxThreadsDim
write(
,)" maxGridSize=",prop%maxGridSize
write(
,)" totalConstMem=",prop%totalConstMem
write(
,)" major=",prop%major
write(
,)" minor=",prop%minor
write(
,)" clockRate=",prop%clockRate
write(
,)" textureAlignment=",prop%textureAlignment
write(
,)" deviceOverlap=",prop%deviceOverlap
write(
,)" multiProcessorCount=",prop%multiProcessorCount
write(
,)“kernelExecTimeoutEnabled=”,prop%kernelExecTimeoutEnabled
write(
,)" integrated=",prop%integrated
write(
,)" canMapHostMemory=",prop%canMapHostMemory
write(
,)" computeMode=",prop%computeMode
n = 10
do i=1,n
do j=1,n
input_a(i,j) = i
input_b(i,j) = j
enddo
enddo
call sum(input_a,input_b,output_c,n)
do i=1,n
do j=1,n
print
, output_c(i,j)
enddo
enddo
end


The errors are:

Description: unresolved external symbol CUDAGETDEVICEPROPERTIES@8 referenced in function_MAIN
File: ConsoleApp.obj
Description: unresolved external symbol _cudafor
File: ConsoleApp.obj
Description: 2 unresolved externals
File: CudaFortramSample.exe

Thank you for you help!

Sincerely,

Chris Nogales

Hi Chris,

Looks like you’re missing the “-Mcuda” flag during the link. Under your project properties, look for the “Fortran->Language” option and then select “yes” for Cuda Fortran.

Note that we just added support in 10.5 for mixing CUDA Fortran with the PGI Accelerator model. However, this support should considered “Beta” since it’s still experimental.

Hope this helps,
Mat

Thank you! It works now.
-Chris