Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
5b51b63e
Commit
5b51b63e
authored
Jun 11, 2020
by
Uwe Schulzweida
Browse files
varAddRecord(): removed stdname, longname and units.
parent
c2c11e13
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/stream_cgribex.c
View file @
5b51b63e
...
...
@@ -555,7 +555,7 @@ void cgribexAddRecord(stream_t *streamptr, cgribexrec_t *cgribexp, int param, si
int
varID
=
0
,
levelID
=
0
;
varAddRecord
(
recID
,
param
,
gridID
,
zaxistype
,
lbounds
,
level1
,
level2
,
0
,
0
,
datatype
,
&
varID
,
&
levelID
,
tsteptype
,
numavg
,
leveltype
,
-
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
,
NULL
);
record
->
varID
=
(
short
)
varID
;
record
->
levelID
=
(
short
)
levelID
;
...
...
src/stream_ext.c
View file @
5b51b63e
...
...
@@ -192,7 +192,7 @@ void extAddRecord(stream_t *streamptr, int param, int level, size_t xysize,
int
varID
,
levelID
=
0
;
varAddRecord
(
recID
,
param
,
gridID
,
leveltype
,
0
,
level
,
0
,
0
,
0
,
datatype
,
&
varID
,
&
levelID
,
TSTEP_INSTANT
,
0
,
0
,
-
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
,
NULL
);
record
->
varID
=
(
short
)
varID
;
record
->
levelID
=
(
short
)
levelID
;
...
...
src/stream_gribapi.c
View file @
5b51b63e
...
...
@@ -445,6 +445,24 @@ VarScanKeys gribapiGetScanKeys(grib_handle *gh)
return
scanKeys
;
}
static
void
gribapiGetNameKeys
(
grib_handle
*
gh
,
int
varID
)
{
char
string
[
CDI_MAX_NAME
];
size_t
vlen
=
CDI_MAX_NAME
;
gribapiGetString
(
gh
,
"name"
,
string
,
vlen
);
// longname
if
(
string
[
0
])
varDefKeyString
(
varID
,
CDI_KEY_LONGNAME
,
string
);
gribapiGetString
(
gh
,
"units"
,
string
,
vlen
);
if
(
string
[
0
])
varDefKeyString
(
varID
,
CDI_KEY_UNITS
,
string
);
string
[
0
]
=
0
;
const
int
status
=
grib_get_string
(
gh
,
"cfName"
,
string
,
&
vlen
);
if
(
status
!=
0
||
vlen
<=
1
||
strncmp
(
string
,
"unknown"
,
7
)
==
0
)
string
[
0
]
=
0
;
if
(
string
[
0
])
varDefKeyString
(
varID
,
CDI_KEY_STDNAME
,
string
);
}
static
void
gribapiGetKeys
(
grib_handle
*
gh
,
int
varID
)
{
...
...
@@ -637,8 +655,6 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
int
leveltype1
,
int
leveltype2
,
int
lbounds
,
int
level1
,
int
level2
,
int
level_sf
,
int
level_unit
,
VarScanKeys
*
scanKeys
,
const
var_tile_t
*
tiles
,
int
lread_additional_keys
)
{
char
stdname
[
CDI_MAX_NAME
],
longname
[
CDI_MAX_NAME
],
units
[
CDI_MAX_NAME
];
const
int
vlistID
=
streamptr
->
vlistID
;
const
int
tsID
=
streamptr
->
curTsID
;
const
int
recID
=
recordNewEntry
(
streamptr
,
tsID
);
...
...
@@ -716,27 +732,12 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
// if ( datatype > 32 ) datatype = CDI_DATATYPE_PACK32;
if
(
datatype
<
0
)
datatype
=
CDI_DATATYPE_PACK
;
stdname
[
0
]
=
0
;
longname
[
0
]
=
0
;
units
[
0
]
=
0
;
if
(
varname
[
0
]
!=
0
)
{
size_t
vlen
=
CDI_MAX_NAME
;
gribapiGetString
(
gh
,
"name"
,
longname
,
vlen
);
// longname
gribapiGetString
(
gh
,
"units"
,
units
,
vlen
);
const
int
status
=
grib_get_string
(
gh
,
"cfName"
,
stdname
,
&
vlen
);
if
(
status
!=
0
||
vlen
<=
1
||
strncmp
(
stdname
,
"unknown"
,
7
)
==
0
)
stdname
[
0
]
=
0
;
}
// fprintf(stderr, "param %d name %s %s %s\n", param, name, longname, units);
// add the previously read record data to the (intermediate) list of records
int
tile_index
=
0
;
int
varID
=
0
,
levelID
=
0
;
varAddRecord
(
recID
,
param
,
gridID
,
zaxistype
,
lbounds
,
level1
,
level2
,
level_sf
,
level_unit
,
datatype
,
&
varID
,
&
levelID
,
tsteptype
,
numavg
,
leveltype1
,
leveltype2
,
varname
,
stdname
,
longname
,
units
,
scanKeys
,
tiles
,
&
tile_index
);
varname
,
scanKeys
,
tiles
,
&
tile_index
);
record
->
varID
=
(
short
)
varID
;
record
->
levelID
=
(
short
)
levelID
;
...
...
@@ -745,6 +746,7 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
if
(
uvRelativeToGrid
)
varDefKeyInt
(
varID
,
CDI_KEY_UVRELATIVETOGRID
,
1
);
if
(
varname
[
0
])
gribapiGetNameKeys
(
gh
,
varID
);
gribapiGetKeys
(
gh
,
varID
);
if
(
lread_additional_keys
)
...
...
@@ -753,7 +755,7 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
double
dval
;
for
(
int
i
=
0
;
i
<
cdiNAdditionalGRIBKeys
;
i
++
)
{
/
*
note: if the key is not defined, we do not throw an error!
*/
/
/
note: if the key is not defined, we do not throw an error!
if
(
grib_get_long
(
gh
,
cdiAdditionalGRIBKeys
[
i
],
&
lval
)
==
0
)
varDefOptGribInt
(
varID
,
tile_index
,
lval
,
cdiAdditionalGRIBKeys
[
i
]);
if
(
grib_get_double
(
gh
,
cdiAdditionalGRIBKeys
[
i
],
&
dval
)
==
0
)
...
...
src/stream_ieg.c
View file @
5b51b63e
...
...
@@ -612,7 +612,7 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
int
varID
,
levelID
=
0
;
varAddRecord
(
recID
,
param
,
gridID
,
leveltype
,
lbounds
,
level1
,
level2
,
0
,
0
,
datatype
,
&
varID
,
&
levelID
,
TSTEP_INSTANT
,
0
,
0
,
-
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
,
NULL
);
record
->
varID
=
(
short
)
varID
;
record
->
levelID
=
(
short
)
levelID
;
...
...
src/stream_srv.c
View file @
5b51b63e
...
...
@@ -190,7 +190,7 @@ void srv_add_record(stream_t *streamptr, int param, int level, size_t xsize, siz
int
varID
,
levelID
=
0
;
varAddRecord
(
recID
,
param
,
gridID
,
leveltype
,
0
,
level
,
0
,
0
,
0
,
datatype
,
&
varID
,
&
levelID
,
TSTEP_INSTANT
,
0
,
0
,
-
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
,
NULL
);
xassert
(
varID
<=
SHRT_MAX
&&
levelID
<=
SHRT_MAX
);
record
->
varID
=
(
short
)
varID
;
...
...
src/varscan.c
View file @
5b51b63e
...
...
@@ -71,9 +71,6 @@ typedef struct
bool
lmissval
;
double
missval
;
char
*
name
;
char
*
stdname
;
char
*
longname
;
char
*
units
;
/* meta-data for specification of tiles (currently only GRIB-API: */
subtype_t
*
tiles
;
...
...
@@ -119,9 +116,6 @@ void paramInitEntry(unsigned varID, int param)
vartable
[
varID
].
lmissval
=
false
;
vartable
[
varID
].
missval
=
0
;
vartable
[
varID
].
name
=
NULL
;
vartable
[
varID
].
stdname
=
NULL
;
vartable
[
varID
].
longname
=
NULL
;
vartable
[
varID
].
units
=
NULL
;
vartable
[
varID
].
tiles
=
NULL
;
}
...
...
@@ -174,9 +168,6 @@ void varFree(void)
}
if
(
vartable
[
varID
].
name
)
Free
(
vartable
[
varID
].
name
);
if
(
vartable
[
varID
].
stdname
)
Free
(
vartable
[
varID
].
stdname
);
if
(
vartable
[
varID
].
longname
)
Free
(
vartable
[
varID
].
longname
);
if
(
vartable
[
varID
].
units
)
Free
(
vartable
[
varID
].
units
);
if
(
vartable
[
varID
].
tiles
)
subtypeDestroyPtr
(
vartable
[
varID
].
tiles
);
cdi_keys_t
*
keysp
=
&
(
vartable
[
varID
].
keys
);
...
...
@@ -399,8 +390,7 @@ int varInsertTileSubtype(vartable_t *vptr, const var_tile_t *tiles)
void
varAddRecord
(
int
recID
,
int
param
,
int
gridID
,
int
zaxistype
,
int
lbounds
,
int
level1
,
int
level2
,
int
level_sf
,
int
level_unit
,
int
prec
,
int
*
pvarID
,
int
*
plevelID
,
int
tsteptype
,
int
numavg
,
int
ltype1
,
int
ltype2
,
const
char
*
name
,
const
char
*
stdname
,
const
char
*
longname
,
const
char
*
units
,
const
VarScanKeys
*
scanKeys
,
const
var_tile_t
*
tiles
,
int
*
tile_index
)
const
char
*
name
,
const
VarScanKeys
*
scanKeys
,
const
var_tile_t
*
tiles
,
int
*
tile_index
)
{
unsigned
varID
=
(
cdiSplitLtype105
!=
1
||
zaxistype
!=
ZAXIS_HEIGHT
)
?
varGetEntry
(
param
,
gridID
,
zaxistype
,
ltype1
,
tsteptype
,
name
,
scanKeys
,
tiles
)
:
(
unsigned
)
CDI_UNDEFID
;
...
...
@@ -422,9 +412,6 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
if
(
numavg
)
vartable
[
varID
].
timave
=
1
;
if
(
name
&&
name
[
0
]
)
vartable
[
varID
].
name
=
strdup
(
name
);
if
(
stdname
&&
stdname
[
0
]
)
vartable
[
varID
].
stdname
=
strdup
(
stdname
);
if
(
longname
&&
longname
[
0
]
)
vartable
[
varID
].
longname
=
strdup
(
longname
);
if
(
units
&&
units
[
0
]
)
vartable
[
varID
].
units
=
strdup
(
units
);
}
else
{
...
...
@@ -486,9 +473,7 @@ int cmpLevelTable(const void* s1, const void* s2)
int
cmp
=
0
;
const
leveltable_t
*
x
=
(
const
leveltable_t
*
)
s1
;
const
leveltable_t
*
y
=
(
const
leveltable_t
*
)
s2
;
/*
printf("%g %g %d %d\n", x->leve11, y->level1, x, y);
*/
// printf("%g %g %d %d\n", x->leve11, y->level1, x, y);
if
(
x
->
level1
<
y
->
level1
)
cmp
=
-
1
;
else
if
(
x
->
level1
>
y
->
level1
)
cmp
=
1
;
...
...
@@ -501,9 +486,7 @@ int cmpLevelTableInv(const void* s1, const void* s2)
int
cmp
=
0
;
const
leveltable_t
*
x
=
(
const
leveltable_t
*
)
s1
;
const
leveltable_t
*
y
=
(
const
leveltable_t
*
)
s2
;
/*
printf("%g %g %d %d\n", x->leve11, y->level1, x, y);
*/
// printf("%g %g %d %d\n", x->leve11, y->level1, x, y);
if
(
x
->
level1
<
y
->
level1
)
cmp
=
1
;
else
if
(
x
->
level1
>
y
->
level1
)
cmp
=
-
1
;
...
...
@@ -707,11 +690,11 @@ void cdi_generate_vars(stream_t *streamptr)
if
(
lbounds
)
Free
(
dlevels2
);
Free
(
dlevels
);
/
*
define new subtype for tile set
*/
/
/
define new subtype for tile set
int
tilesetID
=
CDI_UNDEFID
;
if
(
vartable
[
varid
].
tiles
)
tilesetID
=
vlistDefTileSubtype
(
vlistID
,
vartable
[
varid
].
tiles
);
/
*
generate new variable
*/
/
/
generate new variable
int
varID
=
stream_new_var
(
streamptr
,
gridID
,
zaxisID
,
tilesetID
);
varID
=
vlistDefVarTiles
(
vlistID
,
gridID
,
zaxisID
,
TIME_VARYING
,
tilesetID
);
...
...
@@ -725,9 +708,6 @@ void cdi_generate_vars(stream_t *streamptr)
if
(
vartable
[
varid
].
lmissval
)
vlistDefVarMissval
(
vlistID
,
varID
,
vartable
[
varid
].
missval
);
if
(
vartable
[
varid
].
name
)
vlistDefVarName
(
vlistID
,
varID
,
vartable
[
varid
].
name
);
if
(
vartable
[
varid
].
stdname
)
vlistDefVarStdname
(
vlistID
,
varID
,
vartable
[
varid
].
stdname
);
if
(
vartable
[
varid
].
longname
)
vlistDefVarLongname
(
vlistID
,
varID
,
vartable
[
varid
].
longname
);
if
(
vartable
[
varid
].
units
)
vlistDefVarUnits
(
vlistID
,
varID
,
vartable
[
varid
].
units
);
vlist_t
*
vlistptr
=
vlist_to_pointer
(
vlistID
);
for
(
int
i
=
0
;
i
<
vartable
[
varid
].
opt_grib_nentries
;
i
++
)
...
...
@@ -743,7 +723,7 @@ void cdi_generate_vars(stream_t *streamptr)
strdupx
(
vartable
[
varid
].
opt_grib_kvpair
[
i
].
keyword
);
vlistptr
->
vars
[
varID
].
opt_grib_kvpair
[
i
].
update
=
true
;
}
/
*
note: if the key is not defined, we do not throw an error!
*/
/
/
note: if the key is not defined, we do not throw an error!
if
(
cdiDefaultTableID
!=
CDI_UNDEFID
)
{
...
...
@@ -1059,6 +1039,14 @@ void varDefKeyBytes(int varID, int key, const unsigned char *bytes, int length)
}
void
varDefKeyString
(
int
varID
,
int
key
,
const
char
*
string
)
{
int
length
=
strlen
(
string
)
+
1
;
cdi_keys_t
*
keysp
=
&
(
vartable
[
varID
].
keys
);
cdiDefVarKeyBytes
(
keysp
,
key
,
(
const
unsigned
char
*
)
string
,
length
);
}
#ifdef HAVE_LIBGRIB_API
/* Resizes and initializes opt_grib_kvpair data structure. */
static
...
...
src/varscan.h
View file @
5b51b63e
...
...
@@ -9,8 +9,7 @@
void
varAddRecord
(
int
recID
,
int
param
,
int
gridID
,
int
zaxistype
,
int
lbounds
,
int
level1
,
int
level2
,
int
level_sf
,
int
level_unit
,
int
prec
,
int
*
pvarID
,
int
*
plevelID
,
int
tsteptype
,
int
numavg
,
int
ltype1
,
int
ltype2
,
const
char
*
name
,
const
char
*
stdname
,
const
char
*
longname
,
const
char
*
units
,
const
VarScanKeys
*
scanKeys
,
const
var_tile_t
*
tiles
,
int
*
tile_index
);
const
char
*
name
,
const
VarScanKeys
*
scanKeys
,
const
var_tile_t
*
tiles
,
int
*
tile_index
);
void
varDefVCT
(
size_t
vctsize
,
double
*
vctptr
);
void
varDefZAxisReference
(
int
nlev
,
int
nvgrid
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]);
...
...
@@ -31,6 +30,7 @@ int varInqTable(int varID);
void
varDefKeyInt
(
int
varID
,
int
key
,
int
value
);
void
varDefKeyBytes
(
int
varID
,
int
key
,
const
unsigned
char
*
bytes
,
int
length
);
void
varDefKeyString
(
int
varID
,
int
key
,
const
char
*
string
);
void
varDefOptGribInt
(
int
varID
,
int
tile_index
,
long
lval
,
const
char
*
keyword
);
void
varDefOptGribDbl
(
int
varID
,
int
tile_index
,
double
dval
,
const
char
*
keyword
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment