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
e30d5b0a
Commit
e30d5b0a
authored
Mar 20, 2020
by
Uwe Schulzweida
Browse files
Added cdo_varlist.cc cdo_varlist.h.
parent
5e7e76ac
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/Makefile.am
View file @
e30d5b0a
...
...
@@ -43,6 +43,8 @@ libcdo_la_SOURCES = after_dvtrans.cc \
cdo_season.h
\
cdo_task.cc
\
cdo_task.h
\
cdo_varlist.cc
\
cdo_varlist.h
\
cdo_vlist.cc
\
cdo_vlist.h
\
cdo_wtime.h
\
...
...
src/Vertintap.cc
View file @
e30d5b0a
...
...
@@ -304,16 +304,14 @@ Vertintap(void *process)
{
vert_index
.
resize
(
gridsize
*
nplev
);
List
Var
var3Df
,
var3Dh
;
Cdo
Var
var3Df
,
var3Dh
;
var3Df
.
gridsize
=
gridsize
;
var3Df
.
nlevels
=
nhlevf
;
var3Df
.
nwpv
=
1
;
var3Df
.
memType
=
memtype
;
full_press
.
init
(
var3Df
);
var3Dh
.
gridsize
=
gridsize
;
var3Dh
.
nlevels
=
nhlevf
;
var3Dh
.
nwpv
=
1
;
var3Dh
.
memType
=
memtype
;
half_press
.
init
(
var3Dh
);
}
...
...
src/cdo_varlist.cc
0 → 100644
View file @
e30d5b0a
/*
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2020 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "cdo_varlist.h"
void
varListInit
(
VarList
&
vl
,
int
vlistID
)
{
const
auto
nvars
=
vlistNvars
(
vlistID
);
vl
.
resize
(
nvars
);
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
vlistInqVarName
(
vlistID
,
varID
,
vl
[
varID
].
name
);
vl
[
varID
].
gridID
=
vlistInqVarGrid
(
vlistID
,
varID
);
vl
[
varID
].
zaxisID
=
vlistInqVarZaxis
(
vlistID
,
varID
);
vl
[
varID
].
gridsize
=
gridInqSize
(
vl
[
varID
].
gridID
);
vl
[
varID
].
nlevels
=
zaxisInqSize
(
vl
[
varID
].
zaxisID
);
vl
[
varID
].
datatype
=
vlistInqVarDatatype
(
vlistID
,
varID
);
vl
[
varID
].
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
vl
[
varID
].
timetype
=
vlistInqVarTimetype
(
vlistID
,
varID
);
vl
[
varID
].
code
=
vlistInqVarCode
(
vlistID
,
varID
);
vl
[
varID
].
param
=
vlistInqVarParam
(
vlistID
,
varID
);
vl
[
varID
].
nwpv
=
vlistInqVarNumber
(
vlistID
,
varID
);
if
(
Options
::
CDO_Memtype
==
MemType
::
Native
)
vl
[
varID
].
memType
=
(
vl
[
varID
].
datatype
==
CDI_DATATYPE_FLT32
||
vl
[
varID
].
datatype
==
CDI_DATATYPE_CPX32
)
?
MemType
::
Float
:
MemType
::
Double
;
else
vl
[
varID
].
memType
=
Options
::
CDO_Memtype
;
}
}
void
varListSetUniqueMemtype
(
VarList
&
vl
)
{
const
int
nvars
=
vl
.
size
();
if
(
nvars
)
{
const
auto
memtype
=
vl
[
0
].
memType
;
int
varID
;
for
(
varID
=
1
;
varID
<
nvars
;
++
varID
)
{
if
(
vl
[
varID
].
memType
!=
memtype
)
break
;
}
if
(
varID
<
nvars
)
varListSetMemtype
(
vl
,
MemType
::
Double
);
}
}
void
varListSetMemtype
(
VarList
&
vl
,
MemType
memType
)
{
for
(
auto
&
var
:
vl
)
var
.
memType
=
memType
;
}
src/cdo_varlist.h
0 → 100644
View file @
e30d5b0a
/*
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2020 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef CDO_VARLIST_H
#define CDO_VARLIST_H
#include <vector>
#include <cdi.h>
#include "cdo_varlist.h"
#include "cdo_options.h"
struct
CdoVar
{
char
name
[
CDI_MAX_NAME
];
MemType
memType
;
int
gridID
;
int
zaxisID
;
size_t
gridsize
;
int
nlevels
;
int
datatype
;
double
missval
;
int
timetype
;
int
code
;
int
param
;
int
nwpv
;
// number of words per value; real:1 complex:2
CdoVar
()
:
memType
(
MemType
::
Native
),
gridID
(
-
1
),
zaxisID
(
-
1
),
nlevels
(
0
),
datatype
(
-
1
),
missval
(
0
),
timetype
(
-
1
),
code
(
0
),
param
(
0
),
nwpv
(
1
)
{
name
[
0
]
=
0
;
};
};
using
VarList
=
std
::
vector
<
CdoVar
>
;
void
varListInit
(
VarList
&
vl
,
int
vlistID
);
void
varListSetUniqueMemtype
(
VarList
&
vl
);
void
varListSetMemtype
(
VarList
&
vl
,
MemType
memType
);
#endif
src/cdo_vlist.cc
View file @
e30d5b0a
...
...
@@ -683,60 +683,6 @@ vlist_get_psvarid(int vlistID, int zaxisID)
return
-
1
;
}
void
varListInit
(
VarList
&
vl
,
int
vlistID
)
{
const
auto
nvars
=
vlistNvars
(
vlistID
);
vl
.
resize
(
nvars
);
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
vlistInqVarName
(
vlistID
,
varID
,
vl
[
varID
].
name
);
vl
[
varID
].
gridID
=
vlistInqVarGrid
(
vlistID
,
varID
);
vl
[
varID
].
zaxisID
=
vlistInqVarZaxis
(
vlistID
,
varID
);
vl
[
varID
].
gridsize
=
gridInqSize
(
vl
[
varID
].
gridID
);
vl
[
varID
].
nlevels
=
zaxisInqSize
(
vl
[
varID
].
zaxisID
);
vl
[
varID
].
datatype
=
vlistInqVarDatatype
(
vlistID
,
varID
);
vl
[
varID
].
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
vl
[
varID
].
timetype
=
vlistInqVarTimetype
(
vlistID
,
varID
);
vl
[
varID
].
code
=
vlistInqVarCode
(
vlistID
,
varID
);
vl
[
varID
].
param
=
vlistInqVarParam
(
vlistID
,
varID
);
vl
[
varID
].
nwpv
=
vlistInqVarNumber
(
vlistID
,
varID
);
if
(
Options
::
CDO_Memtype
==
MemType
::
Native
)
vl
[
varID
].
memType
=
(
vl
[
varID
].
datatype
==
CDI_DATATYPE_FLT32
||
vl
[
varID
].
datatype
==
CDI_DATATYPE_CPX32
)
?
MemType
::
Float
:
MemType
::
Double
;
else
vl
[
varID
].
memType
=
Options
::
CDO_Memtype
;
}
}
void
varListSetUniqueMemtype
(
VarList
&
vl
)
{
const
auto
nvars
=
vl
.
size
();
if
(
nvars
)
{
const
auto
memtype
=
vl
[
0
].
memType
;
int
varID
;
for
(
varID
=
1
;
varID
<
nvars
;
++
varID
)
{
if
(
vl
[
varID
].
memType
!=
memtype
)
break
;
}
if
(
varID
<
nvars
)
{
for
(
varID
=
0
;
varID
<
nvars
;
++
varID
)
vl
[
varID
].
memType
=
MemType
::
Double
;
}
}
}
void
varListSetMemtype
(
VarList
&
vl
,
MemType
memType
)
{
const
auto
nvars
=
vl
.
size
();
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
vl
[
varID
].
memType
=
memType
;
}
int
vlistGetFirstSpectralGrid
(
int
vlistID
)
{
...
...
src/cdo_vlist.h
View file @
e30d5b0a
...
...
@@ -21,6 +21,7 @@
#include <cdi.h>
#include "cdo_varlist.h"
#include "cdo_options.h"
#include "array.h"
...
...
@@ -39,27 +40,6 @@ void vlist_change_hybrid_zaxis(int vlistID1, int vlistID2, int zaxisID1, int zax
void
cdoCompareGrids
(
int
gridID1
,
int
gridID2
);
// TODO: Check if this belongs here or if it should be in griddes.*
struct
ListVar
{
char
name
[
CDI_MAX_NAME
];
MemType
memType
;
int
gridID
;
int
zaxisID
;
size_t
gridsize
;
int
nlevels
;
int
datatype
;
double
missval
;
int
timetype
;
int
code
;
int
param
;
int
nwpv
;
// number of words per value; real:1 complex:2
};
using
VarList
=
std
::
vector
<
ListVar
>
;
void
varListInit
(
VarList
&
vl
,
int
vlistID
);
void
varListSetUniqueMemtype
(
VarList
&
vl
);
void
varListSetMemtype
(
VarList
&
vl
,
MemType
memType
);
int
vlistGetFirstGaussianGrid
(
int
vlistID
);
int
vlistGetFirstSpectralGrid
(
int
vlistID
);
int
vlistGetFirstFourierGrid
(
int
vlistID
);
...
...
src/field.cc
View file @
e30d5b0a
...
...
@@ -31,13 +31,13 @@ Field::Field() : fpeRaised(0), nwpv(1), memType(MemType::Native), grid(-1), grid
Field3D
::
Field3D
()
:
nlevels
(
0
)
{}
void
Field
::
init
(
const
List
Var
&
listV
ar
)
Field
::
init
(
const
Cdo
Var
&
v
ar
)
{
grid
=
listV
ar
.
gridID
;
gridsize
=
listV
ar
.
gridsize
;
missval
=
listV
ar
.
missval
;
memType
=
listV
ar
.
memType
;
size
=
listV
ar
.
gridsize
*
listV
ar
.
nwpv
;
grid
=
v
ar
.
gridID
;
gridsize
=
v
ar
.
gridsize
;
missval
=
v
ar
.
missval
;
memType
=
v
ar
.
memType
;
size
=
v
ar
.
gridsize
*
v
ar
.
nwpv
;
if
(
memType
==
MemType
::
Float
)
vec_f
.
resize
(
size
);
else
...
...
@@ -90,14 +90,14 @@ Field::check_gridsize() const
}
void
Field3D
::
init
(
const
List
Var
&
listV
ar
)
{
nlevels
=
listV
ar
.
nlevels
;
grid
=
listV
ar
.
gridID
;
gridsize
=
listV
ar
.
gridsize
;
missval
=
listV
ar
.
missval
;
memType
=
listV
ar
.
memType
;
size
=
listV
ar
.
nlevels
*
listV
ar
.
gridsize
*
listV
ar
.
nwpv
;
Field3D
::
init
(
const
Cdo
Var
&
v
ar
)
{
nlevels
=
v
ar
.
nlevels
;
grid
=
v
ar
.
gridID
;
gridsize
=
v
ar
.
gridsize
;
missval
=
v
ar
.
missval
;
memType
=
v
ar
.
memType
;
size
=
v
ar
.
nlevels
*
v
ar
.
gridsize
*
v
ar
.
nwpv
;
if
(
memType
==
MemType
::
Float
)
vec_f
.
resize
(
size
);
else
...
...
src/field.h
View file @
e30d5b0a
...
...
@@ -53,7 +53,7 @@ public:
Varray
<
double
>
weightv
;
Field
();
void
init
(
const
List
Var
&
listV
ar
);
void
init
(
const
Cdo
Var
&
v
ar
);
void
resize
(
size_t
count
);
void
resize
(
size_t
count
,
double
value
);
void
resizef
(
size_t
count
);
...
...
@@ -71,7 +71,7 @@ public:
size_t
nlevels
;
Field3D
();
void
init
(
const
List
Var
&
listV
ar
);
void
init
(
const
Cdo
Var
&
v
ar
);
};
struct
RecordInfo
...
...
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