Skip to content

Commit

Permalink
fixed issues
Browse files Browse the repository at this point in the history
- bug where cap soil profile from last message was used if no profile was supplied in a subsequent message
- fixed problem with variable capture also vor DataAccessor
  • Loading branch information
bergm committed Aug 30, 2024
1 parent 5cc7165 commit af039e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/run/run-monica-capnp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,18 @@ kj::Promise<void> RunMonica::run(RunContext context)
};

auto proms = kj::heapArrayBuilder<kj::Promise<void>>(2);
DataAccessor da;
//DataAccessor da;
//J11Array soilLayers;

if (envR.hasTimeSeries()) {
auto ts = envR.getTimeSeries();
proms.add(dataAccessorFromTimeSeries(ts).then([&da](const DataAccessor &da2) {
da = da2;
proms.add(dataAccessorFromTimeSeries(ts).then([this](const DataAccessor &da2) {
_da = da2;
}, [](auto &&e) {
KJ_LOG(INFO, "Error while trying to get data accessor from time series: ", e);
}));
} else {
_da = DataAccessor();
proms.add(kj::READY_NOW);
}

Expand All @@ -133,11 +134,12 @@ kj::Promise<void> RunMonica::run(RunContext context)
KJ_LOG(INFO, "Error while trying to get soil layers: ", e);
}));
} else {
_soilLayers = J11Array();
proms.add(kj::READY_NOW);
}

return kj::joinPromises(proms.finish()).then([context, runMonica, da, this]() mutable {
auto out = runMonica(da, _soilLayers);
return kj::joinPromises(proms.finish()).then([context, runMonica, this]() mutable {
auto out = runMonica(_da, _soilLayers);
auto rs = context.getResults();
auto res = rs.initResult();
res.initStructure().setJson();
Expand Down
2 changes: 2 additions & 0 deletions src/run/run-monica-capnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Copyright (C) Leibniz Centre for Agricultural Landscape Research (ZALF)
#include "common/common.h"
#include "common/restorer.h"
#include "json11/json11-helper.h"
#include "climate/climate-common.h"

#include "model.capnp.h"
#include "common.capnp.h"
Expand Down Expand Up @@ -74,6 +75,7 @@ class RunMonica final : public MonicaEnvInstance::Server {
mas::infrastructure::common::Restorer *_restorer{nullptr};
MonicaEnvInstance::Client _client{nullptr};
Tools::J11Array _soilLayers;
Climate::DataAccessor _da;
};

} // namespace monica

0 comments on commit af039e6

Please sign in to comment.