示例#1
0
void	decode_nldn (char *curtim, char *gemfil, char *prmfil, char *filetyp, 
		int maxtim, int nhours, int *iret)
{
int maxfil=1, iflsrc=2;
int ier,ichk,nexp,nret,loglev;
nldn_file ltgf;
char errmsg[80];
static char errgrp[] = {"decode_nldn"};

nldninit();

*iret = 0;

ltgf.gemfil = (char *)malloc(strlen(gemfil) + 1);
strcpy(ltgf.gemfil,gemfil);

ltgf.curtim = (char *)malloc(strlen(curtim) + 1);
cst_uclc(curtim, ltgf.curtim, &ier);

ltgf.ifltyp = (char *)malloc(strlen(filetyp) + 1);
cst_uclc(filetyp, ltgf.ifltyp, &ier);

ltgf.maxtim = maxtim;
ltgf.iflsrc = iflsrc;

/*
 * File types can be hour, day, or month, for hourly, daily, or monthly files
 *      OR can be minute stored in xx minute bins.
 */
ltgf.itype = 0; ltgf.ifactor = 0;
if (strncmp(filetyp,"hour",4) == 0) 
   ltgf.itype = 1;
else if (strncmp(filetyp,"day",3) == 0) 
   ltgf.itype = 2;
else if (strncmp(filetyp,"month",5) == 0) 
   ltgf.itype = 3;
else if (strncmp(filetyp,"minute",6) == 0) 
   {
   ltgf.itype = 4; nexp = 1;
   st_c2i ( filetyp+6, &nexp, &ltgf.ifactor, &nret, &ier, 2);
   if ( ier != 0 ) 
      {
      sprintf(errmsg,"Can't decode bin size, use 10 min as default\0");
      loglev = 0;
      dc_wclg ( loglev, errgrp, ier, errmsg, &ichk);
      ltgf.ifactor = 10;
      }
   }
/* use the -b nhours to specify the output file frequency (60 min default)*/
ltgf.ibin = nhours;


dc_fint(&maxfil, &iflsrc, prmfil, &ier, strlen(prmfil) );

while(*iret == 0)
   dcnldn_input(ltgf,iret);

dc_fcls(&ier);
}
示例#2
0
void cfl_inqr ( const char *filnam, const char *defdir, long *flen,
						char *newfil, int *iret )
/************************************************************************
 * cfl_inqr								*
 *									*
 * This function determines whether a file exists and the file size.	*
 * If there is a leading ^, the file name is case sensitive. Otherwise	*
 * if the file is not found, the file name is changed to all lower case *
 * and test again.							*
 *									*
 * The file is located by searching in the following order (environment	*
 * variables may be used as part of the paths):				*
 *									*
 *	1. filnam (as given)						*
 *	2. defdir/filnam						*
 *	3. filenam (lower case)						*
 *	4. defdir/filnam (lower case)					*
 *									*
 * cfl_inqr ( filnam, defdir, flen, newfil, iret )			*
 *									*
 * Input parameters:							*
 *	*filnam		char		File name			*
 *	*defdir		char		Default directory		*
 *									*
 * Output parameters:							*
 *	*flen		long		File size			*
 *	*newfil		char		Expanded file name		*
 *	*iret		int		Return code			*
 *					  0 = Normal, file exists	*
 *					 -1 = File does not exist	*
 **									*
 * G. Krueger/EAI	 3/96						*
 * G. Krueger/EAI        8/96	Match with FL library			*
 * T. Lee/SAIC		12/02	Initialize flen				*
 * B. Yin/SAIC		 4/07	Check ^ and try the lower case		*
 ***********************************************************************/
{
	int		ier, ier1;
	char		t_defdir[LLPATH], t_filnam[FILE_FULLSZ];
	struct stat	stbuf;
	Boolean		caseFlag;
/*---------------------------------------------------------------------*/
/*
 *  Set the case flag.
 */
    if ( filnam[0] == '^' ) {
	caseFlag = False;
	css_envr ( &filnam[1], t_filnam, &ier );
    }
    else {
	caseFlag = True;	
	css_envr ( filnam, t_filnam, &ier );
    }
    strcpy(newfil, t_filnam);
/*
 *  Check the file status.
 */
    if ( (ier1 = stat( newfil, &stbuf) ) != 0 ) {
	if ( defdir != NULL ) {
/*
 *  Try the DEFDIR directory.
 */
	    css_envr ( defdir, t_defdir, &ier );
	    sprintf(newfil, "%s/%s", t_defdir, t_filnam);
	    ier1 = stat ( newfil, &stbuf );
	}
    }

/*
 * If the file is not found and the case flag is true,
 * change the file name to lower case and try.
 */
    if ( ier1 != 0 && caseFlag ) {
	cst_uclc( t_filnam, newfil, &ier );
/*
 *  Check the file status as all lower case characters.
 */
	if ( (ier1 = stat ( newfil, &stbuf )) != 0 ) {
	    if ( defdir != NULL ) {
/*
 *  Try the DEFDIR directory with all lower case characters.
 */
		css_envr ( defdir, t_defdir, &ier );
		sprintf(newfil, "%s/%s", t_defdir, t_filnam);
		ier1 = stat ( newfil, &stbuf );
	    }
	}
    }

/*
 *  Return outputs based upon status.
 */
    if ( ier1 == 0 ) {
	*flen = (long)stbuf.st_size;
	*iret = G_NORMAL;
    } 
    else {
	*flen = 0;
	if ( defdir == NULL ) 
	    strcpy(newfil, t_filnam);
	else
	    sprintf(newfil, "%s/%s", t_defdir, t_filnam);
	cfl_iret ( errno, iret, &ier );
    }
}
示例#3
0
void dc_init ( char *prgnam, int argc, char **argv, int numexp, 
				char parms[][DCMXLN], int *num, int *iret )
/************************************************************************
 * dc_init								*
 *                                                                      *
 * This routine initializes the bridge and decoder parameters and	*
 * processes the command line options.					*
 *                                                                      *
 * dc_init ( prgnam, argc, argv, numexp, parms, num, iret )		*
 *                                                                      *
 * Input parameters:							*
 *	*prgnam		char		Program name			*
 *	argc		int		Number of command line args	*
 *	**argv		char		Command line arguments		*
 *	numexp		int		Number of expected parameters	*
 *                                                                      *
 * Output parameters:							*
 *	parms[][DCMXLN]	char		Parameters found on command line*
 *	*num		int		Number of parameters found	*
 *	*iret		int		Return code			*
 *					   0 = normal return		*
 *					 -11 = no command line args	*
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * A. Chang/EAi		 5/95						*
 * S. Jacobs/NMC	 7/95	Update and clean up			*
 * S. Jacobs/NCEP	 6/96	Updated documentation; Changed atoi to	*
 *				cst_numb; Removed the +3 return	code;	*
 *				Changed ldfd to a FILE stream - fplog	*
 * S. Jacobs/NCEP	 7/96	Reorganized the source code		*
 * K. Tyle/GSC		 7/96	NT_HELP --> IP_HELP			*
 * S. Jacobs/NCEP	 7/96	Removed log file open			*
 * K. Tyle/GSC		 1/97	Added calls to IN_BDTA and ER_STAT;	*
 *				changed numerr in startup dc_wclg call	*
 * K. Tyle/GSC		 1/97	Use iflg in call to ER_STAT		*
 * D. Kidwell/NCEP	 9/97	Added version number to help option     *
 * I. Durham/GSC	 5/98	Changed underscore decl. to an include	*
 * S. Jacobs/NCEP	 1/00	Added command line input of env vars	*
 * S. Jacobs/NCEP	 2/01	Removed all references to ulog		*
 * R. Tian/SAIC		 8/02	Added version to log file		*
 * m.gamazaychikov/SAIC	07/05	Added -w input parameter		*
 * H. Zeng/SAIC		08/05	Added second station table		*
 * L. Hinson/AWC        06/08   Add -r circular flag switch             *
 * S. Jacobs/NCEP	 3/12	Add $HOME to the logs directory		*
 * S. Jacobs/NCEP	12/13	Added more options for log location	*
 ***********************************************************************/
{
	int	ch, i, errflg, ier;
	int	pagflg = G_FALSE;
	int	iflg   = G_TRUE;

/*
**	These variables are used for logging errors and notices.
*/
	char	tdclog[DCMXLN];
	int	logflg, ibuf;
	char	errstr[DCMXLN];
	char	version[128];

/*
**	These variables are used by getopt. Unset the error reporting.
*/
	char		optver[20];

/*---------------------------------------------------------------------*/
	*iret = 0;

/*
**	Set the process ID for log messages.
*/
	ipid = (int) getpid ();

/*
**	Initialize the bulletin counter.
*/
	nbull = 0;

/*
**	Save the program name as a global variable.
*/
	strcpy ( cprgnm, prgnam );

/*
**	Set up the signal handlers.
*/
	dc_sgnl ( );
    
/*
**	Get and process the command line options.
**
**	Set the default values for parsing the command line.
*/
	strcpy ( curtim, "SYSTEM" );
	cst_uclc ( cprgnm, tdclog, &ier );
	strcat ( tdclog, ".log" );
	logflg    = G_FALSE;
	itmout    = DCDFTM;
	irltim    = G_TRUE;
	txtflg    = G_TRUE;
        circflg   = G_FALSE;
	ivrblv    = 0;
	prmfil[0] = CHNULL;
	stntbl[0] = CHNULL;
	iadstn    = IMISSD;
	maxtim    = IMISSD;
	nhours    = IMISSD;
	iwndht    = IMISSD;

/*
**	Get the valid options from the command line.
**	The valid options are:
**		-v	Set the level of verbosity for the logs
**		-c	Set the "current" time
**		-b	Number of hours to decode prior to "current" time
**		-d	Set the decoder log file name
**		-t	Set the interval for the time out
**		-p	Set the parameter packing table
**		-s	Set the station table
**		-S	Set the second station table
**		-a	Set the number of additional stations
**		-m	Set the max number of times
**		-e	Set an environment variable=value
**		-n	Set a flag to NOT save the text data
**              -r      Set a flag to force circular files
**		-w	Set the cutoff "close-to-the-surface" height
**		-h	Print the help file, then exit the program
*/
	opterr = 1;
	errflg = 0;
	while ( ( ch = getopt ( argc, argv,
				"v:c:b:d:t:p:s:S:a:m:e:w:nhr" ) ) != EOF ) {
	    switch ( ch ) {
		case 'v':
			cst_numb ( optarg, &ivrblv, &ier );
			if  ( ivrblv < 0 )  ivrblv = 0;
			break;
		case 'c':
			strcpy ( curtim, optarg );
			irltim = G_FALSE;
			break;
		case 'b':
			cst_numb ( optarg, &nhours, &ier );
			break;
		case 'd':
			strcpy ( tdclog, optarg );
			logflg = G_TRUE;
			break;
		case 't':
			cst_numb ( optarg, &itmout, &ier );
			if  ( itmout < 1 )  itmout = DCDFTM;
			break;
		case 'p':
			strcpy ( prmfil, optarg );
			break;
		case 's':
			strcpy ( stntbl, optarg );
			break;
		case 'S':
			strcpy ( stntb2, optarg );
			break;
		case 'a':
			cst_numb ( optarg, &iadstn, &ier );
			break;
		case 'm':
			cst_numb ( optarg, &maxtim, &ier );
			break;
		case 'e':
			envobj = (envlist *) malloc ( sizeof(envlist) );
			envobj->env = malloc ( strlen(optarg)+1 );
			strcpy ( envobj->env, optarg );
			envobj->env[strlen(optarg)] = '\0';
			envobj->next = envhead;
			envhead = envobj;
			break;
		case 'n':
			txtflg = G_FALSE;
			break;
		case 'w':
			cst_numb ( optarg, &iwndht, &ier );
			break;
                case 'r':
                        circflg = G_TRUE;
                        break;
		case 'h':
			ip_help ( cprgnm, &pagflg, &ier,
				  strlen(cprgnm) );
			strcpy ( cprgnm, "DECODE" );
			ip_help ( cprgnm, &pagflg, &ier,
				  strlen(cprgnm) );
			ss_vers ( optver, &ier,
				  sizeof (optver) );
			printf ( ">%s<\n", optver );
			exit ( 0 );
			break;
		case '?':
			errflg++;
			break;
	    }
	}

/*
**	Initialize GEMPAK and set error reporting parameters.
*/
	in_bdta ( &ier );
	ibuf = 1;
	er_stat ( &ivrblv, &ibuf, &iflg, &ier );

/*
**	Open the decoder log.
**
**	If the processing is in real-time add the directory to the 
**	file name.
*/
	if  ( !logflg && irltim )
	{
	    if ( tdclog[0] == '/' ) {
		strcpy ( dcdlog, tdclog );
	    }
	    else if ( getenv("GEMPAK_DECODER_LOGS") ) {
		strcpy ( dcdlog, "$GEMPAK_DECODER_LOGS/" );
		strcat ( dcdlog, tdclog );
	    }
	    else {
		strcpy ( dcdlog, "$HOME/" );
		strcat ( dcdlog, tdclog );
	    }
	}
	else
	{
	    strcpy ( dcdlog, tdclog );
	}

/*
**	Send a start up message to the decoder log.
*/
	ss_vers ( version, &ier, sizeof(version) );
	dc_wclg ( 0, "DCINIT", 3, version, &ier );

/*
**	Set all of the environment variables.
*/
	envobj = envhead;
	while ( envobj != NULL ) {
	    if  ( putenv ( envobj->env ) != 0 )  {
		strcpy ( errstr, envobj->env );
		dc_wclg ( 0, "DCINIT", -17, errstr, &ier );
	    }
	    envobj = envobj->next;
	}

/*
**	Adjust argc and argv by the option index.
*/
	argc -= optind;
	argv += optind;

/*
**	Initialize the output string array.
*/
	for ( i = 0; i < numexp; i++ )
	    strcpy ( parms[i], " " );

/*
**	Get the decoder specific parameters.
*/
	*num = argc;

	if  ( *num == 0 )
	{
/*
**	    If there are no parameters write a message and return
**	    with an error.
*/
	    *iret = -11;
	    dc_wclg ( 0, "DCINIT", *iret, " ", &ier );
	}
	else
	{
/*
**	    Otherwise, set the parameters to be returned.
*/
	    for ( i = 0; i < *num; i++ )
		if  ( i < numexp )  strcpy ( parms[i], argv[i] );
	}
}
示例#4
0
void db_getQueryText ( char *queryType, char *queryText, int *iret ) 
/************************************************************************
 *									*
 * db_getQueryText            						*
 *									*
 * This function generates a string containing microEngine user script  * 
 * based on the query type and strings defined in the dncmn.h header.	*
 *									*
 * Currently supported query types:					*
 *									*
 *	flName								* 
 *									*
 * void db_getQueryText ( char *queryType, char *queryText, int *iret )	*
 *                                                                      *
 * Input parameters:                                                    *
 *      *queryType	char		type of the query		*
 *                                                                      *
 * Output parameters:                                                   *
 *      *queryText	char		text of the query		*
 *	*iret		int		return code:			*
 *                                      -1: query type is incorrect     *
 *					 0: normal                      *
 **                                                                     *
 * Log:                                                                 *
 *									*
 * m.gamazaychikov/CWS	01/10	Created                                 *
 * m.gamazaychikov/CWS  11/10   Removed code intented for NMAP bridge   *
 ************************************************************************/
{
    char columnName[25];
    int  ier;
/*---------------------------------------------------------------------*/

    *iret = 0;
 
   /* 
    * Construct the import statement
    */
    
    //sprintf (queryText, "%s", "import ");
    sprintf (queryText, "%s", "import time; t1 = time.time();");
    strcat  (queryText, "import ");
    strcat  (queryText,  eLibClass);
    strcat  (queryText, ";");
    strcat  (queryText, "query =");
    strcat  (queryText,  eLibClass);
    strcat  (queryText, ".");
    strcat  (queryText,  eLibClass);
    strcat  (queryText, "(");
    strcat  (queryText, "\"");
    strcat  (queryText,  ePlugIn);
    strcat  (queryText, "\"");
    strcat  (queryText, ");");

   /* 
    * Construct the body of the query based on the query type
    *
    * 1. file name query (flName):
    * eLibClass = GempakGridCycleQuery
    */
    if ( strcmp ( queryType, "flName" ) == 0 ) {
       strcat  (queryText, "query.setParameters(\"");
       strcat  (queryText, eParameters);
       strcat  (queryText, "\");");
    }
   /* 
    * 2. grid navigation query (gridNav):
    * eLibClass = GempakGridNavigationRequest
    */
    else if ( ( strcmp ( queryType, "gridNav" ) == 0 ) && 
         ( strcmp ( eSrc, "GRID" ) == 0 ) ) {
       strcat  (queryText, "query.setGridIdParms(\"");
       strcat  (queryText, eGrid);
       if ( gNavDattim[0] != '\0' ) {
           strcat  (queryText, "\",");
           strcat (queryText,"\"");
           strcat (queryText, gNavDattim);
       }
       if ( gEventName[0] != '\0' ) {
           strcat  (queryText, "\",");
           strcat (queryText,"\"");
           strcat (queryText, gEventName);
       }
       strcat  (queryText, "\");");
    }
   /* 
    * 3. db time query (dbTime):
    * eLibClass = GempakCatalogTimeQuery
    */
    else if ( ( strcmp ( queryType, "dbTime" ) == 0 ) && 
         ( strcmp ( eSrc, "GRID" ) == 0 ) ) {
       strcat  (queryText, "query.setParameters(\"");
       strcat  (queryText, eGrid);
       if ( gEventName[0] != '\0' ) {
           strcat (queryText,"|");
           strcat (queryText, gEventName);
       }
       strcat  (queryText, "\");");
    }
   /* 
    * 4. data URI query (dataURI):
    * eLibClass = GempakDataURIRequest
    */
    else if ( ( strcmp ( queryType, "dataURI" ) == 0 ) &&
         ( strcmp ( eSrc, "GRID" ) == 0 ) ) {
       strcat  (queryText, "query.setDataParms(\"");
       cst_uclc (queryType, columnName, &ier);
       strcat  (queryText, columnName);
       strcat  (queryText, ":");
       strcat  (queryText, eMdl);
       strcat  (queryText, "|");
       strcat  (queryText, gDattim);
       strcat  (queryText, "|");
       strcat  (queryText, gCord);
       strcat  (queryText, "|");
       strcat  (queryText, gLevel);
       strcat  (queryText, "|");
       strcat  (queryText, gParm);
       if ( gEventName[0] != '\0' ) {
           strcat  (queryText, "|");
           strcat (queryText, gEventName);
       }
       strcat  (queryText, "\");");
    }
   /* 
    * 5. grid data query (gridDat):
    * eLibClass = GempakGridLinkRequest
    */
    else if ( ( strcmp ( queryType, "gridDat" ) == 0 ) && 
         ( strcmp ( eSrc, "GRID" ) == 0 ) ) {
       strcat  (queryText, "query.setDataUri(\"");
       strcat  (queryText, eDistnctField);
       strcat  (queryText, "\");");
    }
   /* 
    * 6. (ensMember):
    * eLibClass = GempakEnsMemberRequest
    */
    else if ( ( strcmp ( queryType, "ensMember" ) == 0 ) &&
         ( strcmp ( eSrc, "GRID" ) == 0 ) ) {
       strcat  (queryText, "query.setDataParms(\"");
       strcat  (queryText, eMdl);
       strcat  (queryText, "|");
       strcat (queryText, gEventName);
       strcat  (queryText, "|");
       strcat  (queryText, gDattim);
       strcat  (queryText, "\");");
    }
    else if ( ( strcmp ( queryType, "scanDb" ) == 0 ) &&
         ( strcmp ( eSrc, "GRID" ) == 0 ) ) {
       strcat  (queryText, "query.setParameters(\"");
       strcat  (queryText, eParameters);
       strcat  (queryText, "\");");
    }
   /*
    *  TODO: add queries for the following query types
    *        in 'old notation' and change to 'new noation'
    *
    *  	old notation	new notation
    *
    *  	timeqry         dbTime
    *   stidqry
    *   stnmqry
    *   obrvqry
    *
    else if ( ( strcmp ( queryType, "timeqry" ) == 0 ) && 
         ( strcmp ( eSrc, "METAR" ) == 0 ) ) {
       strcat  (queryText, "query.setSource(\"");
       strcat  (queryText, eSrc);
       strcat  (queryText, "\");");
    }
    else if ( ( strcmp ( queryType, "timeqry" ) == 0 ) &&
         ( strcmp ( eSrc, "BUFRUA" ) == 0 ) ) {
    }
    else if ( ( strcmp ( queryType, "timeqry" ) == 0 ) &&
         ( strcmp ( eSrc, "SYNOP" ) == 0 ) ) {
    }
    else if ( ( strcmp ( queryType, "stidqry" ) == 0 ) ) {
       strcat  (queryText, "query.setGempakArea(\"");
       strcat  (queryText, gArea);
       strcat  (queryText, "\");");
    }
    else if ( ( strcmp ( queryType, "stnmqry" ) == 0 ) ) {
       strcat  (queryText, "query.setGempakArea(\"");
       strcat  (queryText, gArea);
       strcat  (queryText, "\");");
       strcat  (queryText, "query.returnStationNumber();");
    }
    else if (  ( strcmp ( queryType, "obrvqry" ) == 0 ) ) {
       if ( strcmp ( eSrc, "METAR" ) == 0 )  {
          strcat  (queryText, "query.setCount(");
          sprintf (dum, "%d", eCount);
          strcat  (queryText, dum);
          strcat  (queryText, ");");
          strcat  (queryText, "query.setType(\"");
          strcat  (queryText, eSrc);
          strcat  (queryText, "\");");
          strcat  (queryText, "query.setArea(\"");
          strcat  (queryText, gArea);
          strcat  (queryText, "\");");
          strcat  (queryText, "query.setTime(\"");
          strcat  (queryText, gDattim);
          strcat  (queryText, "\");");
       }
       else if ( strcmp ( eSrc, "BUFRUA" ) == 0 )  {
          strcat  (queryText, "query.setArea(\"");
          strcat  (queryText, gArea);
          strcat  (queryText, "\");");
          strcat  (queryText, "query.setTime(\"");
          strcat  (queryText, gDattim);
          strcat  (queryText, "\");");
          strcat  (queryText, "query.setPart(\"");
          strcat  (queryText, ePrt);
          strcat  (queryText, "\");");
        }
        else if ( strcmp ( eSrc, "SYNOP" ) == 0 )  {
          strcat  (queryText, "query.setArea(\"");
          strcat  (queryText, gArea);
          strcat  (queryText, "\");");
          strcat  (queryText, "query.setTime(\"");
          strcat  (queryText, gDattim);
          strcat  (queryText, "\");");
          strcat  (queryText, "query.setRepType(\"");
          strcat  (queryText, ePrt);
          strcat  (queryText, "\");");
        }
    }
    *
    */
    else {
       *iret = -1;
       return;
    }
    //strcat  (queryText, "return query.execute();");
    strcat  (queryText, "qResults = query.execute(); print \"");
    strcat  (queryText, eLibClass);
    strcat  (queryText, " took %0.3f ms\" % ((time.time()-t1)*1000.0); return qResults;");
    return;
}
示例#5
0
文件: gb22gem.c 项目: Unidata/LDM
void gb2_2gem( Gribmsg *cmsg, Geminfo *gem , char **tbls, int *iret )
/************************************************************************
 * gb2_2gem								*
 *									*
 * This function converts GRIB2 Product Definition info and             *
 * Grid Definition info to GEMPAK header info.                          *
 *									*
 * gb2_2gem ( cmsg, gem, iret )				         	*
 *									*
 * Output parameters:							*
 *      *cmsg        struct gribmsg     current GRIB field              *
 *	*ivers		int		GRIB version number		*
 *	*iret		int		Return code			*
 *                                        0 = Successful                *
 *                                      -34 = Could not process GRIB2   *
 *                                            message                   *
 **									*
 * Log:									*
 * S. Gilbert/NCEP		 11/2004				*
 * S. Emmerson/Unidata           10/2018                                *
 *     Unknown PDTN when decoding time is no longer an error            *
 ***********************************************************************/
{
/*---------------------------------------------------------------------*/
    int iaccm, cntrid, ier, itmp, scal;
    char gdattm1[DTTMSZ];
    static char gdattm2[DTTMSZ]="                    ";
    char wmocntr[8];
    struct gribfield *tg;
    float missng;

    *iret = 0;
    tg=cmsg->gfld;

/*    printf("gem:%s:%s:\n",*(tbls+0),tbls[0]);
    printf("gem:%s:%s:\n",*(tbls+1),tbls[1]);
    printf("gem:%s:%s:\n",*(tbls+2),tbls[2]);
    printf("gem:%s:%s:\n",*(tbls+3),tbls[3]);
    printf("gem:%s:%s:\n",*(tbls+4),tbls[4]);
*/

    /*
     *    Get Originating Center from wmocenter.tbl
     */
    cntrid = tg->idsect[0];
    gb2_gtcntr( cntrid, tbls[4], wmocntr, &ier);
    if ( ier != 0 ) {
        char    msg[132];

        (void)snprintf(msg, sizeof(msg),
                "Couldn't find originating center %d in table \"%s\"",
                cntrid, tbls[4] ? tbls[4] : "wmocenter.tbl");
        msg[sizeof(msg)-1] = 0;
        ER_WMSG("GB", &ier, msg, &itmp, 2, 1);
    }
    cst_uclc(wmocntr, cmsg->origcntr, &ier);
    
    /*
     *    Convert Date/Time information
     */
    gb2_ftim ( tg, gdattm1, &iaccm, iret );
    if (*iret == -27)
        *iret = 0; // Not really an error

    strncpy( gem->gdattm1, gdattm1, DTTMSZ-1)[DTTMSZ-1] = 0;
    strncpy( gem->gdattm2, gdattm2, DTTMSZ-1)[DTTMSZ-1] = 0;
    cmsg->tmrange=iaccm;

    /*
     *    Convert Parameter information
     */
    gb2_param( tbls[0], tbls[1], cmsg, gem->parm, &scal, &missng, &ier );
    if ( ier != 0 ) {
        ER_WMSG("GB", &ier, "Couldn't get parameter values", &itmp, 2, 1);
        *iret=-34;
        return;
    }
    gem->iuscal=scal;
    gem->rmsval=missng;

    /*
     *    Convert Level information
     */
    gem->level[0]=-1;
    gem->level[1]=-1;
    gem->vcord=0;
    /*gb2_vcrd( tbls[2], tbls[3], cmsg, gem->level, &gem->vcord, &ier);*/
    /* S. Chiswell modification to get unit of vertical coordinate */
    gem->unit[0] = '\0';
    gb2_vcrd( tbls[2], tbls[3], cmsg, gem->level, &gem->vcord, gem->unit, &ier);
    if ( ier != 0 ) {
        ER_WMSG("GB", &ier, "Couldn't compute vertical co-ordinate values",
                &itmp, 2, 1);
        *iret=-34;
        return;
    }

    /*
     *    Convert GDS info to Gempak navigation block.
     */
#if 0
    gb2_gdsnav( tg, gem->cproj, &cmsg->kx, &cmsg->ky, gem->gdsarr,
                gem->corners, gem->navblk, &cmsg->g2scan_mode, &ier );
    if ( ier != 0 ) {
        er_wmsg("GB", &ier, " ", &itmp, 2, 1);
        *iret=-34;
        return;
    }
#endif
     /*printf("SAGgrd %d %s %d %d\n",*iret, gem->cproj,cmsg->kx,cmsg->ky);*/

}