Hi Mat,
I am writing my first programs with CUDA fortran, so maybe I have a stupid error…
But I can’t see why I cannot write a code like the one below.
The error is
PGF90-S-0188-Argument number 5 to in: type mismatch (test2.cuf: 42)
0 inform, 0 warnings, 1 severes, 0 fatal for sub1_device
module test_cuda
use cudafor
implicit none
contains
!----
logical attributes(device) FUNCTION In (X0min, X0Max, xMin, xMax, I)
implicit none
REAL(kind=8), value :: X0min,X0max,xMin, xMax
REAL(kind=8) :: I
IF ( X0Min >= xMax .OR. X0Max <= xMin ) THEN
In = .FALSE.
I = 0.D0
ELSE
In = .TRUE.
I = 0.5D0 / (X0max - X0min)
END IF
END FUNCTION In
!----
attributes(device) subroutine sub1_device(x0,dx0)
implicit none
real(kind=8), value :: x0,dx0
real(kind=8) :: lmin, lmax, I
real(kind=8) :: WL, WU
lmin = x0 - 0.5D0 * dx0
lmax = x0 - 0.5D0 * dx0
I = 0.D0
WL = 1.D0
WU = 3.D0
if (In(lmin,lmax,WL,WU,I)) then
! some code here
end if
end subroutine sub1_device
!---
attributes(global) subroutine kernel_1(N1,nblocks,nthreads)
use cudafor
implicit none
integer, value :: N1, nthreads, nblocks
real(kind=8) :: x0_dev, dx0_dev
integer :: i, idx
idx = (blockidx%x-1)*blockdim%x + threadidx%x
do i=idx,N1,nthreads*nblocks
x0_dev = 1.5D0
dx0_dev = 1.D0
call sub1_device(x0_dev,dx0_dev)
end do
end subroutine
!---
end module
!----------
program test
use cudafor
use test_cuda
integer :: nblocks, nthreads
integer :: N1
!--- kernel call
nblocks = 32
nthreads = 256
N1 = 1000
call kernel_1<<<nblocks,nthreads>>>(N1,nblocks,nthreads)
end program