Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
55c73af4
Commit
55c73af4
authored
2 years ago
by
Volker Neff
Browse files
Options
Downloads
Patches
Plain Diff
add missing files
parent
2d9ba6e5
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Draft: [WIP] New Field Architekture
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/field.inl
+92
-0
92 additions, 0 deletions
src/field.inl
src/field3d.inl
+29
-0
29 additions, 0 deletions
src/field3d.inl
with
121 additions
and
0 deletions
src/field.inl
0 → 100644
+
92
−
0
View file @
55c73af4
/*
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 diff is collapsed.
Click to expand it.
src/field3d.inl
0 → 100644
+
29
−
0
View file @
55c73af4
/*
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment