[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[McIDAS #NPS-283856]: XCD change



Hi Kevin,

re:
> Good to see you at the MUG Meeting.

It was great to meet you in person!

> I can put in that change that you mentioned I needed to make in
> DMGRID/DMBIN for Sun.

Excellent.  I really appreciate this!

> Let me know what it is.

Here are changes needed in dmgrid.pgm and dmbin.pgm:

dmgrid.pgm:

line 296:

change:

        ok = m0grabyt(spool , ptfile , slpflg , 4 , 4 , 0 , temp , 
     &                numret , loc , reset)
        call movc(1,temp,3,version,0)


to:
        ok = m0grabyt(spool , ptfile , slpflg , 4 , 4 , 0 , temp ,
     &                numret , loc , reset)
        call movc(1,temp,3,version,3)
        call swbyt4(version,1)

I suggest letting the user know that a certain GRIB message has been
rejected:

line 345:

change:

c          call sdest('GRIB-2 not supported in DMGRID',0)

to:

           call edest('GRIB-x not supported in DMGRID', version)


The mod(s) to dmbin.pgm are virtually identical:

line 334:

change:

           ok = m0grabyt(spool , ptfile , slpflg , 4 , 4 , 0 , temp ,
     &                numret , loc , reset)
           call movc(1,temp,3,version,0)


to:

           ok = m0grabyt(spool , ptfile , slpflg , 4 , 4 , 0 , temp ,
     &                numret , loc , reset)
           call movc(1,temp,3,version,3)
           call swbyt4(version,1)


Also, if by some chance the unpacked GRIB type is not 1 or 2, then
skip the GRIB message but keep processing:

line 383:

change:

             else
               write(cline,FMT='(a11,1x,i8,1x,a30,1x,i15)') 'GRIB Vsn ='
     &           , version, 'is not supported, spool loc =', loc
               goto 2000
             endif


to:

             else 
               write(cline,FMT='(a11,1x,i8,1x,a30,1x,i15)') 'GRIB Vsn ='
     &           , version, 'is not supported, spool loc =', loc
               call edest(cline,0)
               goto 100
             endif 


Those are the changes that are necessary to allow DMGRID/DMBIN to run
on big-endian systems.  There is another change that is needed to correctly
process fields that have been excluded from being decoded/filed through
the NOGRIB.CFG mechanism:

xcdgrib.c

Line 343:

change:

  if (ok)
  {
    return (0);
    /*return (-20);*/
  }

to:

  { 
    /* return (0) */;
    return (-20);
  }

Line 3614:

change:

  ok = Mcgribdecoder ((void *) input , *n_bytes , &is , &pds , &gds ,
                    &bms , &bds , &actual_data[0] ,
                    &gbtab000 , &gbtab002 , &gbtab004 ,
                    &gbtab00a , &gbtab00b , t_file);


   if (ok < 0) {

        (void)sprintf(errstr,"Could not decode GRIB file, ok = %d ",ok);
        M0sxtrce(errstr);
        return(-1000+ok);
   }    

to:

  ok = Mcgribdecoder ((void *) input , *n_bytes , &is , &pds , &gds ,
                    &bms , &bds , &actual_data[0] ,
                    &gbtab000 , &gbtab002 , &gbtab004 ,
                    &gbtab00a , &gbtab00b , t_file);

  
   if (ok < 0) {
      
        (void)sprintf(errstr,"Could/did not decode GRIB file, ok = %d ",ok);
        M0sxtrce(errstr);
        return(-1000+ok);
   }


Then, another change has to be made in dmgrid.pgm:

Line 360:

change:

      decok = mcgrb2mc(buffer,msglen,header,grddat,MAXGRIDPT,
     &                 flag,geotyp,ndecfl)
c      call mciydtocyd (header(4), gday)
      gday=header(4)
      header(21) = gribat

      if (decok .lt. 0 .and. decok .ne. -20)then
         call getday(curday)
         call gettim(curtim)
         write(cline,FMT='(2x,a14,1x,i8,1x,a11,1x,i12,1x,i5,1x,i6.6)')
     &     'decoder error ',decok,'message at ',gribat,curday,curtim
         call sdest(cline,0)
         ok = m0dmlog (3, cline)
         write(cline,FMT=
     &    '(5x,a5,i4,1x,a6,i4,1x,a4,i6,1x,2(a3,i6,1x),a4,i4,1x)')
     &    'parm=',header(50),'model=',header(51),
     &    'lev=',header(10),'rt=',header(5),'vt=',header(6),
     &    'geo=',header(49)
         call sdest(cline,0)
      endif 

to:
      decok = mcgrb2mc(buffer,msglen,header,grddat,MAXGRIDPT,
     &                 flag,geotyp,ndecfl)
c      call mciydtocyd (header(4), gday)
      gday=header(4)
      header(21) = gribat

      if (decok .lt. 0 .and. decok .ne. -20)then
         call getday(curday)
         call gettim(curtim)
         ! <<<<< UPC mod 20061022 - -1020 return -> NOGRIB.CFG exclusion >>>>>>
         if ( decok .ne. -1020 ) then
           write(cline,FMT='(2x,a14,1x,i8,1x,a11,1x,i12,1x,i5,1x,i6.6)')
     &     'decoder error ',decok,'message at ',gribat,curday,curtim
           call sdest(cline,0)
           ok = m0dmlog (3, cline)
           write(cline,FMT=
     &      '(5x,a5,i4,1x,a6,i4,1x,a4,i6,1x,2(a3,i6,1x),a4,i4,1x)')
     &      'parm=',header(50),'model=',header(51),
     &      'lev=',header(10),'rt=',header(5),'vt=',header(6),
     &      'geo=',header(49)
           call sdest(cline,0)
         else
           write(cline,FMT='(2x,a24,1x,i12,1x,i5,1x,i6.6)')
     &     'NOGRIB.CFG exclusion at ',gribat,curday,curtim
           ok = m0dmlog (2, cline)
         endif
      endif

Without the modifications to xcdgrib.c, GRIB messages marked for exclusion
from decoding are not handled correctly: the return from Mcgribdecoder
would be 0 (zero) which indicates that the Mcgribdecoder processing was
successful when, in fact, the processing was skipped.  This will cause errors
when processing past the Mcgribdecoder call is attempted. 

When the -20 return from Mcgribdecoder is reinstated, a corresponding
change needs to be made in dmgrid.pgm to let the user know that the
GRIB message was skipped because of a NOGRIB.CFG setting, not because
the GRIB message was bad.

Two other XCD routines need modifications, both for the same reason:

obtgserv.cp
wtxgserv.cp

Both declare variables used as the third parameter to Mcdaytimetosec as
'time_t *' when they should be 'int *':

obtgserv.cp:

Line 677:

  time_t        oldestsecs;  /* oldest seconds allowed */

Line 890:

    ok = Mcdaytimetosec (oldestday, oldesthour, &oldestsecs);

wtxgserv.cp:

Lines 872, 873, 882:

      static time_t s_secs;             /* starting time seconds */
      static time_t e_secs;             /* ending time seconds */
 ...
      time_t    w_secs;                 /* seconds from WMO header day/time */

Lines 890, 891, 917:

         ok = Mcdaytimetosec (search_start_day, start_time, &s_secs);
         ok = Mcdaytimetosec (search_end_day, end_time, &e_secs);
 ...
      ok = Mcdaytimetosec (w_day, w_time, &w_secs);


In all 4 variable declarations listed above, 'time_t' should be replaced by 
'int'.


The changes in obtgserv.cp and wtxgserv.cp are needed to:

1) match the function declaration of Mcdaytimetosec in daytime.c:

   Line 428:

   int Mcdaytimetosec (int day, int hms, int *secs)

   NOTE: the documentation header to Mcdaytimetosec, which is converted into
   a man page, is incorrect and misleading:

   Line 397:

   *$ Interface:
   *$      include "time.h"
   *$      int
   *$      Mcdaytimetosec (int day, int hms, time_t *secs)


   This should be:

   *$ Interface:
   *$      int
   *$      Mcdaytimetosec (int day, int hms, int *secs)


2) build XCD in 64-bit mode where a 'time_t' is not likely to be the same
   size as an 'int'.


The above changes have been made in Unidata McIDAS-X and have not been
seen to have any impact on any functionality for 32-bit builds.  Again,
they are mandatory for 64-bit builds!

Cheers,

Tom
****************************************************************************
Unidata User Support                                    UCAR Unidata Program
(303) 497-8642                                                 P.O. Box 3000
address@hidden                                   Boulder, CO 80307
----------------------------------------------------------------------------
Unidata HomePage                       http://www.unidata.ucar.edu
****************************************************************************


Ticket Details
===================
Ticket ID: NPS-283856
Department: Support McIDAS
Priority: Normal
Status: Closed