Commit d0b388ef authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added function cdiUnitNamePtr()

parent d507706e
......@@ -333,6 +333,16 @@ void stream_write_record(int streamID, int memtype, const void *data, int nmiss)
void uuid2str(const char *uuid, char *uuidstr);
void str2uuid(const char *uuidstr, char *uuid);
#define CDI_UNIT_PA 1
#define CDI_UNIT_HPA 2
#define CDI_UNIT_MM 3
#define CDI_UNIT_CM 4
#define CDI_UNIT_DM 5
#define CDI_UNIT_M 6
char *cdiUnitNamePtr(int cdi_unit);
#endif /* _CDI_INT_H */
/*
......
......@@ -748,9 +748,9 @@ void grib2GetLevel(grib_handle *gh, int *leveltype, int *lbounds, int *level1, i
{
GRIB_CHECK(grib_get_long(gh, "scaleFactorOfFirstFixedSurface", &factor), 0);
GRIB_CHECK(grib_get_double(gh, "scaledValueOfFirstFixedSurface", &dlevel1), 0);
dlevel1 *= 1000*grib2ScaleFactor(factor);
*level_sf = CONV_MM_TO_M;
*level_unit = 1;
*level_sf = 1000;
dlevel1 *= (*level_sf)*grib2ScaleFactor(factor);
*level_unit = CDI_UNIT_M;
}
else if ( *leveltype == GRIB2_LTYPE_ISOBARIC )
{
......@@ -774,13 +774,14 @@ void grib2GetLevel(grib_handle *gh, int *leveltype, int *lbounds, int *level1, i
{
GRIB_CHECK(grib_get_long(gh, "scaleFactorOfFirstFixedSurface", &factor), 0);
GRIB_CHECK(grib_get_double(gh, "scaledValueOfFirstFixedSurface", &dlevel1), 0);
dlevel1 *= 1000*grib2ScaleFactor(factor);
*level_sf = 1000;
dlevel1 *= (*level_sf)*grib2ScaleFactor(factor);
*level1 = (int) dlevel1;
GRIB_CHECK(grib_get_long(gh, "scaleFactorOfSecondFixedSurface", &factor), 0);
GRIB_CHECK(grib_get_double(gh, "scaledValueOfSecondFixedSurface", &dlevel2), 0);
dlevel2 *= 1000*grib2ScaleFactor(factor);
dlevel2 *= (*level_sf)*grib2ScaleFactor(factor);
*level2 = (int) dlevel2;
*level_sf = CONV_MM_TO_M;
*level_unit = CDI_UNIT_M;
}
else
{
......
......@@ -495,7 +495,7 @@ void cdi_generate_vars(stream_t *streamptr)
comptype = vartable[varid].comptype;
level_sf = 1;
if ( vartable[varid].level_sf == CONV_MM_TO_M ) level_sf = 0.001;
if ( vartable[varid].level_sf != 0 ) level_sf = 1./vartable[varid].level_sf;
zaxisID = UNDEFID;
......@@ -560,12 +560,9 @@ void cdi_generate_vars(stream_t *streamptr)
dlevels2[levelID] = level_sf*vartable[varid].levelTable[levelID].level2;
}
if ( vartable[varid].level_sf == CONV_MM_TO_M )
zaxisID = varDefZaxis(vlistID, zaxistype, nlevels, dlevels, lbounds, dlevels1, dlevels2,
Vctsize, Vct, NULL, NULL, "m", 0, 0, ltype);
else
zaxisID = varDefZaxis(vlistID, zaxistype, nlevels, dlevels, lbounds, dlevels1, dlevels2,
Vctsize, Vct, NULL, NULL, NULL, 0, 0, ltype);
char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
zaxisID = varDefZaxis(vlistID, zaxistype, nlevels, dlevels, lbounds, dlevels1, dlevels2,
Vctsize, Vct, NULL, NULL, unitptr, 0, 0, ltype);
if ( lbounds ) free(dlevels1);
if ( lbounds ) free(dlevels2);
......
......@@ -5,7 +5,6 @@
# include "grid.h"
#endif
#define CONV_MM_TO_M 77
void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
int level1, int level2, int level_sf, int level_unit, int prec,
......
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