/*
** Do not change these include commands.
** All necessary header files are included in "geminc.h".
** All macros and constants are in "gemprm.h" and "bridge.h".
*/

#include "geminc.h"
#include "gemprm.h"
#include "bridge.h"

#include "dccmn.h"  /* contains prototype for dc_wclg */

#include "decod_ut.h"

main ( argc, argv )
	int	argc;
	char	*argv[];

/************************************************************************
 * DCNCLD								*
 *									*
 * This program decodes NASA Langley cloud data into BUFR format.	*
 *									*
 * If an error occurs, the program return code is set to -1 and an	*
 * appropriate error message is written to the decoder log; otherwise,	*
 * the program return code is set to 0.					*
 *									*
 *	Command line:							*
 *	    dcncld [options] [ncldfl] [bufrtb] [bufrof]			*
 *									*
 *	Input files:							*
 *	    ncldfl	= NASA Langley cloud data file			*
 *	    bufrtb	= BUFR tables file				*
 *									*
 *	Output files:							*
 *	    bufrof	= BUFR output file				*
 *									*
 **									*
 * Log:									*
 * J. Ator/NCEP		06/10						*
 * J. Ator/NCEP         01/19   Modify for Dell environment		*
 * J. Ator/NCEP         09/21   Modify for WCOSS2 environment           *
 ***********************************************************************/

{

#define NUMEXP	3

	int	nexp	= NUMEXP;
	char	*prgnam = "DCNCLD";

/*
**	Define the standard decoder parameters.
*/
	char	stntbl[DCMXLN], stntb2[DCMXLN];
	char	prmfil[DCMXLN];
	int	iadstn;
	int	maxtim;
	int	nhours;
	int	txtflg;
	int	iwndht;
        int     circflg;

/*
**	Define default values for the standard decoder parameters.
*/
	char	*defprm	= " ";
	char	*defstn	= " ";
	char	*dfstn2	= " ";
	int	idfadd	= 0;
	int	idfmax	= 0;
	int	ndfhr1	= 1440;  /* =  60 days */
	int	ndfhr2	= 2880;  /* = 120 days */
	int	idfwdh	= 0;

/*
**	Define the additional decoder parameters.
*/
	const char *dvstr = DVSTR;  /* DVSTR is a compile-time macro */
	char	ncldfl[DCMXLN];
	char	bufrtb[DCMXLN];
	char	bufrof[DCMXLN];

/*
**	Do not change these variables.  These variables are used by all
**	decoders for getting the command line parameters.
*/
	char	parms[NUMEXP][DCMXLN];
	char	curtim[DCMXLN];
	int	num;
	int	iret;
	int	ier;


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

/*
**	Initialize the output logs, set the time out, and 
**	parse the command line parameters.
*/
	dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret );

/*
**	Check for an initialization error.
*/
	if  ( iret < 0 )  {
	    dc_exit ( &iret );
	}

/*
**	Set each standard decoder parameter to the value from the
**	command line options (if defined) or else to the default
**	value.
*/
        dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1,
                  ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn,
                  &maxtim, curtim, &nhours, &txtflg, &circflg,
                  &iwndht, &iret );
                                                                                
/*
**	Set default values for the additional decoder parameters.
*/
	strcpy ( ncldfl, "ncldfl" );
	strcpy ( bufrtb, "bufrtab.012" );
	strcpy ( bufrof, "bufr.out" );

/*
**	Now, for each additional decoder parameter, if a value was
**	defined on the command line, then use that value instead of
**	the default value.
*/
	if  ( num > 0 )  {
	    strcpy ( ncldfl, parms[0] );
	}

	if  ( num > 1 )  {
	    strcpy ( bufrtb, parms[1] );
	}

	if  ( num > 2 )  {
	    strcpy ( bufrof, parms[2] );
	}

/*
** Call the decoding routine.
**
** Change this function call and define command for the
** specific decoder.
*/

#ifdef UNDERSCORE
#define nc_dcod nc_dcod_
#endif

	void nc_dcod ( char *, char *, char *, int *, char *, int *,
                       size_t, size_t, size_t, size_t );

	ut_prvs ( dvstr, strlen(dvstr) );
	nc_dcod ( curtim, ncldfl, bufrtb, &nhours, bufrof, &iret, 
		  strlen(curtim), strlen(ncldfl),
		  strlen(bufrtb), strlen(bufrof) );

/*
**	Send shut down message and close the log file.
*/
        dc_wclg ( 0, "DC", 5, " ", &ier );
        dc_wclg ( 0, "DC", 6, " ", &ier );

/*
**      Exit the program.
*/
        exit ( iret );

}