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
72f35c69
Commit
72f35c69
authored
1 year ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Pack: change datatype to int16 if set to CDI_DATATYPE_INT32|CDI_DATATYPE_UINT32
parent
114bcc43
No related branches found
No related tags found
1 merge request
!103
M214003/develop
Pipeline
#40122
passed
1 year ago
Stage: build
Stage: check
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Pack.cc
+17
-15
17 additions, 15 deletions
src/Pack.cc
src/field_memory.cc
+4
-4
4 additions, 4 deletions
src/field_memory.cc
with
21 additions
and
19 deletions
src/Pack.cc
+
17
−
15
View file @
72f35c69
...
...
@@ -26,7 +26,7 @@
#include
"field_functions.h"
static
int
get_type_values
(
const
int
datatype
,
double
&
tmin
,
double
&
tmax
,
double
&
tmv
)
get_type_values
(
int
datatype
,
double
&
tmin
,
double
&
tmax
,
double
&
tmv
)
{
int
status
=
0
;
...
...
@@ -47,7 +47,7 @@ get_type_values(const int datatype, double &tmin, double &tmax, double &tmv)
}
static
int
compute_scale_and_offset
(
const
int
datatype
,
const
double
fmin
,
const
double
fmax
,
double
&
scaleFactor
,
double
&
addOffset
)
compute_scale_and_offset
(
int
datatype
,
double
fmin
,
double
fmax
,
double
&
scaleFactor
,
double
&
addOffset
)
{
scaleFactor
=
1.0
;
addOffset
=
0.0
;
...
...
@@ -131,11 +131,23 @@ public:
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
streamID2
=
cdo_open_write
(
1
);
varListInit
(
varList
,
vlistID1
);
nvars
=
vlistNvars
(
vlistID1
);
streamID2
=
cdo_open_write
(
1
);
if
(
CdoDefault
::
DataType
!=
CDI_UNDEFID
)
{
// 32-bit float routing error with CDI_DATATYPE_INT32|CDI_DATATYPE_UINT32
if
(
CdoDefault
::
DataType
==
CDI_DATATYPE_FLT64
||
CdoDefault
::
DataType
==
CDI_DATATYPE_FLT32
||
CdoDefault
::
DataType
==
CDI_DATATYPE_INT32
||
CdoDefault
::
DataType
==
CDI_DATATYPE_UINT32
)
{
cdo_warning
(
"Changed default output datatype to int16"
);
CdoDefault
::
DataType
=
datatype
;
}
else
{
datatype
=
CdoDefault
::
DataType
;
}
}
}
void
...
...
@@ -168,17 +180,6 @@ public:
auto
nts
=
tsID
;
if
(
CdoDefault
::
DataType
!=
CDI_UNDEFID
)
{
if
(
CdoDefault
::
DataType
==
CDI_DATATYPE_FLT64
||
CdoDefault
::
DataType
==
CDI_DATATYPE_FLT32
)
{
cdo_warning
(
"Changed default output datatype to int16"
);
CdoDefault
::
DataType
=
datatype
;
}
else
{
datatype
=
CdoDefault
::
DataType
;
}
}
CdoDefault
::
DataType
=
datatype
;
constexpr
double
undefValue
=
1.0e300
;
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
...
...
@@ -237,10 +238,10 @@ public:
if
(
hasValidData
)
{
auto
memTypeIsFloat
=
(
var
.
memType
==
MemType
::
Float
);
double
scaleFactor
,
addOffset
;
if
(
!
compute_scale_and_offset
(
datatype
,
fmin
,
fmax
,
scaleFactor
,
addOffset
))
{
auto
memTypeIsFloat
=
(
var
.
memType
==
MemType
::
Float
);
cdiDefKeyFloat
(
vlistID2
,
varID
,
CDI_KEY_ADDOFFSET
,
memTypeIsFloat
?
(
float
)
addOffset
:
addOffset
);
cdiDefKeyFloat
(
vlistID2
,
varID
,
CDI_KEY_SCALEFACTOR
,
memTypeIsFloat
?
(
float
)
scaleFactor
:
scaleFactor
);
}
...
...
@@ -290,5 +291,6 @@ Pack(void *process)
pack
.
init
(
process
);
pack
.
run
();
pack
.
close
();
return
nullptr
;
}
This diff is collapsed.
Click to expand it.
src/field_memory.cc
+
4
−
4
View file @
72f35c69
...
...
@@ -12,7 +12,7 @@
#include
"cdo_options.h"
static
void
fields_from_vlist_kernel
(
const
int
vlistID
,
FieldVector2D
&
field2D
,
int
ptype
,
bool
lfill
,
double
fillValue
)
fields_from_vlist_kernel
(
int
vlistID
,
FieldVector2D
&
field2D
,
int
ptype
,
bool
lfill
,
double
fillValue
)
{
auto
allocateData
=
(
ptype
&
FIELD_VEC
);
auto
nvars
=
vlistNvars
(
vlistID
);
...
...
@@ -70,19 +70,19 @@ fields_from_vlist_kernel(const int vlistID, FieldVector2D &field2D, int ptype, b
}
void
fields_from_vlist
(
const
int
vlistID
,
FieldVector2D
&
field2D
)
fields_from_vlist
(
int
vlistID
,
FieldVector2D
&
field2D
)
{
fields_from_vlist_kernel
(
vlistID
,
field2D
,
0
,
false
,
0
);
}
void
fields_from_vlist
(
const
int
vlistID
,
FieldVector2D
&
field2D
,
int
ptype
)
fields_from_vlist
(
int
vlistID
,
FieldVector2D
&
field2D
,
int
ptype
)
{
fields_from_vlist_kernel
(
vlistID
,
field2D
,
ptype
,
false
,
0
);
}
void
fields_from_vlist
(
const
int
vlistID
,
FieldVector2D
&
field2D
,
int
ptype
,
double
fillValue
)
fields_from_vlist
(
int
vlistID
,
FieldVector2D
&
field2D
,
int
ptype
,
double
fillValue
)
{
fields_from_vlist_kernel
(
vlistID
,
field2D
,
ptype
,
true
,
fillValue
);
}
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