Commit 1ca26551 authored by Florian Prill's avatar Florian Prill
Browse files

[cdi-tiles] Adapted implementation to changed template.

parent 72af9ddc
......@@ -32,6 +32,7 @@ config/mkinstalldirs -text
/configure -text
/configure.ac -text
/do_configure.sh -text
/do_configure.xce.sh -text
doc/Doxyfile -text
doc/cdi_cman.pdf -text
doc/cdi_fman.pdf -text
......
......@@ -10,5 +10,8 @@ run:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../build/lib64 ./main
runfortran:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../build/lib64:/opt/grib_api/lib64 ./example
xce:
cc -DHAVE_CF_INTERFACE -DHAVE_LIBNETCDF -DHAVE_LIBGRIB -DHAVE_LIBGRIB_API ${GRIB_API_INCLUDE} -I${NETCDF_DIR}/include -c ../src/cdilib.c -o cdilib.o
ftn -I../build/include cdilib.o example.f90 -L${NETCDF_DIR}/lib ${GRIB_API_LIB} -lgrib_api -lnetcdff -lnetcdf -o example
clean:
rm -f main main.o example cdilib.o
......@@ -13,8 +13,8 @@ PROGRAM example
WRITE (0,*) "cdi-tiles example"
! Register additional GRIB keys which are read when file is opened.
CALL cdiDefAdditionalKey("identificationNumberOfTile")
CALL cdiDefAdditionalKey("attribute")
CALL cdiDefAdditionalKey("tileIndex")
CALL cdiDefAdditionalKey("tileAttribute")
streamID = streamOpenRead("NWP_tiles_test.grb")
! streamID = streamOpenRead("NWP_tiles_test.nc")
......@@ -30,10 +30,10 @@ PROGRAM example
IF (tile_index /= CDI_UNDEFID) THEN
CALL subtypeDefActiveIndex(subtypeID, tile_index)
WRITE (0,*) "VAR ", TRIM(name)
WRITE (0,*) " identificationNumberOfTile = ", &
& vlistInqVarIntKey(vlistID, varID, "identificationNumberOfTile")
WRITE (0,*) " attribute = ", &
& vlistInqVarIntKey(vlistID, varID, "attribute")
WRITE (0,*) " tileIndex = ", &
& vlistInqVarIntKey(vlistID, varID, "tileIndex")
WRITE (0,*) " tileAttribute = ", &
& vlistInqVarIntKey(vlistID, varID, "tileAttribute")
! query grid size, allocate buffer
gridID = vlistInqVarGrid(vlistID, varID)
......
module swap grib_api grib_api/1.13.0-prerelease
CC="cc" \
LDFLAGS="-L$NETCDF_DIR/lib $GRIB_API_LIB" \
CFLAGS="$GRIB_API_INCLUDE -I$NETCDF_DIR/include " \
./configure --prefix=$HOME/CDI/branches/cdi-tiles/build \
--with-netcdf=yes --with-grib-api=yes --disable-shared
......@@ -190,12 +190,12 @@ typedef struct {
enum {
/* subtype attributes wrt. TILES */
SUBTYPE_ATT_IDENTIFICATION_NO_OF_TILE = 0,
SUBTYPE_ATT_IDENTIFICATION_NO_OF_ATTR = 1,
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_ATTRIBUTE = 5
SUBTYPE_ATT_TILEATTRIBUTE = 5
} subtype_attributes;
......@@ -1100,7 +1100,7 @@ subtype_query_t matchAND(subtype_query_t q1, subtype_query_t q2);
int subtypeInqSubEntry(int subtypeID, subtype_query_t criterion);
/* subtypeInqTile: Specialized version of subtypeInqSubEntry looking for tile/attribute pair. */
int subtypeInqTile(int subtypeID, int identificationNumberOfTile, int attribute);
int subtypeInqTile(int subtypeID, int tileindex, int attribute);
/* vlistInqVarSubtype: Return subtype ID for a given variable. */
int vlistInqVarSubtype(int vlistID, int varID);
......
......@@ -130,8 +130,8 @@ Record;
* contains "-1" if this is no tile-variable. */
typedef struct {
int
identificationNumberOfTile,
identificationNumberOfAttribute,
tileindex,
totalno_of_tileattr_pairs,
tileClassification,
numberOfTiles,
numberOfAttributes,
......
......@@ -1286,17 +1286,15 @@ int gribapiScanTimestep1(stream_t * streamptr)
grib2GetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
/* read in tiles attributes (if there are any) */
/* NOTE THAT "identificationNumberOfAttribute" HOLDS THE
* TOTAL NO. OF TILE/ATTRIBUTE PAIRS!!! */
if (grib_get_long(gh, "identificationNumberOfTile", &lpar) != 0)
tiles.identificationNumberOfTile = -1;
if (grib_get_long(gh, "tileIndex", &lpar) != 0)
tiles.tileindex = -1;
else
tiles.identificationNumberOfTile = (int) lpar;
if (grib_get_long(gh, "identificationNumberOfAttribute", &lpar) != 0)
tiles.identificationNumberOfAttribute = -1;
tiles.tileindex = (int) lpar;
if (grib_get_long(gh, "totalNumberOfTileAttributePairs", &lpar) != 0)
tiles.totalno_of_tileattr_pairs = -1;
else
tiles.identificationNumberOfAttribute = (int) lpar;
tiles.totalno_of_tileattr_pairs = (int) lpar;
if (grib_get_long(gh, "tileClassification", &lpar) != 0)
tiles.tileClassification = -1;
else
......@@ -1309,19 +1307,11 @@ int gribapiScanTimestep1(stream_t * streamptr)
tiles.numberOfAttributes = -1;
else
tiles.numberOfAttributes = (int) lpar;
if (grib_get_long(gh, "attribute", &lpar) != 0)
if (grib_get_long(gh, "tileAttribute", &lpar) != 0)
tiles.attribute = -1;
else
tiles.attribute = (int) lpar;
/*
printf("tiles: identificationNumberOfTile=%d, identificationNumberOfAttribute=%d\n",
tiles.identificationNumberOfTile, tiles.identificationNumberOfAttribute);
printf(" tileClassification=%d, numberOfTiles=%d\n",
tiles.tileClassification, tiles.numberOfTiles);
printf(" numberOfAttributes=%d, attribute=%d\n",
tiles.numberOfAttributes, tiles.attribute);
*/
}
cdiParamToString(param, paramstr, sizeof(paramstr));
......@@ -1641,17 +1631,15 @@ int gribapiScanTimestep2(stream_t * streamptr)
grib2GetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
/* read in tiles attributes (if there are any) */
/* NOTE THAT "identificationNumberOfAttribute" HOLDS THE
* TOTAL NO. OF TILE/ATTRIBUTE PAIRS!!! */
if (grib_get_long(gh, "identificationNumberOfTile", &lpar) != 0)
tiles.identificationNumberOfTile = -1;
if (grib_get_long(gh, "tileIndex", &lpar) != 0)
tiles.tileindex = -1;
else
tiles.identificationNumberOfTile = (int) lpar;
if (grib_get_long(gh, "identificationNumberOfAttribute", &lpar) != 0)
tiles.identificationNumberOfAttribute = -1;
tiles.tileindex = (int) lpar;
if (grib_get_long(gh, "totalNumberOfTileAttributePairs", &lpar) != 0)
tiles.totalno_of_tileattr_pairs = -1;
else
tiles.identificationNumberOfAttribute = (int) lpar;
tiles.totalno_of_tileattr_pairs = (int) lpar;
if (grib_get_long(gh, "tileClassification", &lpar) != 0)
tiles.tileClassification = -1;
else
......@@ -1664,6 +1652,10 @@ int gribapiScanTimestep2(stream_t * streamptr)
tiles.numberOfAttributes = -1;
else
tiles.numberOfAttributes = (int) lpar;
if (grib_get_long(gh, "tileAttribute", &lpar) != 0)
tiles.attribute = -1;
else
tiles.attribute = (int) lpar;
}
cdiParamToString(param, paramstr, sizeof(paramstr));
......@@ -1945,17 +1937,15 @@ int gribapiScanTimestep(stream_t * streamptr)
grib2GetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
/* read in tiles attributes (if there are any) */
/* NOTE THAT "identificationNumberOfAttribute" HOLDS THE
* TOTAL NO. OF TILE/ATTRIBUTE PAIRS!!! */
if (grib_get_long(gh, "identificationNumberOfTile", &lpar) != 0)
tiles.identificationNumberOfTile = -1;
if (grib_get_long(gh, "tileIndex", &lpar) != 0)
tiles.tileindex = -1;
else
tiles.identificationNumberOfTile = (int) lpar;
if (grib_get_long(gh, "identificationNumberOfAttribute", &lpar) != 0)
tiles.identificationNumberOfAttribute = -1;
tiles.tileindex = (int) lpar;
if (grib_get_long(gh, "totalNumberOfTileAttributePairs", &lpar) != 0)
tiles.totalno_of_tileattr_pairs = -1;
else
tiles.identificationNumberOfAttribute = (int) lpar;
tiles.totalno_of_tileattr_pairs = (int) lpar;
if (grib_get_long(gh, "tileClassification", &lpar) != 0)
tiles.tileClassification = -1;
else
......@@ -1968,6 +1958,10 @@ int gribapiScanTimestep(stream_t * streamptr)
tiles.numberOfAttributes = -1;
else
tiles.numberOfAttributes = (int) lpar;
if (grib_get_long(gh, "tileAttribute", &lpar) != 0)
tiles.attribute = -1;
else
tiles.attribute = (int) lpar;
}
cdiParamToString(param, paramstr, sizeof(paramstr));
......
......@@ -51,12 +51,12 @@ const int nSubtypeAttributes = 6;
/* Literal constants corresponding to the different constants of the
enumeration "subtype_attributes". */
const char* subtypeAttributeName[] = {
"identificationNumberOfTile",
"identificationNumberOfAttribute",
"tileIndex",
"totalNumberOfTileAttributePairs",
"tileClassification",
"numberOfTiles",
"numberOfAttributes",
"attribute"
"numberOfTileAttributes",
"tileAttribute"
};
......@@ -754,11 +754,11 @@ int subtypeInqSubEntry(int subtypeID, subtype_query_t criterion)
}
int subtypeInqTile(int subtypeID, int identificationNumberOfTile, int attribute)
int subtypeInqTile(int subtypeID, int tileindex, int attribute)
{
return subtypeInqSubEntry(subtypeID,
matchAND(keyValuePair("identificationNumberOfTile", identificationNumberOfTile),
keyValuePair("attribute", attribute)));
matchAND(keyValuePair("tileIndex", tileindex),
keyValuePair("tileAttribute", attribute)));
}
......
......@@ -425,7 +425,7 @@ int varInsertTileSubtype(vartable_t *vptr, var_tile_t tiles)
subtype_t *subtype_ptr;
subtypeAllocate(&subtype_ptr, SUBTYPE_TILES);
subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_IDENTIFICATION_NO_OF_ATTR, tiles.identificationNumberOfAttribute);
subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS, tiles.totalno_of_tileattr_pairs);
subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_TILE_CLASSIFICATION , tiles.tileClassification);
subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_NUMBER_OF_TILES , tiles.numberOfTiles);
......@@ -434,9 +434,9 @@ int varInsertTileSubtype(vartable_t *vptr, var_tile_t tiles)
* tile/attribute pair (based on "tiles").
*/
struct subtype_entry_t *entry = subtypeEntryInsert(subtype_ptr);
subtypeDefEntryDataP(entry, SUBTYPE_ATT_NUMBER_OF_ATTR , tiles.numberOfAttributes);
subtypeDefEntryDataP(entry, SUBTYPE_ATT_IDENTIFICATION_NO_OF_TILE, tiles.identificationNumberOfTile);
subtypeDefEntryDataP(entry, SUBTYPE_ATT_ATTRIBUTE, tiles.attribute);
subtypeDefEntryDataP(entry, SUBTYPE_ATT_NUMBER_OF_ATTR, tiles.numberOfAttributes);
subtypeDefEntryDataP(entry, SUBTYPE_ATT_TILEINDEX, tiles.tileindex);
subtypeDefEntryDataP(entry, SUBTYPE_ATT_TILEATTRIBUTE, tiles.attribute);
if (vptr->tiles == NULL) {
vptr->tiles = subtype_ptr;
......@@ -663,9 +663,9 @@ void cdi_generate_vars(stream_t *streamptr)
for (int isub=1; isub<vartable[varid].nsubtypes; isub++) {
if (vartable[varid].recordTable[isub].nlevels != nlevels)
{
fprintf(stderr, "isub = %d / %d :: "
fprintf(stderr, "var \"%s\": isub = %d / %d :: "
"nlevels = %d, vartable[varid].recordTable[isub].nlevels = %d\n",
isub, vartable[varid].nsubtypes,
vartable[varID].name, isub, vartable[varid].nsubtypes,
nlevels, vartable[varid].recordTable[isub].nlevels);
Error("zaxis size must not change for same parameter!");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment