Skip to content
Snippets Groups Projects
Commit 55c73af4 authored by Volker Neff's avatar Volker Neff
Browse files

add missing files

parent 2d9ba6e5
No related branches found
No related tags found
1 merge request!6Draft: [WIP] New Field Architekture
/*
This file is part of CDO. CDO is a collection of Operators to manipulate and analyse Climate model Data.
Author: Volker Neff
*/
#ifndef FIELD_INL
#define FIELD_INL
#include "field.h"
template<typename T>
Field<T>::Field(int grid, size_t gridsize, double missval, size_t size)
: grid(grid), gridsize(gridsize), size(size), missval(missval), m_count(size)
{
varrayResize(vec, size);
}
// In the original version was a resize for double and a resizef for float
template<typename T>
inline void Field<T>::resize(const size_t count)
{
m_count = count;
varrayResize(vec, m_count);
if (!size) {
size = m_count;
}
}
template<typename T>
inline void Field<T>::resize(const size_t count, const T value)
{
m_count = count;
varrayResizeInit(vec, m_count, value);
if (!size) {
size = m_count;
}
}
template<typename T>
template<typename U>
inline void Field<T>::resize(const size_t count, const U value)
{
m_count = count;
varrayResizeInit(vec, m_count, static_cast<T>(value));
if (!size) {
size = m_count;
}
}
template<typename T>
inline bool Field<T>::empty() const
{
return m_count == 0;
}
template<typename T>
inline bool Field<T>::hasData() const
{
return !vec.empty();
}
template<typename T>
inline void Field<T>::check_gridsize() const
{
if (size == 0) {
fprintf(stderr, "Internal problem, size of field not set!\n");
}
if (size > m_count) {
fprintf(stderr, "Internal problem, size of field is greater than allocated size of field!\n");
}
}
template<typename T>
inline T Field<T>::getMissValue() const
{
return missval;
}
template<typename T>
inline double Field<T>::getMissValueDouble() const
{
return missval;
}
template<typename T>
inline void Field<T>::setMissValue(double value)
{
this->missval = static_cast<T>(value);
}
#endif // FIELD_INL
\ No newline at end of file
/*
This file is part of CDO. CDO is a collection of Operators to manipulate and analyse Climate model Data.
Author: Volker Neff
*/
#ifndef FIELD3D_INL
#define FIELD3D_INL
#include "field.h"
template<typename T>
inline Field3D<T>::Field3D(int grid, size_t gridsize, double missval, size_t size, size_t nlevels)
: Field<T>(grid, gridsize, missval, size), nlevels(nlevels)
{
}
template<typename T>
inline Field3D_t Field3D<T>::init(const CdoVar& var) {
if(var.memType == MemType::Float) {
return Field<float>{var.gridID, var.gridsize, var.missval, var.gridsize * var.nwpv, var.nlevels};
} else if (var.memType == MemType::Double) {
return Field<double>{var.gridID, var.gridsize, var.missval, var.gridsize * var.nwpv, var.nlevels};
} else {
throw std::runtime_error("Not supported type");
}
}
#endif // FIELD3D_INL
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment