void gb2_vcrd ( char *wmolvltbl, char *lcllvltbl, Gribmsg *cmsg, int *levels, int *vcord, char *unit, int *iret ) /************************************************************************ * gb2_vcrd * * * * This routine computes the vertical coordinate level/layer values * * from the GRIB2 PDS. Also, the GEMPAK vertical coordinate type is * * obtained from the appropriate GRIB2 vertical coordinate table. * * * * If either wmolvltbl or lcllvltbl are NULL, the default tables are * * read. * * * * gb2_vcrd ( wmolvltbl, lcllvltbl, cmsg, levels, vcord, iret ) * * * * Input parameters: * * *wmolvltbl char WMO vertical coordinate table * * *lcllvltbl char Local vertical coordinate table * * *cmsg struct Gribmsg GRIB2 message structure * * * * Output parameters: * * levels[2] int lower/upper level/layer values * * *vcord int GEMPAK vertical goordinate type * * *iret int return code * * -27 = Unrecognized PDT number * ** * * Log: * * S. Gilbert/NCEP 11/04 * * S. Gilbert/NCEP 10/05 Use new routines to read tables * ***********************************************************************/ { int ret, ier, lvl1, lvl2, iver, lclver, ilen; G2level g2lev; G2lvls *g2lvltbl; char vparm[12], ctemp[20]; float rlevel[2]; double sfact; /*---------------------------------------------------------------------*/ *iret = 0; /* * Get Level into from vertical coordinate table(s). */ iver=cmsg->gfld->idsect[2]; lclver=cmsg->gfld->idsect[3]; lvl1=cmsg->gfld->ipdtmpl[9]; lvl2=cmsg->gfld->ipdtmpl[12]; if ( ( lvl1 < 192 || lvl1 == 255 ) && ( lvl2 < 192 || lvl2 == 255 ) ) { /* * Get WMO vertical coordinate table. */ gb2_gtwmolvltbl( wmolvltbl, iver, &g2lvltbl, &ier); if ( ier == 0 ) { /* * Get Level into from WMO vertical coordinate table. */ gb2_sklvl( lvl1, lvl2, g2lvltbl, &g2lev, &ier); } } else { /* * Get Local vertical coordinate table. */ gb2_gtlcllvltbl( lcllvltbl, cmsg->origcntr, lclver, &g2lvltbl, &ier); if ( ier == 0 ) { /* * Get Level into from Local vertical coordinate table. */ gb2_sklvl( lvl1, lvl2, g2lvltbl, &g2lev, &ier); } } if ( ier != 0 ) { *iret=ier; if ( ier == -30 ) { sprintf(ctemp,"%d|%d", lvl1, lvl2); er_wmsg("GB",&ier,ctemp,&ret,2,strlen(ctemp)); } return; } /* * Calculate GEMPAK vertical coordinate type */ lv_cord ( g2lev.abbrev, vparm, vcord, &ier, 4, 12); if ( ier != 0 ) { *iret=-7; return; } /*cst_lstr ( g2lev.unit, &ilen, &ier );*/ cst_rmbl ( g2lev.unit, unit, &ilen, &ier ); if ( ( strcmp(unit,"Pa") == 0 ) && ( g2lev.scale == -2 ) ) sprintf ( unit, "hPa\0" ); /*else strncat( unit, g2lev.unit, ilen);*/ /* * Extract vertical coordinate levels from GRIB2 PDS */ gb2_vlev ( cmsg->gfld, rlevel, &ier ); if ( ier != 0 ) { *iret=ier; return; } /* * Scale level values by scale factor found in vertical * coordinate table. */ sfact=pow((double)10.0,g2lev.scale); levels[0] = (int)rint( rlevel[0] * sfact ); if ( rlevel[1] == -1.0 ) { levels[1] = -1; } else { levels[1] = (int)rint( rlevel[1] * sfact ); } if ( lvl1 == 1 ) { /* Surface */ levels[0] = 0; levels[1] = -1; } }
void gb2_level2g2( int vcord, char *wmolvltbl, char *lcllvltbl, int wmover, int lclver, char *wmocntr, G2level *tblentry, int *iret ) /************************************************************************ * gb2_level2g2 * * * * This routine returns the Grib2 vertical coordinate table entry that * * matches the given vertical coordinate. * * * * If either wmolvltbl or lcllvltbl are NULL, the default tables are * * read. * * * * gb2_level2g2 ( vcord, wmolvltbl, lcllvltbl, wmover, lclver, wmocntr, * * tblentry, iret ) * * * * Input parameters: * * vcord int 4 byte vert. coord. abbrev. * * *wmolvltbl char WMO vert. coord. table * * *lcllvltbl char Local vert. coord. table * * wmover int WMO table version number * * lclver int Local table version number * * *wmocntr char Originating center abbreviation * * * * Output parameters: * * *tblentry G2level GRIB2 vert. coord. table entry * * *iret int return code * * 1 = No gempak vert. coord. * * defined for this grid * ** * * Log: * * S. Gilbert/NCEP 08/05 * ***********************************************************************/ { int ret, ier; char vcabbrev[5]; G2lvls *g2lvltbl; /*---------------------------------------------------------------------*/ *iret = 0; ier = -1; /* * Get Level info from Vertical Coordinate table(s). */ if ( wmover != 255 ) { /* try WMO vert. coord. table */ /* * get WMO vert. coord. Table */ gb2_gtwmolvltbl ( wmolvltbl, wmover, &g2lvltbl, &ier); if ( ier == 0 ) { /* * Check for desired Level in table */ gb2_skvcord( vcord, g2lvltbl, tblentry, &ier); } } /* * Try local vertical coordinate table next... */ if ( ier != 0 ) { /* * get Local vert. coord. Table */ gb2_gtlcllvltbl ( lcllvltbl, wmocntr, lclver, &g2lvltbl, &ier); if ( ier == 0 ) { /* * Check for desired level in table */ gb2_skvcord( vcord, g2lvltbl, tblentry, &ier); } } if ( ier != 0 ) { if ( ier == -30 ) { vcabbrev[4]='\0'; lv_ccrd( &vcord, vcabbrev, &ret, 4 ); ER_WMSG("GB",&ier,vcabbrev,&ret,2,4); } *iret=1; return; } }