Skip to content
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

Feature/open source #23

Merged
merged 17 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
###############################################################################
# MONIO - Met Office NetCDF Input Output #
# #
# (C) Crown Copyright 2023, Met Office. #
# (C) Crown Copyright 2023, Met Office. All rights reserved. #
# #
# 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. #
# 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/. #
###############################################################################

cmake_minimum_required(VERSION 3.12)
Expand Down
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2023, Met Office

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ Where `localFieldSet` is the `atlas::FieldSet` to be populated with data from th

### Writing Increment Files

Writing of an LFRic-compatible, time-independent, increment file can be carried out with the following call:
Writing of an LFRic-compatible, time-independent, increment file is dependent on geometry data and other metadata being available at the resolution you intend to write. These will be available if MONIO has already been used to read LFRic-compatible data at the same resolution you intend to write (see the read functions described above). If MONIO has not been used for reading, writing will first require that geometry and metadata are copied from an appropriate input file using the following call:

```
monio::Monio::get().initialiseFile(grid, filePath);
```

Where `grid` is a reference to the `atlas::CubedSphereGrid` used to setup the geometry of the `atlas::FieldSet`, `filePath` is a `std::string` defining a valid path to the file to be read. This particular function call returns an `int` that determines the variable naming convention used in the input file. However, it is necessary to capture and use that `int` here.

Following this, or if MONIO was also used to read LFRic-compatible data, writing of an LFRic-compatible, time-independent, increment file can be carried out with the following call:

```
monio::Monio::get().writeIncrements(localFieldSet, fieldMetadataVec, filePath, isLFRicNaming);
Expand All @@ -71,7 +79,15 @@ Where `localFieldSet` is the `atlas::FieldSet` containing the data to be written

### Writing State Files

_This method is intended for use with tests only_. Writing of an LFRic-compatible, time-independent, state file can be carried out with the following call:
_This method is intended for use with tests only_. Writing of an LFRic-compatible, time-independent, state file is dependent on geometry data and other metadata being available at the resolution you intend to write. These will be available if MONIO has already been used to read LFRic-compatible data at the same resolution you intend to write (see the read functions described above). If MONIO has not been used for reading, writing will first require that geometry and metadata are copied from an appropriate input file using the following call:

```
monio::Monio::get().initialiseFile(grid, filePath);
```

Where `grid` is a reference to the `atlas::CubedSphereGrid` used to setup the geometry of the `atlas::FieldSet`, `filePath` is a `std::string` defining a valid path to the file to be read. This particular function call returns an `int` that determines the variable naming convention used in the input file. However, it is necessary to capture and use that `int` here.

Following this, writing of an LFRic-compatible, time-independent, state file can be carried out with the following call:

```
monio::Monio::get().writeState(localFieldSet, fieldMetadataVec, filePath, isLFRicNaming);
Expand All @@ -81,13 +97,13 @@ Where `localFieldSet` is the `atlas::FieldSet` containing the data to be written

### Writing A FieldSet

For debugging, it may occasionally be useful to output a `FieldSet` from any arbitrary position in the code into a NetCDF so that it can be examined. For this reason, MONIO offers the following call:
For debugging, it may occasionally be useful to output an `atlas::FieldSet` from any arbitrary position in the code into a NetCDF so that it can be examined. For this reason, MONIO offers the following call:

```
monio::Monio::get().writeFieldSet(localFieldSet, filePath);
```

Where `localFieldSet` is the `atlas::FieldSet` containing the data to be written to file, and `filePath` is a `std::string` defining a valid path to the intended output file.
Where `localFieldSet` is the `atlas::FieldSet` containing the data to be written to file, and `filePath` is a `std::string` defining a valid path to the intended output file. It should be noted that this particular writing method requires no existing geometric data or metadata to be provided, and so requires no supporting function call to be executed beforehand. For this reason, data are written in their default, Atlas order.

## Issues

Expand Down
6 changes: 3 additions & 3 deletions ci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
###############################################################################
# MONIO - Met Office NetCDF Input Output #
# #
# (C) Crown Copyright 2023, Met Office. #
# (C) Crown Copyright 2023, Met Office. All rights reserved. #
# #
# 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. #
# 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/. #
###############################################################################

cmake_minimum_required( VERSION 3.20 FATAL_ERROR )
Expand Down
6 changes: 3 additions & 3 deletions ci/build-and-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
###############################################################################
# MONIO - Met Office NetCDF Input Output #
# #
# (C) Crown Copyright 2023, Met Office. #
# (C) Crown Copyright 2023, Met Office. All rights reserved. #
# #
# 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. #
# 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/. #
###############################################################################
set -euo pipefail

Expand Down
6 changes: 3 additions & 3 deletions ci/build-and-test
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
###############################################################################
# MONIO - Met Office NetCDF Input Output #
# #
# (C) Crown Copyright 2023, Met Office. #
# (C) Crown Copyright 2023, Met Office. All rights reserved. #
# #
# 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. #
# 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/. #
###############################################################################
set -euxo pipefail

Expand Down
6 changes: 3 additions & 3 deletions ci/get-ref-branch
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
###############################################################################
# MONIO - Met Office NetCDF Input Output #
# #
# (C) Crown Copyright 2023, Met Office. #
# (C) Crown Copyright 2023, Met Office. All rights reserved. #
# #
# 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. #
# 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/. #
###############################################################################
set -euxo pipefail
repo="$1" # expect path to a repo clone
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
###############################################################################
# MONIO - Met Office NetCDF Input Output #
# #
# (C) Crown Copyright 2023, Met Office. #
# (C) Crown Copyright 2023, Met Office. All rights reserved. #
# #
# 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. #
# 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/. #
###############################################################################

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
82 changes: 41 additions & 41 deletions src/monio/AtlasReader.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/******************************************************************************
* MONIO - Met Office NetCDF Input Output *
* *
* (C) Crown Copyright 2023 Met Office *
* (C) Crown Copyright 2023, Met Office. All rights reserved. *
* *
* 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. *
* 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/. *
******************************************************************************/
#include "AtlasReader.h"

Expand Down Expand Up @@ -41,25 +41,25 @@ void monio::AtlasReader::populateFieldWithDataContainer(atlas::Field& field,
if (mpiCommunicator_.rank() == mpiRankOwner_) {
int dataType = dataContainer.get()->getType();
switch (dataType) {
case consts::eDataTypes::eDouble: {
const std::shared_ptr<DataContainerDouble> dataContainerDouble =
std::static_pointer_cast<DataContainerDouble>(dataContainer);
populateField(field, dataContainerDouble->getData(), lfricToAtlasMap, noFirstLevel);
break;
}
case consts::eDataTypes::eFloat: {
const std::shared_ptr<DataContainerFloat> dataContainerFloat =
std::static_pointer_cast<DataContainerFloat>(dataContainer);
populateField(field, dataContainerFloat->getData(), lfricToAtlasMap, noFirstLevel);
break;
}
case consts::eDataTypes::eInt: {
const std::shared_ptr<DataContainerInt> dataContainerInt =
std::static_pointer_cast<DataContainerInt>(dataContainer);
populateField(field, dataContainerInt->getData(), lfricToAtlasMap, noFirstLevel);
break;
}
default: {
case consts::eDataTypes::eDouble: {
const std::shared_ptr<DataContainerDouble> dataContainerDouble =
std::static_pointer_cast<DataContainerDouble>(dataContainer);
populateField(field, dataContainerDouble->getData(), lfricToAtlasMap, noFirstLevel);
break;
}
case consts::eDataTypes::eFloat: {
const std::shared_ptr<DataContainerFloat> dataContainerFloat =
std::static_pointer_cast<DataContainerFloat>(dataContainer);
populateField(field, dataContainerFloat->getData(), lfricToAtlasMap, noFirstLevel);
break;
}
case consts::eDataTypes::eInt: {
const std::shared_ptr<DataContainerInt> dataContainerInt =
std::static_pointer_cast<DataContainerInt>(dataContainer);
populateField(field, dataContainerInt->getData(), lfricToAtlasMap, noFirstLevel);
break;
}
default: {
Monio::get().closeFiles();
utils::throwException("AtlasReader::populateFieldWithDataContainer()> "
"Data type not coded for...");
Expand All @@ -74,25 +74,25 @@ void monio::AtlasReader::populateFieldWithDataContainer(atlas::Field& field,
if (mpiCommunicator_.rank() == mpiRankOwner_) {
int dataType = dataContainer.get()->getType();
switch (dataType) {
case consts::eDataTypes::eDouble: {
const std::shared_ptr<DataContainerDouble> dataContainerDouble =
std::static_pointer_cast<DataContainerDouble>(dataContainer);
populateField(field, dataContainerDouble->getData());
break;
}
case consts::eDataTypes::eFloat: {
const std::shared_ptr<DataContainerFloat> dataContainerFloat =
std::static_pointer_cast<DataContainerFloat>(dataContainer);
populateField(field, dataContainerFloat->getData());
break;
}
case consts::eDataTypes::eInt: {
const std::shared_ptr<DataContainerInt> dataContainerInt =
std::static_pointer_cast<DataContainerInt>(dataContainer);
populateField(field, dataContainerInt->getData());
break;
}
default: {
case consts::eDataTypes::eDouble: {
const std::shared_ptr<DataContainerDouble> dataContainerDouble =
std::static_pointer_cast<DataContainerDouble>(dataContainer);
populateField(field, dataContainerDouble->getData());
break;
}
case consts::eDataTypes::eFloat: {
const std::shared_ptr<DataContainerFloat> dataContainerFloat =
std::static_pointer_cast<DataContainerFloat>(dataContainer);
populateField(field, dataContainerFloat->getData());
break;
}
case consts::eDataTypes::eInt: {
const std::shared_ptr<DataContainerInt> dataContainerInt =
std::static_pointer_cast<DataContainerInt>(dataContainer);
populateField(field, dataContainerInt->getData());
break;
}
default: {
Monio::get().closeFiles();
utils::throwException("AtlasReader::populateFieldWithDataContainer()> "
"Data type not coded for...");
Expand Down
6 changes: 3 additions & 3 deletions src/monio/AtlasReader.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/******************************************************************************
* MONIO - Met Office NetCDF Input Output *
* *
* (C) Crown Copyright 2023 Met Office *
* (C) Crown Copyright 2023, Met Office. All rights reserved. *
* *
* 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. *
* 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/. *
******************************************************************************/
#pragma once

Expand Down
Loading