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
ae31b708
Commit
ae31b708
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
ZaxisDescription: change type of string members to std::string
parent
58fd0d99
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!29
M214003/develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cdo_history.cc
+2
-2
2 additions, 2 deletions
src/cdo_history.cc
src/cdo_zaxis.cc
+52
-52
52 additions, 52 deletions
src/cdo_zaxis.cc
with
54 additions
and
54 deletions
src/cdo_history.cc
+
2
−
2
View file @
ae31b708
...
...
@@ -60,7 +60,7 @@ cdo_append_history(int vlistID, const char *histstring)
const
auto
atttype
=
cdiInqAttType
(
vlistID
,
CDI_GLOBAL
,
historyAttrName
);
if
(
atttype
==
CDI_DATATYPE_TXT
)
{
int
ghistorysize
=
cdiInqAttLen
(
vlistID
,
CDI_GLOBAL
,
historyAttrName
);
auto
ghistorysize
=
cdiInqAttLen
(
vlistID
,
CDI_GLOBAL
,
historyAttrName
);
if
(
ghistorysize
<
0
)
ghistorysize
=
0
;
if
(
ghistorysize
>
0
)
{
...
...
@@ -81,7 +81,7 @@ cdo_append_history(int vlistID, const char *histstring)
history
+=
ghistory
.
data
();
}
cdiDefAttTxt
(
vlistID
,
CDI_GLOBAL
,
historyAttrName
,
strlen
(
history
.
c_str
()
),
history
.
c_str
());
cdiDefAttTxt
(
vlistID
,
CDI_GLOBAL
,
historyAttrName
,
history
.
size
(
),
history
.
c_str
());
}
void
...
...
This diff is collapsed.
Click to expand it.
src/cdo_zaxis.cc
+
52
−
52
View file @
ae31b708
...
...
@@ -22,7 +22,7 @@
#define MAX_LINE_LEN 65536
struct
z
axis
_t
struct
Z
axis
Desciption
{
Varray
<
double
>
vals
;
Varray
<
double
>
lbounds
;
...
...
@@ -67,7 +67,7 @@ getoptname(char *optname, const char *optstring, int nopt)
}
int
zaxisDefine
(
z
axis
_t
zaxis
)
zaxisDefine
(
Z
axis
Desciption
zaxis
)
{
if
(
zaxis
.
type
==
CDI_UNDEFID
)
cdo_abort
(
"zaxistype undefined!"
);
if
(
zaxis
.
size
==
0
)
cdo_abort
(
"zaxis size undefined!"
);
...
...
@@ -104,7 +104,7 @@ struct KVMap
};
static
void
zaxis_read_data
(
size_t
nkv
,
KVMap
*
kvmap
,
z
axis
_t
*
zaxis
,
size_t
&
natts
,
const
char
*
dname
)
zaxis_read_data
(
size_t
nkv
,
KVMap
*
kvmap
,
Z
axis
Desciption
&
zaxis
,
size_t
&
natts
,
const
char
*
dname
)
{
// char uuidStr[256];
...
...
@@ -124,60 +124,60 @@ zaxis_read_data(size_t nkv, KVMap *kvmap, zaxis_t *zaxis, size_t &natts, const c
{
auto
zaxistype
=
parameter_to_word
(
value
);
if
(
zaxistype
==
"pressure"
)
zaxis
->
type
=
ZAXIS_PRESSURE
;
else
if
(
zaxistype
==
"hybrid_half"
)
zaxis
->
type
=
ZAXIS_HYBRID_HALF
;
else
if
(
zaxistype
==
"hybrid"
)
zaxis
->
type
=
ZAXIS_HYBRID
;
else
if
(
zaxistype
==
"height"
)
zaxis
->
type
=
ZAXIS_HEIGHT
;
else
if
(
zaxistype
==
"depth_below_sea"
)
zaxis
->
type
=
ZAXIS_DEPTH_BELOW_SEA
;
else
if
(
zaxistype
==
"depth_below_land"
)
zaxis
->
type
=
ZAXIS_DEPTH_BELOW_LAND
;
else
if
(
zaxistype
==
"isentropic"
)
zaxis
->
type
=
ZAXIS_ISENTROPIC
;
else
if
(
zaxistype
==
"surface"
)
zaxis
->
type
=
ZAXIS_SURFACE
;
else
if
(
zaxistype
==
"generic"
)
zaxis
->
type
=
ZAXIS_GENERIC
;
if
(
zaxistype
==
"pressure"
)
zaxis
.
type
=
ZAXIS_PRESSURE
;
else
if
(
zaxistype
==
"hybrid_half"
)
zaxis
.
type
=
ZAXIS_HYBRID_HALF
;
else
if
(
zaxistype
==
"hybrid"
)
zaxis
.
type
=
ZAXIS_HYBRID
;
else
if
(
zaxistype
==
"height"
)
zaxis
.
type
=
ZAXIS_HEIGHT
;
else
if
(
zaxistype
==
"depth_below_sea"
)
zaxis
.
type
=
ZAXIS_DEPTH_BELOW_SEA
;
else
if
(
zaxistype
==
"depth_below_land"
)
zaxis
.
type
=
ZAXIS_DEPTH_BELOW_LAND
;
else
if
(
zaxistype
==
"isentropic"
)
zaxis
.
type
=
ZAXIS_ISENTROPIC
;
else
if
(
zaxistype
==
"surface"
)
zaxis
.
type
=
ZAXIS_SURFACE
;
else
if
(
zaxistype
==
"generic"
)
zaxis
.
type
=
ZAXIS_GENERIC
;
else
cdo_abort
(
"Invalid zaxis type: %s (zaxis description file: %s)"
,
zaxistype
,
dname
);
}
else
if
(
key
==
"datatype"
)
{
auto
datatype
=
parameter_to_word
(
value
);
if
(
datatype
==
"double"
)
zaxis
->
datatype
=
CDI_DATATYPE_FLT64
;
else
if
(
datatype
==
"float"
)
zaxis
->
datatype
=
CDI_DATATYPE_FLT32
;
else
if
(
datatype
==
"int"
)
zaxis
->
datatype
=
CDI_DATATYPE_INT32
;
else
if
(
datatype
==
"short"
)
zaxis
->
datatype
=
CDI_DATATYPE_INT16
;
if
(
datatype
==
"double"
)
zaxis
.
datatype
=
CDI_DATATYPE_FLT64
;
else
if
(
datatype
==
"float"
)
zaxis
.
datatype
=
CDI_DATATYPE_FLT32
;
else
if
(
datatype
==
"int"
)
zaxis
.
datatype
=
CDI_DATATYPE_INT32
;
else
if
(
datatype
==
"short"
)
zaxis
.
datatype
=
CDI_DATATYPE_INT16
;
else
cdo_abort
(
"Invalid datatype: %s (zaxis description file: %s)"
,
datatype
,
dname
);
}
else
if
(
key
==
"size"
)
zaxis
->
size
=
parameter_to_int
(
value
);
else
if
(
key
==
"scalar"
)
zaxis
->
scalar
=
parameter_to_bool
(
value
);
else
if
(
key
==
"vctsize"
)
zaxis
->
vctsize
=
parameter_to_int
(
value
);
else
if
(
key
==
"name"
)
strcpy
(
zaxis
->
name
,
parameter_to_word
(
value
.
c_str
()));
else
if
(
key
==
"units"
)
strcpy
(
zaxis
->
units
,
parameter_to_word
(
value
.
c_str
()));
else
if
(
key
==
"longname"
)
strcpy
(
zaxis
->
longname
,
value
.
c_str
());
else
if
(
key
==
"size"
)
zaxis
.
size
=
parameter_to_int
(
value
);
else
if
(
key
==
"scalar"
)
zaxis
.
scalar
=
parameter_to_bool
(
value
);
else
if
(
key
==
"vctsize"
)
zaxis
.
vctsize
=
parameter_to_int
(
value
);
else
if
(
key
==
"name"
)
strcpy
(
zaxis
.
name
,
parameter_to_word
(
value
.
c_str
()));
else
if
(
key
==
"units"
)
strcpy
(
zaxis
.
units
,
parameter_to_word
(
value
.
c_str
()));
else
if
(
key
==
"longname"
)
strcpy
(
zaxis
.
longname
,
value
.
c_str
());
else
if
(
key
==
"levels"
)
{
if
(
zaxis
->
size
==
0
)
cdo_abort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
->
size
!=
nvalues
)
cdo_abort
(
"size=%zu and number of levels=%zu differ!"
,
zaxis
->
size
,
nvalues
);
zaxis
->
vals
.
resize
(
zaxis
->
size
);
for
(
size_t
i
=
0
;
i
<
zaxis
->
size
;
++
i
)
zaxis
->
vals
[
i
]
=
parameter_to_double
(
values
[
i
]);
if
(
zaxis
.
size
==
0
)
cdo_abort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
.
size
!=
nvalues
)
cdo_abort
(
"size=%zu and number of levels=%zu differ!"
,
zaxis
.
size
,
nvalues
);
zaxis
.
vals
.
resize
(
zaxis
.
size
);
for
(
size_t
i
=
0
;
i
<
zaxis
.
size
;
++
i
)
zaxis
.
vals
[
i
]
=
parameter_to_double
(
values
[
i
]);
}
else
if
(
key
==
"lbounds"
)
{
if
(
zaxis
->
size
==
0
)
cdo_abort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
->
size
!=
nvalues
)
cdo_abort
(
"size=%zu and number of lbounds=%zu differ!"
,
zaxis
->
size
,
nvalues
);
zaxis
->
lbounds
.
resize
(
zaxis
->
size
);
for
(
size_t
i
=
0
;
i
<
zaxis
->
size
;
++
i
)
zaxis
->
lbounds
[
i
]
=
parameter_to_double
(
values
[
i
]);
if
(
zaxis
.
size
==
0
)
cdo_abort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
.
size
!=
nvalues
)
cdo_abort
(
"size=%zu and number of lbounds=%zu differ!"
,
zaxis
.
size
,
nvalues
);
zaxis
.
lbounds
.
resize
(
zaxis
.
size
);
for
(
size_t
i
=
0
;
i
<
zaxis
.
size
;
++
i
)
zaxis
.
lbounds
[
i
]
=
parameter_to_double
(
values
[
i
]);
}
else
if
(
key
==
"ubounds"
)
{
if
(
zaxis
->
size
==
0
)
cdo_abort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
->
size
!=
nvalues
)
cdo_abort
(
"size=%zu and number of ubounds=%zu differ!"
,
zaxis
->
size
,
nvalues
);
zaxis
->
ubounds
.
resize
(
zaxis
->
size
);
for
(
size_t
i
=
0
;
i
<
zaxis
->
size
;
++
i
)
zaxis
->
ubounds
[
i
]
=
parameter_to_double
(
values
[
i
]);
if
(
zaxis
.
size
==
0
)
cdo_abort
(
"size undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
.
size
!=
nvalues
)
cdo_abort
(
"size=%zu and number of ubounds=%zu differ!"
,
zaxis
.
size
,
nvalues
);
zaxis
.
ubounds
.
resize
(
zaxis
.
size
);
for
(
size_t
i
=
0
;
i
<
zaxis
.
size
;
++
i
)
zaxis
.
ubounds
[
i
]
=
parameter_to_double
(
values
[
i
]);
}
else
if
(
key
==
"vct"
)
{
if
(
zaxis
->
vctsize
==
0
)
cdo_abort
(
"vctsize undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
->
vctsize
!=
nvalues
)
cdo_abort
(
"vctsize=%zu and size of vct=%zu differ!"
,
zaxis
->
vctsize
,
nvalues
);
zaxis
->
vct
.
resize
(
zaxis
->
vctsize
);
for
(
size_t
i
=
0
;
i
<
zaxis
->
vctsize
;
++
i
)
zaxis
->
vct
[
i
]
=
parameter_to_double
(
values
[
i
]);
if
(
zaxis
.
vctsize
==
0
)
cdo_abort
(
"vctsize undefined (zaxis description file: %s)!"
,
dname
);
if
(
zaxis
.
vctsize
!=
nvalues
)
cdo_abort
(
"vctsize=%zu and size of vct=%zu differ!"
,
zaxis
.
vctsize
,
nvalues
);
zaxis
.
vct
.
resize
(
zaxis
.
vctsize
);
for
(
size_t
i
=
0
;
i
<
zaxis
.
vctsize
;
++
i
)
zaxis
.
vct
[
i
]
=
parameter_to_double
(
values
[
i
]);
}
else
{
...
...
@@ -267,10 +267,10 @@ zaxis_from_file(FILE *zfp, const char *filename)
ik
++
;
}
z
axis
_t
zaxis
;
Z
axis
Desciption
zaxis
;
size_t
natts
=
0
;
zaxis_read_data
(
nkv
,
kvmap
.
data
(),
&
zaxis
,
natts
,
filename
);
zaxis_read_data
(
nkv
,
kvmap
.
data
(),
zaxis
,
natts
,
filename
);
int
zaxisID
=
(
zaxis
.
type
==
CDI_UNDEFID
)
?
CDI_UNDEFID
:
zaxisDefine
(
zaxis
);
if
(
zaxisID
!=
CDI_UNDEFID
&&
natts
>
0
)
zaxis_read_attributes
(
natts
,
nkv
,
kvmap
.
data
(),
zaxisID
);
...
...
@@ -279,11 +279,11 @@ zaxis_from_file(FILE *zfp, const char *filename)
}
static
void
gen_zaxis_height
(
z
axis
_t
*
zaxis
,
const
char
*
pline
)
gen_zaxis_height
(
Z
axis
Desciption
&
zaxis
,
const
char
*
pline
)
{
int
zaxistype
=
ZAXIS_HEIGHT
;
if
(
Options
::
CMOR_Mode
)
zaxis
->
scalar
=
true
;
if
(
Options
::
CMOR_Mode
)
zaxis
.
scalar
=
true
;
if
(
*
pline
!=
0
)
{
...
...
@@ -306,18 +306,18 @@ gen_zaxis_height(zaxis_t *zaxis, const char *pline)
if
(
*
pline
==
0
)
return
;
const
char
*
units
=
pline
;
zaxis
->
type
=
zaxistype
;
zaxis
->
size
=
1
;
// zaxis
->
scalar = true;
zaxis
->
vals
.
resize
(
1
);
zaxis
->
vals
[
0
]
=
value
;
strcpy
(
zaxis
->
units
,
units
);
zaxis
.
type
=
zaxistype
;
zaxis
.
size
=
1
;
// zaxis
.
scalar = true;
zaxis
.
vals
.
resize
(
1
);
zaxis
.
vals
[
0
]
=
value
;
strcpy
(
zaxis
.
units
,
units
);
auto
len
=
strlen
(
units
);
if
(
len
>
2
&&
units
[
len
-
2
]
==
'_'
&&
units
[
len
-
1
]
==
's'
)
{
zaxis
->
units
[
len
-
2
]
=
0
;
zaxis
->
scalar
=
true
;
zaxis
.
units
[
len
-
2
]
=
0
;
zaxis
.
scalar
=
true
;
}
}
}
...
...
@@ -332,7 +332,7 @@ zaxis_from_name(const char *zaxisnameptr)
auto
zaxisname
=
strdup
(
zaxisnameptr
);
cstr_to_lower
(
zaxisname
);
z
axis
_t
zaxis
;
Z
axis
Desciption
zaxis
;
auto
pline
=
zaxisname
;
if
(
cdo_cmpstrLenRhs
(
pline
,
"surface"
))
// surface
...
...
@@ -345,7 +345,7 @@ zaxis_from_name(const char *zaxisnameptr)
else
if
(
cdo_cmpstrLenRhs
(
zaxisname
,
"height"
,
len
))
{
pline
=
&
zaxisname
[
len
];
gen_zaxis_height
(
&
zaxis
,
pline
);
gen_zaxis_height
(
zaxis
,
pline
);
}
if
(
zaxis
.
type
!=
CDI_UNDEFID
)
zaxisID
=
zaxisDefine
(
zaxis
);
...
...
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