Skip to content

Commit

Permalink
Check each async call individually
Browse files Browse the repository at this point in the history
Previously some data not found interrupted the search of other datas
  • Loading branch information
mpartio committed Aug 6, 2024
1 parent 16dbaad commit 930e122
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions himan-plugins/source/preform_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,24 @@ void preform_hybrid::FreezingArea(shared_ptr<const plugin_configuration> conf, c

future<vector<double>> futTavg01, futTavg12, futrhAvg01, futrhAvgUpper12;

// Some data is optional; if it's not found, we'll initialize it to missing
auto CaptureOrInitializeToMissing = [N](future<vector<double>>& fut) -> vector<double>
{
try
{
return fut.get();
}
catch (const HPExceptionType& e)
{
if (e == kFileDataNotFound)
{
vector<double> ret_(N, MissingDouble());
return ret_;
}

throw e;
}
};
try
{
// 0-kohtien lkm pinnasta (yläraja 10km, jotta ylinkin nollakohta varmasti löytyy)
Expand Down Expand Up @@ -535,36 +553,19 @@ void preform_hybrid::FreezingArea(shared_ptr<const plugin_configuration> conf, c

// 3 <--> 4
Tavg34 = h->VerticalAverage<double>(TParam, zeroLevel3, zeroLevel4);

Tavg01 = futTavg01.get();
Tavg12 = futTavg12.get();
rhAvg01 = futrhAvg01.get();
rhAvgUpper12 = futrhAvgUpper12.get();
}
catch (const HPExceptionType& e)
{
if (e == kFileDataNotFound)
{
log.Debug("Some zero level not found from entire data");
}

if (Tavg01.empty())
{
Tavg01 = vector<double>(N, MissingDouble());
}
if (Tavg12.empty())
{
Tavg12 = vector<double>(N, MissingDouble());
}
if (rhAvg01.empty())
{
rhAvg01 = vector<double>(N, MissingDouble());
}
if (rhAvgUpper12.empty())
{
rhAvgUpper12 = vector<double>(N, MissingDouble());
}
}

Tavg01 = CaptureOrInitializeToMissing(futTavg01);
Tavg12 = CaptureOrInitializeToMissing(futTavg12);
rhAvg01 = CaptureOrInitializeToMissing(futrhAvg01);
rhAvgUpper12 = CaptureOrInitializeToMissing(futrhAvgUpper12);
}
catch (const HPExceptionType& e)
{
Expand Down

0 comments on commit 930e122

Please sign in to comment.