-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hotfix/0.35.1: (24 commits) Update changelog Version 0.35.1 Add errors for healpix grid when ordering is not 'ring' Better error message when MatchingPartitioner is not initialised with Mesh/FunctionSpace to match atlas-grid-points Improve GridBuilder and atlas-grids output Fixup 03ef162 Use configurable KDTree geometry in PointCloud Configurable geometry in KDTree Fix warning about returning 0 instead of nullptr in ElementType.cc Fix warning about readability braces in ElementType.cc Fixes to MeshBuilder validate_mesh_vs_grid Fixup 0b1ed6b, fixing warnings of missing typename Add control to skip Gmsh-output of triangles with too large edge length ratio Add atlas::io support for std::vector<std::array> Better error message in atlas::io StdVectorAdaptor Allow constructor of atlas::io::ArrayShape with different integer types Support atlas_io with vector<std::int64_t> Make treat_failure_as_missing_value configurable Use search radius in FiniteElement when mesh defines metadata to do so ...
- Loading branch information
Showing
36 changed files
with
879 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.35.0 | ||
0.35.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
atlas_io/src/atlas_io/types/array/adaptors/StdVectorOfStdArrayAdaptor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* (C) Copyright 2020 ECMWF. | ||
* | ||
* 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. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation | ||
* nor does it submit to any jurisdiction. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include <array> | ||
|
||
#include "atlas_io/Data.h" | ||
#include "atlas_io/Exceptions.h" | ||
#include "atlas_io/Metadata.h" | ||
#include "atlas_io/types/array/ArrayMetadata.h" | ||
#include "atlas_io/types/array/ArrayReference.h" | ||
|
||
namespace std { | ||
|
||
//--------------------------------------------------------------------------------------------------------------------- | ||
|
||
template <typename T, size_t N> | ||
void interprete(const std::vector<std::array<T, N>>& vector_of_array, atlas::io::ArrayReference& out) { | ||
using atlas::io::ArrayReference; | ||
out = ArrayReference{vector_of_array.front().data(), {vector_of_array.size(),N}}; | ||
} | ||
|
||
//--------------------------------------------------------------------------------------------------------------------- | ||
|
||
template <typename T, size_t N> | ||
void decode(const atlas::io::Metadata& m, const atlas::io::Data& encoded, std::vector<std::array<T, N>>& out) { | ||
atlas::io::ArrayMetadata array(m); | ||
if (array.datatype().kind() != atlas::io::ArrayMetadata::DataType::kind<T>()) { | ||
std::stringstream err; | ||
err << "Could not decode " << m.json() << " into std::vector<" << atlas::io::demangle<T>() << ">. " | ||
<< "Incompatible datatype!"; | ||
throw atlas::io::Exception(err.str(), Here()); | ||
} | ||
if (array.rank() != 2) { | ||
std::stringstream err; | ||
err << "Could not decode " << m.json() << " into std::vector<std::array<" << atlas::io::demangle<T>() << "," << N << ">>. " | ||
<< "Incompatible rank!"; | ||
throw atlas::io::Exception(err.str(), Here()); | ||
} | ||
if (array.shape(1) != N) { | ||
std::stringstream err; | ||
err << "Could not decode " << m.json() << " into std::vector<std::array<" << atlas::io::demangle<T>() << "," << N << ">>. " | ||
<< "Incompatible size!"; | ||
throw atlas::io::Exception(err.str(), Here()); | ||
} | ||
const std::array<T,N>* data = static_cast<const std::array<T,N>*>(encoded.data()); | ||
// std::copy(data, data + array.shape(0), out.begin()); | ||
out.assign(data, data + array.shape(0)); | ||
|
||
} | ||
|
||
//--------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} // end namespace std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* (C) Copyright 2013 ECMWF. | ||
* | ||
* 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. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation | ||
* nor does it submit to any jurisdiction. | ||
*/ | ||
|
||
#include <fstream> | ||
|
||
#include "atlas/grid.h" | ||
#include "atlas/library.h" | ||
#include "atlas/runtime/AtlasTool.h" | ||
#include "atlas/util/GridPointsJSONWriter.h" | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
using namespace atlas; | ||
using eckit::PathName; | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
class Program : public AtlasTool { | ||
int execute(const Args& args) override; | ||
std::string briefDescription() override { return "Write grid points to file"; } | ||
std::string usage() override { return name() + " GRID [OPTION]... [--help]"; } | ||
std::string longDescription() override { | ||
return " The 'GRID' argument can be either the name of a named grid, or the path to a" | ||
" YAML configuration file that describes the grid.\n" | ||
"Example values for grid names are: N80, F40, O24, L64x33, CS-ED-12. See the program " | ||
"'atlas-grids' for a list of named grids.\n" | ||
"\n"; | ||
} | ||
|
||
public: | ||
Program(int argc, char** argv); | ||
|
||
private: | ||
}; | ||
|
||
//----------------------------------------------------------------------------- | ||
|
||
Program::Program(int argc, char** argv): AtlasTool(argc, argv) { | ||
add_option(new SimpleOption<std::string>("output.file", "Output file. If not specified, output is directed to stdout")); | ||
add_option(new SimpleOption<std::string>("output.format", "Output format. If not specified: json")); | ||
add_option(new SimpleOption<long>("field_base", "Base used for field output. Default=0")); | ||
add_option(new SimpleOption<long>("index_base", "Base used for index input. Default=0")); | ||
add_option(new SimpleOption<std::string>("index", | ||
"Select grid point indices (first_index=<index_base>, last_index = <index_base> + <size> - 1). " | ||
"If not provided, all points are selected. " | ||
"Format: comma separated list, where '-' can be used to represent a range. e.g. '[1-3,5,7-10]'." | ||
"Square brackets are optional. white-spaces and newline characters are allowed as in a valid JSON array.")); | ||
add_option(new SimpleOption<std::string>("field","Field to output. [\"lonlat\"(D),\"index\",\"partition\"]")); | ||
add_option(new Separator("Advanced")); | ||
add_option(new SimpleOption<std::string>("partitioner.type", | ||
"Partitioner [equal_regions,checkerboard,equal_bands,regular_bands]")); | ||
add_option(new SimpleOption<long>("partition", "partition [0:partitions-1]")); | ||
add_option(new SimpleOption<long>("partitions", "Number of partitions")); | ||
add_option(new SimpleOption<long>("json.precision", "Number of digits after decimal in output")); | ||
add_option(new SimpleOption<bool>("json.pretty", "Pretty printing of json output")); | ||
add_option(new SimpleOption<bool>("verbose", "Output progress to stdout, default=false")); | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
|
||
std::string get_arg(const AtlasTool::Args& args, const std::string& flag, const std::string& default_value = "") { | ||
for (int i = 0; i < args.count() - 1; ++i) { | ||
if (args(i) == flag) { | ||
return args(i + 1); | ||
} | ||
} | ||
if (not default_value.empty()) { | ||
return default_value; | ||
} | ||
throw_Exception("Could not find argument for flag " + flag); | ||
} | ||
|
||
int Program::execute(const Args& args) { | ||
|
||
Grid grid; | ||
{ | ||
std::string key = args.count() ? args(0) : ""; | ||
if (!key.empty()) { | ||
eckit::PathName path{key}; | ||
grid = path.exists() ? Grid(Grid::Spec{path}) : Grid(key); | ||
|
||
} | ||
} | ||
if (!grid) { | ||
Log::error() << "Grid not specified as positional argument" << std::endl; | ||
return failed(); | ||
} | ||
|
||
util::GridPointsJSONWriter writer{grid,args}; | ||
if (mpi::rank() == 0 ) { | ||
std::string output_file; | ||
if (args.get("output.file",output_file)) { | ||
Log::info() << "Grid contains " << grid.size() << " points." << std::endl; | ||
std::ofstream out(output_file); | ||
writer.write(out, Log::info()); | ||
Log::info() << "File " << output_file << " written." << std::endl; | ||
} | ||
else { | ||
writer.write(std::cout); | ||
} | ||
} | ||
return success(); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
int main(int argc, char** argv) { | ||
Program tool(argc, argv); | ||
return tool.start(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.