Problem with FDTD program

Hello, I’m a spanish student and I’m new in CUDA. I have made several examples (HelloCuda, matrix, …) without any problem. Now I’m trying to write this code that I have already done in C, but I don’t know if in CUDA is possible or not.

C Code

for (n=0;n<100;n++)
{
for (k=0;k<200;k++)
{
ex[k+1]=ex[k+1]+.5*(hy[k]-hy[k+1]);
if ((k+1)==kc)
{
pulse=exp(-.5*(pow((t0-T)/spread,2.0)));
ex[kc]=pulse;
}
hy[k]=hy[k]+.5*(ex[k]-ex[k+1]);
}
}

I’m calculating the equation FDTD 1D in the vacuum (Maxwell equation). The problem is that “ex” need data from “hy” and “hy” need data from “ex” and I can’t control it in the kernel. Is it possible to make this in CUDA?

I hope your help.

Thanks.