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

20000929: nagrib cannot handle gribs with BMS section



------- Forwarded Message

>To: address@hidden
>From: Harry Edmon <address@hidden>
>Subject: nagrib cannot handle gribs with BMS section
>Organization: UCAR/Unidata
>Keywords: 200009291724.e8THO0b00319

*************************************************************************
* This message has been formatted as a MIME message.  If you are reading
* this, your mail reader does not support MIME.  To display the non-text
* portions of this message you will need a MIME-capable mail reader such
* as Ishmail (address@hidden).
*************************************************************************

------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/enriched

The gempak program nagrib cannot properly handle a GRIB file with a BMS
section. 


I have a proposed fix, which includes a new subroutine.


Here is the diff for nagrib.f:



------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/plain
Content-Disposition: attachment;
        filename=nagrib.diff

*** nagrib.f.dst        Wed Aug 25 14:26:00 1999
--- nagrib.f    Fri Sep 29 09:49:57 2000
***************
*** 363,368 ****
--- 363,371 ----
  C*                            If it is OK, process the grid.
  C
                                IF  ( gsflag )  THEN
+                                   IF ( jisbms ) THEN
+                                       CALL GB_GBMS ( iret )
+                                   ENDIF
                                    CALL GB_GBDH ( length,
       +                                                   ibflag, i2scl, ref,
       +                                                   nbits, iret )

------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/enriched





Here is the new routine in source/gemlib/gb called gbgbms.c:



------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/plain
Content-Disposition: attachment;
        filename=gbgbms.c

#include "gbcmn.h"

void    gb_gbms_ ( iret )
int     *iret;

/************************************************************************
 * gb_gbms                                                              *
 *                                                                      *
 * This function gets the GRIB data from GB_BMS.   Currently it just    *
 * sets bmslength.                                                      *
 * grid of floating point numbers.                                      *
 *                                                                      *
 * gb_gbms ( iret )                                                     *
 *                                                                      *
 * Output parameters:                                                   *
 *      *iret           int             Return code                     *
 *                                           +5 = BDS too short         *
 *                                          -16 = Error on next msg     *
 *                                          -18 = Invalid bitmap        *
 ***********************************************************************/

{
int             offset, ret, nbytes, indx;
unsigned char   *buffer;
/*---------------------------------------------------------------------*/

        *iret = 0;

        /*
         *      Read the BMS to get the bitmap.
         */
        offset = cursor + ISLENGTH + pdslength + gdslength;
        /* 
         *      Allocate space for the buffer.
         */
        buffer = (unsigned char *)
                  malloc ( 3 * sizeof(unsigned char) );
            cfl_seek ( gbfile.fptr, offset, SEEK_SET, &ret );
            cfl_read ( gbfile.fptr, 3, buffer, &nbytes, &ret );
            if ( ret != 0 ) {
                *iret = -16;
                return;
            }

            indx = 0;
            bmslength = gb_btoi ( buffer, indx, 3, FALSE );
            free ( buffer );
}

------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/enriched





And here is the diff for the Makefile in source/gemlib/gb:



------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/plain
Content-Disposition: attachment;
        filename=diff

*** Makefile.dst        Thu Mar 12 11:39:30 1998
--- Makefile    Fri Sep 29 09:46:49 2000
***************
*** 27,32 ****
--- 27,33 ----
        $(ALIB)(gbends.o) \
        $(ALIB)(gbensemble.o) \
        $(ALIB)(gbgaus.o) \
+       $(ALIB)(gbgbms.o) \
        $(ALIB)(gbgds.o) \
        $(ALIB)(gbges.o) \
        $(ALIB)(gbggds.o) \

------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Type: text/enriched




------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb
Content-Description: Signature
Content-Type: text/plain


--
Dr. Harry Edmon                 E-MAIL: address@hidden
(206) 543-0547                  FAX:    (206) 543-0308
Dept of Atmospheric Sciences
University of Washington, Box 351640, Seattle, WA 98195-1640

------------9ljk3mdi0odi0mc4xodmzos5hz2z5y25rqgf0bw9zlndhc2hpb--


------- End of Forwarded Message