Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
ff847dce
Commit
ff847dce
authored
Oct 10, 2020
by
Uwe Schulzweida
Browse files
Added CHECK_UNUSED_VECTOR
parent
b429b304
Pipeline
#4581
passed with stages
in 16 minutes and 54 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Arith.cc
View file @
ff847dce
...
...
@@ -68,7 +68,7 @@ Arith(void *process)
int
varID
,
levelID
;
int
nlevels2
=
1
;
int
levelID2
=
-
1
;
std
::
vector
<
std
::
vector
<
size_t
>
>
varnmiss
;
Varray2D
<
size_t
>
varnmiss
;
Varray2D
<
double
>
vardata
;
std
::
vector
<
size_t
>
varnmiss2
;
Varray
<
double
>
vardata2
;
...
...
src/Command.cc
View file @
ff847dce
...
...
@@ -56,7 +56,7 @@ static int gl_levelID = 0;
static
int
gl_tsID1
=
0
;
static
int
gl_tsID2
=
0
;
static
int
gl_ntsteps
=
-
1
;
static
std
::
vector
<
double
>
gl_data
;
static
Varray
<
double
>
gl_data
;
static
int
Done
=
0
;
...
...
src/Cond2.cc
View file @
ff847dce
...
...
@@ -44,7 +44,7 @@ Cond2(void *process)
int
varID
,
levelID
;
double
missval1
=
-
9.E33
;
size_t
nmiss1
=
0
;
std
::
vector
<
std
::
vector
<
size_t
>
>
varnmiss1
;
Varray2D
<
size_t
>
varnmiss1
;
Varray2D
<
double
>
vardata1
;
cdoInitialize
(
process
);
...
...
src/Intlevel.cc
View file @
ff847dce
...
...
@@ -176,7 +176,7 @@ vert_interp_lev3d(size_t gridsize, int nlev1, double missval, const Field3D &fie
}
void
vert_gen_weights
(
int
expol
,
int
nlev1
,
const
Varray
<
double
>
&
lev1
,
int
nlev2
,
const
Varray
<
double
>
&
lev2
,
Varray
<
int
>
&
lev_idx
,
Varray
<
float
>
&
lev_wgt
)
vert_gen_weights
(
int
expol
,
int
nlev1
,
const
Varray
<
double
>
&
lev1
,
int
nlev2
,
const
std
::
vector
<
double
>
&
lev2
,
Varray
<
int
>
&
lev_idx
,
Varray
<
float
>
&
lev_wgt
)
{
for
(
int
i2
=
0
;
i2
<
nlev2
;
++
i2
)
{
...
...
@@ -239,7 +239,7 @@ levelDirDown(const int nlev, const double *const lev)
template
<
typename
T
>
static
void
vert_gen_weights3d1d
(
bool
expol
,
size_t
gridsize
,
int
nlev1
,
const
Varray
<
T
>
&
xlev1
,
int
nlev2
,
const
Varray
<
double
>
&
lev2
,
vert_gen_weights3d1d
(
bool
expol
,
size_t
gridsize
,
int
nlev1
,
const
Varray
<
T
>
&
xlev1
,
int
nlev2
,
const
std
::
vector
<
double
>
&
lev2
,
Varray
<
int
>
&
xlev_idx
,
Varray
<
float
>
&
xlev_wgt
)
{
const
auto
nthreads
=
Threading
::
ompNumThreads
;
...
...
@@ -274,7 +274,7 @@ vert_gen_weights3d1d(bool expol, size_t gridsize, int nlev1, const Varray<T> &xl
}
static
void
vert_gen_weights3d1d
(
bool
expol
,
size_t
gridsize
,
int
nlev1
,
Field3D
&
field1
,
int
nlev2
,
const
Varray
<
double
>
&
lev2
,
vert_gen_weights3d1d
(
bool
expol
,
size_t
gridsize
,
int
nlev1
,
Field3D
&
field1
,
int
nlev2
,
const
std
::
vector
<
double
>
&
lev2
,
Varray
<
int
>
&
lev_idx
,
Varray
<
float
>
&
lev_wgt
)
{
if
(
field1
.
memType
==
MemType
::
Float
)
...
...
@@ -288,7 +288,7 @@ vert_gen_weights3d1d(bool expol, size_t gridsize, int nlev1, Field3D &field1, in
}
static
int
createZaxisFromZvar
(
const
Varray
<
double
>
&
levels
,
int
vlistID
,
int
varID
)
createZaxisFromZvar
(
const
std
::
vector
<
double
>
&
levels
,
int
vlistID
,
int
varID
)
{
int
nlevels
=
levels
.
size
();
int
zaxisID
=
zaxisCreate
(
ZAXIS_GENERIC
,
nlevels
);
...
...
@@ -309,7 +309,7 @@ createZaxisFromZvar(const Varray<double> &levels, int vlistID, int varID)
}
static
int
createZaxisFromZaxis
(
const
Varray
<
double
>
&
levels
,
int
zaxisID1
)
createZaxisFromZaxis
(
const
std
::
vector
<
double
>
&
levels
,
int
zaxisID1
)
{
int
nlevels
=
levels
.
size
();
int
zaxisID2
=
zaxisCreate
(
zaxisInqType
(
zaxisID1
),
nlevels
);
...
...
@@ -335,7 +335,7 @@ createZaxisFromZaxis(const Varray<double> &levels, int zaxisID1)
}
static
void
intlevelGetParameter
(
Varray
<
double
>
&
lev2
,
std
::
string
&
zdescription
,
std
::
string
&
zvarname
)
intlevelGetParameter
(
std
::
vector
<
double
>
&
lev2
,
std
::
string
&
zdescription
,
std
::
string
&
zvarname
)
{
const
auto
pargc
=
operatorArgc
();
if
(
pargc
)
...
...
@@ -406,7 +406,7 @@ Intlevel(void *process)
operatorInputArg
(
"level|zdescription, [zvarname]"
);
Varray
<
double
>
lev2
;
std
::
vector
<
double
>
lev2
;
int
zaxisID2
=
CDI_UNDEFID
;
std
::
string
zvarname
;
auto
argv
=
cdoGetOperArgv
();
...
...
src/Vertintap.cc
View file @
ff847dce
...
...
@@ -141,7 +141,7 @@ Vertintap(void *process)
operatorInputArg
(
cdoOperatorEnter
(
operatorID
));
Varray
<
double
>
plev
;
std
::
vector
<
double
>
plev
;
if
(
operatorArgc
()
==
1
&&
cdoOperatorArgv
(
0
)
==
"default"
)
{
if
(
useHeightLevel
)
...
...
src/Vertintgh.cc
View file @
ff847dce
...
...
@@ -86,7 +86,7 @@ Vertintgh(void *process)
int
zaxisID2
=
CDI_UNDEFID
;
const
auto
&
arg1
=
cdoOperatorArgv
(
0
);
Varray
<
double
>
heightlevs
;
std
::
vector
<
double
>
heightlevs
;
if
(
operatorArgc
()
==
1
&&
!
isdigit
(
arg1
[
0
]))
{
auto
zfilename
=
arg1
.
c_str
();
...
...
src/Vertintml.cc
View file @
ff847dce
...
...
@@ -150,7 +150,7 @@ Vertintml(void *process)
operatorInputArg
(
cdoOperatorEnter
(
operatorID
));
Varray
<
double
>
plev
;
std
::
vector
<
double
>
plev
;
if
(
operatorArgc
()
==
1
&&
cdoOperatorArgv
(
0
)
==
"default"
)
{
if
(
useHeightLevel
)
...
...
src/array.h
View file @
ff847dce
...
...
@@ -23,6 +23,72 @@
#include <cfloat>
#include "compare.h"
//#define CHECK_UNUSED_VECTOR 1
#ifdef CHECK_UNUSED_VECTOR
template
<
typename
T
>
class
#if defined(__GNUG__)
__attribute__
((
warn_unused
))
#endif
CheckUnusedVector
{
public:
T
dummy
[
1
];
size_t
m_count
;
CheckUnusedVector
()
{
dummy
[
0
]
=
0
;
}
CheckUnusedVector
(
size_t
count
)
:
m_count
(
count
)
{
dummy
[
0
]
=
0
;
}
CheckUnusedVector
(
size_t
count
,
const
T
&
value
)
:
m_count
(
count
)
{
dummy
[
0
]
=
value
;
}
//CheckUnusedVector(CheckUnusedVector&& other) { }
T
*
begin
()
noexcept
{
return
&
dummy
[
0
];
}
T
*
end
()
noexcept
{
return
&
dummy
[
0
]
+
1
;
}
bool
empty
()
const
{
return
true
;
}
size_t
size
()
const
{
return
m_count
;
}
void
resize
(
size_t
count
)
{
m_count
=
count
;
}
void
resize
(
size_t
count
,
const
T
&
value
)
{
m_count
=
count
;
dummy
[
0
]
=
value
;
}
T
*
data
()
noexcept
{
return
&
dummy
[
0
];
}
const
T
*
data
()
const
noexcept
{
return
&
dummy
[
0
];
}
T
&
operator
[](
size_t
pos
)
{
(
void
)
pos
;
return
dummy
[
0
];
}
T
operator
[](
size_t
pos
)
const
{
(
void
)
pos
;
return
dummy
[
0
];
}
//const T& operator [](int pos) { (void) pos; return dummy[0]; }
//const T operator [](int pos) const { (void) pos; return dummy[0]; }
CheckUnusedVector
&
operator
=
(
const
CheckUnusedVector
&
other
)
{
(
void
)
other
;
return
*
this
;
}
CheckUnusedVector
&
operator
=
(
CheckUnusedVector
&&
other
)
{
(
void
)
other
;
return
*
this
;
}
// Copy constructor
CheckUnusedVector
(
const
CheckUnusedVector
&
obj2
)
{
dummy
[
0
]
=
obj2
.
dummy
[
0
];
}
};
template
<
typename
T
>
using
Varray
=
CheckUnusedVector
<
T
>
;
template
<
typename
T
>
using
Varray2D
=
Varray
<
Varray
<
T
>>
;
template
<
typename
T
>
using
Varray3D
=
Varray2D
<
Varray
<
T
>>
;
template
<
typename
T
>
using
Varray4D
=
Varray3D
<
Varray
<
T
>>
;
#else
template
<
typename
T
>
using
Varray
=
std
::
vector
<
T
>
;
template
<
typename
T
>
using
Varray2D
=
std
::
vector
<
std
::
vector
<
T
>>
;
template
<
typename
T
>
using
Varray3D
=
std
::
vector
<
std
::
vector
<
std
::
vector
<
T
>>>
;
template
<
typename
T
>
using
Varray4D
=
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
vector
<
T
>>>>
;
#endif
struct
MinMax
{
...
...
@@ -50,18 +116,6 @@ struct MinMaxMean : MinMax
MinMaxMean
(
double
rmin
,
double
rmax
,
double
rmean
)
:
mean
(
rmean
)
{
min
=
rmin
;
max
=
rmax
;
n
=
0
;
};
};
template
<
typename
T
>
using
Varray
=
std
::
vector
<
T
>
;
template
<
typename
T
>
using
Varray2D
=
std
::
vector
<
std
::
vector
<
T
>>
;
template
<
typename
T
>
using
Varray3D
=
std
::
vector
<
std
::
vector
<
std
::
vector
<
T
>>>
;
template
<
typename
T
>
using
Varray4D
=
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
vector
<
T
>>>>
;
#define IX2D(y, x, nx) ((y) * (nx) + (x))
template
<
typename
T
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment