diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d1b26a..a126730 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### # MONIO - Met Office NetCDF Input Output # # # -# (C) Crown Copyright 2023 Met Office # +# (C) Crown Copyright 2023, Met Office. # # # # This software is licensed under the terms of the Apache Licence Version 2.0 # # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # diff --git a/ci/CMakeLists.txt b/ci/CMakeLists.txt index 0728893..c36f6bf 100644 --- a/ci/CMakeLists.txt +++ b/ci/CMakeLists.txt @@ -1,3 +1,12 @@ +############################################################################### +# MONIO - Met Office NetCDF Input Output # +# # +# (C) Crown Copyright 2023, Met Office. # +# # +# This software is licensed under the terms of the Apache Licence Version 2.0 # +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # +############################################################################### + cmake_minimum_required( VERSION 3.20 FATAL_ERROR ) project( monio-ci VERSION 0.0.1 LANGUAGES C CXX Fortran ) diff --git a/ci/build-and-lint b/ci/build-and-lint index ce6653e..b25c8b1 100755 --- a/ci/build-and-lint +++ b/ci/build-and-lint @@ -1,7 +1,12 @@ #!/bin/bash -# -# (C) Crown Copyright 2023, the Met Office. All rights reserved. -# +############################################################################### +# MONIO - Met Office NetCDF Input Output # +# # +# (C) Crown Copyright 2023, Met Office. # +# # +# This software is licensed under the terms of the Apache Licence Version 2.0 # +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # +############################################################################### set -euo pipefail finally() { diff --git a/ci/build-and-test b/ci/build-and-test index 71844e2..de7bf90 100755 --- a/ci/build-and-test +++ b/ci/build-and-test @@ -1,7 +1,12 @@ #!/bin/bash -# -# (C) Crown Copyright 2023, the Met Office. All rights reserved. -# +############################################################################### +# MONIO - Met Office NetCDF Input Output # +# # +# (C) Crown Copyright 2023, Met Office. # +# # +# This software is licensed under the terms of the Apache Licence Version 2.0 # +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # +############################################################################### set -euxo pipefail finally() { diff --git a/ci/get-ref-branch b/ci/get-ref-branch index 3ce3028..5ed7616 100755 --- a/ci/get-ref-branch +++ b/ci/get-ref-branch @@ -1,4 +1,12 @@ #!/bin/bash +############################################################################### +# MONIO - Met Office NetCDF Input Output # +# # +# (C) Crown Copyright 2023, Met Office. # +# # +# This software is licensed under the terms of the Apache Licence Version 2.0 # +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # +############################################################################### set -euxo pipefail repo="$1" # expect path to a repo clone diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84f4966..c9741fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### # MONIO - Met Office NetCDF Input Output # # # -# (C) Crown Copyright 2023 Met Office # +# (C) Crown Copyright 2023, Met Office. # # # # This software is licensed under the terms of the Apache Licence Version 2.0 # # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # diff --git a/src/monio/AtlasReader.cc b/src/monio/AtlasReader.cc index 3d34676..e893c31 100644 --- a/src/monio/AtlasReader.cc +++ b/src/monio/AtlasReader.cc @@ -12,6 +12,7 @@ #include "Utils.h" #include "UtilsAtlas.h" +#include "Monio.h" monio::AtlasReader::AtlasReader(const eckit::mpi::Comm& mpiCommunicator, const int mpiRankOwner): @@ -59,6 +60,7 @@ void monio::AtlasReader::populateFieldWithDataContainer(atlas::Field& field, break; } default: { + Monio::get().closeFiles(); utils::throwException("AtlasReader::populateFieldWithDataContainer()> " "Data type not coded for..."); } @@ -91,6 +93,7 @@ void monio::AtlasReader::populateFieldWithDataContainer(atlas::Field& field, break; } default: { + Monio::get().closeFiles(); utils::throwException("AtlasReader::populateFieldWithDataContainer()> " "Data type not coded for..."); } @@ -107,6 +110,7 @@ void monio::AtlasReader::populateField(atlas::Field& field, auto fieldView = atlas::array::make_view(field); // Field with noFirstLevel == true should have been adjusted to have 70 levels. if (noFirstLevel == true && field.levels() == consts::kVerticalFullSize) { + Monio::get().closeFiles(); utils::throwException("AtlasReader::populateField()> Field levels misconfiguration..."); // Only valid case for field with noFirstLevel == true. Field is adjusted to have 70 levels but // read data still has enough to fill 71. @@ -118,6 +122,7 @@ void monio::AtlasReader::populateField(atlas::Field& field, if (std::size_t(index) <= dataVec.size()) { fieldView(i, j - 1) = dataVec[index]; } else { + Monio::get().closeFiles(); utils::throwException("AtlasReader::populateField()> Calculated index exceeds size of " "data for field \"" + field.name() + "\"."); } @@ -132,6 +137,7 @@ void monio::AtlasReader::populateField(atlas::Field& field, if (std::size_t(index) <= dataVec.size()) { fieldView(i, j) = dataVec[index]; } else { + Monio::get().closeFiles(); utils::throwException("AtlasReader::populateField()> Calculated index exceeds size of " "data for field \"" + field.name() + "\"."); } @@ -170,6 +176,7 @@ void monio::AtlasReader::populateField(atlas::Field& field, if (std::size_t(index) <= dataVec.size()) { fieldView(i, j) = dataVec[index]; } else { + Monio::get().closeFiles(); utils::throwException("AtlasReader::populateField()> " "Calculated index exceeds size of data."); } @@ -192,6 +199,7 @@ atlas::Field monio::AtlasReader::getReadField(atlas::Field& field, if (atlasType != atlasType.KIND_REAL64 && atlasType != atlasType.KIND_REAL32 && atlasType != atlasType.KIND_INT32) { + Monio::get().closeFiles(); utils::throwException("AtlasReader::getReadField())> Data type not coded for..."); } atlas::util::Config atlasOptions = atlas::option::name(field.name()) | diff --git a/src/monio/AtlasWriter.cc b/src/monio/AtlasWriter.cc index 938c93f..a98ed43 100644 --- a/src/monio/AtlasWriter.cc +++ b/src/monio/AtlasWriter.cc @@ -17,6 +17,7 @@ #include "DataContainerFloat.h" #include "DataContainerInt.h" #include "Metadata.h" +#include "Monio.h" #include "Utils.h" #include "UtilsAtlas.h" #include "Writer.h" @@ -202,7 +203,8 @@ void monio::AtlasWriter::populateDataContainerWithField( break; } default: { - utils::throwException("AtlasWriter::populateDataContainerWithField()> " + Monio::get().closeFiles(); +utils::throwException("AtlasWriter::populateDataContainerWithField()> " "Data type not coded for..."); } } @@ -254,7 +256,8 @@ void monio::AtlasWriter::populateDataContainerWithField( break; } default: { - utils::throwException("AtlasWriter::populateDataContainerWithField()> " + Monio::get().closeFiles(); +utils::throwException("AtlasWriter::populateDataContainerWithField()> " "Data type not coded for..."); } } @@ -268,7 +271,8 @@ void monio::AtlasWriter::populateDataVec(std::vector& dataVec, oops::Log::debug() << "AtlasWriter::populateDataVec() " << field.name() << std::endl; int numLevels = field.levels(); if ((lfricToAtlasMap.size() * numLevels) != dataVec.size()) { - utils::throwException("AtlasWriter::populateDataVec()> " + Monio::get().closeFiles(); +utils::throwException("AtlasWriter::populateDataVec()> " "Data container is not configured for the expected data..."); } auto fieldView = atlas::array::make_view(field); @@ -323,10 +327,12 @@ atlas::Field monio::AtlasWriter::getWriteField(atlas::Field& field, if (atlasType != atlasType.KIND_REAL64 && atlasType != atlasType.KIND_REAL32 && atlasType != atlasType.KIND_INT32) { + Monio::get().closeFiles(); utils::throwException("AtlasWriter::getWriteField())> Data type not coded for..."); } // Erroneous case. For noFirstLevel == true field should have 70 levels if (noFirstLevel == true && field.levels() == consts::kVerticalFullSize) { + Monio::get().closeFiles(); utils::throwException("AtlasWriter::getWriteField()> Field levels misconfiguration..."); } // WARNING - This name-check is an LFRic-Lite specific convention... @@ -350,6 +356,7 @@ atlas::Field monio::AtlasWriter::getWriteField(atlas::Field& field, field.metadata().set("name", writeName); } } else { + Monio::get().closeFiles(); utils::throwException("AtlasWriter::getWriteField()> Field write name misconfiguration..."); } return field; diff --git a/src/monio/AtlasWriter.h b/src/monio/AtlasWriter.h index 3e96b25..5f066b7 100644 --- a/src/monio/AtlasWriter.h +++ b/src/monio/AtlasWriter.h @@ -1,10 +1,10 @@ /****************************************************************************** * MONIO - Met Office NetCDF Input Output * * * -* (C) Crown Copyright 2023, Met Office. All rights reserved. * +* (C) Crown Copyright 2023 Met Office * * * -* This software is licensed under the terms of the 3-Clause BSD License * -* which can be obtained from https://opensource.org/license/bsd-3-clause/. * +* This software is licensed under the terms of the Apache Licence Version 2.0 * +* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * ******************************************************************************/ #pragma once diff --git a/src/monio/Data.cc b/src/monio/Data.cc index a5df14b..37d388e 100644 --- a/src/monio/Data.cc +++ b/src/monio/Data.cc @@ -17,6 +17,7 @@ #include "DataContainerDouble.h" #include "DataContainerFloat.h" #include "DataContainerInt.h" +#include "Monio.h" #include "Utils.h" namespace { @@ -142,6 +143,7 @@ std::shared_ptr if (it != dataContainers_.end()) { return it->second; } else { + Monio::get().closeFiles(); utils::throwException("DataContainer named \"" + name + "\" was not found."); } } diff --git a/src/monio/DataContainerDouble.cc b/src/monio/DataContainerDouble.cc index a281f1b..855b438 100644 --- a/src/monio/DataContainerDouble.cc +++ b/src/monio/DataContainerDouble.cc @@ -11,6 +11,7 @@ #include #include "Constants.h" +#include "Monio.h" #include "Utils.h" monio::DataContainerDouble::DataContainerDouble(const std::string& name) : @@ -30,6 +31,7 @@ const std::vector& monio::DataContainerDouble::getData() const { const double& monio::DataContainerDouble::getDatum(const size_t index) { if (index > dataVector_.size()) { + Monio::get().closeFiles(); utils::throwException("DataContainerDouble::getDatum()> Passed index exceeds vector size..."); } diff --git a/src/monio/DataContainerFloat.cc b/src/monio/DataContainerFloat.cc index 772a349..c598987 100644 --- a/src/monio/DataContainerFloat.cc +++ b/src/monio/DataContainerFloat.cc @@ -11,6 +11,7 @@ #include #include "Constants.h" +#include "Monio.h" #include "Utils.h" monio::DataContainerFloat::DataContainerFloat(const std::string& name) : @@ -30,6 +31,7 @@ const std::vector& monio::DataContainerFloat::getData() const { const float& monio::DataContainerFloat::getDatum(const size_t index) { if (index > dataVector_.size()) { + Monio::get().closeFiles(); utils::throwException("DataContainerFloat::getDatum()> Passed index exceeds vector size..."); } return dataVector_[index]; diff --git a/src/monio/DataContainerInt.cc b/src/monio/DataContainerInt.cc index 89ca2dd..218213c 100644 --- a/src/monio/DataContainerInt.cc +++ b/src/monio/DataContainerInt.cc @@ -11,6 +11,7 @@ #include #include "Constants.h" +#include "Monio.h" #include "Utils.h" monio::DataContainerInt::DataContainerInt(const std::string& name) : @@ -30,6 +31,7 @@ const std::vector& monio::DataContainerInt::getData() const { const int& monio::DataContainerInt::getDatum(const size_t index) { if (index > dataVector_.size()) { + Monio::get().closeFiles(); utils::throwException("DataContainerInt::getDatum()> Passed index exceeds vector size..."); } return dataVector_[index]; diff --git a/src/monio/File.cc b/src/monio/File.cc index 5221101..f25eb30 100644 --- a/src/monio/File.cc +++ b/src/monio/File.cc @@ -254,8 +254,8 @@ void monio::File::readAttributes(Metadata& metadata) { metadata.addGlobalAttr(globAttr->getName(), globAttr); } } else { - utils::throwException( - "File::readAttributes()> Write file accessed for reading..."); + close(); + utils::throwException("File::readAttributes()> Write file accessed for reading..."); } } diff --git a/src/monio/Metadata.cc b/src/monio/Metadata.cc index ac00ade..4d82321 100644 --- a/src/monio/Metadata.cc +++ b/src/monio/Metadata.cc @@ -20,6 +20,7 @@ #include "AttributeDouble.h" #include "AttributeInt.h" #include "AttributeString.h" +#include "Monio.h" #include "Utils.h" monio::Metadata::Metadata() { @@ -142,6 +143,7 @@ int monio::Metadata::getDimension(const std::string& dimName) { if (isDimDefined(dimName) == true) { return dimensions_.at(dimName); } else { + Monio::get().closeFiles(); utils::throwException("Metadata::getDimension()> dimension \"" + dimName + "\" not found..."); } } @@ -170,6 +172,7 @@ std::shared_ptr monio::Metadata::getVariable(const std::string& if (it != variables_.end()) { return variables_.at(varName); } else { + Monio::get().closeFiles(); utils::throwException("Metadata::getVariable()> variable \"" + varName + "\" not found..."); } } @@ -182,6 +185,7 @@ const std::shared_ptr if (it != variables_.end()) { return variables_.at(varName); } else { + Monio::get().closeFiles(); utils::throwException("Metadata::getVariable()> variable \"" + varName + "\" not found..."); } } @@ -223,6 +227,7 @@ const std::vector monio::Metadata::getVarStrAttrs( varStrAttrs.push_back(attr); } if (varNames.size() != varStrAttrs.size()) { + Monio::get().closeFiles(); utils::throwException("Metadata::getVarStrAttrs()> " "Unmatched number of variables and attributes..."); } @@ -361,6 +366,7 @@ void monio::Metadata::deleteVariable(const std::string& varName) { if (it != variables_.end()) { variables_.erase(varName); } else { + Monio::get().closeFiles(); utils::throwException("Metadata::deleteVariable()> Variable \"" + varName + "\" not found..."); } } @@ -432,6 +438,7 @@ void monio::Metadata::printVariables() { break; } default: { + Monio::get().closeFiles(); utils::throwException("Metadata::printGlobalAttrs()> Data type not coded for..."); } } @@ -464,6 +471,7 @@ void monio::Metadata::printGlobalAttrs() { break; } default: { + Monio::get().closeFiles(); utils::throwException("Metadata::printGlobalAttrs()> Data type not coded for..."); } } diff --git a/src/monio/Monio.cc b/src/monio/Monio.cc index a9553e2..1c885ef 100644 --- a/src/monio/Monio.cc +++ b/src/monio/Monio.cc @@ -48,6 +48,7 @@ void monio::Monio::readState(atlas::FieldSet& localFieldSet, const util::DateTime& dateTime) { oops::Log::debug() << "Monio::readState()" << std::endl; if (localFieldSet.size() == 0) { + Monio::get().closeFiles(); utils::throwException("Monio::readState()> localFieldSet has zero fields..."); } if (filePath.length() != 0) { @@ -85,12 +86,15 @@ void monio::Monio::readState(atlas::FieldSet& localFieldSet, } catch (netCDF::exceptions::NcException& exception) { reader_.closeFile(); std::string exceptionMessage = exception.what(); + Monio::get().closeFiles(); utils::throwException("Monio::readState()> An exception has occurred: " + exceptionMessage); } } else { + Monio::get().closeFiles(); utils::throwException("Monio::readState()> File \"" + filePath + "\" does not exist..."); } } else { + Monio::get().closeFiles(); utils::throwException("Monio::readState()> No file path supplied..."); } } @@ -100,6 +104,7 @@ void monio::Monio::readIncrements(atlas::FieldSet& localFieldSet, const std::string& filePath) { oops::Log::debug() << "Monio::readIncrements()" << std::endl; if (localFieldSet.size() == 0) { + Monio::get().closeFiles(); utils::throwException("Monio::readIncrements()> localFieldSet has zero fields..."); } if (filePath.length() != 0) { @@ -137,13 +142,16 @@ void monio::Monio::readIncrements(atlas::FieldSet& localFieldSet, oops::Log::info() << " exception.what()> " << exception.what() << std::endl; reader_.closeFile(); std::string exceptionMessage = exception.what(); + Monio::get().closeFiles(); utils::throwException("Monio::readIncrements()> An exception has occurred: " + exceptionMessage); } } else { + Monio::get().closeFiles(); utils::throwException("Monio::readIncrements()> File \"" + filePath + "\" does not exist..."); } } else { + Monio::get().closeFiles(); utils::throwException("Monio::readIncrements()> No file path supplied..."); } } @@ -154,6 +162,7 @@ void monio::Monio::writeIncrements(const atlas::FieldSet& localFieldSet, const bool isLfricNaming) { oops::Log::debug() << "Monio::writeIncrements()" << std::endl; if (localFieldSet.size() == 0) { + Monio::get().closeFiles(); utils::throwException("Monio::writeIncrements()> localFieldSet has zero fields..."); } if (filePath.length() != 0) { @@ -174,6 +183,7 @@ void monio::Monio::writeIncrements(const atlas::FieldSet& localFieldSet, } else if (isLfricNaming == false && fieldMetadata.jediName == globalField.name()) { writeName = fieldMetadata.jediName; } else { + Monio::get().closeFiles(); utils::throwException("Monio::writeIncrements()> " "Field metadata configuration error..."); } @@ -194,6 +204,7 @@ void monio::Monio::writeIncrements(const atlas::FieldSet& localFieldSet, } catch (netCDF::exceptions::NcException& exception) { writer_.closeFile(); std::string exceptionMessage = exception.what(); + Monio::get().closeFiles(); utils::throwException("Monio::writeIncrements()> An exception occurred: " + exceptionMessage); } } else { @@ -208,6 +219,7 @@ void monio::Monio::writeState(const atlas::FieldSet& localFieldSet, const bool isLfricNaming) { oops::Log::debug() << "Monio::writeState()" << std::endl; if (localFieldSet.size() == 0) { + Monio::get().closeFiles(); utils::throwException("Monio::writeState()> localFieldSet has zero fields..."); } if (filePath.length() != 0) { @@ -228,6 +240,7 @@ void monio::Monio::writeState(const atlas::FieldSet& localFieldSet, } else if (isLfricNaming == false && fieldMetadata.jediName == globalField.name()) { writeName = fieldMetadata.jediName; } else { + Monio::get().closeFiles(); utils::throwException("Monio::writeState()> Field metadata configuration error..."); } oops::Log::debug() << "Monio::writeState() processing data for> \"" << @@ -247,6 +260,7 @@ void monio::Monio::writeState(const atlas::FieldSet& localFieldSet, } catch (netCDF::exceptions::NcException& exception) { writer_.closeFile(); std::string exceptionMessage = exception.what(); + Monio::get().closeFiles(); utils::throwException("Monio::writeState()> An exception has occurred: " + exceptionMessage); } } else { @@ -259,6 +273,7 @@ void monio::Monio::writeFieldSet(const atlas::FieldSet& localFieldSet, const std::string& filePath) { oops::Log::debug() << "Monio::writeFieldSet()" << std::endl; if (localFieldSet.size() == 0) { + Monio::get().closeFiles(); utils::throwException("Monio::writeFieldSet()> localFieldSet has zero fields..."); } if (filePath.length() != 0) { @@ -278,6 +293,7 @@ void monio::Monio::writeFieldSet(const atlas::FieldSet& localFieldSet, } catch (netCDF::exceptions::NcException& exception) { writer_.closeFile(); std::string exceptionMessage = exception.what(); + Monio::get().closeFiles(); utils::throwException("Monio::writeFieldSet()> An exception occurred: " + exceptionMessage); } } else { @@ -369,10 +385,10 @@ void monio::Monio::createDateTimes(FileData& fileData, std::shared_ptr timeVar = fileData.getMetadata().getVariable(timeVarName); std::shared_ptr timeDataBase = fileData.getData().getContainer(timeVarName); - if (timeDataBase->getType() != consts::eDouble) - utils::throwException("Monio::createDateTimes()> " - "Time data not stored as double..."); - + if (timeDataBase->getType() != consts::eDouble) { + Monio::get().closeFiles(); + utils::throwException("Monio::createDateTimes()> Time data not stored as double..."); + } std::shared_ptr timeData = std::static_pointer_cast(timeDataBase); diff --git a/src/monio/Reader.cc b/src/monio/Reader.cc index a8ae4b3..7499172 100644 --- a/src/monio/Reader.cc +++ b/src/monio/Reader.cc @@ -259,6 +259,7 @@ size_t monio::Reader::findTimeStep(const FileData& fileData, const util::DateTim oops::Log::debug() << "Reader::findTimeStep()" << std::endl; if (fileData.getDateTimes().size() == 0) { oops::Log::debug() << "Reader::findTimeStep()> Date times not initialised..." << std::endl; + closeFile(); utils::throwException("Reader::findTimeStep()> Date times not initialised..."); } diff --git a/src/monio/UtilsAtlas.cc b/src/monio/UtilsAtlas.cc index be7a53e..68526ac 100644 --- a/src/monio/UtilsAtlas.cc +++ b/src/monio/UtilsAtlas.cc @@ -19,6 +19,7 @@ #include "DataContainerDouble.h" #include "DataContainerFloat.h" +#include "Monio.h" #include "Utils.h" namespace monio { @@ -38,8 +39,8 @@ std::vector getLfricCoords( coordVectorArray[coordCount] = coordData; coordCount++; } else { - utils::throwException("utilsatlas::getLfricCoords()> " - "Data type not coded for..."); + Monio::get().closeFiles(); + utils::throwException("utilsatlas::getLfricCoords()> Data type not coded for..."); } } // Populate Atlas PointLonLat vector @@ -49,6 +50,7 @@ std::vector getLfricCoords( lfricCoords.push_back(atlas::PointLonLat(*lonIt, *latIt)); } } else { + Monio::get().closeFiles(); utils::throwException("utilsatlas::getLfricCoords()> " "Incorrect number of coordinate axes..."); } @@ -100,6 +102,7 @@ std::vector createLfricAtlasMap(const std::vector& a std::vector lfricAtlasMap; // Essential check to ensure grid is configured to accommodate the data if (atlasCoords.size() != lfricCoords.size()) { + Monio::get().closeFiles(); utils::throwException("utilsatlas::createLfricAtlasMap()> " "Configured grid is not compatible with input file..."); } @@ -135,6 +138,7 @@ atlas::Field getGlobalField(const atlas::Field& field) { if (atlasType != atlasType.KIND_REAL64 && atlasType != atlasType.KIND_REAL32 && atlasType != atlasType.KIND_INT32) { + Monio::get().closeFiles(); utils::throwException("utilsatlas::getGlobalFieldSet())> Data type not coded for..."); } const auto& functionSpace = field.functionspace(); @@ -155,6 +159,7 @@ atlas::FieldSet getGlobalFieldSet(const atlas::FieldSet& fieldSet) { } return globalFieldSet; } else { + Monio::get().closeFiles(); utils::throwException("utilsatlas::getGlobalFieldSet()> FieldSet has zero fields..."); } } @@ -183,17 +188,19 @@ int getGlobalDataSize(const atlas::Field& field) { int atlasTypeToMonioEnum(atlas::array::DataType atlasType) { switch (atlasType.kind()) { - case atlasType.KIND_INT32: { - return consts::eInt; - } - case atlasType.KIND_REAL32: { - return consts::eFloat; - } - case atlasType.KIND_REAL64: { - return consts::eDouble; - } - default: - utils::throwException("utilsatlas::atlasTypeToMonioEnum()> Data type not coded for..."); + case atlasType.KIND_INT32: { + return consts::eInt; + } + case atlasType.KIND_REAL32: { + return consts::eFloat; + } + case atlasType.KIND_REAL64: { + return consts::eDouble; + } + default: { + Monio::get().closeFiles(); + utils::throwException("utilsatlas::atlasTypeToMonioEnum()> Data type not coded for..."); + } } } diff --git a/src/monio/Variable.cc b/src/monio/Variable.cc index 63501b8..507472c 100644 --- a/src/monio/Variable.cc +++ b/src/monio/Variable.cc @@ -15,6 +15,7 @@ #include "AttributeInt.h" #include "AttributeString.h" #include "Constants.h" +#include "Monio.h" #include "Utils.h" monio::Variable::Variable(const std::string name, const int type): @@ -59,7 +60,8 @@ std::shared_ptr if (attributes_.find(attrName) != attributes_.end()) { return attributes_.at(attrName); } else { - utils::throwException("Variable::getAttribute()> Attribute \"" + + Monio::get().closeFiles(); +utils::throwException("Variable::getAttribute()> Attribute \"" + attrName + "\" not found..."); } } @@ -75,11 +77,13 @@ std::string monio::Variable::getStrAttr(const std::string& attrName) { value = attrStr->getValue(); return value; } else { - utils::throwException("Variable::getAttribute()> " + Monio::get().closeFiles(); +utils::throwException("Variable::getAttribute()> " "Variable attribute data type not coded for..."); } } else { - utils::throwException("Variable::getAttribute()> Attribute \"" + + Monio::get().closeFiles(); +utils::throwException("Variable::getAttribute()> Attribute \"" + attrName + "\" not found..."); } } @@ -91,7 +95,8 @@ void monio::Variable::addDimension(const std::string& dimName, const size_t size if (it == dimensions_.end()) { dimensions_.push_back(std::make_pair(dimName, size)); } else { - utils::throwException("Variable::addDimension()> Dimension \"" + + Monio::get().closeFiles(); +utils::throwException("Variable::addDimension()> Dimension \"" + dimName + "\" already defined..."); } } @@ -102,7 +107,8 @@ void monio::Variable::addAttribute(std::shared_ptr attr) { if (it == attributes_.end()) { attributes_.insert(std::make_pair(attrName, attr)); } else { - utils::throwException("Variable::addAttribute()> multiple definitions of \"" + + Monio::get().closeFiles(); +utils::throwException("Variable::addAttribute()> multiple definitions of \"" + attrName + "\"..."); } } @@ -122,7 +128,8 @@ void monio::Variable::deleteAttribute(const std::string& attrName) { if (it != attributes_.end()) { attributes_.erase(attrName); } else { - utils::throwException("Variable::deleteAttribute()> Attribute \"" + + Monio::get().closeFiles(); +utils::throwException("Variable::deleteAttribute()> Attribute \"" + attrName + "\" does not exist..."); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 57636e0..0f049d5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### # MONIO - Met Office NetCDF Input Output # # # -# (C) Crown Copyright 2023 Met Office # +# (C) Crown Copyright 2023, Met Office. # # # # This software is licensed under the terms of the Apache Licence Version 2.0 # # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. # diff --git a/test/mains/TestFieldSetWrite.cc b/test/mains/TestFieldSetWrite.cc index fbae32d..30db5f4 100644 --- a/test/mains/TestFieldSetWrite.cc +++ b/test/mains/TestFieldSetWrite.cc @@ -11,7 +11,7 @@ /// \brief This test targets Monio::writeFieldSet. An LFRic background file is read, field sets are /// populated, and written directly to file. No comparison takes place as the data are left -/// in Atlas order. A test pass is achieved simply if the function calls pass without issue. +/// in Atlas order. A pass is achieved simply if the function calls complete without issue. int main(int argc, char ** argv) { oops::Run run(argc, argv); monio::test::FieldSetWrite tests; diff --git a/test/mains/TestStateBasic.cc b/test/mains/TestStateBasic.cc index 587714e..224ee22 100644 --- a/test/mains/TestStateBasic.cc +++ b/test/mains/TestStateBasic.cc @@ -11,7 +11,7 @@ /// \brief This test targets a workflow that avoids the Monio singleton, and the use of Atlas. It /// reads an input file, writes the data to file, reads that back in and checks the data for -/// integrity. A test pass is achieved if the data first read matches the written data. +/// integrity. A test pass is achieved if the data first read matches that written. int main(int argc, char ** argv) { oops::Run run(argc, argv); monio::test::StateBasic tests;