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

Added function isec1DefLevel().

parent bcba91e4
...@@ -1861,6 +1861,14 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI ...@@ -1861,6 +1861,14 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
} }
} }
static
void isec1DefLevel(int *isec1, int leveltype, int level1, int level2)
{
ISEC1_LevelType = leveltype;
ISEC1_Level1 = level1;
ISEC1_Level2 = level2;
}
static static
void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int levelID) void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int levelID)
{ {
...@@ -1892,9 +1900,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev ...@@ -1892,9 +1900,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
case ZAXIS_DEPTH_BELOW_SEA: case ZAXIS_DEPTH_BELOW_SEA:
case ZAXIS_ISENTROPIC: case ZAXIS_ISENTROPIC:
{ {
ISEC1_LevelType = grib_ltype; isec1DefLevel(grib_ltype, (int) zaxisInqLevel(zaxisID, levelID), 0);
ISEC1_Level1 = (int) (zaxisInqLevel(zaxisID, levelID));
ISEC1_Level2 = 0;
break; break;
} }
case ZAXIS_CLOUD_BASE: case ZAXIS_CLOUD_BASE:
...@@ -1904,26 +1910,17 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev ...@@ -1904,26 +1910,17 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
case ZAXIS_SEA_BOTTOM: case ZAXIS_SEA_BOTTOM:
case ZAXIS_ATMOSPHERE: case ZAXIS_ATMOSPHERE:
{ {
ISEC1_LevelType = grib_ltype; isec1DefLevel(grib_ltype, 0, 0);
ISEC1_Level1 = 0;
ISEC1_Level2 = 0;
break; break;
} }
case ZAXIS_HYBRID: case ZAXIS_HYBRID:
case ZAXIS_HYBRID_HALF: case ZAXIS_HYBRID_HALF:
{ {
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) ) if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
{ isec1DefLevel(GRIB1_LTYPE_HYBRID_LAYER, (int)zaxisInqLbound(zaxisID, levelID),
ISEC1_LevelType = GRIB1_LTYPE_HYBRID_LAYER; (int)zaxisInqUbound(zaxisID, levelID));
ISEC1_Level1 = (int) (zaxisInqLbound(zaxisID, levelID));
ISEC1_Level2 = (int) (zaxisInqUbound(zaxisID, levelID));
}
else else
{ isec1DefLevel(GRIB1_LTYPE_HYBRID, (int) zaxisInqLevel(zaxisID, levelID), 0);
ISEC1_LevelType = GRIB1_LTYPE_HYBRID;
ISEC1_Level1 = (int) (zaxisInqLevel(zaxisID, levelID));
ISEC1_Level2 = 0;
}
int vctsize = zaxisInqVctSize(zaxisID); int vctsize = zaxisInqVctSize(zaxisID);
if ( vctsize > 255 ) if ( vctsize > 255 )
...@@ -1945,8 +1942,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev ...@@ -1945,8 +1942,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
case ZAXIS_PRESSURE: case ZAXIS_PRESSURE:
{ {
level = zaxisInqLevel(zaxisID, levelID); level = zaxisInqLevel(zaxisID, levelID);
if ( level < 0 ) if ( level < 0 ) Warning("Pressure level of %f Pa is below zero!", level);
Warning("Pressure level of %f Pa is below zero!", level);
char units[128]; char units[128];
zaxisInqUnits(zaxisID, units); zaxisInqUnits(zaxisID, units);
...@@ -1954,16 +1950,11 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev ...@@ -1954,16 +1950,11 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
double dum; double dum;
if ( level < 32768 && (level < 100 || modf(level/100, &dum) > 0) ) if ( level < 32768 && (level < 100 || modf(level/100, &dum) > 0) )
{ grib_ltype = GRIB1_LTYPE_99;
grib_ltype = GRIB1_LTYPE_99;
}
else else
{ level = level/100;
level = level/100;
} isec1DefLevel(grib_ltype, (int) level, 0);
ISEC1_LevelType = grib_ltype;
ISEC1_Level1 = (int) level;
ISEC1_Level2 = 0;
break; break;
} }
case ZAXIS_HEIGHT: case ZAXIS_HEIGHT:
...@@ -1979,26 +1970,17 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev ...@@ -1979,26 +1970,17 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
else if ( units[0] == 'k' ) level *= 1000; else if ( units[0] == 'k' ) level *= 1000;
} }
ISEC1_LevelType = grib_ltype; isec1DefLevel(grib_ltype, (int) level, 0);
ISEC1_Level1 = (int) level;
ISEC1_Level2 = 0;
break; break;
} }
case ZAXIS_SIGMA: case ZAXIS_SIGMA:
{ {
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) ) if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
{ isec1DefLevel(GRIB1_LTYPE_SIGMA_LAYER, (int) zaxisInqLbound(zaxisID, levelID),
ISEC1_LevelType = GRIB1_LTYPE_SIGMA_LAYER; (int) zaxisInqUbound(zaxisID, levelID));
ISEC1_Level1 = (int) zaxisInqLbound(zaxisID, levelID);
ISEC1_Level2 = (int) zaxisInqUbound(zaxisID, levelID);
}
else else
{ isec1DefLevel(GRIB1_LTYPE_SIGMA, (int) zaxisInqLevel(zaxisID, levelID), 0);
ISEC1_LevelType = GRIB1_LTYPE_SIGMA;
ISEC1_Level1 = (int) zaxisInqLevel(zaxisID, levelID);
ISEC1_Level2 = 0;
}
break; break;
} }
...@@ -2014,26 +1996,16 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev ...@@ -2014,26 +1996,16 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
else factor = 100; // meter else factor = 100; // meter
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) ) if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
{ isec1DefLevel(GRIB1_LTYPE_LANDDEPTH_LAYER, (int) (factor*zaxisInqLbound(zaxisID, levelID)),
ISEC1_LevelType = GRIB1_LTYPE_LANDDEPTH_LAYER; (int) (factor*zaxisInqUbound(zaxisID, levelID)));
ISEC1_Level1 = (int) (factor*zaxisInqLbound(zaxisID, levelID));
ISEC1_Level2 = (int) (factor*zaxisInqUbound(zaxisID, levelID));
}
else else
{ isec1DefLevel(GRIB1_LTYPE_LANDDEPTH, (int) (factor*zaxisInqLevel(zaxisID, levelID)), 0);
ISEC1_LevelType = GRIB1_LTYPE_LANDDEPTH;
ISEC1_Level1 = (int) (factor*zaxisInqLevel(zaxisID, levelID));
ISEC1_Level2 = 0;
}
break; break;
} }
case ZAXIS_GENERIC: case ZAXIS_GENERIC:
{ {
ISEC1_LevelType = ltype; isec1DefLevel(ltype, (int) zaxisInqLevel(zaxisID, levelID), 0);
ISEC1_Level1 = (int) zaxisInqLevel(zaxisID, levelID);
ISEC1_Level2 = 0;
break; break;
} }
default: default:
......
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