diff --git a/src/InitEvolv.cu b/src/InitEvolv.cu index d8366372..59242293 100755 --- a/src/InitEvolv.cu +++ b/src/InitEvolv.cu @@ -325,11 +325,11 @@ void warmstart(Param XParam,Forcing XForcing, BlockP XBlock, T* zb, Ev if (XForcing.Atmp.uniform) { - atmpi = T(XForcing.Atmp.nowvalue); + atmpi = float(XForcing.Atmp.nowvalue); } else { - atmpi = interp2BUQ(xi, yi, XForcing.Atmp); + atmpi = float(interp2BUQ(xi, yi, XForcing.Atmp)); } zsbnd = zsbnd - (atmpi- (T)XParam.Paref) * (T)XParam.Pa2m; } diff --git a/src/InitialConditions.cu b/src/InitialConditions.cu index e0efba8f..f03df8ac 100644 --- a/src/InitialConditions.cu +++ b/src/InitialConditions.cu @@ -227,8 +227,8 @@ template void FindTSoutNodes(Param& XParam, BlockP XBlock, Bndblock dxblk = (T)(XParam.blkwidth) * levdx; - blkxmin = ((T)XParam.xo + XBlock.xo[ib] - 0.5 * levdx); - blkymin = ((T)XParam.yo + XBlock.yo[ib] - 0.5 * levdx); + blkxmin = ((T)XParam.xo + XBlock.xo[ib] - T(0.5) * levdx); + blkymin = ((T)XParam.yo + XBlock.yo[ib] - T(0.5) * levdx); blkxmax = (blkxmin + dxblk); blkymax = (blkymin + dxblk); @@ -639,7 +639,7 @@ template void Findoutzoneblks(Param& XParam, BlockP& XBlock) std::vector cornerblk; //index of the blocks at the corner of the zone outzoneP Xzone; //info on outzone given by the user outzoneB XzoneB; //info on outzone computed and used actually for writing nc files - double eps; + //double eps; // Find the blocks to output and the corners of this area for each zone for (int o = 0; o < XParam.outzone.size(); o++) diff --git a/src/Poly.cu b/src/Poly.cu index 6dc320aa..c189c4f8 100644 --- a/src/Poly.cu +++ b/src/Poly.cu @@ -374,8 +374,8 @@ bool PolygonIntersect(Polygon P, Polygon Q) if (intersect) { - i = P.vertices.size(); - j = Q.vertices.size(); + i = (int)P.vertices.size(); + j = (int)Q.vertices.size(); break; } diff --git a/src/ReadForcing.cu b/src/ReadForcing.cu index 55bc1f20..1d407527 100755 --- a/src/ReadForcing.cu +++ b/src/ReadForcing.cu @@ -216,7 +216,7 @@ void readforcing(Param & XParam, Forcing & XForcing) XForcing.rivers[Rin].flowinput = readFlowfile(XForcing.rivers[Rin].Riverflowfile, XParam.reftime); //Check the time range of the river forcing - nt = XForcing.rivers[Rin].flowinput.size(); + nt = (int)XForcing.rivers[Rin].flowinput.size(); XForcing.rivers[Rin].to = XForcing.rivers[Rin].flowinput[0].time; XForcing.rivers[Rin].tmax = XForcing.rivers[Rin].flowinput[nt-1].time; if ( XForcing.rivers[Rin].tmax < XParam.endtime) @@ -260,7 +260,7 @@ void readforcing(Param & XParam, Forcing & XForcing) } //Sanity check on the time range of the forcing - nt = XForcing.UWind.unidata.size(); + nt = (int)XForcing.UWind.unidata.size(); if (XForcing.UWind.unidata[nt - 1].time < XParam.endtime || XForcing.VWind.unidata[nt - 1].time < XParam.endtime) { XParam.endtime = min(XForcing.UWind.unidata[nt - 1].time, XForcing.VWind.unidata[nt - 1].time); @@ -309,7 +309,7 @@ void readforcing(Param & XParam, Forcing & XForcing) InitDynforcing(gpgpu, XParam, XForcing.Atmp); // Deflault is zero wich is terrible so change to Paref so limitwaves generated at the edge of forcing // Users should insure there forcing extend well beyond the intended model extent. - XForcing.Atmp.clampedge = XParam.Paref; + XForcing.Atmp.clampedge = T(XParam.Paref); //readDynforcing(gpgpu, XParam.totaltime, XForcing.Atmp); } } @@ -819,7 +819,7 @@ std::vector readNestfile(std::string ncfile,std::string varname, int hor , std::vector WLS,Unest,Vnest; //Define NC file variables int nnx, nny, nt, nbndpts, indxx, indyy, indx, indy,nx, ny; - double dx, dy, xxo, yyo, to, xmax, ymax, tmax,xo,yo; + double dx, dy, xxo, yyo, tmax,xo,yo; double * ttt, *zsa; bool checkhh = false; int iswet; @@ -1480,8 +1480,8 @@ template T readforcinghead(T ForcingParam) } if (ForcingParam.extension.compare("nc") == 0) { - int dummy; - double dummyb, dummyc; + //int dummy; + //double dummyb, dummyc; //log("netcdf file"); //readgridncsize(ForcingParam.inputfile, ForcingParam.varname, ForcingParam.nx, ForcingParam.ny, dummy, ForcingParam.dx, ForcingParam.xo, ForcingParam.yo, dummyb, ForcingParam.xmax, ForcingParam.ymax, dummyc, ForcingParam.flipxx, ForcingParam.flipyy); diff --git a/src/ReadInput.cu b/src/ReadInput.cu index 5976cebd..72cd393e 100644 --- a/src/ReadInput.cu +++ b/src/ReadInput.cu @@ -1182,7 +1182,7 @@ void checkparamsanity(Param& XParam, Forcing& XForcing) XForcing.bot.isright = 0; XForcing.bot.istop = -1; - XForcing.Atmp.clampedge = XParam.Paref; + XForcing.Atmp.clampedge = float(XParam.Paref); if (!XForcing.Atmp.inputfile.empty()) { @@ -1484,7 +1484,7 @@ std::vector split(const std::string s, const std::string delim) if (ide < (rem.length() - delim.length())) { - loc = ide + delim.length(); + loc = int(ide + delim.length()); rem = rem.substr(loc); } } diff --git a/src/Read_netcdf.cu b/src/Read_netcdf.cu index f7e6c9ce..f3f38384 100755 --- a/src/Read_netcdf.cu +++ b/src/Read_netcdf.cu @@ -182,7 +182,7 @@ void readgridncsize(const std::string ncfilestr, const std::string varstr, std:: double * ytempvar; ytempvar = (double *)malloc(ny*sizeof(double)); size_t start[] = { 0 }; - size_t count[] = { ny }; + size_t count[] = { (size_t)ny }; status = nc_get_vara_double(ncid, varid, start, count, ytempvar); if (status != NC_NOERR) handle_ncerror(status); @@ -200,7 +200,7 @@ void readgridncsize(const std::string ncfilestr, const std::string varstr, std:: else { size_t start[] = { 0, 0 }; - size_t count[] = { ny, nx }; + size_t count[] = { (size_t)ny, (size_t)nx }; status = nc_get_vara_double(ncid, varid, start, count, ycoord); if (status != NC_NOERR) handle_ncerror(status); @@ -220,7 +220,7 @@ void readgridncsize(const std::string ncfilestr, const std::string varstr, std:: double * xtempvar; xtempvar = (double *)malloc(nx*sizeof(double)); size_t start[] = { 0 }; - size_t count[] = { nx }; + size_t count[] = { (size_t)nx }; status = nc_get_vara_double(ncid, varid, start, count, xtempvar); if (status != NC_NOERR) handle_ncerror(status); @@ -238,7 +238,7 @@ void readgridncsize(const std::string ncfilestr, const std::string varstr, std:: else { size_t start[] = { 0, 0 }; - size_t count[] = { ny, nx }; + size_t count[] = { (size_t)ny, (size_t)nx }; status = nc_get_vara_double(ncid, varid, start, count, xcoord); if (status != NC_NOERR) handle_ncerror(status); @@ -276,8 +276,8 @@ void readgridncsize(const std::string ncfilestr, const std::string varstr, std:: //allocate temporary array and read time vector double * ttempvar; ttempvar = (double *)malloc(nt * sizeof(double)); - size_t start[] = { 0 }; - size_t count[] = { nt }; + //size_t start[] = { 0 }; + //size_t count[] = { (size_t)nt }; //status = nc_get_vara_double(ncid, varid, start, count, ttempvar); status = readnctime2(ncid, reftime, nt, ttempvar); @@ -332,7 +332,7 @@ void readgridncsize(forcingmap& Fmap, Param XParam) template void readgridncsize(T& Imap) { double a, b, c; - int duma, dumb, dumc; + int duma; readgridncsize(Imap.inputfile, Imap.varname, "2000-01-01T00:00:00", Imap.nx, Imap.ny, duma, Imap.dx, Imap.dy, a, Imap.xo, Imap.yo, b, Imap.xmax, Imap.ymax, c, Imap.flipxx, Imap.flipyy); } template void readgridncsize(inputmap &Imap); @@ -634,7 +634,7 @@ int readncslev1(std::string filename, std::string varstr, size_t indx, size_t in if (sferr == NC_NOERR || oferr == NC_NOERR) // data must be packed { - zsa[0] = zsa[0] * scalefac + offset; + zsa[0] = zsa[0] * (T)scalefac + (T)offset; } if (checkhh) @@ -679,17 +679,17 @@ int readncslev1(std::string filename, std::string varstr, size_t indx, size_t in if (sferr == NC_NOERR || oferr == NC_NOERR) // data must be packed { - zsa[0] = zsa[0] * scalefac + offset; + zsa[0] = zsa[0] * (T)scalefac + (T)offset; } hha = zsa[0]; if (hha > eps) { - zsa[0] = zza; + zsa[0] = T(zza); } else { - zsa[0] = 0.0; + zsa[0] = T(0.0); wet = 0; } @@ -961,9 +961,9 @@ void readWNDstep(forcingmap WNDUmap, forcingmap WNDVmap, int steptoread, float * //size_t startl[]={hdstep-1,lev,0,0}; //size_t countlu[]={1,1,netau,nxiu}; //size_t countlv[]={1,1,netav,nxiv}; - size_t startl[] = { steptoread, 0, 0 }; - size_t countlu[] = { 1, WNDUmap.ny, WNDUmap.nx }; - size_t countlv[] = { 1, WNDVmap.ny, WNDVmap.nx }; + size_t startl[] = { (size_t)steptoread, 0, 0 }; + size_t countlu[] = { 1, (size_t)WNDUmap.ny, (size_t)WNDUmap.nx }; + size_t countlv[] = { 1, (size_t)WNDVmap.ny, (size_t)WNDVmap.nx }; //static ptrdiff_t stridel[]={1,1,1,1}; //static ptrdiff_t stridel[] = { 1, 1, 1 }; @@ -1052,8 +1052,8 @@ void readATMstep(forcingmap ATMPmap, int steptoread, float *&Po) //size_t startl[]={hdstep-1,lev,0,0}; //size_t countlu[]={1,1,netau,nxiu}; //size_t countlv[]={1,1,netav,nxiv}; - size_t startl[] = { steptoread, 0, 0 }; - size_t countlu[] = { 1, ATMPmap.ny, ATMPmap.nx }; + size_t startl[] = { (size_t)steptoread, 0, 0 }; + size_t countlu[] = { 1, (size_t)ATMPmap.ny, (size_t)ATMPmap.nx }; //size_t countlv[] = { 1, WNDVmap.ny, WNDVmap.nx }; //static ptrdiff_t stridel[]={1,1,1,1}; diff --git a/src/Reimann.cu b/src/Reimann.cu index be634203..1fc3fb30 100644 --- a/src/Reimann.cu +++ b/src/Reimann.cu @@ -114,8 +114,8 @@ template __global__ void UpdateButtingerXGPU(Param XParam, BlockP X vr = vi - dx * dvdxi; } if (hn > eps) { - ul = uli + (1. - dx * dhdxil / hn) * dx * dudxil; - vl = vli + (1. - dx * dhdxil / hn) * dx * dvdxil; + ul = uli + (T(1.0) - dx * dhdxil / hn) * dx * dudxil; + vl = vli + (T(1.0) - dx * dhdxil / hn) * dx * dvdxil; } else { ul = uli + dx * dudxil; @@ -299,16 +299,16 @@ template __host__ void UpdateButtingerXCPU(Param XParam, BlockP XBl //To avoid high velocities near dry cells, we reconstruct velocities according to Bouchut. T ul, ur, vl, vr, sl, sr; if (hi > eps) { - ur = ui - (1. + dx * dhdxi / hi) * dx * dudxi; - vr = vi - (1. + dx * dhdxi / hi) * dx * dvdxi; + ur = ui - (T(1.0) + dx * dhdxi / hi) * dx * dudxi; + vr = vi - (T(1.0) + dx * dhdxi / hi) * dx * dvdxi; } else { ur = ui - dx * dudxi; vr = vi - dx * dvdxi; } if (hn > eps) { - ul = uli + (1. - dx * dhdxil / hn) * dx * dudxil; - vl = vli + (1. - dx * dhdxil / hn) * dx * dvdxil; + ul = uli + (T(1.0) - dx * dhdxil / hn) * dx * dudxil; + vl = vli + (T(1.0) - dx * dhdxil / hn) * dx * dvdxil; } else { ul = uli + dx * dudxil; @@ -680,16 +680,16 @@ template __host__ void UpdateButtingerYCPU(Param XParam, BlockP XBl //To avoid high velocities near dry cells, we reconstruct velocities according to Bouchut. T ul, ur, vl, vr, sl, sr; if (hi > eps) { - ur = ui - (1. + dx * dhdyi / hi) * dx * dudyi; - vr = vi - (1. + dx * dhdyi / hi) * dx * dvdyi; + ur = ui - (T(1.0) + dx * dhdyi / hi) * dx * dudyi; + vr = vi - (T(1.0) + dx * dhdyi / hi) * dx * dvdyi; } else { ur = ui - dx * dudyi; vr = vi - dx * dvdyi; } if (hn > eps) { - ul = uli + (1. - dx * dhdyil / hn) * dx * dudyil; - vl = vli + (1. - dx * dhdyil / hn) * dx * dvdyil; + ul = uli + (T(1.0) - dx * dhdyil / hn) * dx * dudyil; + vl = vli + (T(1.0) - dx * dhdyil / hn) * dx * dvdyil; } else { ul = uli + dx * dudyil; @@ -712,7 +712,7 @@ template __host__ void UpdateButtingerYCPU(Param XParam, BlockP XBl } - fv = (fh > 0. ? ul : ur) * fh; + fv = (fh > T(0.0) ? ul : ur) * fh; // Topographic source term @@ -812,7 +812,7 @@ template __host__ __device__ T hllc(T g, T delta, T epsi, T CFL, T cm, double a = max(fabs(SL), fabs(SR)); if (a > epsi) { dlt = delta * cm / fm; - dt = CFL * dlt / a; + dt = CFL * dlt / T(a); } else diff --git a/src/Spherical.cu b/src/Spherical.cu index ef3fbef6..9d98e600 100644 --- a/src/Spherical.cu +++ b/src/Spherical.cu @@ -58,12 +58,12 @@ __host__ __device__ T haversin(T Radius, T lon1, T lat1, T lon2, T lat2) phi1 = lat1 * T(pi / 180.0); phi2 = lat2 * T(pi / 180.0); - T sindphid2 = sin(dphi / 2.0); - T sindlbdad2 = sin(dlbda / 2.0); + T sindphid2 = sin(dphi / T(2.0)); + T sindlbdad2 = sin(dlbda / T(2.0)); a = sindphid2 * sindphid2 + cos(phi1) * cos(phi2) * sindlbdad2 * sindlbdad2; - c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a)); + c = T(2.0) * atan2(sqrt(a), sqrt(T(1.0) - a)); return Radius * c; diff --git a/src/Updateforcing.cu b/src/Updateforcing.cu index 79c3f29c..4a9c9b8c 100755 --- a/src/Updateforcing.cu +++ b/src/Updateforcing.cu @@ -736,7 +736,7 @@ template void deformstep(Param XParam, Loop XLoop, std::vector deform[nd].startime + deform[nd].duration) { - dtdef = min(XLoop.dt, XLoop.totaltime - (deform[nd].startime + deform[nd].duration)); + dtdef = (T)min(XLoop.dt, XLoop.totaltime - (deform[nd].startime + deform[nd].duration)); } diff --git a/src/Util_CPU.cu b/src/Util_CPU.cu index ad859f24..23877d92 100644 --- a/src/Util_CPU.cu +++ b/src/Util_CPU.cu @@ -158,7 +158,7 @@ __host__ __device__ T calcres(Param XParam, T dx, int level) if (XParam.spherical) { - ddx = ddx * XParam.Radius * pi / T(180.0); + ddx = ddx * T(XParam.Radius * pi / 180.0); } return ddx;