diff --git a/src/GridManip.cu b/src/GridManip.cu index 050acfb3..dc6180b9 100755 --- a/src/GridManip.cu +++ b/src/GridManip.cu @@ -453,7 +453,7 @@ template void InterpstepCPU(int nx, int ny, int hdstep, double to template void InterpstepCPU(int nx, int ny, int hdstep, double totaltime, double hddt, double*& Ux, double* Uo, double* Un); -template __global__ void InterpstepGPU(int nx, int ny, int hdstp, T totaltime, T hddt, T*Ux, T* Uo, T* Un) +template __global__ void InterpstepGPU(int nx, int ny, T totaltime, T beforetime, T aftertime, T*Ux, T* Uo, T* Un) { unsigned int ix = blockIdx.x * blockDim.x + threadIdx.x; unsigned int iy = blockIdx.y * blockDim.y + threadIdx.y; @@ -464,19 +464,21 @@ template __global__ void InterpstepGPU(int nx, int ny, int hdstp, T to __shared__ T Uxn[16][16]; // __shared__ float Ums[16]; - + T hddt = aftertime - beforetime; if (ix < nx && iy < ny) { Uxo[tx][ty] = Uo[ix + nx * iy]/**Ums[tx]*/; Uxn[tx][ty] = Un[ix + nx * iy]/**Ums[tx]*/; - Ux[ix + nx * iy] = Uxo[tx][ty] + (totaltime - hddt * hdstp) * (Uxn[tx][ty] - Uxo[tx][ty]) / hddt; + Ux[ix + nx * iy] = Uxo[tx][ty] + (totaltime - beforetime) * (Uxn[tx][ty] - Uxo[tx][ty]) / (hddt); } } //template __global__ void InterpstepGPU(int nx, int ny, int hdstp, T totaltime, T hddt, T* Ux, T* Uo, T* Un); -template __global__ void InterpstepGPU(int nx, int ny, int hdstp, float totaltime, float hddt, float* Ux, float* Uo, float* Un); -template __global__ void InterpstepGPU(int nx, int ny, int hdstp, double totaltime, double hddt, double* Ux, double* Uo, double* Un); +template __global__ void InterpstepGPU(int nx, int ny, float totaltime, float beforetime, float aftertime, float* Ux, float* Uo, float* Un); +template __global__ void InterpstepGPU(int nx, int ny, double totaltime, double beforetime, double aftertime, double* Ux, double* Uo, double* Un); + + template void Copy2CartCPU(int nx, int ny, T* dest, T* src) { diff --git a/src/GridManip.h b/src/GridManip.h index 4ee385ad..0bd725fd 100755 --- a/src/GridManip.h +++ b/src/GridManip.h @@ -23,7 +23,8 @@ template T interp2BUQ(T x, T y, F forcing); template T interp2BUQ(T x, T y, T dx, F forcing); template void InterpstepCPU(int nx, int ny, int hdstep, F totaltime, F hddt, T*& Ux, T* Uo, T* Un); -template __global__ void InterpstepGPU(int nx, int ny, int hdstp, T totaltime, T hddt, T* Ux, T* Uo, T* Un); +//template __global__ void InterpstepGPU(int nx, int ny, int hdstp, T totaltime, T hddt, T* Ux, T* Uo, T* Un); +template __global__ void InterpstepGPU(int nx, int ny, T totaltime, T beforetime, T aftertime, T* Ux, T* Uo, T* Un); template void Copy2CartCPU(int nx, int ny, T* dest, T* src); diff --git a/src/Read_netcdf.cu b/src/Read_netcdf.cu index 1f7701fb..bec9caa4 100755 --- a/src/Read_netcdf.cu +++ b/src/Read_netcdf.cu @@ -546,6 +546,7 @@ int readnctime2(int ncid,char * timecoordname,std::string refdate,size_t nt, dou for (int it = 0; it < nt; it++) { time[it] = time[it] * fac + offset; + //printf("%f\n", time[it]); } ///status = nc_close(ncid); diff --git a/src/Updateforcing.cu b/src/Updateforcing.cu index cc332bf2..b2a69c93 100755 --- a/src/Updateforcing.cu +++ b/src/Updateforcing.cu @@ -98,7 +98,9 @@ void Forcingthisstep(Param XParam, double totaltime, DynForcingP &XDynFor // Interpolate the forcing array to this time if (XParam.GPUDEVICE >= 0) { - InterpstepGPU << > > (XDynForcing.nx, XDynForcing.ny, XDynForcing.instep - 1, float(totaltime), float(XDynForcing.dt), XDynForcing.now_g, XDynForcing.before_g, XDynForcing.after_g); + float bftime = float(XDynForcing.to+XDynForcing.dt*(XDynForcing.instep-1)); + float aftime = float(XDynForcing.to + XDynForcing.dt * (XDynForcing.instep)); + InterpstepGPU << > > (XDynForcing.nx, XDynForcing.ny, float(totaltime), bftime,aftime, XDynForcing.now_g, XDynForcing.before_g, XDynForcing.after_g); CUDA_CHECK(cudaDeviceSynchronize()); CUDA_CHECK(cudaMemcpyToArray(XDynForcing.GPU.CudArr, 0, 0, XDynForcing.now_g, XDynForcing.nx * XDynForcing.ny * sizeof(float), cudaMemcpyDeviceToDevice)); @@ -377,7 +379,7 @@ template __global__ void AddrainforcingImplicitGPU(Param XParam, Loop< Rainhh = max(Rainhh / T(1000.0) / T(3600.0) * T(XLoop.dt), T(0.0)) * XBlock.activeCell[i]; // convert from mm/hrs to m/s and - + //printf("%f\n", Rainhh); T qvol = hi / (hi + Rainhh); XEv.h[i] = hi + Rainhh;