Error: must have arithmetic type

Graduate student at Rutgers assigned to porting a C/C++ CFD code to the tesla 2070 recently purchased.
This may be a C issue rather than a CUDA issue, but here it is:

#define L 10
#define steps 1
#define C 2

global void u_approx(double *u[L+3][steps+1]){

double a = 1;
double dx = 1;
int x, t, D;
int Ca = C*a;

for( t = 1; t <= steps; ++t){
for( x = blockIdx.x + 2; x < L; x = x+C){
D = u[x+C][t-1] - u[x-C][t-1];
switch (D)
case 0:
u[t] = u[x - Ca][t - Ca];
problem line: u[x][t] = (-a/dx)*( (u[x+C][t-1] - u[x-C][t-1])/2 ) + u[x][t-1];[/b]

int main(void)

double u[L+3][steps+1];
double *u_dev[L+3][steps+1];

cublasAlloc( (L+3)*(steps+1), sizeof(double), (void**)&u_dev);
cublasSetMatrix ( L+3, steps+1, sizeof(double), u, L+3, u_dev, L+3);

I am getting a “ error: expression must have arithmetic or enum type”. I assume is has to do with passing the 2-D array around incorrectly.
Any ideas?

The “/b” in " u[t-1];[/b]" at the end of your problem line?

No that was accidental from when I made the font bold. That is not in the actual code.

This error typically occurs when a floating-point expression is used for indexing an array, which is not supported in C/C++. Staring at your code, I was unable to spot anything that’s not an integer. Could you attach a complete, self-contained (thus compilable) file that reproduces the problem? What toolchain are you using (which CUDA version)?

here is the entire script. i have the sdk 4.0.17 installed. i compile with nvcc -lcublas.
Is there a debugger I should know about? My gdb fails me once i get inside the triple angle braces.
thanks a lot. (1.48 KB)

You are inconsistently using [font=“Courier New”]*u[/font] in the declaration of u_approx () and [font=“Courier New”]u[/font] accessing it inside the function. Use the same in both places.

Thanks, I am getting all zero’s now, but the data transfers must be working properly, so I can move forward with the debug.

Thanks so much! The first sentence shed light on a mistake I made but couldn’t find out for 10 minutes. My mistake is exactly I used the wrong variable in a macro that’s calculating the index for an array. Appreciate the help!