Commit f5d92a18 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Set constant variables to const.

parent b22e68dd
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
void MakeGeopotHeight(double *geop, double *gt, double *gq, double *ph, int nhor, int nlev); void MakeGeopotHeight(double *geop, double *gt, double *gq, double *ph, int nhor, int nlev);
double *vlist_hybrid_vct(int vlistID, int *rzaxisIDh, int *rnvct, int *rnhlevf); void vlist_hybrid_vct(int vlistID, int *rzaxisIDh, int *rnvct, std::vector<double> &vct, int *rnhlevf);
void * void *
Derivepar(void *process) Derivepar(void *process)
...@@ -60,15 +60,15 @@ Derivepar(void *process) ...@@ -60,15 +60,15 @@ Derivepar(void *process)
cdoInitialize(process); cdoInitialize(process);
// clang-format off // clang-format off
int GHEIGHT = cdoOperatorAdd("gheight", 0, 0, nullptr); const int GHEIGHT = cdoOperatorAdd("gheight", 0, 0, nullptr);
int SEALEVELPRESSURE = cdoOperatorAdd("sealevelpressure", 0, 0, nullptr); const int SEALEVELPRESSURE = cdoOperatorAdd("sealevelpressure", 0, 0, nullptr);
// clang-format on // clang-format on
int operatorID = cdoOperatorID(); const int operatorID = cdoOperatorID();
int streamID1 = cdoStreamOpenRead(cdoStreamName(0)); const int streamID1 = cdoStreamOpenRead(cdoStreamName(0));
int vlistID1 = cdoStreamInqVlist(streamID1); const int vlistID1 = cdoStreamInqVlist(streamID1);
int gridID = vlistGrid(vlistID1, 0); int gridID = vlistGrid(vlistID1, 0);
if (gridInqType(gridID) == GRID_SPECTRAL) cdoAbort("Spectral data unsupported!"); if (gridInqType(gridID) == GRID_SPECTRAL) cdoAbort("Spectral data unsupported!");
...@@ -78,14 +78,15 @@ Derivepar(void *process) ...@@ -78,14 +78,15 @@ Derivepar(void *process)
int zaxisIDh = -1; int zaxisIDh = -1;
int nvct = 0; int nvct = 0;
int nhlevf = 0; int nhlevf = 0;
double *vct = vlist_hybrid_vct(vlistID1, &zaxisIDh, &nvct, &nhlevf); std::vector<double> vct;
vlist_hybrid_vct(vlistID1, &zaxisIDh, &nvct, vct, &nhlevf);
if (Options::cdoVerbose) if (Options::cdoVerbose)
for (i = 0; i < nvct / 2; ++i) cdoPrint("vct: %5d %25.17f %25.17f", i, vct[i], vct[nvct / 2 + i]); for (i = 0; i < nvct / 2; ++i) cdoPrint("vct: %5d %25.17f %25.17f", i, vct[i], vct[nvct / 2 + i]);
if (zaxisIDh == -1) cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!"); if (zaxisIDh == -1) cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!");
int nvars = vlistNvars(vlistID1); const int nvars = vlistNvars(vlistID1);
bool useTable = false; bool useTable = false;
for (varID = 0; varID < nvars; varID++) for (varID = 0; varID < nvars; varID++)
...@@ -102,11 +103,11 @@ Derivepar(void *process) ...@@ -102,11 +103,11 @@ Derivepar(void *process)
for (varID = 0; varID < nvars; varID++) for (varID = 0; varID < nvars; varID++)
{ {
int gridID = vlistInqVarGrid(vlistID1, varID); const int gridID = vlistInqVarGrid(vlistID1, varID);
int zaxisID = vlistInqVarZaxis(vlistID1, varID); const int zaxisID = vlistInqVarZaxis(vlistID1, varID);
int nlevel = zaxisInqSize(zaxisID); const int nlevel = zaxisInqSize(zaxisID);
int instNum = institutInqCenter(vlistInqVarInstitut(vlistID1, varID)); const int instNum = institutInqCenter(vlistInqVarInstitut(vlistID1, varID));
int tableNum = tableInqNum(vlistInqVarTable(vlistID1, varID)); const int tableNum = tableInqNum(vlistInqVarTable(vlistID1, varID));
int code = vlistInqVarCode(vlistID1, varID); int code = vlistInqVarCode(vlistID1, varID);
int param = vlistInqVarParam(vlistID1, varID); int param = vlistInqVarParam(vlistID1, varID);
...@@ -264,7 +265,7 @@ Derivepar(void *process) ...@@ -264,7 +265,7 @@ Derivepar(void *process)
cdoPrint("using %s", var_stdname(surface_air_pressure)); cdoPrint("using %s", var_stdname(surface_air_pressure));
} }
int vlistID2 = vlistCreate(); const int vlistID2 = vlistCreate();
int var_id = -1; int var_id = -1;
...@@ -286,11 +287,11 @@ Derivepar(void *process) ...@@ -286,11 +287,11 @@ Derivepar(void *process)
vlistDefVarStdname(vlistID2, varID, var_stdname(var_id)); vlistDefVarStdname(vlistID2, varID, var_stdname(var_id));
vlistDefVarUnits(vlistID2, varID, var_units(var_id)); vlistDefVarUnits(vlistID2, varID, var_units(var_id));
int taxisID1 = vlistInqTaxis(vlistID1); const int taxisID1 = vlistInqTaxis(vlistID1);
int taxisID2 = taxisDuplicate(taxisID1); const int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2); vlistDefTaxis(vlistID2, taxisID2);
int streamID2 = cdoStreamOpenWrite(cdoStreamName(1)); const int streamID2 = cdoStreamOpenWrite(cdoStreamName(1));
pstreamDefVlist(streamID2, vlistID2); pstreamDefVlist(streamID2, vlistID2);
int tsID = 0; int tsID = 0;
...@@ -373,7 +374,7 @@ Derivepar(void *process) ...@@ -373,7 +374,7 @@ Derivepar(void *process)
if (operatorID == GHEIGHT) if (operatorID == GHEIGHT)
{ {
presh(nullptr, half_press.data(), vct, ps.data(), nhlevf, gridsize); presh(nullptr, half_press.data(), vct.data(), ps.data(), nhlevf, gridsize);
arrayCopy(gridsize, sgeopot.data(), gheight.data() + gridsize * nhlevf); arrayCopy(gridsize, sgeopot.data(), gheight.data() + gridsize * nhlevf);
MakeGeopotHeight(gheight.data(), temp.data(), hum.data(), half_press.data(), gridsize, nhlevf); MakeGeopotHeight(gheight.data(), temp.data(), hum.data(), half_press.data(), gridsize, nhlevf);
...@@ -388,7 +389,7 @@ Derivepar(void *process) ...@@ -388,7 +389,7 @@ Derivepar(void *process)
} }
else if (operatorID == SEALEVELPRESSURE) else if (operatorID == SEALEVELPRESSURE)
{ {
presh(full_press.data(), half_press.data(), vct, ps.data(), nhlevf, gridsize); presh(full_press.data(), half_press.data(), vct.data(), ps.data(), nhlevf, gridsize);
extra_P(sealevelpressure.data(), &half_press[gridsize * (nhlevf)], &full_press[gridsize * (nhlevf - 1)], sgeopot.data(), extra_P(sealevelpressure.data(), &half_press[gridsize * (nhlevf)], &full_press[gridsize * (nhlevf - 1)], sgeopot.data(),
&temp[gridsize * (nhlevf - 1)], gridsize); &temp[gridsize * (nhlevf - 1)], gridsize);
...@@ -407,8 +408,6 @@ Derivepar(void *process) ...@@ -407,8 +408,6 @@ Derivepar(void *process)
vlistDestroy(vlistID2); vlistDestroy(vlistID2);
if (vct) Free(vct);
cdoFinish(); cdoFinish();
return nullptr; return nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment