Skip to content

Commit

Permalink
Add ifs-mappings and multiple rules
Browse files Browse the repository at this point in the history
  • Loading branch information
geier1993 committed Sep 5, 2024
1 parent 8f51f99 commit 3b172aa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/metkit/config/LibMetkit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ eckit::PathName LibMetkit::mars2gribRuleListYamlFile() {
eckit::PathName LibMetkit::mars2gribStatParamRuleListYamlFile() {
return "~metkit/share/metkit/mars2grib/StatParamRuleList.yaml";
}
eckit::PathName LibMetkit::mars2gribIfsPrefixToLevTypeYamlFile() {
return "~metkit/share/metkit/mars2grib/IfsPrefixToLevTypeRuleList.yaml";
}

//----------------------------------------------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions src/metkit/config/LibMetkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class LibMetkit : public eckit::system::Library {

static eckit::PathName mars2gribRuleListYamlFile();
static eckit::PathName mars2gribStatParamRuleListYamlFile();
static eckit::PathName mars2gribIfsPrefixToLevTypeYamlFile();

static const LibMetkit& instance();

Expand Down
6 changes: 6 additions & 0 deletions src/metkit/mars2grib/Mars2Grib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ static pthread_once_t once = PTHREAD_ONCE_INIT;

static std::unique_ptr<metkit::mars2grib::RuleList> mars2GribRuleList_{nullptr};
static std::unique_ptr<metkit::mars2grib::RuleList> statParamInfoRuleList_{nullptr};
static std::unique_ptr<metkit::mars2grib::RuleList> ifsPrefixToLevTypeRuleList_{nullptr};
}

static void init() {
local_mutex = new eckit::Mutex();
mars2GribRuleList_ = std::make_unique<metkit::mars2grib::RuleList>(eckit::YAMLConfiguration{LibMetkit::mars2gribRuleListYamlFile()});
statParamInfoRuleList_ = std::make_unique<metkit::mars2grib::RuleList>(eckit::YAMLConfiguration{LibMetkit::mars2gribStatParamRuleListYamlFile()});
ifsPrefixToLevTypeRuleList_ = std::make_unique<metkit::mars2grib::RuleList>(eckit::YAMLConfiguration{LibMetkit::mars2gribIfsPrefixToLevTypeYamlFile()});
}

namespace metkit::mars2grib {
Expand All @@ -54,6 +56,10 @@ const RuleList& statParamRuleList() {
return *(statParamInfoRuleList_.get());
}

const RuleList& ifsPrefixToLevTypeRuleList() {
pthread_once(&once, init);
return *(ifsPrefixToLevTypeRuleList_.get());
}


void convertMars2Grib(const eckit::ValueMap& initial, KeySetter& out, const RuleList& ruleList) {
Expand Down
1 change: 1 addition & 0 deletions src/metkit/mars2grib/Mars2Grib.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace metkit::mars2grib {

const RuleList& ruleList();
const RuleList& statParamRuleList();
const RuleList& ifsPrefixToLevTypeRuleList();

/**
* Reads specific mars keys
Expand Down

0 comments on commit 3b172aa

Please sign in to comment.