Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
38b804e8
Commit
38b804e8
authored
Jun 15, 2015
by
Uwe Schulzweida
Browse files
Use subtypes, only where tiles are used
parent
5e4fb1ad
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/cdi_int.h
View file @
38b804e8
...
...
@@ -138,33 +138,6 @@ typedef struct {
attribute
;
}
var_tile_t
;
/* No. of different constants in the enumeration
"subtype_attributes" */
static
const
int
nSubtypeAttributes
=
6
;
enum
{
/* subtype attributes wrt. TILES */
SUBTYPE_ATT_TILEINDEX
=
0
,
SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS
=
1
,
SUBTYPE_ATT_TILE_CLASSIFICATION
=
2
,
SUBTYPE_ATT_NUMBER_OF_TILES
=
3
,
SUBTYPE_ATT_NUMBER_OF_ATTR
=
4
,
SUBTYPE_ATT_TILEATTRIBUTE
=
5
};
/* Literal constants corresponding to the different constants of the
enumeration "subtype_attributes". */
static
const
char
*
subtypeAttributeName
[]
=
{
"tileIndex"
,
"totalNumberOfTileAttributePairs"
,
"tileClassification"
,
"numberOfTiles"
,
"numberOfTileAttributes"
,
"tileAttribute"
};
typedef
struct
{
...
...
src/stream_cdf.c
View file @
38b804e8
...
...
@@ -24,7 +24,6 @@
#include
"cdf_int.h"
#include
"varscan.h"
#include
"vlist.h"
#include
"subtype.h"
//#define PROJECTION_TEST
...
...
@@ -6874,8 +6873,6 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
free
(
varInfo
);
}
int
trivial_tileID
=
vlistInsertTrivialTileSubtype
(
vlistID
);
for
(
int
varID1
=
0
;
varID1
<
nvars
;
varID1
++
)
{
int
gridID
,
zaxisID
;
...
...
@@ -6885,7 +6882,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
zaxisID
=
ncvars
[
ncvarid
].
zaxisID
;
stream_new_var
(
streamptr
,
gridID
,
zaxisID
,
CDI_UNDEFID
);
int
varID
=
vlistDefVar
Tiles
(
vlistID
,
gridID
,
zaxisID
,
ncvars
[
ncvarid
].
tsteptype
,
trivial_tileID
);
int
varID
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID
,
ncvars
[
ncvarid
].
tsteptype
);
#if defined (HAVE_NETCDF4)
if
(
ncvars
[
ncvarid
].
deflate
)
...
...
src/stream_gribapi.c
View file @
38b804e8
...
...
@@ -15,6 +15,7 @@
#include
"vlist.h"
#include
"stream_grb.h"
#include
"calendar.h"
#include
"subtype.h"
#if defined (HAVE_LIBGRIB_API)
...
...
@@ -483,7 +484,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
(
*
record
).
ilevel2
=
level2
;
(
*
record
).
ltype
=
leveltype1
;
(
*
record
).
tsteptype
=
tsteptype
;
if
(
tiles
)
(
*
record
).
tiles
=
*
tiles
;
if
(
tiles
)
(
*
record
).
tiles
=
*
tiles
;
else
(
*
record
).
tiles
=
dummy_tiles
;
//FIXME: This may leave the variable name unterminated (which is the behavior that I found in the code).
// I don't know precisely how this field is used, so I did not change this behavior to avoid regressions,
...
...
@@ -943,8 +945,10 @@ int gribapiScanTimestep1(stream_t * streamptr)
nrecs
,
(
int
)
recpos
,
varname
,
paramstr
,
leveltype1
,
level1
,
level2
,
vdate
,
vtime
);
}
var_tile_t
*
ptiles
=
NULL
;
if
(
memcmp
(
&
tiles
,
&
dummy_tiles
,
sizeof
(
var_tile_t
))
!=
0
)
ptiles
=
&
tiles
;
gribapiAddRecord
(
streamptr
,
param
,
gh
,
recsize
,
recpos
,
datatype
,
comptype
,
varname
,
leveltype1
,
leveltype2
,
lbounds
,
level1
,
level2
,
level_sf
,
level_unit
,
&
tiles
,
1
);
leveltype1
,
leveltype2
,
lbounds
,
level1
,
level2
,
level_sf
,
level_unit
,
p
tiles
,
1
);
grib_handle_delete
(
gh
);
gh
=
NULL
;
...
...
src/stream_record.c
View file @
38b804e8
...
...
@@ -27,6 +27,7 @@ void recordInitEntry(record_t *record)
record
->
varID
=
CDI_UNDEFID
;
record
->
levelID
=
CDI_UNDEFID
;
memset
(
record
->
varname
,
0
,
sizeof
(
record
->
varname
));
memset
(
&
record
->
tiles
,
0
,
sizeof
(
record
->
tiles
));
}
...
...
src/stream_var.c
View file @
38b804e8
...
...
@@ -103,7 +103,7 @@ int streamvar_new_entry(stream_t *streamptr)
}
void
allocate_record_table_entry
(
stream_t
*
streamptr
,
int
varID
,
int
subID
,
int
nlevs
)
void
allocate_record_table_entry
(
stream_t
*
streamptr
,
int
varID
,
int
subID
,
int
nlevs
)
{
int
*
level
=
(
int
*
)
xmalloc
((
size_t
)
nlevs
*
sizeof
(
int
));
int
*
lindex
=
(
int
*
)
xmalloc
((
size_t
)
nlevs
*
sizeof
(
int
));
...
...
@@ -147,7 +147,7 @@ int stream_new_var(stream_t *streamptr, int gridID, int zaxisID, int tilesetID)
streamvar_init_recordtable
(
streamptr
,
varID
,
isub
);
allocate_record_table_entry
(
streamptr
,
varID
,
isub
,
nlevs
);
if
(
CDI_Debug
)
Message
(
"streamptr->vars[varID].recordTable[isub].recordID[0]=%d"
,
Message
(
"streamptr->vars[varID].recordTable[isub].recordID[0]=%d"
,
streamptr
->
vars
[
varID
].
recordTable
[
isub
].
recordID
[
0
]);
}
...
...
src/subtype.c
View file @
38b804e8
...
...
@@ -699,8 +699,15 @@ int subtypeCompare(int subtypeID1, int subtypeID2)
/* Get the size of a subtype (e.g. no. of tiles). */
int
subtypeInqSize
(
int
subtypeID
)
{
subtype_t
*
subtype_ptr
=
reshGetVal
(
subtypeID
,
&
subtypeOps
);
return
subtype_ptr
->
nentries
;
if
(
subtypeID
==
CDI_UNDEFID
)
{
return
0
;
}
else
{
subtype_t
*
subtype_ptr
=
reshGetVal
(
subtypeID
,
&
subtypeOps
);
return
subtype_ptr
->
nentries
;
}
}
...
...
src/subtype.h
View file @
38b804e8
#ifndef _SUBTYPE_H
#define _SUBTYPE_H
/* No. of different constants in the enumeration
"subtype_attributes" */
static
const
int
nSubtypeAttributes
=
6
;
enum
{
/* subtype attributes wrt. TILES */
SUBTYPE_ATT_TILEINDEX
=
0
,
SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS
=
1
,
SUBTYPE_ATT_TILE_CLASSIFICATION
=
2
,
SUBTYPE_ATT_NUMBER_OF_TILES
=
3
,
SUBTYPE_ATT_NUMBER_OF_ATTR
=
4
,
SUBTYPE_ATT_TILEATTRIBUTE
=
5
};
/* Literal constants corresponding to the different constants of the
enumeration "subtype_attributes". */
static
const
char
*
subtypeAttributeName
[]
=
{
"tileIndex"
,
"totalNumberOfTileAttributePairs"
,
"tileClassification"
,
"numberOfTiles"
,
"numberOfTileAttributes"
,
"tileAttribute"
};
/* Data type specifying an attribute of a subtype (for example an
attribute of a set of TILES) or an attribute of a subtype entry
(for example an attribute of a single TILE). This data type is part
...
...
src/varscan.c
View file @
38b804e8
...
...
@@ -424,6 +424,8 @@ paramNewEntry(int param)
static
int
varInsertTileSubtype
(
vartable_t
*
vptr
,
const
var_tile_t
*
tiles
)
{
if
(
tiles
==
NULL
)
return
-
1
;
int
totalno_of_tileattr_pairs
=
-
1
;
int
tileClassification
=
-
1
;
int
numberOfTiles
=
-
1
;
...
...
@@ -792,7 +794,8 @@ void cdi_generate_vars(stream_t *streamptr)
free
(
dlevels
);
/* define new subtype for tile set */
int
tilesetID
=
vlistDefTileSubtype
(
vlistID
,
vartable
[
varid
].
tiles
);
int
tilesetID
=
CDI_UNDEFID
;
if
(
vartable
[
varid
].
tiles
)
tilesetID
=
vlistDefTileSubtype
(
vlistID
,
vartable
[
varid
].
tiles
);
/* generate new variable */
int
varID
=
stream_new_var
(
streamptr
,
gridID
,
zaxisID
,
tilesetID
);
...
...
src/vlist.c
View file @
38b804e8
...
...
@@ -720,7 +720,7 @@ void vlistCat(int vlistID2, int vlistID1)
vlistAdd2GridIDs
(
vlistptr2
,
vars1
[
varID
].
gridID
);
vlistAdd2ZaxisIDs
(
vlistptr2
,
vars1
[
varID
].
zaxisID
);
vlistAdd2SubtypeIDs
(
vlistptr2
,
vlistptr1
->
vars
[
varID
].
subtypeID
);
vlistAdd2SubtypeIDs
(
vlistptr2
,
vars
1
[
varID
].
subtypeID
);
}
}
...
...
src/vlist.h
View file @
38b804e8
...
...
@@ -207,6 +207,8 @@ vlistAdd2ZaxisIDs(vlist_t *vlistptr, int zaxisID)
static
inline
void
vlistAdd2SubtypeIDs
(
vlist_t
*
vlistptr
,
int
subtypeID
)
{
if
(
subtypeID
==
CDI_UNDEFID
)
return
;
int
index
,
nsubs
=
vlistptr
->
nsubtypes
;
for
(
index
=
0
;
index
<
nsubs
;
index
++
)
if
(
vlistptr
->
subtypeIDs
[
index
]
==
subtypeID
)
break
;
...
...
src/vlist_var.c
View file @
38b804e8
...
...
@@ -41,6 +41,7 @@ void vlistvarInitEntry(int vlistID, int varID)
vlistptr
->
vars
[
varID
].
xyz
=
321
;
vlistptr
->
vars
[
varID
].
gridID
=
CDI_UNDEFID
;
vlistptr
->
vars
[
varID
].
zaxisID
=
CDI_UNDEFID
;
vlistptr
->
vars
[
varID
].
subtypeID
=
CDI_UNDEFID
;
vlistptr
->
vars
[
varID
].
instID
=
CDI_UNDEFID
;
vlistptr
->
vars
[
varID
].
modelID
=
CDI_UNDEFID
;
vlistptr
->
vars
[
varID
].
tableID
=
CDI_UNDEFID
;
...
...
@@ -136,6 +137,7 @@ void vlistCheckVarID(const char *caller, int vlistID, int varID)
Errorc
(
"varID %d undefined!"
,
varID
);
}
int
vlistDefVarTiles
(
int
vlistID
,
int
gridID
,
int
zaxisID
,
int
tsteptype
,
int
tilesetID
)
{
vlist_t
*
vlistptr
=
vlist_to_pointer
(
vlistID
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment