Commit 953a0820 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Moved paramToString() to param_conversion.cc.

parent fe56b990
......@@ -34,23 +34,6 @@
#include "util_files.h"
#include "cdi_lockedIO.h"
void
paramToString(int param, char *paramstr, int maxlen)
{
int dis, cat, num;
cdiDecodeParam(param, &num, &cat, &dis);
const size_t umaxlen = maxlen >= 0 ? (unsigned) maxlen : 0U;
int len;
if (dis == 255 && (cat == 255 || cat == 0))
len = snprintf(paramstr, umaxlen, "%d", num);
else if (dis == 255)
len = snprintf(paramstr, umaxlen, "%d.%d", num, cat);
else
len = snprintf(paramstr, umaxlen, "%d.%d.%d", num, cat, dis);
if (len >= maxlen || len < 0) fprintf(stderr, "Internal problem (%s): size of input string is too small!\n", __func__);
}
typedef enum
{
......
......@@ -172,8 +172,6 @@ stringToParam(const char *const paramstr)
int pnum = -1, pcat = 255, pdis = 255;
sscanf(paramstr, "%d.%d.%d", &pnum, &pcat, &pdis);
if (Options::cdoVerbose) cdoPrint("pnum, pcat, pdis: %d.%d.%d", pnum, pcat, pdis);
return cdiEncodeParam(pnum, pcat, pdis);
}
......@@ -183,6 +181,24 @@ stringToParam(const std::string &paramstr)
return stringToParam(paramstr.c_str());
}
void
paramToString(int param, char *paramstr, int maxlen)
{
int dis, cat, num;
cdiDecodeParam(param, &num, &cat, &dis);
size_t umaxlen = (maxlen >= 0) ? (unsigned) maxlen : 0U;
int len;
if (dis == 255 && (cat == 255 || cat == 0))
len = snprintf(paramstr, umaxlen, "%03d", num);
else if (dis == 255)
len = snprintf(paramstr, umaxlen, "%03d.%03d", num, cat);
else
len = snprintf(paramstr, umaxlen, "%03d.%03d.%03d", num, cat, dis);
if (len >= maxlen || len < 0) cdoAbort("Internal problem (%s): size of input string is too small!", __func__);
}
/* time/date/season converisons */
/* =================================================================================== */
void
......
......@@ -23,6 +23,7 @@ double radius_str_to_deg(const char *string);
int stringToParam(const std::string &paramstr);
int stringToParam(const char *paramstr);
void paramToString(int param, char *paramstr, int maxlen);
/* time/date/season converisons */
/* =================================================================================== */
......
......@@ -174,10 +174,8 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
}
}
/*
Search for bicubic failed - use a distance-weighted average instead
(this is typically near the pole) Distance was stored in src_lats!
*/
// Search for bicubic failed - use a distance-weighted average instead
// (this is typically near the pole) Distance was stored in src_lats!
if (search_result < 0)
{
if (num_src_points(&src_grid->mask[0], src_add, src_lats) > 0)
......@@ -291,10 +289,8 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
}
}
/*
Search for bicubic failed - use a distance-weighted average instead
(this is typically near the pole) Distance was stored in src_lats!
*/
// Search for bicubic failed - use a distance-weighted average instead
// (this is typically near the pole) Distance was stored in src_lats!
if (search_result < 0)
{
if (num_src_points(src_grid_mask, src_add, src_lats) > 0)
......
......@@ -19,9 +19,8 @@
#include <vector>
/* Predeclarations */
// Predeclarations
struct RemapVars;
/**/
struct Addweight
{
......
Supports Markdown
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