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
d660d9b2
Commit
d660d9b2
authored
3 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Added examples/cdi_append.c.
parent
77354f50
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#13876
failed
3 years ago
Stage: external
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/Makefile.am
+3
-1
3 additions, 1 deletion
examples/Makefile.am
examples/cdi_append.c
+80
-0
80 additions, 0 deletions
examples/cdi_append.c
with
83 additions
and
1 deletion
examples/Makefile.am
+
3
−
1
View file @
d660d9b2
...
...
@@ -2,7 +2,7 @@
#
EXTRA_DIST
=
cdi_read_f2003.f90 cdi_write_f2003.f90
#
check_PROGRAMS
=
cdi_write cdi_write_relativ cdi_write_ens cdi_write_hybrid cdi_write_local cdi_read cdi_copy
check_PROGRAMS
=
cdi_write cdi_write_relativ cdi_write_ens cdi_write_hybrid cdi_write_local cdi_read cdi_copy
cdi_append
if
CREATE_ISOC
check_PROGRAMS
+=
cdi_read_f2003 cdi_write_f2003
endif
...
...
@@ -22,6 +22,7 @@ cdi_write_hybrid_SOURCES = cdi_write_hybrid.c
cdi_write_local_SOURCES
=
cdi_write_local.c
cdi_read_SOURCES
=
cdi_read.c
cdi_copy_SOURCES
=
cdi_copy.c
cdi_append_SOURCES
=
cdi_append.c
#
cdi_read_f2003_SOURCES
=
cdi_read_f2003.f90
cdi_read_f2003_LDADD
=
$(
top_builddir
)
/src/libcdi_f2003.la
$(
top_builddir
)
/src/libcdi.la
...
...
@@ -40,6 +41,7 @@ if ENABLE_ALL_STATIC
cdi_write_LDFLAGS
=
-all-static
cdi_read_LDFLAGS
=
-all-static
cdi_copy_LDFLAGS
=
-all-static
cdi_append_LDFLAGS
=
-all-static
cdi_read_f2003_LDFLAGS
=
-all-static
cdi_write_f2003_LDFLAGS
=
-all-static
endif
...
...
This diff is collapsed.
Click to expand it.
examples/cdi_append.c
0 → 100644
+
80
−
0
View file @
d660d9b2
#include
<stdio.h>
#include
"cdi.h"
int
main
(
void
)
{
enum
{
nlon
=
12
,
// Number of longitudes
nlat
=
6
,
// Number of latitudes
nlev
=
5
,
// Number of levels
nts
=
3
,
// Number of time steps
};
SizeType
nmiss
=
0
;
double
var1
[
nlon
*
nlat
];
double
var2
[
nlon
*
nlat
*
nlev
];
// Append a dataset (created by cdi_write)
int
streamID
=
streamOpenAppend
(
"example.nc"
);
if
(
streamID
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID
));
return
1
;
}
// Get the variable list of the dataset
int
vlistID
=
streamInqVlist
(
streamID
);
int
numVars
=
vlistNvars
(
vlistID
);
if
(
numVars
!=
2
)
{
fprintf
(
stderr
,
"Unexpected number of variables: %d
\n
"
,
numVars
);
return
1
;
}
int
varID1
=
0
;
int
varID2
=
1
;
SizeType
varSize1
=
gridInqSize
(
vlistInqVarGrid
(
vlistID
,
varID1
))
*
zaxisInqSize
(
vlistInqVarZaxis
(
vlistID
,
varID1
));
if
(
varSize1
!=
nlon
*
nlat
)
{
fprintf
(
stderr
,
"Unexpected size of variable 1: %ld
\n
"
,
(
long
)
varSize1
);
return
1
;
}
SizeType
varSize2
=
gridInqSize
(
vlistInqVarGrid
(
vlistID
,
varID2
))
*
zaxisInqSize
(
vlistInqVarZaxis
(
vlistID
,
varID2
));
if
(
varSize2
!=
nlon
*
nlat
*
nlev
)
{
fprintf
(
stderr
,
"Unexpected size of variable 2: %ld
\n
"
,
(
long
)
varSize2
);
return
1
;
}
int
taxisID
=
vlistInqTaxis
(
vlistID
);
int
nsteps
=
vlistNtsteps
(
vlistID
);
printf
(
"Number of timesteps: %d
\n
"
,
nsteps
);
// Loop over the number of time steps
for
(
int
tsID
=
0
;
tsID
<
nts
;
tsID
++
)
{
// Set the verification date to 1985-01-01 + tsID
taxisDefVdate
(
taxisID
,
19850101
+
nsteps
+
tsID
);
// Set the verification time to 12:00:00
taxisDefVtime
(
taxisID
,
120000
);
// Define the time step
streamDefTimestep
(
streamID
,
nsteps
+
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
;
// Write var1 and var2
streamWriteVar
(
streamID
,
varID1
,
var1
,
nmiss
);
streamWriteVar
(
streamID
,
varID2
,
var2
,
nmiss
);
}
// Close the output stream
streamClose
(
streamID
);
return
0
;
}
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