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

Simplify if statement.

parent 427625e0
......@@ -102,6 +102,13 @@ static int hours[MaxHours + 1];
static std::vector<double> LevelFound;
static inline bool
filetype_is_netcdf(int filetype)
{
return filetype == CDI_FILETYPE_NC || filetype == CDI_FILETYPE_NC2 || filetype == CDI_FILETYPE_NC4
|| filetype == CDI_FILETYPE_NC4C || filetype == CDI_FILETYPE_NC5;
}
static void
lprintf(FILE *fp)
{
......@@ -588,9 +595,7 @@ static void
after_control(struct Control *globs, struct Variable *vars)
{
int i;
int nrecs;
int64_t rdate, vdate;
int rtime, vtime;
int nrecs = 0;
int code;
RARG rarg;
......@@ -601,10 +606,13 @@ after_control(struct Control *globs, struct Variable *vars)
TsID = 0;
bool righttime = false;
while ((nrecs = streamInqTimestep(globs->istreamID, TsID)) > 0)
while (true)
{
vdate = taxisInqVdate(globs->taxisID);
vtime = taxisInqVtime(globs->taxisID);
nrecs = streamInqTimestep(globs->istreamID, TsID);
if (nrecs <= 0) break;
const auto vdate = taxisInqVdate(globs->taxisID);
const auto vtime = taxisInqVtime(globs->taxisID);
after_setDateTime(&globs->StartDate, vdate, vtime);
after_setDateTime(&globs->NewDate, vdate, vtime);
......@@ -615,25 +623,16 @@ after_control(struct Control *globs, struct Variable *vars)
break;
}
if (righttime)
break;
else
TsID++;
}
if (righttime) break;
if (taxisInqType(globs->taxisID) == TAXIS_RELATIVE)
{
rdate = taxisInqRdate(globs->taxisID);
rtime = taxisInqRtime(globs->taxisID);
}
else
{
rdate = after_getDate(globs->StartDate);
rtime = after_getTime(globs->StartDate);
TsID++;
}
if (ofiletype == CDI_FILETYPE_NC || ofiletype == CDI_FILETYPE_NC2 || ofiletype == CDI_FILETYPE_NC4
|| ofiletype == CDI_FILETYPE_NC4C || ofiletype == CDI_FILETYPE_NC5)
const auto taxis_is_relative = (taxisInqType(globs->taxisID) == TAXIS_RELATIVE);
const auto rdate = taxis_is_relative ? taxisInqRdate(globs->taxisID) : after_getDate(globs->StartDate);
const auto rtime = taxis_is_relative ? taxisInqRtime(globs->taxisID) : after_getTime(globs->StartDate);
if (filetype_is_netcdf(ofiletype))
{
taxisDefCalendar(globs->taxisID2, CALENDAR_PROLEPTIC);
taxisDefType(globs->taxisID2, TAXIS_RELATIVE);
......@@ -1797,8 +1796,7 @@ after_processing(struct Control *globs, struct Variable *vars)
{
if (ofiletype == CDI_FILETYPE_GRB)
afterAbort("Can't write fourier coefficients to GRIB!");
else if (ofiletype == CDI_FILETYPE_NC || ofiletype == CDI_FILETYPE_NC2 || ofiletype == CDI_FILETYPE_NC4
|| ofiletype == CDI_FILETYPE_NC4C || ofiletype == CDI_FILETYPE_NC5)
else if (filetype_is_netcdf(ofiletype))
afterAbort("Can't write fourier coefficients to NetCDF!");
}
......
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