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
aad1f826
Commit
aad1f826
authored
15 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
grbWriteVar: bug fix
parent
0a0b7d9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
ChangeLog
+5
-0
5 additions, 0 deletions
ChangeLog
examples/cdi_copy_file.c
+99
-0
99 additions, 0 deletions
examples/cdi_copy_file.c
src/cdi.inc
+2
-2
2 additions, 2 deletions
src/cdi.inc
src/stream_grb.c
+8
-5
8 additions, 5 deletions
src/stream_grb.c
with
115 additions
and
7 deletions
.gitattributes
+
1
−
0
View file @
aad1f826
...
...
@@ -73,6 +73,7 @@ examples/Makefile.am -text
examples/Makefile.in -text
examples/cdi_copy.c -text
examples/cdi_copy_f.f -text
examples/cdi_copy_file.c -text
examples/cdi_read.c -text
examples/cdi_read_example.f90 -text
examples/cdi_read_f.f -text
...
...
This diff is collapsed.
Click to expand it.
ChangeLog
+
5
−
0
View file @
aad1f826
2009-10-28 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* grbWriteVar: bug fix
* Version 1.4.0.2 released
2009-10-23 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* stream_cdf:cdfDefXaxis: bug fix for multi generic grids [report: Uwe Mikolajewicz]
...
...
This diff is collapsed.
Click to expand it.
examples/cdi_copy_file.c
0 → 100644
+
99
−
0
View file @
aad1f826
#include
<stdio.h>
#include
<stdlib.h>
#include
"cdi.h"
/* gcc -g -O2 -o cdi_copy_file cdi_copy_file.c -I../src ../src/libcdi.a -lm */
#define MAX_LEVEL 200
int
main
(
int
argc
,
char
*
argv
[])
{
int
linfo
=
0
;
int
vlistID1
,
vlistID2
,
varID
,
streamID1
,
streamID2
,
tsID
;
int
nmiss
,
nvars
,
status
,
gridsize
;
double
*
vardata
=
NULL
;
const
char
*
ifile
,
*
ofile
;
if
(
argc
==
1
)
{
fprintf
(
stderr
,
"usage: %s ifile ofile
\n
"
,
argv
[
0
]);
return
(
-
1
);
}
ifile
=
argv
[
1
];
ofile
=
argv
[
2
];
/* Open the input dataset */
streamID1
=
streamOpenRead
(
ifile
);
if
(
streamID1
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID1
));
return
(
1
);
}
/* Get the variable list of the dataset */
vlistID1
=
streamInqVlist
(
streamID1
);
nvars
=
vlistNvars
(
vlistID1
);
gridsize
=
vlistGridsizeMax
(
vlistID1
);
vardata
=
(
double
*
)
malloc
(
gridsize
*
MAX_LEVEL
*
sizeof
(
double
));
/* Open the output dataset (GRIB fromat) */
streamID2
=
streamOpenWrite
(
ofile
,
FILETYPE_GRB
);
if
(
streamID2
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID2
));
return
(
1
);
}
vlistID2
=
vlistDuplicate
(
vlistID1
);
streamDefVlist
(
streamID2
,
vlistID2
);
/* Loop over all time steps */
tsID
=
0
;
while
(
(
status
=
streamInqTimestep
(
streamID1
,
tsID
))
)
{
/* Define the output time step */
streamDefTimestep
(
streamID2
,
tsID
);
for
(
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
/* Read variable */
streamReadVar
(
streamID1
,
varID
,
vardata
,
&
nmiss
);
if
(
linfo
)
{
int
i
,
k
,
nlevel
;
nlevel
=
zaxisInqSize
(
vlistInqVarZaxis
(
vlistID1
,
varID
));
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistID1
,
varID
));
for
(
k
=
0
;
k
<
nlevel
;
++
k
)
{
double
fmin
=
1.e30
,
fmax
=
-
1.e30
,
fmean
=
0
;
for
(
i
=
0
;
i
<
gridsize
;
++
i
)
{
if
(
vardata
[
k
*
gridsize
+
i
]
<
fmin
)
fmin
=
vardata
[
k
*
gridsize
+
i
];
if
(
vardata
[
k
*
gridsize
+
i
]
>
fmax
)
fmax
=
vardata
[
k
*
gridsize
+
i
];
fmean
+=
vardata
[
k
*
gridsize
+
i
];
}
printf
(
"%3d %3d %3d %9g %9g %9g
\n
"
,
tsID
,
varID
,
k
,
fmin
,
fmean
/
gridsize
,
fmax
);
}
}
/* Write variable */
streamWriteVar
(
streamID2
,
varID
,
vardata
,
nmiss
);
}
tsID
++
;
}
/* Close the streams */
streamClose
(
streamID1
);
streamClose
(
streamID2
);
free
(
vardata
);
return
0
;
}
This diff is collapsed.
Click to expand it.
src/cdi.inc
+
2
−
2
View file @
aad1f826
!
This
file
was
automatically
created
,
don
'
t
edit
!
!
!
Fortran
interface
for
CDI
library
version
1.
3.2
!
Fortran
interface
for
CDI
library
version
1.
4.1
!
!
Author
:
!
-------
!
Uwe
Schulzweida
,
MPI
-
MET
,
Hamburg
,
Septem
ber
2009
!
Uwe
Schulzweida
,
MPI
-
MET
,
Hamburg
,
Octo
ber
2009
!
INTEGER
CDI_UNDEFID
...
...
This diff is collapsed.
Click to expand it.
src/stream_grb.c
+
8
−
5
View file @
aad1f826
...
...
@@ -479,15 +479,18 @@ int grbWriteVarSliceDP(int streamID, int varID, int levelID, const double *data,
void
grbWriteVarDP
(
int
streamID
,
int
varID
,
const
double
*
data
,
int
nmiss
)
{
int
vlistID
,
zaxisID
,
levelID
,
nlevs
;
int
vlistID
,
gridID
,
zaxisID
,
levelID
,
nlevs
;
int
gridsize
;
vlistID
=
streamInqVlist
(
streamID
);
zaxisID
=
vlistInqVarZaxis
(
vlistID
,
varID
);
nlevs
=
zaxisInqSize
(
zaxisID
);
vlistID
=
streamInqVlist
(
streamID
);
gridID
=
vlistInqVarGrid
(
vlistID
,
varID
);
gridsize
=
gridInqSize
(
gridID
);
zaxisID
=
vlistInqVarZaxis
(
vlistID
,
varID
);
nlevs
=
zaxisInqSize
(
zaxisID
);
for
(
levelID
=
0
;
levelID
<
nlevs
;
levelID
++
)
{
grbWriteVarSliceDP
(
streamID
,
varID
,
levelID
,
data
,
nmiss
);
grbWriteVarSliceDP
(
streamID
,
varID
,
levelID
,
data
+
levelID
*
gridsize
,
nmiss
);
}
}
...
...
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