Example #1
0
void init_driver(int *iret) {

   int ier, mode = 0;

   *iret = 0;

   in_bdta(&ier);
   if ( ier != 0 ) {
      *iret = -11;
      return;
   }

   gd_init(&ier);
   if ( ier != 0 ) {
      *iret = -12;
      return;
   }

   gg_init(&mode, &ier);
   if ( ier != 0 ) {
      *iret = -13;
      return;
   }

   dg_intl(&ier);
   if ( ier != 0 ) {
      *iret = -14;
      return;
   }

   db_init(&ier);
   if ( ier != 0 ) {
      *iret = -15;
      return;
   }

}
Example #2
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] );
	}
}
Example #3
0
int main ( void )
/************************************************************************
 * TESTCVQ								*
 *									*
 * This program tests the CGEMLIB "CVQ" functions.			*
 *									*
 **									*
 * Log:									*
 * E. Wehner/EAi	 6/97	Created					*
 * E. Wehner/EAi	 7/97	Fixed typecasting of group type		*
 * E. Wehner/EAi	 7/97	Added cvq_higrp.			*
 * I. Durham/GSC	 5/98	Changed underscore decl. to an include	*
 * A. Hardy/SAIC	11/01   Added maxoff to cvq_scangrp		*
 ***********************************************************************/
{
	int		cont, iret, numsub, i, ier;
	int		flag, level, elevel, ebuff;
	int		eflag;
	int		ingrp, maxoff;
	long		size;
	char		select[LLSCRN], filnam[LLSCRN];
	char		grp[4], path[133]; 
	VG_DBStruct     el;
	int		vgstart;
	char		gptyp;		/* group type */
	int		gpnum;		/* group number */
	int		members[10];
	int		fpos;
	int		tgtyp;		/* temporary group type */

/*---------------------------------------------------------------------*/
    iret = 0;
    size = 0;
    cont = G_FALSE;
    flag = G_FALSE;
    eflag = G_FALSE;
    strcpy(grp, "CVQ");
    level = 0;
    elevel = 2;
    ebuff = 0;

    in_bdta(&ier);
    er_stat(&elevel, &ebuff, &eflag, &ier);

    vgstart = 0;
    cvg_rdrec ( filnam, vgstart, &el, &iret );

    while ( cont == G_FALSE ) 
    {
	numsub = 0;
	printf ( "\n\n" );
	printf ("  1 = CVQ_SCANGRP   2 = CVQ_GETGINF   3 = CVQ_NXTGNM\n");
	printf ("  4 = CVQ_HIGP   \n");
	printf ( "\n" );
	printf ( "Select a function number or type EXIT: " );
	scanf ( " %s", select );

	switch ( select[0] ) 
	{
	    case 'e':
	    case 'E':
		cont = G_TRUE;
		break;
	    default:
		numsub = atoi ( select );
		break;
        }

/*---------------------------------------------------------------------*/
	switch (numsub)
	{
/*
 *	----------------------------------------------------------
 *	       CVQ_SCANGRP - retrieve the members of a group
 *	----------------------------------------------------------
 */
	    case 1:

		printf ( "Enter the VG file name to scan:\n" );
		scanf ( " %s", filnam );
		printf( "Enter Group type to retrieve:\n");
		scanf( " %i", &tgtyp);
		printf( "Enter Group number to retrieve: \n");
		scanf( " %i", &gpnum);
		printf( "Enter maximum number of offsets to find: \n"); 
		scanf( " %i", &maxoff);

		gptyp = (char)tgtyp;

		cvq_scangrp( filnam, gptyp, gpnum, maxoff, members, 
		             &ingrp, &iret);

		printf ( "\nCVQ_SCANGRP: iret = %d\n\n", iret );
		printf(" Extracted %i elements in group: %i/%i  \n", ingrp,
				gptyp, gpnum);

		for (i = 0;  i< ingrp; i++)
		{
                        /* read header */
                    cfl_inqr ( filnam, " ", &size, path, &ier );
		    if (members[i] < size)
		    {

                        cvg_rdrec ( filnam, members[i], &el, &iret );
                        cvg_dump ( el, el.hdr.recsz, el.hdr.recsz, 
					flag, &iret );

		    }

		}

		er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp),
		  strlen(filnam) );
    		break;
/*
 *	----------------------------------------------------------
 *	       CVQ_GETGINF - Return group type and number from elem.
 *	----------------------------------------------------------
 */
	    case 2:
                printf ( "Enter the VG file name to examine:\n" );
                scanf ( " %s", filnam );
                printf( "Enter file location of element in question:\n");
                scanf( " %i", &fpos);

                cvq_getginf( filnam, fpos, &gptyp, &gpnum, &iret);

                printf ( "\nCVQ_GETGINF: iret = %d\n\n", iret );
                printf(" Element is in group %c %i \n", gptyp, gpnum);

                er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp),
                  strlen(filnam) );
		break;
/*
 *	----------------------------------------------------------
 *	       CVQ_NXTGNM - Get next group number used in file 
 *	----------------------------------------------------------
 */
	    case 3:
                printf ( "Enter the VG file name to examine:\n" );
                scanf ( " %s", filnam );
                printf( "Enter the group type to retrieve from:\n");
                scanf( " %i", &tgtyp);
		gptyp = (char)tgtyp;
	
		printf( "Locate the next group number above: \n");
		scanf( " %i", &gpnum);

                cvq_nxtgnm( filnam, gptyp, &gpnum, &iret);

                printf ( "\nCVQ_NXTGNM: iret = %d\n\n", iret );
                printf(" The next group number of group type %c is %i \n", 
				gptyp, gpnum);

                er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp),
                  strlen(filnam) );

		break;

/*
 *	----------------------------------------------------------
 *	       CVQ_HIGP - Get highest group number used in file 
 *	----------------------------------------------------------
 */
	    case 4:
                printf ( "Enter the VG file name to examine:\n" );
                scanf ( " %s", filnam );
	
                cvq_higp( filnam, &gpnum, &iret);

                printf ( "\nCVQ_HIGP: iret = %d\n\n", iret );
                printf(" The highest group number is %i \n", 
				gpnum);

                er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp),
                  strlen(filnam) );

		break;


	}
    }
    return 0;
}
Example #4
0
int main ( void )
/************************************************************************
 * TESTNSN								*
 *									*
 * This program test the NSN library of routines.			*
 *									*
 **									*
 * Log:									*
 * S. Jacobs/NCEP	 6/99	Created					*
 * M. Li/GSC		 7/00	Added nsn_save and nsn_rest		*
 * T. Lee/SAIC		 8/03	Add time interval to nsn_gtim, nsn_dspl	*
 * T. Lee/SAIC		 2/04	Add reference time flag to nsn_gtim	*
 * T. Lee/SAIC		 4/04	Added delta reference time to nsn_gtim	*
 * T. Lee/SAIC		10/04	Added bin hours				*
 * T. Piper/SAIC        01/08   Added GD_INIT; removed from IN_BDTA     *
 * F. J. Yen/NCEP	04/08   Insert new parms for nsn_dspl (CSC).	*
 *				Request input for bin hours.		*
 ***********************************************************************/
{
	int	cont, ier, iret, numsub, id;
	char	ergrp[4], erstr[81], select[LLSCRN];

	int	iindex, jindex, knt, ntime, match, ititl, idelta,
		mode, istat, minute, isbcat, mrange, intrvl,
		ibfr, iaftr, mbfr, maftr, mstrct;
	char	alias[81], cycle[81], parms[81], color[81],
		level[81], vcord[81], filter[81], txtatt[81],
		garea[81], proj[5], panel[81], dattim[21], device[81],
		map[21], ltln[21], ans[9];
	unsigned int	jflag;
	Boolean	iflag;
	dttms_t	endtim, timarr[2000];

	char	blank[] = " ";

/*---------------------------------------------------------------------*/

	in_bdta ( &ier );
	gd_init ( &ier );

	mode = 1;
	ginitp ( &mode, &istat, &ier );

	printf ( "Enter full DEVICE string:\n" );
	scanf ( " %s", device );

	gg_sdev ( device, &ier, strlen ( device ) );

	strcpy ( ergrp, "NSN" );

	cont = G_TRUE;

	while ( cont ) {
	    printf ( "\n\n" );
	    printf ( "   1 = NSN_INIT   2 = NSN_SATT   3 = NSN_QATT\n" );
	    printf ( "   4 = NSN_GTIM   5 = NSN_DSPL   6 = NSN_SAVE\n" );
	    printf ( "   7 = NSN_REST\n\n" );
	    printf ( "  20 = Change device\n\n" );
	    printf ( "\n" );
	    printf ( "Select a subroutine number or type EXIT: " );
	    scanf ( " %s", select );
	    switch ( select[0] ) {
		case 'e':
		case 'E':
			cont = G_FALSE;
		default:
			numsub = atoi ( select );
			break;
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 1 )  {
		nsn_init ( &iret );

		printf ( "iret = %d\n", iret );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 2 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );
		printf ( "Enter the data alias (e.g., UAIR):\n" );
		scanf  ( " %s", alias );
		printf ( "Enter data subcategory number:\n" );
		scanf  ( " %d", &isbcat );
		printf ( "Enter the cycle date/time or NONE:\n" );
		scanf  ( " %s", cycle );
		printf ( "Enter the parm list:\n" );
		scanf  ( " %s", parms );
		printf ( "Enter the color list:\n" );
		scanf  ( " %s", color );
		printf ( "Enter the level:\n" );
		scanf  ( " %s", level );
		printf ( "Enter the vertical coordinate:\n" );
		scanf  ( " %s", vcord );
		printf ( "Enter the filter:\n" );
		scanf  ( " %s", filter );
		printf ( "Enter the text attributes string:\n" );
		scanf  ( " %s", txtatt );

		nsn_satt ( iindex, alias, isbcat, cycle, parms, color,
			   level, vcord, filter, txtatt, &jindex,
			   &iret );

		printf ( "iret   = %d\n", iret );
		printf ( "jindex = %d\n", jindex );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 3 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );

		nsn_qatt ( iindex, alias, &isbcat, cycle, parms, color,
			   level, vcord, filter, txtatt, &iret );

		printf ( "iret   = %d\n", iret );
		printf ( "alias  = %s\n", alias );
		printf ( "isbcat = %d\n", isbcat );
		printf ( "cycle  = %s\n", cycle );
		printf ( "parms  = %s\n", parms );
		printf ( "color  = %s\n", color );
		printf ( "level  = %s\n", level );
		printf ( "vcord  = %s\n", vcord );
		printf ( "filter = %s\n", filter );
		printf ( "txtatt = %s\n", txtatt );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 4 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );
                printf ( "Enter end time for range:\n" );
		scanf  ( " %s", endtim );
		printf ( "Enter time range in minutes:\n" );
		scanf  ( " %d", &mrange );
		printf ( "Enter time interval in minutes:\n" );
		scanf  ( " %d", &intrvl );
		printf ( "Enter reference time flag:\n" );
		scanf  ( " %u", &jflag );
		iflag = (Boolean) jflag;
		printf ( "Enter delta reference time in minutes:\n" );
		scanf  ( " %d", &idelta );


		nsn_gtim ( iindex, endtim, mrange, intrvl, iflag, 
			   &idelta, &ntime, timarr, &iret );

		printf ( "idelta = %d\n", idelta );
		printf ( "iret   = %d\n", iret );
		printf ( "ntime  = %d\n", ntime );
		if  ( ntime > 0 )  {
		    for ( knt = 0; knt < ntime; knt++ ) {
			printf ( "Times: timarr[%d] = %s\n",
				 knt, timarr[knt] );
		    }
		}

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 5 )  {
		printf ( "Enter index number:\n" );
		scanf  ( " %d", &iindex );

		nsn_qatt ( iindex, alias, &isbcat, cycle, parms, color,
			   level, vcord, filter, txtatt, &iret );

		printf ( "Enter GAREA:\n" );
		scanf  ( " %s", garea );

		printf ( "Default projection? (y/n)\n" );
		scanf  ( " %s", ans );
		if  ( ans[0] == 'N' || ans[0] == 'n' )  {
		    printf ( "Enter PROJ:\n" );
		    scanf  ( " %s", proj );
		}
		else {
		    strcpy ( proj, blank );
		}

		printf ( "Enter PANEL:\n" );
		scanf  ( " %s", panel );
		printf ( "Enter DATTIM:\n" );
		scanf  ( " %s", dattim );

                printf ( "Enter end time for range:\n" );
		scanf  ( " %s", endtim );
		printf ( "Enter the time range in minutes:\n" );
		scanf  ( " %d", &mrange );
		printf ( "Enter the time interval in minutes:\n" );
		scanf  ( " %d", &intrvl );

		printf ( "Enter time match type:\n" );
		scanf  ( " %d", &match );
		printf ( "Enter minutes for difference match:\n" );
		scanf  ( " %d", &minute );
		printf ( "Enter title line:\n" );
		scanf  ( " %d", &ititl );
                printf ( "Enter binning time before current time: hh mm:\n" );
                scanf  ( " %d %d", &ibfr, &mbfr );
                printf ( "Enter binning time after current time: hh mm:\n" );
                scanf  ( " %d %d", &iaftr, &maftr );
                printf ( "Enter most recent only flag (0 for no; 1 for yes)\n" );
                scanf  ( " %d", &mstrct );

		gg_maps ( proj, garea, blank, &id, &ier,
			  strlen ( proj ), strlen ( garea ),
			  strlen ( blank ) );

		gclear ( &ier );

		strcpy ( map, "1" );
		gg_map ( map, &ier, strlen ( map ) );

		strcpy ( ltln, "2" );
		gg_ltln ( ltln, &ier, strlen ( ltln ) );

		nsn_dspl ( panel, dattim, alias, &isbcat, cycle, parms,
			   color, level, vcord, filter, txtatt,       
			   endtim, &mrange, &intrvl, &match, &minute, 
			   &ititl, &ibfr, &mbfr, &iaftr, &maftr,
			   &mstrct, &iret,
			   strlen ( panel ), strlen ( dattim ),
			   strlen ( alias ), strlen ( cycle ),
			   strlen ( parms ), strlen ( color ),
			   strlen ( level ), strlen ( vcord ),
			   strlen ( filter ), strlen ( txtatt ),
			   strlen ( endtim ) );

		geplot ( &ier );

		if  ( iret != 0 )  {
		    strcpy ( erstr, " " );
		    er_wmsg ( ergrp, &iret, erstr, &ier,
			      strlen ( ergrp ), strlen ( erstr ) );
		}
	    }

/*---------------------------------------------------------------------*/
            if  ( numsub == 6 )  {
                nsn_save ( &iret );

                printf ( "iret = %d\n", iret );

                if  ( iret != 0 )  {
                    strcpy ( erstr, " " );
                    er_wmsg ( ergrp, &iret, erstr, &ier,
                              strlen ( ergrp ), strlen ( erstr ) );
                }
            }

/*---------------------------------------------------------------------*/
            if  ( numsub == 7 )  {
                nsn_rest ( &iret );

                printf ( "iret = %d\n", iret );

                if  ( iret != 0 )  {
                    strcpy ( erstr, " " );
                    er_wmsg ( ergrp, &iret, erstr, &ier,
                              strlen ( ergrp ), strlen ( erstr ) );
                }
            }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 10 )  {
		dumpcmn ( &iret );
	    }

/*---------------------------------------------------------------------*/
	    if  ( numsub == 20 )  {
		printf ( "Enter full DEVICE string:\n" );
		scanf ( " %s", device );

		gg_sdev ( device, &ier, strlen ( device ) );
	    }

	}
	return(0);
}
Example #5
0
int main ( int argc, char *argv[] )
/************************************************************************
 * sigavgf                                                              *
 *                                                                      *
 * This program reads Significant Weather ASCII files and encodes the   *
 * information into a VG file format.   	                        *
 *                                                                      *
 * command line:                                                        *
 *      sigavgf dattim hh                                               *
 *              dattim      GEMPAK date/time string                     *
 *              hh          Valid time (hours) - must be 18 or 24       *
 **                                                                     *
 * Log:                                                                 *
 * A. Hardy/SAIC     3/02      Created					* 
 * A. Hardy/SAIC     5/02      Added optional input file name; changed  *
 * 			       default input file name			*
 * M. Li/SAIC	     7/04      Removed grpch from sigajet		*
 * M. Li/SAIC	     9/04      Add idcent, chbase and chtop to cas_rdhdr*
 * M. Li/SAIC	     1/05      Process SWM 				*
 * M. Li/SAIC	    10/05      Checked for new format of jet info	*
 ***********************************************************************/
{
    int 	ier, numerr, leverr, pagflg, grpid, iret;
    int         itime[5], jtime[5], idcent;
    float	chbase, chtop;
    int         numtrp, rnum, lnum, hnum, membx, memhi, memlo;
    int         memcld, memmcld, memfrt, memjet, memstm, memtur, memvlr;
    int         numcld, nummcld, numfrt, numjet, numstm, numtur, numvlr;

    char 	fhour [3], fname[256], gtstr[12], grpch, chlvl[10];
    char	errgrp[8], cc[50], casgrp[4];
    char	path[256];
    char	newflvl[10];
    long	size;


    cloud_t     *ptrc, *head,  *ptr2;
    mcloud_t    *ptrm, *headm, *ptr2m;
    jets_t      *ptrj, *headj, *ptr2j;
    front_t     *ptrf, *headf, *ptr2f;
    turb_t      *ptrb, *headb, *ptr2b;
    storm_t     *ptrs, *heads, *ptr2s;
    volrad_t    *ptrv, *headv, *ptr2v;
    trop_t      *ptrr, *headr, *ptr2r;
    trophi_t    *ptrh, *headh, *ptr2h;
    troplo_t    *ptrl, *headl, *ptr2l;

    Boolean     readflg;

    FILE *ifpout;
    /*---------------------------------------------------------------------*/
 
    iret    = 0;
    leverr  = 0;
    readflg = True;
    ifpout  = NULL;

    strcpy ( errgrp, "SIGAVGF" );
    strcpy ( casgrp, "CAS");
    strcpy ( cc, " " );

    rnum   = lnum   = hnum   = 0;
    membx  = memhi  = memlo  = 0;
    memcld = memmcld = memfrt = memjet = memstm = memtur = memvlr = 0;
    numcld = nummcld = numfrt = numjet = numstm = numtur = numvlr = 0;

    ptrc   =  NULL;
    ptrm   =  NULL;
    ptrj   =  NULL;
    ptrf   =  NULL;
    ptrb   =  NULL;
    ptrs   =  NULL;
    ptrv   =  NULL;
    ptrr   =  NULL;
    ptrh   =  NULL;
    ptrl   =  NULL;

    in_bdta ( &ier );

   /*
    * If the forecast hour is not on the command line, print help 
    * and exit.
    */

    if ( argc < 3 ) {
        pagflg = G_FALSE;
        ip_help ( errgrp, &pagflg, &ier, 
                  strlen(errgrp) );
        numerr = -1;
        er_lmsg ( &leverr, errgrp, &numerr, cc, &ier,
                  strlen(errgrp), strlen(cc) );
        exit (1);
    }

    strcpy ( fhour, argv[2] );
    if  ( strcmp ( fhour, "24") != 0 ) { 
        if ( strcmp ( fhour, "18") != 0 ) {
            numerr = -2;
            er_lmsg ( &leverr, errgrp, &numerr, fhour, &ier,
                      strlen(errgrp), strlen(fhour) );
            exit (1);
	}
    }

   /*
    *  Check for input file.
    */

    if ( argv[3] != NULL ) {
        strcpy ( fname, argv[3] );
    }
    else {
       
       /*
	* If an input file is not specified, check for the existence of 
	* either SIGWXHI.txt or SIGWXMID.txt.
	*/

        sprintf ( fname, "SIGWXHI.txt" );
	cfl_inqr ( fname, NULL, &size, path, &ier );
	if ( ier != 0 ) {
	    sprintf ( fname, "SIGWXMID.txt" );
            cfl_inqr ( fname, NULL, &size, path, &ier );
	    if ( ier != 0 ) {
		numerr = -3;
                er_lmsg ( &leverr, errgrp, &numerr, fname, &ier,
                          strlen(errgrp), strlen(fname) );
                exit (1);
            }
	}

    }
    ifpout = cas_open ( fname, readflg, &ier );

   /*
    * If input ASCII file failed to open, exit program.
    */

    if ( ier != 0 ) {
         numerr = -3;
         er_lmsg ( &leverr, errgrp, &numerr, fname, &ier,
                      strlen(errgrp), strlen(fname) );
         exit (1);
    }

   /*
    * Read in the input ASCII file into the CAS structures.
    */

    cas_rdhdr ( ifpout, itime, jtime, &idcent, &chbase, &chtop, &ier );

    rewind (ifpout);
    if ( G_ABS ( HI_BASE - chbase ) < 0.5F &&
         G_ABS ( HI_TOP  - chtop  ) < 0.5F ) {
	strcpy ( chlvl, "SWH" );
        cas_rdcld ( ifpout, &numcld, &ptrc, &memcld, &ier );
    } else if ( G_ABS ( MID_BASE - chbase ) < 0.5F &&
                G_ABS ( MID_TOP  - chtop  ) < 0.5F ) {
        strcpy ( chlvl, "SWM" );
   	cas_rdmcld ( ifpout, &nummcld, &ptrm, &memmcld, &ier );
    }

    rewind (ifpout);
    cas_rdjets ( ifpout, &numjet, &ptrj, &memjet, &ier );

    rewind (ifpout);
    cas_rdturb ( ifpout, &numtur, &ptrb, &memtur, &ier );

    rewind (ifpout);
    cas_rdfrt ( ifpout, &numfrt, &ptrf, &memfrt, &ier);

    rewind (ifpout);
    cas_rdtrop ( ifpout, &numtrp, &ptrr, &membx, &rnum,
                 &ptrl, &memlo, &lnum, &ptrh, &memhi,
		 &hnum, &ier );

    rewind (ifpout);
    cas_rdstm ( ifpout, &numstm, &ptrs, &memstm, &ier );

    rewind (ifpout);
    cas_rdvlrd ( ifpout, &numvlr, &ptrv, &memvlr, &ier );

   /*
    * Close input file.
    */

    cas_clos ( ifpout, &ier );
    
   /*
    * If ASCII file failed to close, write error message.
    */

    if ( ier != 0 ) {
         numerr = -4;
         er_lmsg ( &leverr, casgrp, &numerr, fname, &ier,
                      strlen(casgrp), strlen(fname) );
    }

   /*
    * Initialize the group type table.
    */

    ces_gtrtbl ( &iret );

   /*
    * Call appropriate VG file encoding subroutines.
    *
    * Create cloud VG file.
    */

    strcpy ( gtstr, "CLOUD");
    ces_gtgid (gtstr, &grpid, &ier);
    grpch = (char) grpid;
    if ( strcmp ( chlvl, "SWH" ) == 0 ) {
        sigacld ( fhour, numcld, ptrc, itime, grpch, &ier );
    }
    else {
	sigamcld ( fhour, nummcld, ptrm, itime, grpch, &ier );
    }

   /*
    * Create jets VG file.
    */

    ctb_rdprf ( "prefs.tbl", "config", "SIGWX_FLIGHT_LEVELS", newflvl, &ier );
    sigajet ( fhour, numjet, ptrj, itime, chlvl, newflvl, &ier );

   /*
    * Create turbulence VG file.
    */

    strcpy ( gtstr, "TURB");
    ces_gtgid (gtstr, &grpid, &ier);
    grpch = (char) grpid;
    sigatur ( fhour, numtur, ptrb, itime, grpch, chlvl, &ier );

   /*
    * Create front VG file.
    */

    strcpy ( gtstr, "FRONT");
    ces_gtgid (gtstr, &grpid, &ier);
    grpch = (char) grpid;
    sigafrt ( fhour, numfrt, ptrf, itime, grpch, chlvl, &ier );

   /*
    * Create tropopause VG file.
    */

    sigatrp ( fhour, rnum, ptrr, hnum, ptrh, lnum, ptrl, 
	      itime, chlvl, &ier );

   /*
    * Create symbol VG file.
    */

    strcpy ( gtstr, "LABEL");
    ces_gtgid (gtstr, &grpid, &ier);
    grpch = (char) grpid;
    sigavts ( fhour, numstm, ptrs, numvlr, ptrv, 
                       itime, grpch, chlvl, &ier );

   /*
    *  Free all created linked lists.
    */

    /* Free cloud */
    if ( memcld ) {
        head = ptrc;
        ptr2 = head -> next;
        while ( ptr2 != NULL ) {
            free (head);
            head = ptr2;
            ptr2 = ptr2 -> next;
        }
        free ( head );
    }

    /* Free mcloud */
    if ( memmcld ) {
        headm = ptrm;
        ptr2m = headm -> next;
        while ( ptr2m != NULL ) {
            free (headm);
            headm = ptr2m;
            ptr2m = ptr2m -> next;
        }
        free ( headm );
    }


    /* Free jet */
    if ( memjet ) {
        headj = ptrj;
        ptr2j = headj -> next;
        while ( ptr2j != NULL ) {
            free (headj);
            headj = ptr2j;
            ptr2j = ptr2j -> next;
        }
        free ( headj );
    }

    /* Free turb */
    if ( memtur ) {
        headb = ptrb;
        ptr2b = headb -> next;
        while ( ptr2b != NULL ) {
            free (headb);
            headb = ptr2b;
            ptr2b = ptr2b -> next;
        }
        free ( headb );
    }

    /* Free front*/
    if ( memfrt ) {
        headf = ptrf;
        ptr2f = headf -> next;
        while ( ptr2f != NULL ) {
            free (headf);
            headf = ptr2f;
            ptr2f = ptr2f -> next;
        }
        free ( headf );
    }
    /* Free trop*/
    if ( membx ) {
        headr = ptrr;
        ptr2r = headr -> next;
        while ( ptr2r != NULL ) {
            free ( headr );
            headr = ptr2r;
            ptr2r = ptr2r -> next;
        }
        free ( headr );
    }
    if ( memhi ) {
        headh = ptrh;
        ptr2h = headh -> next;
        while ( ptr2h != NULL ) {
            free ( headh );
            headh = ptr2h;
            ptr2h = ptr2h -> next;
        }
        free ( headh );
    }
    if ( memlo ) {
        headl = ptrl;
        ptr2l = headl -> next;
        while ( ptr2l != NULL ) {
            free ( headl );
            headl = ptr2l;
            ptr2l = ptr2l -> next;
        }
        free ( headl );
    }

    if ( memstm ) {
        heads = ptrs;
        ptr2s = heads -> next;
        while ( ptr2s != NULL ) {
            free ( heads );
            heads = ptr2s;
            ptr2s = ptr2s -> next;
        }
        free ( heads );
    }
    if ( memvlr ) {
        headv = ptrv;
        ptr2v = headv -> next;
        while ( ptr2v != NULL ) {
            free ( headv );
            headv = ptr2v;
            ptr2v = ptr2v -> next;
        }
        free ( headv );
    }

    return 0;
}
Example #6
0
int main (void)
/************************************************************************
 * TESTDA								*
 * 									*
 * This program tests the GEMLIB DA functions.				*
 * 									*
 ** 									*
 * Log:									*
 * S. Jacobs/NCEP	 5/13	Initial coding				*
 ***********************************************************************/
{
    int		cont, ier, iret, numsub, is, ie, ii;
    char	select[5];

    char	pyfile[MXFLSZ], pymeth[MXFLSZ];

/*---------------------------------------------------------------------*/
    in_bdta(&ier);

    cont = G_TRUE;

    while ( cont ) {
	printf ( "\n\n" );
	printf ( "  1 = DA_RUNPY for CHAR output\n" );
	printf ( "  2 = DA_RUNPY for INT output\n" );
	printf ( "  3 = DA_RUNPY for FLOAT output\n" );
	printf ( "\n" );
	printf ( "Select a subroutine number or type EXIT: " );
	ier = getinp ( 1, select, NULL, NULL, 4 );
	switch ( select[0] ) {
	    case 'e':
	    case 'E':
		cont = G_FALSE;
	    default:
		numsub = atoi ( select );
		break;
	}

/*---------------------------------------------------------------------*/
	if ( numsub == 1 ) {

	    printf ( "Enter the Python file name (without .py):\n" );
	    ier = getinp ( 1, pyfile, NULL, NULL, MXFLSZ );
	    if ( ier < 0 ) {
	       	break;
	    }

	    printf ( "Enter the Python method name:\n" );
	    ier = getinp ( 1, pymeth, NULL, NULL, MXFLSZ );
	    if ( ier < 0 ) {
	       	break;
	    }

	    printf ( "Enter the number of input strings:\n" );
	    ier = getinp ( 2, NULL, &danarg, NULL, STRSIZE );
	    if ( ier < 0 ) {
	       	break;
	    }

	    daargs = (char **) malloc ( danarg * sizeof(char *) );
	    for ( ii = 0; ii < danarg; ii++ ) {
		daargs[ii] = (char *) malloc ( STRSIZE * sizeof(char) );
		printf ( "Enter input string %d:\n", ii );
		ier = getinp ( 1, daargs[ii], NULL, NULL, STRSIZE );
		if ( ier < 0 ) {
		    break;
		}
	    }

	    datype = DACHAR;
	    da_runpy ( pyfile, pymeth, &iret );

	    printf ( "\nDA_RUNPY: iret = %d\n\n", iret );
	    if  ( iret >= 0 )  {
		printf ( "The length of result is: %ld\n", strlen(daoutc) );
		printf ( "The result is: %s\n\n", daoutc );

		free ( daoutc );
	    }
	    free ( daargs );
	}
/*---------------------------------------------------------------------*/
	if ( numsub == 2 ) {

	    printf ( "Enter the Python file name (without .py):\n" );
	    ier = getinp ( 1, pyfile, NULL, NULL, MXFLSZ );
	    if ( ier < 0 ) {
	       	break;
	    }

	    printf ( "Enter the Python method name:\n" );
	    ier = getinp ( 1, pymeth, NULL, NULL, MXFLSZ );
	    if ( ier < 0 ) {
	       	break;
	    }

	    printf ( "Enter the number of input strings:\n" );
	    ier = getinp ( 2, NULL, &danarg, NULL, STRSIZE );
	    if ( ier < 0 ) {
	       	break;
	    }

	    daargs = (char **) malloc ( danarg * sizeof(char *) );
	    for ( ii = 0; ii < danarg; ii++ ) {
		daargs[ii] = (char *) malloc ( STRSIZE * sizeof(char) );
		printf ( "Enter input string %d:\n", ii );
		ier = getinp ( 1, daargs[ii], NULL, NULL, STRSIZE );
		if ( ier < 0 ) {
		    break;
		}
	    }

	    datype = DAINT;
	    da_runpy ( pyfile, pymeth, &iret );

	    printf ( "\nDA_RUNPY: iret = %d\n\n", iret );
	    if  ( iret >= 0 )  {
		printf ( "The array size of result is: %d\n", danumi );
		printf ( "The result array is:\n" );
		is = 0;
		ie = G_MIN ( 8, danumi );
		while ( is < danumi ) {
		    for ( ii = is; ii < ie; ii++ ) {
			printf ( "%9d ", daouti[ii] );
		    }
		    printf ( "\n" );
		    is = ie;
		    ie = G_MIN ( is+8, danumi );
		}
		printf ( "\n" );

		free ( daouti );
	    }
	    free ( daargs );
	}
/*---------------------------------------------------------------------*/
	if ( numsub == 3 ) {

	    printf ( "Enter the Python file name (without .py):\n" );
	    ier = getinp ( 1, pyfile, NULL, NULL, MXFLSZ );
	    if ( ier < 0 ) {
	       	break;
	    }

	    printf ( "Enter the Python method name:\n" );
	    ier = getinp ( 1, pymeth, NULL, NULL, MXFLSZ );
	    if ( ier < 0 ) {
	       	break;
	    }

	    printf ( "Enter the number of input strings:\n" );
	    ier = getinp ( 2, NULL, &danarg, NULL, STRSIZE );
	    if ( ier < 0 ) {
	       	break;
	    }

	    daargs = (char **) malloc ( danarg * sizeof(char *) );
	    for ( ii = 0; ii < danarg; ii++ ) {
		daargs[ii] = (char *) malloc ( STRSIZE * sizeof(char) );
		printf ( "Enter input string %d:\n", ii );
		ier = getinp ( 1, daargs[ii], NULL, NULL, STRSIZE );
		if ( ier < 0 ) {
		    break;
		}
	    }

	    datype = DAFLOAT;
	    da_runpy ( pyfile, pymeth, &iret );

	    printf ( "\nDA_RUNPY: iret = %d\n\n", iret );

	    if  ( iret >= 0 )  {
		printf ( "The array size of result is: %d\n", danumf );
		printf ( "The result array is:\n" );
		is = 0;
		ie = G_MIN ( 8, danumf );
		while ( is < danumf ) {
		    for ( ii = is; ii < ie; ii++ ) {
			printf ( "%9.2f ", daoutf[ii] );
		    }
		    printf ( "\n" );
		    is = ie;
		    ie = G_MIN ( is+8, danumf );
		}
		printf ( "\n" );

		free ( daoutf );
	    }
	    free ( daargs );
	}

/*---------------------------------------------------------------------*/
    }

    return 0;
}
Example #7
0
int main ( int argc, char **argv )
/************************************************************************
 * mdp									*
 *                                                                      *
 * This program generates the mesoscale discussion latlon pairings.	*
 * Pairings will be written to a file whose filename is based on the	*
 * input filename (filename extension, if exists, is replaced w/ "mdp").*
 *                                                                      *
 * Example:								*
 * mdp input_vgf_file.vgf						*
 * Produces latlon pairings in the ASCII file				*
 * output_vgf_file.mdp							*
 *                                                                      *
 * main(argc, argv)                                                     *
 *                                                                      *
 * Input parameters:                                                    *
 *  argc   int      number of parameters of command line                *
 *  argv   char**   parameter array of command line                     *
 *                                                                      *
 * Output parameters:                                                   *
 * Return parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * D.W.Plummer/NCEP	 6/02						*
 * D.W.Plummer/NCEP	 8/02	Bug fix for lons > 99.995 and < 100.0	*
 * G. Grosshans/SPC	11/02	Updated to decode multi-scalloped lines *
 * G. Grosshans/SPC	12/02	Updated to compute WFO/State		*
 * S. Jacobs/NCEP	 5/03	Clean up unused variables and headers	*
 * G. Grosshans/SPC     10/03   Updated for precision                   *
 * T. Piper/SAIC	12/05	Updated cst_wrap for CSC		*
 * J. Wu/SAIC		04/06	Added parameter in cst_wrap 		*
 * G. Grosshans/SPC	08/08	Updated for SCN 08-45 to add LAT...LON  *
 * 				and list first point as last point      *
 * 				to indicate a closed polygon.  Add      *
 *				word wrapping for ATTN...WFO...		*
 ***********************************************************************/
{
int		ii, ix, iy, ixfirst, iyfirst, pagflg, ne, ilen,
	        npts, ier, iret, nitems, more, curpos;

long		ifilesize;

float		x, y, flat[MAXLISTITEMS], flon[MAXLISTITEMS];

char		vg_class, vg_type, buffer[2048], bufferfinal[2048],
		bufferfinalwfo[2048],str[20], *cptr, errgrp[12], infile[128],
		ifname[128], outfile[128], info[2048], stpo[4],
		cstl_list[1000], cstl_liststate[1000],
		newLineStr[13]="            "; /* 13 spaces */

char		blank[2]={' '}, device[13], dfilnam[73], pro[80];
int		mode, istat, iunit, itype;
float		xsize, ysize, lllat, lllon, urlat, urlon,
		prjang1, prjang2, prjang3;

VG_DBStruct	el;

FILE		*ifptr, *ofptr;

const int line_len = 66;

/*---------------------------------------------------------------------*/

    /* 
     * Set defaults for gsdeva and gsmprj
     */
    mode = 1;
    strcpy ( device, "GN" );
    iunit = 1;
    strcpy ( dfilnam, "MDPSPC" );
    itype = 1;
    xsize = 500.0F;
    ysize = 500.0F;
    lllat = 10.0F;
    lllon = -120.0F;
    urlat = 50.0F;
    urlon = -50.0F;
    strcpy ( pro, "str" );
    prjang1 =   90.0F;
    prjang2 = -105.0F;
    prjang3 =    0.0F;
    cstl_list[0] = '\0';
    cstl_liststate[0] = '\0';

    in_bdta ( &ier );
    ginitp ( &mode, &istat, &ier);
    gsdeva (device, &iunit, dfilnam, &itype, &xsize, &ysize, &iret,
	    strlen(device), strlen(dfilnam));
    gsmprj ( pro, &prjang1, &prjang2, &prjang3, 
	     &lllat, &lllon, &urlat, &urlon, &iret, strlen(pro));
    clo_init ( &ier );

    /*
     *  Check if number of input arguments is correct.
     */
    if ( argc < 2 )  {
	pagflg = G_FALSE;
	strcpy ( errgrp, "MDPSPC" );
        ip_help ( errgrp, &pagflg, &ier,
                  strlen(errgrp) );
	gendp (&mode, &ier);
	exit (0);
    }

    /*
     *  First input on command line is input vgf file name.
     */
    strcpy ( infile, argv[1] );
    cfl_inqr ( infile, NULL, &ifilesize, ifname, &ier );
    ifptr = (FILE *) cfl_ropn(ifname, "", &ier);
    if ( ier != 0 )  {
	printf("Error opening VGF file %s\n", infile );
	gendp (&mode, &ier);
	exit (0);
    }

    /*
     *  Output filename is input filename w/ "mdp" filename extension.
     */
    strcpy ( outfile, infile );
    cptr = strrchr( outfile, '.' );
    if ( cptr != (char *)NULL )  {
	cptr[0] = '\0';
    }
    strcat( outfile, ".mdp" );
    
    /*
     *  Loop through all the elements until a line is found.
     */
    ne = 0;
    more = G_TRUE;
    curpos = 0;
    buffer[0] = '\0';
    bufferfinal[0] = '\0';
    bufferfinalwfo[0] = '\0';
    strcat ( buffer, "LAT...LON   " );
    while ( ne < MAX_EDITABLE_ELEMS && more == G_TRUE )  {
	cvg_rdrecnoc( ifname, ifptr, curpos, &el, &ier );

	if ( ier < 0 )  {
	    more = G_FALSE;
	}
	else  {

	    curpos += el.hdr.recsz;

	    vg_class = el.hdr.vg_class;
	    vg_type  = el.hdr.vg_type;

            if ( ( (int)vg_class == CLASS_LINES ) &&
	    	 ( el.hdr.vg_type == SPLN_ELM ) &&
		 ( (int)el.elem.spl.info.spltyp == 3 ) )  {

		/*
		 *  Open output file.
		 */
		ofptr = (FILE *)cfl_wopn ( outfile, &ier );
		if ( ier != 0 )  {
		    printf("Error opening/creating output file %s\n",
		    	    outfile );
	            gendp (&mode, &ier);
		    exit (0);
    		}

	       /*
		* Find FIPS bounded by the closed line
		*/

		npts = el.elem.spl.info.numpts;

		/*  FIND WHAT STATES ARE IN MD AREA */

		clo_binpoly ( "CNTY_BNDS", npts, el.elem.spl.latlon,
                              &(el.elem.spl.latlon[npts]), &ier );
		clo_tgltln ( "CNTY_BNDS", MAXLISTITEMS, &nitems,
			      flat, flon, &ier);

		for ( ii = 0; ii < nitems; ii++ )  {
		  clo_bginfo( "CNTY_BNDS", ii, info, &ier );
		  cst_gtag( "STATE", info, "?", stpo, &ier);
		  
		  if (strstr(cstl_liststate, stpo)==NULL) {
		    strcat(cstl_liststate, stpo);
		    strcat(cstl_liststate, " ");		  
		  }
		}


		/*  FIND WHAT WFOs ARE IN MD AREA */
		clo_binpoly ( "CWA_BNDS", npts, el.elem.spl.latlon,
                              &(el.elem.spl.latlon[el.elem.spl.info.numpts]),
			      &ier );
		clo_tgltln ( "CWA_BNDS", MAXLISTITEMS, &nitems,
			      flat, flon, &ier);

		for ( ii = 0; ii < nitems; ii++ )  {
		  clo_bginfo( "CWA_BNDS", ii, info, &ier );
		  cst_gtag( "WFO", info, "?", stpo, &ier);
		  strcat(cstl_list, stpo);
		  strcat(cstl_list, "...");		  
		}

		/*
		 *  Format lats and lons into buffer.
		 */
		if ( (int)vg_type == LINE_ELM )  {
		    npts = el.elem.lin.info.numpts;
		}
		else if ( (int)vg_type == SPLN_ELM )  {
		    npts = el.elem.spl.info.numpts;
		}
		for ( ii = 0; ii < npts; ii++ )  {
		    if ( (int)vg_type == LINE_ELM )  {
		        x = el.elem.lin.latlon[ii];
		        y = -el.elem.lin.latlon[ii+npts];
		    }
		    else if ( (int)vg_type == SPLN_ELM )  {
		        x = el.elem.spl.latlon[ii];
		        y = -el.elem.spl.latlon[ii+npts];
		    }
		    /*
		     * Make sure lats and lons are rounded
		     * to 100ths of deg.
		     */
		    x = ((int)(x*100.0F)) / 100.0F;
		    y = ((int)(y*100.0F)) / 100.0F;
		    if ( y >= 100.0F )  y -= 100.0F;
		    ix = G_NINT(x*100.0F);
		    iy = G_NINT(y*100.0F);
		    sprintf( str, "%04d%04d ", ix, iy );
		    strcat ( buffer, str );
		    if ( ii == 0 ) {
                        ixfirst = ix;
			iyfirst = iy;
                    }
		}
		/*
		 *   Repeat first lat/lon point as last lat/lon point 
		 *   to indicate a closed polygon.
		 */


		sprintf( str, "%04d%04d ", ixfirst, iyfirst);
		strcat ( buffer, str );

		sprintf( str, "\n\n" );
		strcat ( buffer, str );

		/*
		 *  Wrap buffer such that only 6 pairs of lat,lons 
		 *  on one line.
		 *  ilen = 55;
		 *  cst_wrap( buffer, blank, &ilen, "\n", (char *)NULL, buffer, &ier );
		 */
		ilen = 66;
		cst_wrap( buffer, blank, &ilen, "\n", newLineStr, buffer, &ier );

	    }

	}
	ne++;
    }

    /*
     * wrap the ATTN...WFO... line
     */
    strcat ( bufferfinalwfo, "ATTN...WFO..." );
    strcat ( bufferfinalwfo, cstl_list );
    cst_wrap( bufferfinalwfo, "...", &line_len, "\n", (char *)NULL, bufferfinalwfo, &ier );

    /*
     * build the output file string and add the ATTN...WFO... string
     */
    strcat ( bufferfinal,"STATES=" );
    strcat ( bufferfinal, cstl_liststate );
    strcat ( bufferfinal, "\n\n" );
    strcat ( bufferfinal, bufferfinalwfo );
/*
    strcat ( bufferfinal,"ATTN...WFO..." );
    strcat ( bufferfinal, cstl_list );
*/
    strcat ( bufferfinal, "\n\n" );
    strcat ( bufferfinal, buffer );

    /*
     *  Write to output file.
     */
    cfl_writ ( ofptr, (int)strlen(bufferfinal),
    	       (unsigned char *)bufferfinal, &ier );

    /*
     *  close files and exit.
     */
    cfl_clos ( ifptr, &ier );
    cfl_clos ( ofptr, &ier );
    gendp (&mode, &ier);
    return(0);

}