Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
libcdi
Commits
2f5f90b9
Commit
2f5f90b9
authored
5 years ago
by
Florian Prill
Browse files
Options
Downloads
Patches
Plain Diff
modified examples/cdi_write.c in order to reproduce GRIB2 bitsPerValue problem.
parent
ad39abec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/cdi_write.c
+7
-13
7 additions, 13 deletions
examples/cdi_write.c
with
7 additions
and
13 deletions
examples/cdi_write.c
+
7
−
13
View file @
2f5f90b9
...
...
@@ -13,7 +13,6 @@ int main(void)
double
lons
[]
=
{
0
,
30
,
60
,
90
,
120
,
150
,
180
,
210
,
240
,
270
,
300
,
330
};
double
lats
[]
=
{
-
75
,
-
45
,
-
15
,
15
,
45
,
75
};
double
levs
[]
=
{
101300
,
92500
,
85000
,
50000
,
20000
};
double
var1
[
nlon
*
nlat
];
double
var2
[
nlon
*
nlat
*
nlev
];
...
...
@@ -24,9 +23,6 @@ int main(void)
gridDefXvals
(
gridID
,
lons
);
gridDefYvals
(
gridID
,
lats
);
// Create a surface level Z-axis
int
zaxisID1
=
zaxisCreate
(
ZAXIS_SURFACE
,
1
);
// Create a pressure level Z-axis
int
zaxisID2
=
zaxisCreate
(
ZAXIS_PRESSURE
,
nlev
);
zaxisDefLevels
(
zaxisID2
,
levs
);
...
...
@@ -35,12 +31,11 @@ int main(void)
int
vlistID
=
vlistCreate
();
// Define the variables
int
varID1
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID1
,
TIME_VARYING
);
int
varID2
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID2
,
TIME_VARYING
);
// Define the variable names
vlistDefVarName
(
vlistID
,
varID
1
,
"
varname1
"
);
vlistDefVar
Nam
e
(
vlistID
,
varID2
,
"varname2"
);
vlistDefVarName
(
vlistID
,
varID
2
,
"
QC
"
);
vlistDefVar
Datatyp
e
(
vlistID
,
varID2
,
16
);
// Create a Time axis
int
taxisID
=
taxisCreate
(
TAXIS_ABSOLUTE
);
...
...
@@ -49,7 +44,7 @@ int main(void)
vlistDefTaxis
(
vlistID
,
taxisID
);
// Create a dataset in netCDF format
int
streamID
=
streamOpenWrite
(
"example.
nc
"
,
CDI_FILETYPE_
NC
);
int
streamID
=
streamOpenWrite
(
"example.
grb
"
,
CDI_FILETYPE_
GRB2
);
if
(
streamID
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID
));
...
...
@@ -69,12 +64,12 @@ int main(void)
// Define the time step
streamDefTimestep
(
streamID
,
tsID
);
// Init var1 and var2
for
(
size_t
i
=
0
;
i
<
nlon
*
nlat
;
i
++
)
var1
[
i
]
=
1
.
1
;
for
(
size_t
i
=
0
;
i
<
nlon
*
nlat
*
nlev
;
i
++
)
var2
[
i
]
=
2
.
2
;
// Init var2
// for ( size_t i = 0; i < nlon*nlat*2; i++ ) var2[i] = 0.;
// for ( size_t i = nlon*nlat*2; i < nlon*nlat*nlev; i++ ) var2[i] = sin((double)i);
for
(
size_t
i
=
0
;
i
<
nlon
*
nlat
*
nlev
;
i
++
)
var2
[
i
]
=
sin
((
double
)
i
);
// Write var1 and var2
streamWriteVar
(
streamID
,
varID1
,
var1
,
nmiss
);
streamWriteVar
(
streamID
,
varID2
,
var2
,
nmiss
);
}
...
...
@@ -84,7 +79,6 @@ int main(void)
// Destroy the objects
vlistDestroy
(
vlistID
);
taxisDestroy
(
taxisID
);
zaxisDestroy
(
zaxisID1
);
zaxisDestroy
(
zaxisID2
);
gridDestroy
(
gridID
);
...
...
This diff is collapsed.
Click to expand it.
Florian Prill
@m300196
mentioned in issue
#3 (closed)
·
5 years ago
mentioned in issue
#3 (closed)
mentioned in issue #3
Toggle commit list
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