int main ( int argc, char *argv[] ) /************************************************************************ * DCHRCN * * * * This program decodes the WTNT23, WTNT24 and WTPZ23 tropical storm * * and hurricane forecast/advisory reports and writes the output to an * * ASCII file. * * * * Command line: * * dcwtch [options] filename * * filename output file name/template * ** * * Log: * * A. Hardy/GSC 9/99 * * A. Hardy/GSC 1/01 Added full prototype * * S. Jacobs/NCEP 2/01 Removed all references to ulog * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Hinson/AWC 06/08 Added circflg parameter to dc_gopt * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCHRCN"; char *defprm = " "; char *defstn = " "; char *dfstn2 = " "; int idfadd = 25; int idfmax = 24; int ndfhr1 = 5; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** 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. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ hc_dcod ( curtim, gemfil, stntbl, prmfil, &iadstn, &maxtim, &nhours, &iret, strlen(curtim), strlen(gemfil), strlen(stntbl), strlen(prmfil) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); return 0; }
int main ( int argc, char *argv[] ) /************************************************************************ * DCMSFC * * * * This program decodes ship, buoy, C-MAN, and Coast Guard reports and * * writes the output to a GEMPAK surface file. * * * * Command line: * * dcmsfc [options] filename * * filename output file name/template * ** * * Log: * * K. Tyle/GSC 4/97 Based on DCMETR * * D. Kidwell/NCEP 10/97 Eliminated bufr references * * I. Durham/GSC 5/98 Changed underscore decl. to an include * * A. Hardy/GSC 1/01 Added full prototype * * S. Jacobs/NCEP 2/01 Removed all references to ulog * * F. J. Yen/NCEP 4/01 Added Coast Guard reports to prolog * * D. Kidwell/NCEP 1/03 Increased idfmax to MMHDRS - 1 * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Hinson/AWC 06/08 Added circflg parameter to dc_gopt * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCMSFC"; char *defprm = "msfc.pack"; char *defstn = "msfstns.tbl"; char *dfstn2 = " "; int idfadd = 25; int idfmax = MMHDRS - 1; int ndfhr1 = 5; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** 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. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ ma_dcod ( curtim, gemfil, stntbl, prmfil, &iadstn, &maxtim, &nhours, &iret, strlen(curtim), strlen(gemfil), strlen(stntbl), strlen(prmfil) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); return(0); }
int main ( int argc, char *argv[] ) /************************************************************************ * DCREDBOOK * * * * This program decodes REDBOOK graphics files and outputs them as * * standard graphics format files from GEMPAK device drivers. * * * * Command line: * * dcgrib [options] device * * device output file device * ** * * Log: * * Chiz/Unidata 8/00 * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCREDBOOK"; char *defprm = " "; char *defstn = " "; char *dfstn2 = " "; int idfadd = 0; int idfmax = 1; int ndfhr1 = 0; int ndfhr2 = 0; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret, ier; char gemdev[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, crcflg, iwndht; char errstr[DCMXLN]; /*---------------------------------------------------------------------*/ /* ** Initialize the output logs, set the time out and ** parse the command line parameters. dc_init calls in_bdta in 5.4.3+. */ dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret ); /* ** Check for an initialization error. ** On an error, exit gracefully. */ if (( iret < 0 )&&(iret != -11)) { sprintf ( errstr, "Error initializing\0" ); dc_wclg ( 0, "DC", iret, errstr, &ier ); dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &crcflg, &iwndht, &iret ); /* ** The if the output file name is not present, use gribkey table ** ** Change this section for the specific decoder. */ strcpy ( gemdev, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ decode_redbook (gemdev, stntbl, &iret); /* ** Send shut down message and close the log files. */ dc_exit ( &iret ); }
int main ( int argc, char *argv[] ) /************************************************************************ * DCTAF * * * * This program decodes TAF reports and writes the output to a GEMPAK * * surface forecast file. * * * * Command line: * * dctaf [options] filename * * filename output file name/template * ** * * Log: * * D. Kidwell/NCEP 9/02 Based on DCMETR * * A. Hardy/NCEP 12/02 Changed stn tbl sfstns.tbl->tafstn.tbl * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Lin/NCEP 04/08 Modified fcst times from 24 to 30 * * L. Hinson/AWC 06/08 Added circflg to dc_gopt and call to * * tf_dcod * * S. Jacobs/NCEP 3/14 Added black list station table * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCTAF"; char *defprm = "taf.pack"; char *defstn = "tafstn.tbl"; char *dfstn2 = "tafblacklist.tbl"; int idfadd = 25; /* idfmax was set to 24 - default number of forecast time ** now it has been changed to 30 */ int idfmax = 30; int ndfhr1 = 5; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** 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. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ tf_dcod ( curtim, gemfil, stntbl, stntb2, prmfil, &iadstn, &maxtim, &nhours, &circflg, &iret, strlen(curtim), strlen(gemfil), strlen(stntbl), strlen(stntb2), strlen(prmfil) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); }
int main(int argc, char *argv[], char *envp[]) { char clength[4]; char *block = (char *)malloc(8192), *oblock = (char *)malloc(262144); unsigned isize = 8192, osize=262144, olength; int length, go; int compress = 0; char *logfname = ""; int bzip2 = 1; int filter = 0; int fd; char stid[5]={0}; #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCNEXR2"; char *defprm = " "; char *defstn = " "; char *dfstn2 = " "; int idfadd=0; int idfmax=0; int ndfhr1=0; int ndfhr2=0; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], newfil[DCMXLN], curtim[DCMXLN]; int i, j, num, iret, ier; char stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, crcflg, iwndht; char errstr[DCMXLN]; extern int optind, opterr; extern char *optarg; int ch; long flen; if(atexit(cleanup) != 0) { printf("could not register exit routine\n"); } /* ** Initialize the output logs, set the time out and ** parse the command line parameters. dc_init calls in_bdta in 5.4.3+. */ /* * process some extra arguments "fC:" for this routine */ num = argc; i = 1; while ( i < num ) { if ( strcmp(argv[i], "-f") == 0 ) { num--; filter = 1; for ( j = i+1; j < argc; j++ ) argv[j-1] = argv[j]; continue; } if ( strcmp(argv[i], "-C") == 0 ) { /* optional compression specification for future use */ num-=2; for ( j = i+2; j < argc; j++ ) argv[j-2] = argv[j]; continue; } i++; } argc = num; dc_init ( prgnam, argc, argv, nexp, parms, &num, &iret ); /* ** Check for an initialization error. ** On an error, exit gracefully. */ if ( iret == -11 ) { fd = 1; } else if ( iret < 0 ) { sprintf ( errstr, "Error initializing\0" ); dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit ( &iret ); } else { char *cpos = strrchr(parms[0],'/'); if ( cpos == NULL ) sprintf(filnam,".%s\0",parms[0]); else { strncpy(filnam,parms[0],cpos - parms[0]+1); strncat(filnam,".",1); strcat(filnam,cpos+1); } cfl_inqr ( parms[0], NULL, &flen, newfil, &iret ); if(iret != 0) { filptr = parms[0]; strcpy(newfil,filnam); sprintf ( errstr, "new output file %s\0",newfil); dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); } if ((fd=mkdirs_open(newfil,O_WRONLY | O_CREAT, 0664)) == -1) { sprintf ( errstr, "Cannot open %s\0", newfil); iret = -10; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit( &iret ); } lseek(fd, 0, SEEK_END); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &crcflg, &iwndht, &iret ); if(stntbl[0] != '\0') { strncat(stid,stntbl,4); sprintf ( errstr, "STID set to %s\0", stid ); dc_wclg ( 2, "DCNEXR2", iret, errstr, &ier ); } /* * set up signal handlers */ go = 1; while (go) { /*bufread(0, (char *)(&length), 4, &i);*/ bufread(0, clength, 4, &i); if (i != 4) { if (i > 0) { sprintf ( errstr, "Short block length\0"); iret = -5; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); } else iret = 0; dc_exit(&iret); } if ( (memcmp(clength, "ARCH", 4)==0) || (memcmp(clength, "AR2V", 4)==0) ) { memcpy(block, clength, 4); bufread(0, block+4, 20, &i); if (i != 20) { sprintf ( errstr, "Missing header\0"); iret = -5; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit( &iret); } if ( stid[0] != 0 ) memcpy(block+20,stid,4); lseek(fd, 0, SEEK_SET); write(fd, block, 24); continue; } length = 0; for(i=0;i<4;i++) length = ( length << 8 ) + (unsigned char)clength[i]; if(length < 0) { sprintf ( errstr, "EOF %ld\0",length); iret = -9; dc_wclg ( 2, "DCNEXR2", iret, errstr, &ier ); length = -length; go = 0; } if (length > isize) { isize = length; sprintf ( errstr, "Expanding input buffer to %d\0", isize); iret = -7; dc_wclg ( 2, "DCNEXR2", iret, errstr, &ier ); if ((block = (char *)realloc(block, isize)) == NULL) { sprintf ( errstr, "Cannot allocate input buffer\0"); iret = -4; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit( &iret ); } } sprintf(errstr, "read block size %d\0",length); dc_wclg ( 4, "DCNEXR2", 0, errstr, &ier ); bufread(0, block, length, &i); if (i != length) { sprintf ( errstr, "Short block read\0"); iret = -5; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit( &iret ); } if (length > 10) { int error; tryagain: olength = osize; if (bzip2 == 1) #ifdef BZ_CONFIG_ERROR error = BZ2_bzBuffToBuffDecompress(oblock, &olength, /*error = bzBuffToBuffDecompress(oblock, &olength,*/ #else error = bzBuffToBuffDecompress(oblock, &olength, #endif block, length, 0, 0); if (error) { if (error == BZ_OUTBUFF_FULL) { osize += 262144; sprintf(errstr, "Expanding output buffer to %d\0", osize); iret = -7; dc_wclg ( 2, "DCNEXR2", iret, errstr, &ier ); if ((oblock=(char*) realloc(oblock, osize)) == NULL) { sprintf(errstr, "Cannot allocate output buffer\0"); iret = -4; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit(&iret); } goto tryagain; } sprintf(errstr, "decompress error - %d\0", error); iret = -5; dc_wclg ( 0, "DCNEXR2", iret, errstr, &ier ); dc_exit( &iret); } if (filter) { int i; for (i=0; i < olength; i += 2432) { struct packet *packet=(struct packet *) (oblock+i); if (packet->type != 2 || packet->rad_status != 28) write(fd, oblock+i, 2432); } } else write(fd, oblock, olength); } nbull++; }
int main ( int argc, char *argv[] ) /************************************************************************ * DCFFG * * * * This program decodes flash flood guidance data and writes the output * * to a GEMPAK file. * * * * Command line: * * dcffgu [options] filename * * filename output file name/template * ** * * Log: * * L. Sager/NCEP 5/96 Copied from DCNMOS * * S. Maxwell/GSC 6/96 Changed ffguid.pack to ffg.pack; * * Updated documentation * * S. Jacobs/NCEP 6/96 Changed atoi to cst_numb * * S. Jacobs/NCEP 7/96 Changed call to DC_INIT; Added DC_GOPT; * * Reorganized the code * * K. Tyle/GSC 3/97 Changed iadstn to 25 * * I. Durham/GSC 5/98 Changed underscore decl. to an include * * A. Hardy/GSC 1/01 Added full prototype * * S. Jacobs/NCEP 2/01 Removed all references to ulog * * m.gamazaychikov/SAIC 07/05 Added parameters to CS of dc_gopt * * H. Zeng/SAIC 08/05 Added parameters to CS of dc_gopt * * L. Hinson/AWC 06/08 Added circflg parameter to dc_gopt * ***********************************************************************/ { /* ** Change the values of these default variables for the ** specific decoder. ** ** These variables are the number of expected command line ** parameters; the program name; the packing and station tables; ** values for the the number of additional stations and the ** number of times; and the number of hours, prior to the ** "current" time, to decode. */ #define NUMEXP 1 int nexp = NUMEXP; char *prgnam = "DCFFG"; char *defprm = "ffg.pack"; char *defstn = "ffgzon.stn"; char *dfstn2 = " "; int idfadd = 25; int idfmax = 24; int ndfhr1 = 24; int ndfhr2 = 24; int idfwdh = 0; /* ** Do not change these variables. These variables are used by all ** decoders for getting the command line parameters. */ char parms[NUMEXP][DCMXLN], curtim[DCMXLN]; int num, iret; char gemfil[DCMXLN], stntbl[DCMXLN], stntb2[DCMXLN], prmfil[DCMXLN]; int iadstn, maxtim, nhours, txtflg, circflg, iwndht; /*---------------------------------------------------------------------*/ /* ** 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. ** On an error, exit gracefully. */ if ( iret < 0 ) { dc_exit ( &iret ); } /* ** Set the decoder parameters to the command line entries or ** default values. */ dc_gopt ( defprm, defstn, dfstn2, idfadd, idfmax, ndfhr1, ndfhr2, idfwdh, prmfil, stntbl, stntb2, &iadstn, &maxtim, curtim, &nhours, &txtflg, &circflg, &iwndht, &iret ); /* ** The output file name must be present. ** ** Change this section for the specific decoder. */ strcpy ( gemfil, parms[0] ); /* ** Call the decoding routine. ** ** Change this function call, and the define command, ** for the specific decoder. */ dcffcd ( curtim, gemfil, prmfil, stntbl, &iadstn, &maxtim, &nhours, &txtflg, &iret, strlen(curtim), strlen(gemfil), strlen(prmfil), strlen(stntbl) ); /* ** Send a shut down message to the logs and close the log files. */ dc_exit ( &iret ); return 0; }