diff --git a/ChangeLog b/ChangeLog index ec0322105170fd2cc2cfb11a9824c698f33110c3..e6f1a9c9c4dd8ac5fc636408d3d9170052c51017 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ 2013-06-11 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> + * GRIB2: added support for snow level (level type 114) * GRIB2: added support for layers with zaxis type ZAXIS_PRESSURE 2013-06-06 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> diff --git a/NEWS b/NEWS index 1c121e6a607df1526d81ddb1d671911970a67879..c6825e7d70017f2e89946e4dd9ab978c02f7a5dc 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ CDI NEWS Version 1.6.1 (18 June 2013): New features: + * GRIB2: added support for snow level (level type 114) * GRIB2: added support for layers with zaxis type ZAXIS_PRESSURE New functions: * cdiHaveFiletype(): Check whether a filetype is available diff --git a/doc/tex/c_ref.tex b/doc/tex/c_ref.tex index 792ecebdb3d83b6fce26898df6ac44362427e359..bc2a48b737e60c3db5b49eaa4eb50d9dec16fd43 100644 --- a/doc/tex/c_ref.tex +++ b/doc/tex/c_ref.tex @@ -1183,7 +1183,7 @@ vlistInqAttFlt \fi } \begin{verbatim} - int vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, int *dp); + int vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double *dp); \end{verbatim} Get the value(s) of a floating point attribute @@ -1213,7 +1213,7 @@ vlistInqAttTxt \fi } \begin{verbatim} - int vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, int *tp); + int vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, char *tp); \end{verbatim} Get the value(s) of a text attribute diff --git a/doc/tex/c_vlist_att.tex b/doc/tex/c_vlist_att.tex index 6da7198082d63273521e283e32ffd959fa16adc7..f1344ab139bd39d7f8fde129b4e4fd735aa0bb70 100644 --- a/doc/tex/c_vlist_att.tex +++ b/doc/tex/c_vlist_att.tex @@ -160,7 +160,7 @@ The function {\tt vlistInqAttFlt} gets the values(s) of a floating point attribu \subsubsection*{Usage} \begin{verbatim} - int vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, int *dp); + int vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double *dp); \end{verbatim} \hspace*{4mm}\begin{minipage}[]{15cm} @@ -218,7 +218,7 @@ The function {\tt vlistInqAttTxt} gets the values(s) of a text attribute. \subsubsection*{Usage} \begin{verbatim} - int vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, int *tp); + int vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, char *tp); \end{verbatim} \hspace*{4mm}\begin{minipage}[]{15cm} diff --git a/doc/tex/c_vlist_var.tex b/doc/tex/c_vlist_var.tex index 22ad2880e730192b17f8f83d9cc5dfb132e87760..409549762c64c03324ed409d8642faad9d53f0b8 100644 --- a/doc/tex/c_vlist_var.tex +++ b/doc/tex/c_vlist_var.tex @@ -381,7 +381,7 @@ Variable list ID, from a previous call to {\htmlref{\tt vlistCreate}{vlistCreate \item[{\tt varID}] Variable identifier. \item[{\tt units}] -Units of the variable. The caller must allocate space for the +Units of the variable. The caller must allocate space for the returned string. The maximum possible length, in characters, of the string is given by the predefined constant {\tt CDI\_MAX\_NAME}. diff --git a/doc/tex/c_zaxis.tex b/doc/tex/c_zaxis.tex index b143fca047162732bd034890ff0d49434910cc66..05affaee1eade4993c4512622f88ffe21ed7f265 100644 --- a/doc/tex/c_zaxis.tex +++ b/doc/tex/c_zaxis.tex @@ -20,7 +20,7 @@ The type of the Z-axis, one of the set of predefined {\CDI} Z-axis types. {\tt ZAXIS\_HYBRID}, {\tt ZAXIS\_SIGMA}, {\tt ZAXIS\_PRESSURE}, {\tt ZAXIS\_HEIGHT}, {\tt ZAXIS\_ISENTROPIC}, {\tt ZAXIS\_ALTITUDE}, {\tt ZAXIS\_MEANSEA}, {\tt ZAXIS\_TOA}, {\tt ZAXIS\_SEA\_BOTTOM}, {\tt ZAXIS\_ATMOSPHERE}, {\tt ZAXIS\_CLOUD\_BASE}, - {\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, + {\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, {\tt ZAXIS\_SNOW}, {\tt ZAXIS\_DEPTH\_BELOW\_SEA} and {\tt ZAXIS\_DEPTH\_BELOW\_LAND}. \item[{\tt size}] Number of levels. @@ -98,7 +98,7 @@ The valid {\CDI} Z-axis types are {\tt ZAXIS\_GENERIC}, {\tt ZAXIS\_SURFACE}, {\tt ZAXIS\_HYBRID}, {\tt ZAXIS\_SIGMA}, {\tt ZAXIS\_PRESSURE}, {\tt ZAXIS\_HEIGHT}, {\tt ZAXIS\_ISENTROPIC}, {\tt ZAXIS\_ALTITUDE}, {\tt ZAXIS\_MEANSEA}, {\tt ZAXIS\_TOA}, {\tt ZAXIS\_SEA\_BOTTOM}, {\tt ZAXIS\_ATMOSPHERE}, {\tt ZAXIS\_CLOUD\_BASE}, -{\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, +{\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, {\tt ZAXIS\_SNOW}, {\tt ZAXIS\_DEPTH\_BELOW\_SEA} and {\tt ZAXIS\_DEPTH\_BELOW\_LAND}. diff --git a/doc/tex/cdi_cman.tex b/doc/tex/cdi_cman.tex index c3f8e7a549a69123fc817d76cab2b5927930ba17..c2bf536be77084ff85d673671a8429da9e59dbe7 100644 --- a/doc/tex/cdi_cman.tex +++ b/doc/tex/cdi_cman.tex @@ -8,15 +8,15 @@ \gdef\pdfoutput{0} \fi -\newif\ifpdf +\newif\ifpdfx \ifnum\pdfoutput=0 % latex is called for dvi output - \pdffalse + \pdfxfalse \usepackage{graphics} \usepackage{hyperref} \else % pdflatex is called for pdf output - \pdftrue + \pdfxtrue \usepackage[pdftex]{graphicx} \usepackage[pdftex]{hyperref} \fi @@ -236,7 +236,7 @@ CDI library routines: \clearpage -\ifpdf +\ifpdfx \phantomsection \fi \addcontentsline{toc}{chapter}{\indexname} diff --git a/doc/tex/cdi_fman.tex b/doc/tex/cdi_fman.tex index 2cc452df64b1830a9bfb53d78a89f35527733a0f..d6706294fcc986202c8ca88e22ade2952bc12912 100644 --- a/doc/tex/cdi_fman.tex +++ b/doc/tex/cdi_fman.tex @@ -8,15 +8,15 @@ \gdef\pdfoutput{0} \fi -\newif\ifpdf +\newif\ifpdfx \ifnum\pdfoutput=0 % latex is called for dvi output - \pdffalse + \pdfxfalse \usepackage{graphics} \usepackage{hyperref} \else % pdflatex is called for pdf output - \pdftrue + \pdfxtrue \usepackage[pdftex]{graphicx} \usepackage[pdftex]{hyperref} \fi @@ -233,7 +233,7 @@ CDI library routines: \clearpage -\ifpdf +\ifpdfx \phantomsection \printindex \fi diff --git a/doc/tex/f_ref.tex b/doc/tex/f_ref.tex index 3977e36f0ce90d411aa8491bd94ef7886304d74f..759dea1067b964c9e798ce50ad3c98898966e4a6 100644 --- a/doc/tex/f_ref.tex +++ b/doc/tex/f_ref.tex @@ -1195,7 +1195,7 @@ vlistInqAttFlt } \begin{verbatim} INTEGER FUNCTION vlistInqAttFlt(INTEGER vlistID, INTEGER varID, - CHARACTER*(*) name, INTEGER mlen, INTEGER dp) + CHARACTER*(*) name, INTEGER mlen, REAL*8 dp) \end{verbatim} Get the value(s) of a floating point attribute @@ -1227,7 +1227,8 @@ vlistInqAttTxt } \begin{verbatim} INTEGER FUNCTION vlistInqAttTxt(INTEGER vlistID, INTEGER varID, - CHARACTER*(*) name, INTEGER mlen, INTEGER tp) + CHARACTER*(*) name, INTEGER mlen, + CHARACTER*(*) tp) \end{verbatim} Get the value(s) of a text attribute diff --git a/doc/tex/f_vlist_att.tex b/doc/tex/f_vlist_att.tex index 39a65cd57fbc4c2dac1cf73774b0335cc429eee2..835e1d2065e35b6de5059fc9ecb3baee47c264cc 100644 --- a/doc/tex/f_vlist_att.tex +++ b/doc/tex/f_vlist_att.tex @@ -165,7 +165,7 @@ The function {\tt vlistInqAttFlt} gets the values(s) of a floating point attribu \begin{verbatim} INTEGER FUNCTION vlistInqAttFlt(INTEGER vlistID, INTEGER varID, - CHARACTER*(*) name, INTEGER mlen, INTEGER dp) + CHARACTER*(*) name, INTEGER mlen, REAL*8 dp) \end{verbatim} \hspace*{4mm}\begin{minipage}[]{15cm} @@ -226,7 +226,8 @@ The function {\tt vlistInqAttTxt} gets the values(s) of a text attribute. \begin{verbatim} INTEGER FUNCTION vlistInqAttTxt(INTEGER vlistID, INTEGER varID, - CHARACTER*(*) name, INTEGER mlen, INTEGER tp) + CHARACTER*(*) name, INTEGER mlen, + CHARACTER*(*) tp) \end{verbatim} \hspace*{4mm}\begin{minipage}[]{15cm} diff --git a/doc/tex/f_vlist_var.tex b/doc/tex/f_vlist_var.tex index fcf9ac74e18e2f54702bb649e7ecb6b6f2edf061..81adbfb3d8b91115a2b7e5c64f5640dcc96950c8 100644 --- a/doc/tex/f_vlist_var.tex +++ b/doc/tex/f_vlist_var.tex @@ -386,7 +386,7 @@ Variable list ID, from a previous call to {\htmlref{\tt vlistCreate}{vlistCreate \item[{\tt varID}] Variable identifier. \item[{\tt units}] -Units of the variable. The caller must allocate space for the +Units of the variable. The caller must allocate space for the returned string. The maximum possible length, in characters, of the string is given by the predefined constant {\tt CDI\_MAX\_NAME}. diff --git a/doc/tex/f_zaxis.tex b/doc/tex/f_zaxis.tex index 26dfacac637e156f5bc9340abec240fcfc5d50ba..7a4a4863e2a4b78e6abf2944820a486dad2aa392 100644 --- a/doc/tex/f_zaxis.tex +++ b/doc/tex/f_zaxis.tex @@ -20,7 +20,7 @@ The type of the Z-axis, one of the set of predefined {\CDI} Z-axis types. {\tt ZAXIS\_HYBRID}, {\tt ZAXIS\_SIGMA}, {\tt ZAXIS\_PRESSURE}, {\tt ZAXIS\_HEIGHT}, {\tt ZAXIS\_ISENTROPIC}, {\tt ZAXIS\_ALTITUDE}, {\tt ZAXIS\_MEANSEA}, {\tt ZAXIS\_TOA}, {\tt ZAXIS\_SEA\_BOTTOM}, {\tt ZAXIS\_ATMOSPHERE}, {\tt ZAXIS\_CLOUD\_BASE}, - {\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, + {\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, {\tt ZAXIS\_SNOW}, {\tt ZAXIS\_DEPTH\_BELOW\_SEA} and {\tt ZAXIS\_DEPTH\_BELOW\_LAND}. \item[{\tt size}] Number of levels. @@ -98,7 +98,7 @@ The valid {\CDI} Z-axis types are {\tt ZAXIS\_GENERIC}, {\tt ZAXIS\_SURFACE}, {\tt ZAXIS\_HYBRID}, {\tt ZAXIS\_SIGMA}, {\tt ZAXIS\_PRESSURE}, {\tt ZAXIS\_HEIGHT}, {\tt ZAXIS\_ISENTROPIC}, {\tt ZAXIS\_ALTITUDE}, {\tt ZAXIS\_MEANSEA}, {\tt ZAXIS\_TOA}, {\tt ZAXIS\_SEA\_BOTTOM}, {\tt ZAXIS\_ATMOSPHERE}, {\tt ZAXIS\_CLOUD\_BASE}, -{\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, +{\tt ZAXIS\_CLOUD\_TOP}, {\tt ZAXIS\_ISOTHERM\_ZERO}, {\tt ZAXIS\_SNOW}, {\tt ZAXIS\_DEPTH\_BELOW\_SEA} and {\tt ZAXIS\_DEPTH\_BELOW\_LAND}. diff --git a/doc/tex/formats.tex b/doc/tex/formats.tex index 5c6588b524f9e87de6ae58f4df85f1e529032b70..7371875fdf63ea77c0171335787e74046052fc6e 100644 --- a/doc/tex/formats.tex +++ b/doc/tex/formats.tex @@ -68,6 +68,7 @@ GRIB1 & GRIB2 & & \\ 111 & 106 & depthBelowLand & Depth below land surface \\ 112 & 106 & depthBelowLandLayer & Layer between two depths below land surface \\ 113 & 107 & theta & Isentropic (theta) level \\ + -- & 114 & -- & Snow level \\ 160 & 160 & depthBelowSea & Depth below sea level \\ \hline \end{tabular} diff --git a/doc/tex/zaxis.tex b/doc/tex/zaxis.tex index bbcbcb164e64a5f149d5fa341ef785545ee34520..997aa9345df523174cfbb1932184f3986c51bec3 100644 --- a/doc/tex/zaxis.tex +++ b/doc/tex/zaxis.tex @@ -21,6 +21,7 @@ The following different Z-axis types are available: \item[{\large\tt ZAXIS\_CLOUD\_BASE }] Cloud base level \item[{\large\tt ZAXIS\_CLOUD\_TOP }] Level of cloud tops \item[{\large\tt ZAXIS\_ISOTHERM\_ZERO }] Level of 0$^{\circ}$ C isotherm +\item[{\large\tt ZAXIS\_SNOW }] Snow level \item[{\large\tt ZAXIS\_DEPTH\_BELOW\_SEA }] Depth below sea level in meters \item[{\large\tt ZAXIS\_DEPTH\_BELOW\_LAND}] Depth below land surface in centimeters \end{deflist} diff --git a/src/cdi.h b/src/cdi.h index 3cef2e2aa94fb406ca9c26e2fcab7d6dd624df97..5c6a7fbee046636bb31095a2944263f44aed61b6 100644 --- a/src/cdi.h +++ b/src/cdi.h @@ -158,7 +158,8 @@ extern "C" { #define ZAXIS_CLOUD_BASE 16 /* Cloud base level */ #define ZAXIS_CLOUD_TOP 17 /* Level of cloud tops */ #define ZAXIS_ISOTHERM_ZERO 18 /* Level of 0o C isotherm */ -#define ZAXIS_REFERENCE 19 /* zaxis reference number */ +#define ZAXIS_SNOW 19 /* Snow level */ +#define ZAXIS_REFERENCE 20 /* zaxis reference number */ /* TIME types */ diff --git a/src/gribapi.h b/src/gribapi.h index 080e39d4b96a1084646ad27e9ece5df50fedc8bd..741ebaf85e82404ddb44d76b1a38726c7099dec2 100644 --- a/src/gribapi.h +++ b/src/gribapi.h @@ -19,6 +19,7 @@ #define GRIB2_LTYPE_HYBRID 105 #define GRIB2_LTYPE_LANDDEPTH 106 #define GRIB2_LTYPE_ISENTROPIC 107 +#define GRIB2_LTYPE_SNOW 114 #define GRIB2_LTYPE_REFERENCE 150 #define GRIB2_LTYPE_SEADEPTH 160 diff --git a/src/stream_grb.c b/src/stream_grb.c index acd1a220d402c7915ca7985f1c974a9b4c299cb1..701317e2420330df78b13cbb8b0ed9c2e0995227 100644 --- a/src/stream_grb.c +++ b/src/stream_grb.c @@ -37,14 +37,14 @@ int grib1ltypeToZaxisType(int grib_ltype) case GRIB1_LTYPE_99: case GRIB1_LTYPE_ISOBARIC: { zaxistype = ZAXIS_PRESSURE; break; } case GRIB1_LTYPE_HEIGHT: { zaxistype = ZAXIS_HEIGHT; break; } - case GRIB1_LTYPE_ALTITUDE: { zaxistype = ZAXIS_ALTITUDE; break; } + case GRIB1_LTYPE_ALTITUDE: { zaxistype = ZAXIS_ALTITUDE; break; } case GRIB1_LTYPE_SIGMA: - case GRIB1_LTYPE_SIGMA_LAYER: { zaxistype = ZAXIS_SIGMA; break; } + case GRIB1_LTYPE_SIGMA_LAYER: { zaxistype = ZAXIS_SIGMA; break; } case GRIB1_LTYPE_HYBRID: - case GRIB1_LTYPE_HYBRID_LAYER: { zaxistype = ZAXIS_HYBRID; break; } + case GRIB1_LTYPE_HYBRID_LAYER: { zaxistype = ZAXIS_HYBRID; break; } case GRIB1_LTYPE_LANDDEPTH: case GRIB1_LTYPE_LANDDEPTH_LAYER: { zaxistype = ZAXIS_DEPTH_BELOW_LAND; break; } - case GRIB1_LTYPE_ISENTROPIC: { zaxistype = ZAXIS_ISENTROPIC; break; } + case GRIB1_LTYPE_ISENTROPIC: { zaxistype = ZAXIS_ISENTROPIC; break; } case GRIB1_LTYPE_SEADEPTH: { zaxistype = ZAXIS_DEPTH_BELOW_SEA; break; } } @@ -75,6 +75,7 @@ int grib2ltypeToZaxisType(int grib_ltype) case GRIB2_LTYPE_LANDDEPTH: /* case GRIB2_LTYPE_LANDDEPTH_LAYER: */ { zaxistype = ZAXIS_DEPTH_BELOW_LAND; break; } case GRIB2_LTYPE_ISENTROPIC: { zaxistype = ZAXIS_ISENTROPIC; break; } + case GRIB2_LTYPE_SNOW: { zaxistype = ZAXIS_SNOW; break; } case GRIB2_LTYPE_SEADEPTH: { zaxistype = ZAXIS_DEPTH_BELOW_SEA; break; } } diff --git a/src/stream_gribapi.c b/src/stream_gribapi.c index f39b409d456f38eda4b5104404939942ae3969e7..953a38df7fdd2b4db4d46923844207127e4f9152 100644 --- a/src/stream_gribapi.c +++ b/src/stream_gribapi.c @@ -2592,6 +2592,29 @@ void gribapiDefLevelType(grib_handle *gh, int gcinit, const char *keyname, long if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, keyname, leveltype), 0); } +static +void grib2DefLevel(grib_handle *gh, int gcinit, long leveltype, int lbounds, double level, double dlevel1, double dlevel2) +{ + long scaled_level; + long factor; + + gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", leveltype); + if ( lbounds ) gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", leveltype); + + if ( !lbounds ) dlevel1 = level; + + getLevelFactor(dlevel1, &factor, &scaled_level); + GRIB_CHECK(grib_set_long(gh, "scaleFactorOfFirstFixedSurface", factor), 0); + GRIB_CHECK(grib_set_long(gh, "scaledValueOfFirstFixedSurface", scaled_level), 0); + + if ( lbounds ) + { + getLevelFactor(dlevel2, &factor, &scaled_level); + GRIB_CHECK(grib_set_long(gh, "scaleFactorOfSecondFixedSurface", factor), 0); + GRIB_CHECK(grib_set_long(gh, "scaledValueOfSecondFixedSurface", scaled_level), 0); + } +} + static void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, int levelID, int gcinit) { @@ -2602,10 +2625,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, int reference; char uuid[17]; size_t len; - long scaled_level; - long factor; double scalefactor; - double dlevel1, dlevel2; + double dlevel1 = 0, dlevel2 = 0; zaxistype = zaxisInqType(zaxisID); @@ -2715,8 +2736,6 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, { if ( lbounds ) { - long level1, level2; - if ( editionNumber <= 1 ) gribapiDefLevelType(gh, gcinit, "indicatorOfTypeOfLevel", GRIB1_LTYPE_HYBRID_LAYER); else @@ -2725,11 +2744,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", GRIB2_LTYPE_HYBRID); } - level1 = zaxisInqLbound(zaxisID, levelID); - level2 = zaxisInqUbound(zaxisID, levelID); - - GRIB_CHECK(grib_set_long(gh, "topLevel", level1), 0); - GRIB_CHECK(grib_set_long(gh, "bottomLevel", level2), 0); + GRIB_CHECK(grib_set_long(gh, "topLevel", (long) dlevel1), 0); + GRIB_CHECK(grib_set_long(gh, "bottomLevel", (long) dlevel2), 0); } else { @@ -2738,7 +2754,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, else gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", GRIB2_LTYPE_HYBRID); - GRIB_CHECK(grib_set_long(gh, "level", level), 0); + GRIB_CHECK(grib_set_long(gh, "level", (long) level), 0); } if ( !gcinit ) @@ -2765,7 +2781,12 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, if ( level < 0 ) Warning("Pressure level of %f Pa is below zero!", level); zaxisInqUnits(zaxisID, units); - if ( memcmp(units, "Pa", 2) != 0 ) level *= 100; + if ( memcmp(units, "Pa", 2) != 0 ) + { + level *= 100; + dlevel1 *= 100; + dlevel2 *= 100; + } if ( editionNumber <= 1 ) { @@ -2781,21 +2802,20 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, } else { - gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", GRIB2_LTYPE_ISOBARIC); - if ( lbounds ) gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", GRIB2_LTYPE_ISOBARIC); - - getLevelFactor(dlevel1, &factor, &scaled_level); - GRIB_CHECK(grib_set_long(gh, "scaleFactorOfFirstFixedSurface", factor), 0); - GRIB_CHECK(grib_set_long(gh, "scaledValueOfFirstFixedSurface", scaled_level), 0); - - if ( lbounds ) - { - getLevelFactor(dlevel2, &factor, &scaled_level); - GRIB_CHECK(grib_set_long(gh, "scaleFactorOfSecondFixedSurface", factor), 0); - GRIB_CHECK(grib_set_long(gh, "scaledValueOfSecondFixedSurface", scaled_level), 0); - } + grib2DefLevel(gh, gcinit, GRIB2_LTYPE_ISOBARIC, lbounds, level, dlevel1, dlevel2); } + break; + } + case ZAXIS_SNOW: + { + if ( editionNumber <= 1 ) + ; // not available + else + { + grib2DefLevel(gh, gcinit, GRIB2_LTYPE_SNOW, lbounds, level, dlevel1, dlevel2); + } + break; } case ZAXIS_HEIGHT: @@ -2854,21 +2874,11 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, else if ( memcmp(units, "dm", 2) == 0 ) scalefactor = 0.1; else scalefactor = 1; // meter - gribapiDefLevelType(gh, gcinit, "typeOfFirstFixedSurface", GRIB2_LTYPE_LANDDEPTH); - if ( lbounds ) gribapiDefLevelType(gh, gcinit, "typeOfSecondFixedSurface", GRIB2_LTYPE_LANDDEPTH); - + level *= scalefactor; + dlevel1 *= scalefactor; dlevel1 *= scalefactor; - getLevelFactor(dlevel1, &factor, &scaled_level); - GRIB_CHECK(grib_set_long(gh, "scaleFactorOfFirstFixedSurface", factor), 0); - GRIB_CHECK(grib_set_long(gh, "scaledValueOfFirstFixedSurface", scaled_level), 0); - if ( lbounds ) - { - dlevel2 *= scalefactor; - getLevelFactor(dlevel2, &factor, &scaled_level); - GRIB_CHECK(grib_set_long(gh, "scaleFactorOfSecondFixedSurface", factor), 0); - GRIB_CHECK(grib_set_long(gh, "scaledValueOfSecondFixedSurface", scaled_level), 0); - } + grib2DefLevel(gh, gcinit, GRIB2_LTYPE_LANDDEPTH, lbounds, level, dlevel1, dlevel2); } break; diff --git a/src/zaxis.c b/src/zaxis.c index f07716cd177f4f5d9171fc180e7956f7255e48c8..2d383926794bc8b89c2d13edeff53abbd97a4ca0 100644 --- a/src/zaxis.c +++ b/src/zaxis.c @@ -47,7 +47,8 @@ ZaxistypeEntry[] = { { /* 16 */ 0, "cloudbase", "cloud_base", "", ""}, { /* 17 */ 0, "cloudtop", "cloud_top", "", ""}, { /* 18 */ 0, "isotherm0", "isotherm_zero", "", ""}, - { /* 19 */ 0, "height", "generalized height","height", "m"}, + { /* 19 */ 0, "snow", "snow", "", ""}, + { /* 20 */ 0, "height", "generalized height","height", "m"}, }; static int CDI_MaxZaxistype = sizeof(ZaxistypeEntry) / sizeof(ZaxistypeEntry[0]); @@ -183,7 +184,7 @@ int zaxisSize(void) @func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT}, @func{ZAXIS_ISENTROPIC}, @func{ZAXIS_ALTITUDE}, @func{ZAXIS_MEANSEA}, @func{ZAXIS_TOA}, @func{ZAXIS_SEA_BOTTOM}, @func{ZAXIS_ATMOSPHERE}, @func{ZAXIS_CLOUD_BASE}, - @func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, + @func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, @func{ZAXIS_SNOW}, @func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}. @Item size Number of levels. @@ -995,7 +996,7 @@ The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE}, @func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT}, @func{ZAXIS_ISENTROPIC}, @func{ZAXIS_ALTITUDE}, @func{ZAXIS_MEANSEA}, @func{ZAXIS_TOA}, @func{ZAXIS_SEA_BOTTOM}, @func{ZAXIS_ATMOSPHERE}, @func{ZAXIS_CLOUD_BASE}, -@func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, +@func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, @func{ZAXIS_SNOW}, @func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}. @EndFunction