source: trunk/WRF.COMMON/WRFV3/external/io_grib1/MEL_grib1/display_gribhdr.c @ 3567

Last change on this file since 3567 was 2759, checked in by aslmd, 2 years ago

adding unmodified code from WRFV3.0.1.1, expurged from useless data +1M size

File size: 5.0 KB
Line 
1/* FILE:  display_gribhdr.c             10-OCT-96 by Alice Nakajima/SAIC */
2#include <stdio.h>              /* standard I/O header file     */
3#include <stdlib.h>
4
5#include "dprints.h"            /* function prototypes */
6#include "gribfuncs.h"          /* prototypes */
7
8#define COLS    10              /* # of cols to print per line */
9#define HALFWAY COLS/2          /* half of #cols */
10
11/*
12**********************************************************************
13* A. FUNCTION:   display_gribhdr
14*      do a byte dump for each of the defined GRIB Sections in the
15*      GRIB message currently stored in the Grib Header struct.
16*
17*    INTERFACE:       
18*       void display_gribhdr (gribhdr)
19*
20*    ARGUMENTS (I=input, O=output, I&O=input and output):
21*      (I)  GRIB_HDR *gribhdr;
22*           holds Grib header info to be printed to standard output;
23*   
24*    RETURNS:  nothing; 
25**********************************************************************
26*/
27#if PROTOTYPE_NEEDED
28void display_gribhdr ( GRIB_HDR *hdr)
29#else
30void display_gribhdr ( hdr)
31        GRIB_HDR *hdr;
32#endif
33{
34  char *func="dislay_gribhr";
35   unsigned char *ptr, *ptr2;
36   long  i, j, cnt, skip;
37   char title[200];
38
39   fprintf(stdout, "In %s: showing Grib msg in Grib Hdr:\n", func);
40/*
41*
42* A.1      IF (the entire_msg buffer is NULL) THEN
43*              PRINT error
44*              RETURN
45*          ENDIF
46*/
47   if (hdr->entire_msg == NULL) {
48        fprintf(stdout,"Entire Msg Buffer is Null, cannot proceed;\n");
49        goto RETURN;
50        }
51/*
52*
53* A.2      IF (sum of section lengths does not equal Total Msg length) THEN
54*              PRINT warning
55*          ELSE
56*              PRINT msg_length
57*          ENDIF
58*/
59   if (hdr->msg_length != (hdr->ids_len + hdr->pds_len + hdr->gds_len
60                           + hdr->bms_len + hdr->bds_len + hdr->eds_len))
61        fprintf(stdout,"\n*******************************************\n"\
62        "WARNING: Msg_length=%d but SUM of sect lengths= %d "\
63        "(%d+%d+%d+%d+%d+%d);\n*******************************************\n",
64        hdr->msg_length,
65        hdr->ids_len+hdr->pds_len+hdr->gds_len+hdr->bms_len+
66        hdr->bds_len+hdr->eds_len, 
67        hdr->ids_len, hdr->pds_len, hdr->gds_len , hdr->bms_len, 
68        hdr->bds_len, hdr->eds_len);
69   else 
70        fprintf(stdout,"Msg_length=%d;  IDS=%ld,"\
71        "PDS=%ld, GDS=%ld, BMS=%ld, BDS=%ld, EDS=%ld;\n",
72        hdr->msg_length,
73        hdr->ids_len, hdr->pds_len, hdr->gds_len , hdr->bms_len, 
74        hdr->bds_len, hdr->eds_len);
75
76   fprintf(stdout,"Printing each defined section, upto 100 bytes only\n");
77/*
78*
79* A.3      PRINT Identification Defn Section if defined;
80*          FUNCTION hdr_print   !dump out its content
81*/
82   if (hdr->ids_ptr == NULL)  fprintf(stdout,"Section 0 is Null, len=%ld;\n",
83        hdr->ids_len);
84   else {
85        cnt= (hdr->ids_len > 100 ? 100 : hdr->ids_len);
86        sprintf(title,"Section 0 Content Len=%ld (upto 100 bytes)", 
87        hdr->ids_len);
88        hdr_print (title, hdr->ids_ptr, cnt);
89        }
90       
91/*
92*
93* A.4      PRINT Product Defn Section if defined;
94*          FUNCTION hdr_print   !dump out its content
95*/
96   if (hdr->pds_ptr == NULL)  fprintf(stdout,"Product Data Section is Null, "\
97        "len=%ld;\n", hdr->pds_len);
98   else {
99        cnt= (hdr->pds_len > 100 ? 100 : hdr->pds_len);
100        sprintf(title,"PDS Content (offs=%ld, Len=%ld)",
101        (long)(hdr->pds_ptr - hdr->entire_msg), hdr->pds_len);
102        hdr_print (title, hdr->pds_ptr, cnt);
103        }
104           
105/*
106*
107* A.5      PRINT Grid Defn Section if defined;
108*          FUNCTION hdr_print   !dump out its content
109*/
110   if (hdr->gds_ptr == NULL)  fprintf(stdout,"Grid Defn Section is Null, "\
111        "len=%ld;\n", hdr->gds_len);
112   else {
113        cnt= (hdr->gds_len > 100 ? 100 : hdr->gds_len);
114        sprintf(title,"GDS Content (offs=%ld, Len=%ld)",
115        (long)(hdr->gds_ptr - hdr->entire_msg), hdr->gds_len);
116        hdr_print (title, hdr->gds_ptr, cnt);
117        }
118       
119/*
120*
121* A.6      PRINT Bitmap Data Section if defined;
122*          FUNCTION hdr_print   !dump out its content upto 100 bytes
123*/
124   if (hdr->bms_ptr == NULL)  fprintf(stdout,"Bitmap Section is Null, "\
125        "len=%ld;\n", hdr->bms_len);
126   else {
127        cnt= (hdr->bms_len > 100 ? 100 : hdr->bms_len);
128        sprintf(title,"BMS Content (offs=%ld, Len=%ld)",
129        (long)(hdr->bms_ptr - hdr->entire_msg), hdr->bms_len);
130        hdr_print (title, hdr->bms_ptr, cnt);
131        }
132       
133/*
134*
135* A.7      PRINT Binary Defn Section if defined;
136*          FUNCTION hdr_print   !dump out its content upto 100 bytes
137*/
138   if (hdr->bds_ptr == NULL)  fprintf(stdout,"Binary Data Section is Null, "\
139        "len=%ld;\n", hdr->bds_len);
140   else {
141        cnt= (hdr->bds_len > 100 ? 100 : hdr->bds_len);
142        sprintf(title,"BDS Content (offs=%ld, Len=%ld)",
143        (long)(hdr->bds_ptr - hdr->entire_msg), hdr->bds_len);
144        hdr_print (title, hdr->bds_ptr, cnt);
145        }
146       
147/*
148*
149* A.8      PRINT End Defn Section if defined;
150*          FUNCTION hdr_print   !dump out its content
151*/
152   if (hdr->eds_ptr == NULL)  fprintf(stdout,"End Data Section is Null, "\
153        "len=%ld;\n", hdr->eds_len);
154   else {
155        cnt= (hdr->eds_len > 100 ? 100 : hdr->eds_len);
156        sprintf(title, "End Data Section (offs=%ld, size=%ld) ",
157        (long) (hdr->eds_ptr - hdr->entire_msg), hdr->eds_len); 
158        hdr_print (title, hdr->eds_ptr, cnt);
159        }
160
161RETURN:
162/*
163*
164* A.9      RETURN to caller  !return nothing
165*/
166   fprintf(stdout, "%s complete;\n", func);
167   return;
168
169/*
170*
171* END OF FUNCTION
172*
173*
174*/
175}
Note: See TracBrowser for help on using the repository browser.