From 9510c34223b00331419528b3218b6066a9890883 Mon Sep 17 00:00:00 2001 From: Cyprien Date: Mon, 9 Oct 2023 17:34:10 +1300 Subject: [PATCH] Reduce warnings step 1 --- src/Advection.cu | 2 +- src/Boundary.cu | 2 +- src/Halo.cu | 2 +- src/InitEvolv.cu | 2 +- src/InitialConditions.cu | 8 +-- src/Mesh.cu | 22 ++++----- src/ReadInput.cu | 2 +- src/Testing.cu | 10 ++-- src/Write_netcdf.cu | 104 +++++++++++++++++++-------------------- src/utctime.cu | 11 +++-- src/utctime.h | 6 +-- 11 files changed, 86 insertions(+), 85 deletions(-) diff --git a/src/Advection.cu b/src/Advection.cu index db3ab18f..2f19765c 100755 --- a/src/Advection.cu +++ b/src/Advection.cu @@ -155,7 +155,7 @@ template __host__ void updateEVCPU(Param XParam, BlockP XBlock, Evol lev = XBlock.level[ib]; delta = calcres(T(XParam.delta), lev); - ybo = XParam.yo + XBlock.yo[ib]; + ybo = (T)XParam.yo + XBlock.yo[ib]; for (int iy = 0; iy < XParam.blkwidth; iy++) { diff --git a/src/Boundary.cu b/src/Boundary.cu index ab588769..4f779942 100644 --- a/src/Boundary.cu +++ b/src/Boundary.cu @@ -262,7 +262,7 @@ template __host__ void bndCPU(Param XParam, bndparam side, BlockP X { atmpi = interp2BUQ(XParam.xo + xx, XParam.yo + yy, Atmp); } - zsatm = -(atmpi - XParam.Paref) * XParam.Pa2m; + zsatm = -(atmpi - (T)XParam.Paref) * (T)XParam.Pa2m; } diff --git a/src/Halo.cu b/src/Halo.cu index 0dd055f3..b7062c90 100644 --- a/src/Halo.cu +++ b/src/Halo.cu @@ -126,7 +126,7 @@ template void Recalculatehh(Param XParam, BlockP XBlock, EvolvingP< { n = memloc(XParam.halowidth, XParam.blkmemwidth, i, j, ib); - Xev.h[n] = max(Xev.zs[n]- zb[n],0.0) ; + Xev.h[n] = max(Xev.zs[n]- zb[n],(T)0.0) ; } } diff --git a/src/InitEvolv.cu b/src/InitEvolv.cu index 6c0ba9b8..d8366372 100755 --- a/src/InitEvolv.cu +++ b/src/InitEvolv.cu @@ -331,7 +331,7 @@ void warmstart(Param XParam,Forcing XForcing, BlockP XBlock, T* zb, Ev { atmpi = interp2BUQ(xi, yi, XForcing.Atmp); } - zsbnd = zsbnd - (atmpi- XParam.Paref) * XParam.Pa2m; + zsbnd = zsbnd - (atmpi- (T)XParam.Paref) * (T)XParam.Pa2m; } XEv.zs[n] = utils::max(zsbnd, zb[n]); diff --git a/src/InitialConditions.cu b/src/InitialConditions.cu index 96a02a98..e0efba8f 100644 --- a/src/InitialConditions.cu +++ b/src/InitialConditions.cu @@ -222,13 +222,13 @@ template void FindTSoutNodes(Param& XParam, BlockP XBlock, Bndblock ib = XBlock.active[blk]; levdx = T(calcres(XParam.dx,XBlock.level[ib])); - x = XParam.TSnodesout[o].x; - y = XParam.TSnodesout[o].y; + x = (T)XParam.TSnodesout[o].x; + y = (T)XParam.TSnodesout[o].y; dxblk = (T)(XParam.blkwidth) * levdx; - blkxmin = (XParam.xo + XBlock.xo[ib] - 0.5 * levdx); - blkymin = (XParam.yo + XBlock.yo[ib] - 0.5 * levdx); + blkxmin = ((T)XParam.xo + XBlock.xo[ib] - 0.5 * levdx); + blkymin = ((T)XParam.yo + XBlock.yo[ib] - 0.5 * levdx); blkxmax = (blkxmin + dxblk); blkymax = (blkymin + dxblk); diff --git a/src/Mesh.cu b/src/Mesh.cu index 4c956725..08959e90 100755 --- a/src/Mesh.cu +++ b/src/Mesh.cu @@ -282,8 +282,8 @@ template void InitBlockxoyo(Param XParam, Forcing XForcing, Blo if ((nmask < (XParam.blkwidth * XParam.blkwidth)) && insidepoly) { // - XBlock.xo[blkid] = nblkx * ((T)XParam.blkwidth) * levdx + T(0.5) * levdx; - XBlock.yo[blkid] = nblky * ((T)XParam.blkwidth) * levdx + T(0.5) * levdx; + XBlock.xo[blkid] = nblkx * ((T)XParam.blkwidth) * (T)levdx + T(0.5) * (T)levdx; + XBlock.yo[blkid] = nblky * ((T)XParam.blkwidth) * (T)levdx + T(0.5) * (T)levdx; XBlock.active[blkid] = blkid; //printf("blkxo=%f\tblkyo=%f\n", blockxo_d[blkid], blockyo_d[blkid]); blkid++; @@ -307,25 +307,25 @@ template void InitBlockneighbours(Param &XParam,Forcing &XForci //==================================== // First setp up neighbours - T levdx = calcres(XParam.dx, XParam.initlevel); + double levdx = calcres(XParam.dx, XParam.initlevel); for (int ibl = 0; ibl < XParam.nblk; ibl++) { int bl = XBlock.active[ibl]; //T espdist = std::numeric_limits::epsilon() * (T)100.0; // i.e. distances are calculated within 100x theoretical machine precision // This too theoretical error definition has been modified to allow more flexibility - T espdist = levdx/3; + T espdist = (T)levdx/3; - leftxo = XBlock.xo[bl] - ((T)XParam.blkwidth) * levdx; + leftxo = XBlock.xo[bl] - ((T)XParam.blkwidth) * (T)levdx; leftyo = XBlock.yo[bl]; - rightxo = XBlock.xo[bl] + ((T)XParam.blkwidth) * levdx; + rightxo = XBlock.xo[bl] + ((T)XParam.blkwidth) * (T)levdx; rightyo = XBlock.yo[bl]; topxo = XBlock.xo[bl]; - topyo = XBlock.yo[bl] + ((T)XParam.blkwidth) * levdx; + topyo = XBlock.yo[bl] + ((T)XParam.blkwidth) * (T)levdx; botxo = XBlock.xo[bl]; - botyo = XBlock.yo[bl] - ((T)XParam.blkwidth) * levdx; + botyo = XBlock.yo[bl] - ((T)XParam.blkwidth) * (T)levdx; // by default neighbour block refer to itself. i.e. if the neighbour block is itself then there are no neighbour XBlock.LeftBot[bl] = bl; @@ -382,12 +382,12 @@ template int CalcMaskblk(Param XParam, BlockP XBlock) int nmask = 0; bool neighbourmask = false; T leftxo, rightxo, topyo, botyo; - T initlevdx = calcres(XParam.dx, XParam.initlevel); + T initlevdx = calcres((T)XParam.dx, XParam.initlevel); for (int ibl = 0; ibl < XParam.nblk; ibl++) { int ib = XBlock.active[ibl]; - T levdx = calcres(XParam.dx, XBlock.level[ib]); + T levdx = calcres((T)XParam.dx, XBlock.level[ib]); leftxo = XBlock.xo[ib]; // in adaptive this shoulbe be a range @@ -449,7 +449,7 @@ template void FindMaskblk(Param XParam, BlockP &XBlock) for (int ibl = 0; ibl < XParam.nblk; ibl++) { int ib = XBlock.active[ibl]; - T levdx = calcres(XParam.dx, XBlock.level[ib]); + T levdx = calcres((T)XParam.dx, XBlock.level[ib]); leftxo = XBlock.xo[ib]; // in adaptive this shoulbe be a range diff --git a/src/ReadInput.cu b/src/ReadInput.cu index 2415a35e..5976cebd 100644 --- a/src/ReadInput.cu +++ b/src/ReadInput.cu @@ -1143,7 +1143,7 @@ void checkparamsanity(Param& XParam, Forcing& XForcing) log("\t" + std::to_string(XParam.xo) + "/" + std::to_string(XParam.xmax) + "/" + std::to_string(XParam.yo) + "/" + std::to_string(XParam.ymax)); log("\t Initial resolution (level " + std::to_string(XParam.initlevel) + ") = " + std::to_string(levdx)); - if (XParam.spherical < 1) + if (XParam.spherical == false) { XParam.delta = XParam.dx; XParam.grdalpha = XParam.grdalpha * pi / 180.0; // grid rotation diff --git a/src/Testing.cu b/src/Testing.cu index 5cd58c5b..50ad8208 100644 --- a/src/Testing.cu +++ b/src/Testing.cu @@ -2177,7 +2177,7 @@ template bool RiverOnBoundary(Param XParam,T slope, int Dir, int Bound MainLoop(XParam, XForcing, XModel, XModel_g); - T TheoryInput = Q * XParam.endtime; + T TheoryInput = Q * (T)XParam.endtime; T SimulatedVolume = T(0.0); @@ -3339,8 +3339,8 @@ template bool ZoneOutputTest(int nzones, T zsinit) { for (int i = 0; i < XForcing.Bathy[0].nx; i++) { - x = XForcing.Bathy[0].xo + i * XForcing.Bathy[0].dx; - y = XForcing.Bathy[0].yo + j * XForcing.Bathy[0].dx; + x = float(XForcing.Bathy[0].xo + i * XForcing.Bathy[0].dx); + y = float(XForcing.Bathy[0].yo + j * XForcing.Bathy[0].dx); r = sqrt(x * x + y * y); if (r < rs) { @@ -3374,8 +3374,8 @@ template bool ZoneOutputTest(int nzones, T zsinit) { for (int i = 0; i < XForcing.targetadapt[0].nx; i++) { - x = XForcing.targetadapt[0].xo + i * XForcing.targetadapt[0].dx; - y = XForcing.targetadapt[0].yo + j * XForcing.targetadapt[0].dx; + x = float(XForcing.targetadapt[0].xo + i * XForcing.targetadapt[0].dx); + y = float(XForcing.targetadapt[0].yo + j * XForcing.targetadapt[0].dx); if (x < 0.0) { XForcing.targetadapt[0].val[i + j * XForcing.targetadapt[0].nx] = -1; diff --git a/src/Write_netcdf.cu b/src/Write_netcdf.cu index b88d645c..9b8e3cf3 100644 --- a/src/Write_netcdf.cu +++ b/src/Write_netcdf.cu @@ -28,8 +28,8 @@ void Calcnxny(Param XParam, int level, int& nx, int& ny) xxmin = XParam.xo + dxp; yymin = XParam.yo + dxp; - nx = round((xxmax - xxmin) / ddx + 1.0); - ny = round((yymax - yymin) / ddx + 1.0); + nx = ftoi(round((xxmax - xxmin) / ddx + 1.0)); + ny = ftoi(round((yymax - yymin) / ddx + 1.0)); } void Calcnxnyzone(Param XParam, int level, int& nx, int& ny, outzoneB Xzone) @@ -386,10 +386,10 @@ for (int lev = Xzone.minlevel; lev <= Xzone.maxlevel; lev++) double ddx = calcres(XParam.dx, lev); double dxp = calcres(XParam.dx, lev + 1); - double xxmax, xxmin, yymax, yymin; - - xxmax = Xzone.xmax - dxp; - yymax = Xzone.ymax - dxp; + double xxmin, yymin; + //doublle xxmax, yymax + //xxmax = Xzone.xmax - dxp; + //yymax = Xzone.ymax - dxp; xxmin = Xzone.xo + dxp; yymin = Xzone.yo + dxp; @@ -487,11 +487,11 @@ template void defncvarBUQ(Param XParam, int* activeblk, int* level, T* //short fillval = 32767 static size_t start2D[] = { 0, 0 }; // start at first value //static size_t count2D[] = { ny, nx }; - static size_t count2D[] = { XParam.blkwidth, XParam.blkwidth }; + static size_t count2D[] = { (size_t)XParam.blkwidth, (size_t)XParam.blkwidth }; static size_t start3D[] = { 0, 0, 0 }; // start at first value //static size_t count3D[] = { 1, ny, nx }; - static size_t count3D[] = { 1, XParam.blkwidth, XParam.blkwidth }; + static size_t count3D[] = { 1, (size_t)XParam.blkwidth, (size_t)XParam.blkwidth }; //size_t count3D[3]; //count3D[0] = 1; //count3D[1] = XParam.blkwidth; @@ -638,18 +638,16 @@ template void defncvarBUQ(Param XParam, int* activeblk, int* level, T* lev = level[bl]; - double xxmax, yymax; + //double xxmax, yymax; double xxmin, yymin; double initdx = calcres(XParam.dx, XParam.initlevel); - //xxmax = XParam.xmax + initdx / 2.0 - calcres(XParam.dx, lev )/2.0; - //yymax = XParam.ymax + initdx / 2.0 - calcres(XParam.dx, lev )/2.0; + - xxmax = Xzone.xmax - calcres(XParam.dx, lev) / 2.0; - yymax = Xzone.ymax - calcres(XParam.dx, lev )/2.0; + //xxmax = Xzone.xmax - calcres(XParam.dx, lev) / 2.0; + //yymax = Xzone.ymax - calcres(XParam.dx, lev )/2.0; - //xxmin = XParam.xo - initdx / 2.0 + calcres(XParam.dx, lev )/2.0; - //yymin = XParam.yo - initdx / 2.0 + calcres(XParam.dx, lev )/2.0; + xxmin = Xzone.xo + calcres(XParam.dx, lev) / 2.0; yymin = Xzone.yo + calcres(XParam.dx, lev )/2.0; //printf("xxmin=%f, yymin=%f, lev=$d \n", xxmin, yymin, lev); @@ -720,7 +718,7 @@ template void defncvarBUQ(Param XParam, int* activeblk, int* level, T* if (status != NC_NOERR) { - printf("\n ib=%d start=[%d,%d,%d]; initlevel=%d; initdx=%f; level=%d; xo=%f; yo=%f; blockxo[ib]=%f xxmin=%f blockyo[ib]=%f yymin=%f startfl=%f\n", bl, start3D[0], start3D[1], start3D[2], XParam.initlevel,initdx,lev, Xzone.xo, Xzone.yo, blockxo[bl], xxmin, blockyo[bl], yymin, (blockyo[bl] - yymin) / calcres(XParam.dx, lev)); + printf("\n ib=%d start=[%d,%d,%d]; initlevel=%d; initdx=%f; level=%d; xo=%f; yo=%f; blockxo[ib]=%f xxmin=%f blockyo[ib]=%f yymin=%f startfl=%f\n", bl, (int)start3D[0], (int)start3D[1], (int)start3D[2], XParam.initlevel,initdx,lev, Xzone.xo, Xzone.yo, blockxo[bl], xxmin, blockyo[bl], yymin, (blockyo[bl] - yymin) / calcres(XParam.dx, lev)); //printf("\n varblk[0]=%f varblk[255]=%f\n", varblk[0], varblk[255]); handle_ncerror(status); } @@ -750,22 +748,22 @@ template void defncvarBUQ(Param XParam, int* activeblk, int* level, doub template void writencvarstepBUQ(Param XParam, int vdim, int * activeblk, int* level, T * blockxo, T *blockyo, std::string varst, T * var, outzoneB Xzone) { - int status, ncid, recid, var_id, ndims; + int status, ncid, recid, var_id; static size_t nrec; short *varblk_s; float * varblk; - int nx, ny; - int dimids[NC_MAX_VAR_DIMS]; - size_t *ddim, *start, *count; + //int nx, ny; + //int dimids[NC_MAX_VAR_DIMS]; + //size_t *ddim, *start, *count; //XParam.outfile.c_str() static size_t start2D[] = { 0, 0 }; // start at first value //static size_t count2D[] = { ny, nx }; - static size_t count2D[] = { XParam.blkwidth, XParam.blkwidth }; + static size_t count2D[] = { (size_t)XParam.blkwidth, (size_t)XParam.blkwidth }; static size_t start3D[] = { 0, 0, 0 }; // start at first value // This is updated to nrec-1 further down //static size_t count3D[] = { 1, ny, nx }; - static size_t count3D[] = { 1, XParam.blkwidth, XParam.blkwidth }; + static size_t count3D[] = { 1, (size_t)XParam.blkwidth, (size_t)XParam.blkwidth }; int smallnc = XParam.smallnc; float scalefactor = XParam.scalefactor; @@ -802,17 +800,15 @@ template void writencvarstepBUQ(Param XParam, int vdim, int * activebl bl = activeblkzone[ibl]; lev = level[bl]; lev < 0 ? sign = "N" : sign = "P"; - double xxmax, xxmin, yymax, yymin; - + double xxmin, yymin; + //double xxmax, yymax; double initdx = calcres(XParam.dx, XParam.initlevel); - //xxmax = XParam.xmax + initdx / 2.0 - calcres(XParam.dx, lev) / 2.0; - //yymax = XParam.ymax + initdx / 2.0 - calcres(XParam.dx, lev) / 2.0; - xxmax = Xzone.xmax - calcres(XParam.dx, lev) / 2.0; - yymax = Xzone.ymax - calcres(XParam.dx, lev) / 2.0; + + //xxmax = Xzone.xmax - calcres(XParam.dx, lev) / 2.0; + //yymax = Xzone.ymax - calcres(XParam.dx, lev) / 2.0; - //xxmin = XParam.xo - initdx / 2.0 + calcres(XParam.dx, lev) / 2.0; - //yymin = XParam.yo - initdx / 2.0 + calcres(XParam.dx, lev) / 2.0; + xxmin = Xzone.xo + calcres(XParam.dx, lev) / 2.0; yymin = Xzone.yo + calcres(XParam.dx, lev) / 2.0; @@ -835,7 +831,7 @@ template void writencvarstepBUQ(Param XParam, int vdim, int * activebl } else { - varblk[r] = var[n]; + varblk[r] = (float)var[n]; } } } @@ -966,12 +962,12 @@ template void Save2Netcdf(Param XParam, Loop XLoop, Modeltm_hour) + (long long)t->tm_min) + (long long)t->tm_sec; } - +/* UTCClock::time_point UTCClock::fromDate( int year, int month, int day, int hour, int min, int sec, int usec) { @@ -152,6 +152,7 @@ UTCClock::time_point UTCClock::fromDate( return from_time_t(tt) + chrono::microseconds(usec); } + void UTCClock::toDate(const UTCClock::time_point &tp, int &year, int &month, @@ -174,14 +175,14 @@ void UTCClock::toDate(const UTCClock::time_point &tp, sec = duration_cast(leftover).count(); usec = (leftover-chrono::seconds(sec)).count(); } - +*/ long long date_string_to_time(std::string date) { struct tm tm = { 0 }; // Important, initialize all members //int n = 0; - int year, mon, day, hour, min, sec; + //int year, mon, day, hour, min, sec; std::vector datetime, ddd, ttt; datetime = split(date, 'T'); if (datetime.size() < 2) diff --git a/src/utctime.h b/src/utctime.h index 2560a9c1..48eb85b3 100644 --- a/src/utctime.h +++ b/src/utctime.h @@ -3,7 +3,7 @@ #include "General.h" #include "ReadInput.h" - +/* struct UTCClock { typedef std::chrono::microseconds duration; @@ -30,8 +30,8 @@ struct UTCClock // want to represent UTC DateTime // static time_point now(); }; - -using UTCTime = std::chrono::time_point; +*/ +//using UTCTime = std::chrono::time_point; long long date_string_to_time(std::string date); double date_string_to_s(std::string datetime, std::string refdate);