[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20000105: NWX Troubles
- Subject: 20000105: NWX Troubles
- Date: Wed, 5 Jan 2000 14:20:14 -0700
Chris,
I think I fixed this here in a september patch. Once we get things shipped
out to the ams- I'll consolidate all these patches again into a completely new
distribution since traking all these patches is a royal pain.
I've attatched the nwx files dir.c and txtw.c to this message. Place these
routines in your $NAWIPS/nprogs/nwx/source directory, then build with:
cd $NAWIPS/nprogs/nwx/source
make all
make install
make clean
Let me know if this clears things up.
Steve Chiswell
Unidata User Support
On Wed, 5 Jan 2000, Unidata Support wrote:
>
> ------- Forwarded Message
>
> >To: Steve Chiswell <address@hidden>
> >From: "C. Vandersip" <address@hidden>
> >Subject: NWX Troubles
> >Organization: .
> >Keywords: 200001051908.MAA15700
>
> Steve,
>
> Have been unable to get new NWX to work properly. Typical message is "No
> data available" for all products. I've read the archives and think I
> understand how nwx finds the sao sources. Here's how our pqact.conf is
> setup:
>
> WMO ^S[AP].* .... ([0-3][0-9])([0-2][0-9])
> STDIOFILE data/surface/sao/(\1:yyyy)(\1:mm)\1\2_sao.wmo
>
> which produces files in this format:
>
> 2000010517_sao.wmo
>
>
> The relevant Gemenviron variables are:
>
> setenv LDMDATA /export/data/
> setenv RAW_SAO $LDMDATA/surface/sao
>
>
> System is Solaris 2.5, nawips5.4pl14.
>
>
> Seems all is setup OK and I don't see a file similar to the one for
> nsharp, so I'm befuddled.
>
> Thanks,
>
> Chris
>
> ###############################################################
> # Chris Vandersip #
> # Computer Research Specialist/Dept. Sysadmin #
> # Rm. 024, Dept. of Meteorology, Florida State University #
> # address@hidden (850)644-2522 #
> ###############################################################
>
>
> ------- End of Forwarded Message
>
>
#include "gui.h"
#include "geminc.h"
#ifdef UNDERSCORE
#define cfdate cfdate_
#endif /* UNDERSCORE */
/*
* Micro to set the date/time based on the input and
* current date/time.
*/
#define SET_DTTM(dttm, curdttm) {\
if ( dttm.year == 0 ) \
dttm.year = curdttm.year; \
if ( dttm.month == 0 ) \
dttm.month = curdttm.month; \
if ( dttm.day == 0 ) \
dttm.day = curdttm.day; \
if ( dttm.hour > 24 ) \
dttm.hour = curdttm.hour; \
}
void dir_getflist();
void dir_getnextf();
int _select_dir ();
char _sdttm[9], _edttm[9]; /* date/time constraints */
char _exten[9]; /* file extension */
int _extlen, _dttmlen;
/************************************************************************
* dir.c *
* *
* This module scans the directory for desired data files. *
* *
* CONTENTS: *
* dir_getflist() get the desired file lists in the directory. *
* dir_getnextf() get the latest file in the file list. *
* _select_dir() internal function used in dir_getfiles to *
* select files with matched extention and time *
* constraints. *
***********************************************************************/
/*=====================================================================*/
void dir_getflist ( dtyp_info, idtyp, startdttm, enddttm, dir_info, iret )
struct datatype_list *dtyp_info;
int idtyp;
struct date_time_info startdttm;
struct date_time_info enddttm;
struct directory_info *dir_info;
int *iret;
/************************************************************************
* dir_getflist *
* *
* This routine will scan the data directory for the existing file *
* names. Only the files matching the requested file extension and *
* the time constraits will be returned. *
* The file names will be sorted in alphabetical order, which based *
* on our yymmdd.ext data file naming convention, the latest appear *
* as the last file in the file list. *
* *
* Input parameters: *
* *dtyp_info struct Data type struct array *
* idtyp int Index into struct array *
* startdttm struct Start date/time information *
* enddttm struct End date/time information *
* *
* Output parameters: *
* *dir_info struct Directory struct array *
* *iret int Return code *
* *
** *
* Log: *
* S. Jacobs/NMC 7/94 *
* C. Lin/EAI 8/95 rewrite for new nwx *
***********************************************************************/
{
int i, ier;
char direxp[133];
struct dirent **namelist;
int itype;
struct date_time_info curtim;
int _select_dir();
extern int alphasort();
/*---------------------------------------------------------------------*/
*iret = G_NORMAL;
/*
* Get the current time.
*/
itype = 1;
cfdate( &itype, &curtim.year, &curtim.month, &curtim.day,
&curtim.hour, &curtim.minute, &ier );
/*
* set the starting time
*/
if ( startdttm.year == -1 )
_sdttm[0] = '\0';
else {
SET_DTTM(startdttm, curtim);
sprintf( _sdttm, "%02d%02d%02d%02d",
startdttm.year, startdttm.month,
startdttm.day, startdttm.hour );
}
/*
* set the ending time
*/
SET_DTTM(enddttm, curtim);
sprintf( _edttm, "%02d%02d%02d%02d",
enddttm.year, enddttm.month,
enddttm.day, enddttm.hour );
_dttmlen = strlen(_sdttm);
/*
* Set EXTEN for use in the SELECT_DIR function.
*/
sprintf( _exten, ".%s", dtyp_info[idtyp].filext );
_extlen = strlen(_exten);
/*
* Expand the environmental variable in the directory path.
*/
css_envr( dtyp_info[idtyp].datadir, direxp, &ier );
if ( ier == 0 ) {
strcpy( dir_info->dirpath, direxp );
}
else {
strcpy( dir_info->dirpath, dtyp_info[idtyp].datadir );
}
/*
* Scan the directory, selecting only the files with the
* correct file extension and time constraints.
*/
if ( ( dir_info->nent =
scandir( dir_info->dirpath, &namelist,
_select_dir, alphasort ) ) <= 0 ) {
*iret = -1;
return;
}
dir_info->cfilnum = dir_info->nent - 1;
/*
* Set the structure array of file names.
*/
for ( i = 0; i < dir_info->nent; i++ ) {
strcpy( dir_info->filnam[i], namelist[i]->d_name );
free( namelist[i] );
}
/*
* Free the allocated space.
*/
free(namelist);
}
/*=====================================================================*/
int _select_dir ( check )
struct dirent *check;
/************************************************************************
* _select_dir *
* *
* This function is used with the SCANDIR function to limit the search *
* to the files matching the file extension for the data type and *
* within the time constraints. *
* *
* Input parameters: *
* *check struct Structure used by SCANDIR *
* *
* Output parameters: *
* _select_dir int Function value *
* 0 = Not a valid file *
* 1 = Valid file *
** *
* Log: *
* S. Jacobs/NMC 7/94 *
* C. Lin/EAI 8/95 use strcmp instead of strstr *
* C. Lin/EAI 10/95 add time constraints checking *
***********************************************************************/
{
int len;
char *ymdhptr;
int i,nondig,itmp;
time_t file_time=0,start_time=0,end_time=0;
struct tm time_str;
/*---------------------------------------------------------------------*/
/*
* Check for the file extension, date/time constraints in the file.
*/
len = strlen(check->d_name);
/* do a Y2k and 4 digit YYYY fix */
/* find location of firts non digit */
i = 0; nondig = -1;
while((i < len)&&(nondig < 0))
{
if(! isdigit(check->d_name[i])) nondig = i;
i++;
}
if(nondig > 9) /* assume YYYYMMDDHH file naming */
ymdhptr = check->d_name + 2;
else
ymdhptr = check->d_name;
/* get start time */
if ( _sdttm != NULL )
{
sscanf(_sdttm,"%2d%2d%2d%2d",
&time_str.tm_year,&time_str.tm_mon,&time_str.tm_mday,&time_str.tm_hour);
time_str.tm_mon -= 1;
if(time_str.tm_year < 70) time_str.tm_year += 100;
time_str.tm_sec = 0;
time_str.tm_min = 0;
time_str.tm_isdst = -1;
start_time = mktime(&time_str);
}
sscanf(_edttm,"%2d%2d%2d%2d",
&time_str.tm_year,&time_str.tm_mon,&time_str.tm_mday,&time_str.tm_hour);
time_str.tm_mon -= 1;
if(time_str.tm_year < 70) time_str.tm_year += 100;
time_str.tm_sec = 0;
time_str.tm_min = 0;
time_str.tm_isdst = -1;
end_time = mktime(&time_str);
if(nondig > 7) /* dont try to make a time unless first 8 chars are
digits */
{
sscanf(ymdhptr,"%2d%2d%2d%2d",
&time_str.tm_year,&time_str.tm_mon,&time_str.tm_mday,&time_str.tm_hour);
time_str.tm_mon -= 1;
if(time_str.tm_year < 70) time_str.tm_year += 100;
time_str.tm_sec = 0;
time_str.tm_min = 0;
time_str.tm_isdst = -1;
file_time = mktime(&time_str);
}
else
file_time = 0;
if ( _sdttm != NULL ) {
if((start_time > file_time)||(file_time > end_time) ||
(strcmp(&(check->d_name[len - _extlen]), _exten) != 0) )
return ( 0 );
else
return ( 1 );
}
else {
if((file_time > end_time) ||
(strcmp(&(check->d_name[len - _extlen]), _exten) != 0) )
return ( 0 );
else
return ( 1 );
}
}
/*=====================================================================*/
void dir_getnextf ( dir_info, strtflg, file_info, iret )
struct directory_info *dir_info;
int strtflg;
struct data_file_info *file_info;
int *iret;
/************************************************************************
* dir_getnextf *
* *
* This routine will open the last file in the data directory. The *
* assumption is that dir_info only contains desired files which meets *
* file extension and date/time limits. *
* *
* dir_getnextf ( dir_info, strtflg, file_info, iret ) *
* *
* Input parameters: *
* *dir_info struct Directory information *
* strtflg int Start/resume flag *
* -1 = Resume backward *
* 0 = Start over *
* 1 = Resume foreward *
* *
* Output parameters: *
* *file_info struct Data file information *
* *iret int Return code *
* 0 -- new file *
* 2 -- no new file *
* 3 -- new file and also last file in *
* forward/backward *
* *
** *
* Log: *
* S. Jacobs/NMC 7/94 *
* C. Lin/EAI 8/95 rewrite for new nwx from nwx2.1 *
* G. Krueger/EAI 3/96 cleaned-out cfl_sopn declaration *
* L. Williams/EAI 5/96 check for daily reports *
* L. Williams/EAI 6/96 check for "S" data type *
***********************************************************************/
{
int iflno, ier;
char newfile, lastf;
struct stat fsbuf;
int i;
/*---------------------------------------------------------------------*/
*iret = G_NORMAL;
newfile = 1;
lastf = 0;
switch ( strtflg ) {
case 0: /* start over, new product */
dir_info->cfilnum = dir_info->nent - 1;
if( dir_info->nent == 1 ) { /* daily report */
lastf = 1;
}
break;
case 1: /* foreward */
/*
* check upper limit
*/
if ( dir_info->cfilnum < dir_info->nent - 1)
dir_info->cfilnum ++;
else
newfile = 0;
if ( dir_info->cfilnum == dir_info->nent-1 ) {
if ( nwxTable->dtyp_info[srchInfo.idtyp].bsflag[0] == 'S' )
dir_info->cfilnum = dir_info->nent - 2 ;
lastf = 1;
}
break;
case -1: /* backward */
/*
* check lower limit
*/
if ( dir_info->cfilnum > 0 ) {
dir_info->cfilnum --;
}
else
newfile = 0;
if ( dir_info->cfilnum == 0 ) {
if ( nwxTable->dtyp_info[srchInfo.idtyp].bsflag[0] == 'S' )
dir_info->cfilnum += 2;
lastf = 1;
}
break;
}
/*
* If new data file is found.
*/
if ( newfile ) {
sprintf( file_info->filnam, "%s/%s", dir_info->dirpath,
dir_info->filnam[dir_info->cfilnum]);
*iret = 0;
if ( lastf ) *iret = 3;
}
else {
*iret = 2;
}
return;
}
/*=====================================================================*/
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/TextF.h>
#include <Xm/BulletinB.h>
#include <Xm/Text.h>
#include <Xm/PushB.h>
#include "gui.h"
Widget txtw_create();
void txtw_prvnxtCb();
void txtw_prntbCb();
void txtw_prdgrpSet();
void txtw_dttmSet();
Widget prodtxtW; /* product group/name display */
Widget dttmtxtW; /* date/time display widget in text window */
Widget textW; /* widget to display text report */
Widget prevBtnW, nextBtnW, prntBtnW; /* previous,next,and print button */
/************************************************************************
* txtw.c *
* *
* This module creates the text display window and defines its *
* callbacks. *
* *
* CONTENTS: *
* txtw_create() creates the text report window. *
* txtw_prvnxtCb() callback for the previous and next button. *
* txtw_prntbCb() callback for the print button. *
* txtw_prdgrpSet() set the prod/group name in text window. *
* txtw_dttmSet() set date/time info in text window. *
***********************************************************************/
/*=====================================================================*/
Widget txtw_create( parent )
Widget parent;
/************************************************************************
* txtw_create *
* *
* txtw_create ( parent ) *
* *
* Input parameters: *
* parent Widget The top level widget *
* *
* Return parameters: *
* Widget The text report window widget *
** *
* Log: *
* C. Lin/EAI 8/95 restructured from nwx2.1 *
* L. Williams/EAI 5/96 remove XmNwidth, XmNheight and *
* XmNcolumns from textW *
************************************************************************/
{
Widget shell, txtform, frame, form, textbb, textcntl;
int n;
Arg wargs[10];
XmString msg;
/*---------------------------------------------------------------------*/
/*
* Create the text output window.
*/
shell = XtCreatePopupShell( "texttop",
transientShellWidgetClass, parent,
NULL, 0 );
XtVaSetValues(shell, XmNtitle, "Text Report", NULL);
/*
* MOTIF 1.1 has problem with taking out close item in mwm.
*/
if ((XmVERSION == 1) && (XmREVISION == 1))
XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
else
NxmMcloseNone(shell);
txtform = XtVaCreateWidget("textform",
xmFormWidgetClass, shell,
NULL);
/*
* widgets for group/product info and date/time info
*/
frame = XtVaCreateWidget("frame",
xmFrameWidgetClass, txtform,
XmNshadowType, XmSHADOW_IN,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
form = XtVaCreateWidget("form",
xmFormWidgetClass, frame,
NULL);
msg = XmStringCreateSimple(" ");
prodtxtW = XtVaCreateManagedWidget("prodtxtW",
xmLabelWidgetClass, form,
XmNlabelString, msg,
XmNtopAttachment, XmATTACH_POSITION,
XmNtopPosition, 20,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(msg);
dttmtxtW = XtVaCreateManagedWidget("dttmtxtW",
xmTextFieldWidgetClass, form,
XmNeditable, False,
XmNcursorPositionVisible, False,
XmNcolumns, 20,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
textbb = XtVaCreateManagedWidget( "textbb",
xmBulletinBoardWidgetClass, txtform,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, frame,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
NULL );
XtManageChild( form );
XtManageChild( frame );
/*
* create text display window.
*/
n = 0;
XtSetArg( wargs[n], XmNrows, 900 ); n++;
XtSetArg( wargs[n], XmNscrollVertical, True ); n++;
XtSetArg( wargs[n], XmNscrollHorizontal, True ); n++;
XtSetArg( wargs[n], XmNeditMode, XmMULTI_LINE_EDIT ); n++;
XtSetArg( wargs[n], XmNeditable, False); n++;
XtSetArg( wargs[n], XmNcursorPositionVisible, False); n++;
textW = XmCreateScrolledText( textbb, "textwin", wargs, n );
XtManageChild( textW );
textcntl = XtVaCreateManagedWidget( "textbb",
xmBulletinBoardWidgetClass, txtform,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, textbb,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNscrollVertical, True,
NULL );
/*
* create previous/next/print buttons
*/
prevBtnW = XtVaCreateManagedWidget( " Previous ",
xmPushButtonWidgetClass, textcntl,
XmNx, 50,
XmNy, 40,
NULL );
XtAddCallback( prevBtnW, XmNactivateCallback, txtw_prvnxtCb,
(XtPointer) -1 );
nextBtnW = XtVaCreateManagedWidget( " Next ",
xmPushButtonWidgetClass, textcntl,
XmNx, 250,
XmNy, 40,
NULL );
XtAddCallback( nextBtnW, XmNactivateCallback, txtw_prvnxtCb,
(XtPointer) 1 );
prntBtnW = XtVaCreateManagedWidget ( " Print ",
xmPushButtonWidgetClass, textcntl,
XmNx, 450,
XmNy, 40,
NULL );
XtAddCallback( prntBtnW, XmNactivateCallback, txtw_prntbCb,
NULL );
XtSetSensitive( prevBtnW, False );
XtSetSensitive( nextBtnW, False );
XtManageChild(txtform);
return(shell);
}
/*=====================================================================*/
void txtw_prvnxtCb( w, data, cb_data )
Widget w;
XtPointer data;
XtPointer cb_data;
/************************************************************************
* txtw_prvnxtbCb *
* *
* This routine is the callback for the previous/next report button. *
* The user may request the previous/next report for single stations *
* only. *
* *
* txtw_prvnxtCb ( w, data, cb_data ) *
* *
* Input parameters: *
* w Widget The input widget *
* data XtPointer The input data for the widget *
* cb_data XtPointer The callback data for the widget*
* *
** *
* S. Jacobs/NMC 8/94 *
* L. Williams/EAI 12/94 Add code to process UVI info *
* C. Lin/EAI 9/95 *
***********************************************************************/
{
int which, iret;
char tstr[25];
char *dtypflag, *datatype;
/*---------------------------------------------------------------------*/
which = (int) data;
/*
* set the flag in usrSelect structure
*/
usrSelect.prvnxt = 1;
/*
* Set the search flag.
*/
srchInfo.sflag = which;
switch ( which ) {
case -1: /* previous button */
/*
* activate next button
*/
if (!XtIsSensitive(nextBtnW) )
XtSetSensitive(nextBtnW, True);
break;
case 1: /* next button */
/*
* activate previous button
*/
if (!XtIsSensitive(prevBtnW) )
XtSetSensitive(prevBtnW, True);
break;
}
/*
* read/display the text
*/
iret = fosd_txtrd();
/*
* decode and plot data when necessary
*/
if ( (iret == 0) || (iret == -3) ) {
if ( (plotData.mode == VALUE) || (plotData.mode == GRAPHIC) ) {
fosd_decode();
fosd_plot();
}
}
if ( (iret == -6) || (iret == -3) ) {
/*
* no more previous/next report
*/
if ( which == -1 )
XtSetSensitive ( prevBtnW, False );
if ( which == 1 )
XtSetSensitive ( nextBtnW, False );
}
}
/*=====================================================================*/
void txtw_prntbCb ( w, data, cb_data )
Widget w;
XtPointer data;
XtPointer cb_data;
/************************************************************************
* txtw_prntbCb *
* *
* This routine is the callback for the print report button. *
* *
* txtw_prntbCb ( w, data, cb_data ) *
* *
* Input parameters: *
* w Widget The input widget *
* data XtPointer The input data for the widget *
* *
* Output parameters: *
* cb_data XtPointer The output data for the widget *
** *
* S. Jacobs/NMC 8/94 *
* S. Jacobs/NMC 9/94 Added print capability *
* S. Jacobs/NMC 9/94 Updated to print large files *
* C. Lin/EAI 9/95 Modified *
* G. Krueger/EAI 3/96 CFL_SWOP -> CFL_WOPN *
***********************************************************************/
{
int ier, iret;
char filnam[73];
FILE *fpout;
char command[33];
FILE *cfl_wopn ( );
/*---------------------------------------------------------------------*/
/*
* Open the temporary file.
*/
strcpy( filnam, "/tmp/nwx.prnt" );
fpout = cfl_wopn( filnam, &iret );
if ( iret != 0 ) return;
/*
* Write the text to the temporary file.
*/
if ( printText[0] )
ier = fwrite( printText, sizeof(char), strlen(printText),
fpout );
else
ier = fwrite( reportText, sizeof(char), strlen(reportText),
fpout );
fclose( fpout );
/*
* Print the temporary file to the default printer.
*/
if ( ier != 0 ) {
if (( MTMACH == MTHP )||(MTMACH == MTIRIS)) {
strcpy( command, "lp -c /tmp/nwx.prnt" );
}
else {
strcpy( command, "lpr /tmp/nwx.prnt" );
}
system( command );
sleep(5);
/*
* Remove the temporary file.
*/
unlink( filnam );
}
}
/*=====================================================================*/
void txtw_prdgrpSet()
/************************************************************************
* txtw_prdgrpSet *
* *
* This function will display the group and product name on the text *
* window as follows: *
* *
* group name: product name *
* *
* *
* void txtw_prdgrpSet() *
* *
** *
* Log: *
* L. Williams/EAI 08/95 *
* C. Lin/EAI 10/95 *
************************************************************************/
{
XmString msg;
char title[100];
char *p;
/*---------------------------------------------------------------------*/
p = (usrSelect.group)->prod[usrSelect.prod].prdname;
while ( *p ) {
if (*p == '*') *p = ' ';
p++;
}
sprintf(title, "%s: %s", (usrSelect.group)->grpname,
(usrSelect.group)->prod[usrSelect.prod].prdname);
msg = XmStringCreateSimple(title);
XtVaSetValues(prodtxtW,
XmNlabelString, msg,
NULL);
XmStringFree(msg);
}
/*=====================================================================*/
void txtw_dttmSet()
/************************************************************************
* txtw_dttmSet *
* *
* This function extracts the date from the filename and displays it on *
* the text window *
* *
* *
* void txtw_dttmSet() *
* *
** *
* Log: *
* L. Williams/EAI 08/95 *
* C. Lin/EAI 09/95 modify to use srchInfo *
* change function name *
* Chiz/Unidata 9/99 Made YYYY compatible, Y2K *
************************************************************************/
{
char *months[]={"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG",
"SEP", "OCT", "NOV", "DEC"};
char year[3], month[3], day[3], hour[3];
char date[30], filnme[20];
int m,iy;
char *ymdh;
int nondig,i;
/*---------------------------------------------------------------------*/
strcpy(filnme,
srchInfo.dir_info.filnam[srchInfo.dir_info.cfilnum]);
/* find location of firts non digit */
i = 0; nondig = -1;
while((i < strlen(filnme))&&(nondig < 0))
{
if(! isdigit(filnme[i])) nondig = i;
i++;
}
if(nondig > 9) /* assume YYYYMMDDHH file naming */
ymdh = filnme + 2;
else
ymdh = filnme;
strncpy(year, ymdh, 2);
year[2] = (char)NULL;
iy = atoi(year);
strncpy(month, ymdh+2, 2);
month[2] = (char)NULL;
m = atoi(month);
strncpy(day, ymdh+4, 2);
day[2] = (char)NULL;
strncpy(hour, ymdh+6, 2);
hour[2] = (char)NULL;
if(iy < 70)
iy += 2000;
else
iy += 1900;
sprintf(date, "%s GMT %s %s %4d", hour, day, months[m-1], iy);
XmTextFieldSetString(dttmtxtW, date);
}
/*=====================================================================*/