-
Notifications
You must be signed in to change notification settings - Fork 19
XIOS: Handle CGField
#951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XIOS: Handle CGField
#951
Changes from 8 commits
d9cd786
c40666f
330e5c8
4e9d7e6
38cdf7b
6e7df34
e150bc0
536b02b
8f40681
ae7c4e0
26a3c6f
0aadc1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -682,7 +682,7 @@ void Xios::affixModelMetadata() | |
| } | ||
| auto dimName = dim.getName(); | ||
| size_t localLength; | ||
| size_t start = 0; | ||
| size_t start; | ||
| if (dimType == ModelArray::Dimension::X) { | ||
| localLength = metadata.getLocalExtentX(); | ||
| start = metadata.getLocalCornerX(); | ||
|
|
@@ -695,8 +695,15 @@ void Xios::affixModelMetadata() | |
| } else if (dimType == ModelArray::Dimension::YVERTEX) { | ||
| localLength = metadata.getLocalExtentY() + 1; | ||
| start = metadata.getLocalCornerY(); | ||
| } else if (dimType == ModelArray::Dimension::XCG) { | ||
| localLength = CGDEGREE * metadata.getLocalExtentX() + 1; | ||
| start = CGDEGREE * metadata.getLocalCornerX(); | ||
| } else if (dimType == ModelArray::Dimension::YCG) { | ||
| localLength = CGDEGREE * metadata.getLocalExtentY() + 1; | ||
| start = CGDEGREE * metadata.getLocalCornerY(); | ||
| } else { | ||
| localLength = dim.getSize(); | ||
| start = 0; | ||
| } | ||
|
|
||
| if (ModelArray::definedDimensions.at(dimType) | ||
|
|
@@ -706,15 +713,21 @@ void Xios::affixModelMetadata() | |
| } else { | ||
| // Otherwise, check that an attempt to modify them isn't being made | ||
| if (dim.getSize() != ModelArray::definedDimensions.at(dimType).globalLength) { | ||
| throw std::runtime_error( | ||
| "Xios: inconsistent global dimensions for " + dimName); | ||
| throw std::runtime_error("Xios: inconsistent global dimensions for " | ||
| + dimName + ": " + std::to_string(dim.getSize()) + " vs. " | ||
| + std::to_string( | ||
| ModelArray::definedDimensions.at(dimType).globalLength)); | ||
| } | ||
| if (localLength != ModelArray::size(dimType)) { | ||
| throw std::runtime_error( | ||
| "Xios: inconsistent local dimensions for " + dimName); | ||
| if (localLength != ModelArray::definedDimensions.at(dimType).localLength) { | ||
| throw std::runtime_error("Xios: inconsistent local dimensions for " | ||
| + dimName + ": " + std::to_string(localLength) + " vs. " | ||
| + std::to_string( | ||
| ModelArray::definedDimensions.at(dimType).localLength)); | ||
| } | ||
| if (start != ModelArray::definedDimensions.at(dimType).start) { | ||
| throw std::runtime_error("Xios: inconsistent start index for " + dimName); | ||
| throw std::runtime_error("Xios: inconsistent start index for " + dimName | ||
| + ": " + std::to_string(start) + " vs. " | ||
| + std::to_string(ModelArray::definedDimensions.at(dimType).start)); | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -727,7 +740,7 @@ void Xios::affixModelMetadata() | |
| { "ydimxdimdg_comp", ModelArray::Type::DG }, | ||
| { "yxdgstress_comp", ModelArray::Type::DGSTRESS }, | ||
| { "ydimxdimdgstress_comp", ModelArray::Type::DGSTRESS }, | ||
| { "ycgxcg", ModelArray::Type::CG }, | ||
| { "y_cgx_cg", ModelArray::Type::CG }, | ||
| { "yvertexxvertexncoords", ModelArray::Type::VERTEX }, | ||
| }; | ||
|
|
||
|
|
@@ -809,9 +822,15 @@ void Xios::affixModelMetadata() | |
| if (dim == ModelArray::Dimension::X) { | ||
| cxios_set_domain_ni_glo(domain, metadata.getGlobalExtentX()); | ||
| cxios_set_domain_ni(domain, metadata.getLocalExtentX()); | ||
| cxios_set_domain_ibegin(domain, metadata.getLocalCornerX()); | ||
| } else if (dim == ModelArray::Dimension::XVERTEX) { | ||
| cxios_set_domain_ni_glo(domain, metadata.getGlobalExtentX() + 1); | ||
| cxios_set_domain_ni(domain, metadata.getLocalExtentX() + 1); | ||
| cxios_set_domain_ibegin(domain, metadata.getLocalCornerX()); | ||
| } else if (dim == ModelArray::Dimension::XCG) { | ||
| cxios_set_domain_ni_glo(domain, CGDEGREE * metadata.getGlobalExtentX() + 1); | ||
| cxios_set_domain_ni(domain, CGDEGREE * metadata.getLocalExtentX() + 1); | ||
| cxios_set_domain_ibegin(domain, CGDEGREE * metadata.getLocalCornerX()); | ||
| } else { | ||
| throw std::runtime_error( | ||
| "Xios: Could not set domain extents based on dimension '" | ||
|
|
@@ -825,7 +844,6 @@ void Xios::affixModelMetadata() | |
| throw std::runtime_error( | ||
| "Xios: Failed to set local x-size for domain '" + domainId + "'"); | ||
| } | ||
| cxios_set_domain_ibegin(domain, metadata.getLocalCornerX()); | ||
| if (!cxios_is_defined_domain_ibegin(domain)) { | ||
| throw std::runtime_error( | ||
| "Xios: Failed to set local starting x-index for domain '" + domainId + "'"); | ||
|
|
@@ -844,9 +862,15 @@ void Xios::affixModelMetadata() | |
| if (dim == ModelArray::Dimension::Y) { | ||
| cxios_set_domain_nj_glo(domain, metadata.getGlobalExtentY()); | ||
| cxios_set_domain_nj(domain, metadata.getLocalExtentY()); | ||
| cxios_set_domain_jbegin(domain, metadata.getLocalCornerY()); | ||
| } else if (dim == ModelArray::Dimension::YVERTEX) { | ||
| cxios_set_domain_nj_glo(domain, metadata.getGlobalExtentY() + 1); | ||
| cxios_set_domain_nj(domain, metadata.getLocalExtentY() + 1); | ||
| cxios_set_domain_jbegin(domain, metadata.getLocalCornerY()); | ||
| } else if (dim == ModelArray::Dimension::YCG) { | ||
| cxios_set_domain_nj_glo(domain, CGDEGREE * metadata.getGlobalExtentY() + 1); | ||
| cxios_set_domain_nj(domain, CGDEGREE * metadata.getLocalExtentY() + 1); | ||
| cxios_set_domain_jbegin(domain, CGDEGREE * metadata.getLocalCornerY()); | ||
| } else { | ||
| throw std::runtime_error( | ||
| "Xios: Could not set domain extents based on dimension '" | ||
|
|
@@ -860,7 +884,6 @@ void Xios::affixModelMetadata() | |
| throw std::runtime_error( | ||
| "Xios: Failed to set local y-size for domain '" + domainId + "'"); | ||
| } | ||
| cxios_set_domain_jbegin(domain, metadata.getLocalCornerY()); | ||
| if (!cxios_is_defined_domain_jbegin(domain)) { | ||
| throw std::runtime_error( | ||
| "Xios: Failed to set local starting y-index for domain '" + domainId + "'"); | ||
|
|
@@ -1675,14 +1698,14 @@ void Xios::write(const std::string fieldId, ModelArray& modelarray) | |
| std::set<std::string> fieldNames = configGetFieldNames(readAccess); | ||
| if (fieldNames.find(fieldId) == fieldNames.end()) { | ||
| throw std::runtime_error( | ||
| "Xios::write: field " + fieldId + " has not been configured for writing with XIOS."); | ||
| "Xios::write: field '" + fieldId + "' has not been configured for writing with XIOS."); | ||
| } | ||
| if (modelarray.nDimensions() != 2) { | ||
| throw std::invalid_argument("Only ModelArrays of dimension 2 are supported"); | ||
| } | ||
| auto dims = modelarray.dimensions(); | ||
| auto type = modelarray.getType(); | ||
| if (type == ModelArray::Type::H) { | ||
| if ((type == ModelArray::Type::H) || (type == ModelArray::Type::CG)) { | ||
| cxios_write_data_k82( | ||
| fieldId.c_str(), fieldId.length(), modelarray.getData(), dims[0], dims[1], -1); | ||
| } else if (type == ModelArray::Type::VERTEX) { | ||
|
|
@@ -1696,7 +1719,7 @@ void Xios::write(const std::string fieldId, ModelArray& modelarray) | |
| dims[1], ModelArray::size(ModelArray::Dimension::DGSTRESS), -1); | ||
| } else { | ||
| throw std::invalid_argument( | ||
| "Only HFields, VertexFields, DGFields, and DGStressFields are supported"); | ||
| "Only HFields, VertexFields, DGFields, DGStressFields, and CGFields are supported"); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1712,14 +1735,14 @@ void Xios::read(const std::string fieldId, ModelArray& modelarray) | |
| std::set<std::string> fieldNames = configGetFieldNames(readAccess); | ||
| if (fieldNames.find(fieldId) == fieldNames.end()) { | ||
| throw std::runtime_error( | ||
| "Xios::read: field " + fieldId + " has not been configured for reading with XIOS."); | ||
| "Xios::read: field '" + fieldId + "' has not been configured for reading with XIOS."); | ||
| } | ||
| if (modelarray.nDimensions() != 2) { | ||
| throw std::invalid_argument("Only ModelArrays of dimension 2 are supported"); | ||
| } | ||
| auto dims = modelarray.dimensions(); | ||
| auto type = modelarray.getType(); | ||
| if (type == ModelArray::Type::H) { | ||
| if ((type == ModelArray::Type::H) || (type == ModelArray::Type::CG)) { | ||
| cxios_read_data_k82( | ||
| fieldId.c_str(), fieldId.length(), modelarray.getData(), dims[0], dims[1]); | ||
| } else if (type == ModelArray::Type::VERTEX) { | ||
|
|
@@ -1733,7 +1756,7 @@ void Xios::read(const std::string fieldId, ModelArray& modelarray) | |
| dims[1], ModelArray::size(ModelArray::Dimension::DGSTRESS)); | ||
| } else { | ||
| throw std::invalid_argument( | ||
| "Only HFields, VertexFields, DGFields, and DGStressFields are supported"); | ||
| "Only HFields, VertexFields, DGFields, DGStressFields, and CGFields are supported"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW this is also how I am currently determining the CG dims.... but I would like to hear Tim's comments on PR #969 first. I am worried we might end up in a situation where CG dims is set in several different places. I don't think you need to change this, just raising it as an FYI.