bufr2synop 0.24.0
Functions
bufr2tac_sqparse.c File Reference

file with the code to parse a sequence of descriptors for a subset More...

#include "bufr2tac.h"
Include dependency graph for bufr2tac_sqparse.c:

Go to the source code of this file.

Functions

int find_descriptor (int *haystack, size_t nlst, int needle)
 Try to find a descriptor in an array. More...
 
int find_descriptor_interval (int *haystack, size_t nlst, int needlemin, int needlemax)
 
int parse_subset_sequence (struct metreport *m, struct bufr_subset_sequence_data *sq, struct bufr2tac_subset_state *st, int *kdtlst, size_t nlst, int *ksec1, char *err)
 Parse a sequence of expanded descriptors for a subset. More...
 

Detailed Description

file with the code to parse a sequence of descriptors for a subset

Definition in file bufr2tac_sqparse.c.

Function Documentation

◆ find_descriptor()

int find_descriptor ( int *  haystack,
size_t  nlst,
int  needle 
)

Try to find a descriptor in an array.

Parameters
haystackarray of integers as descriptors
nlstnumber of descriptors in array
needledescriptor to find

it returns 1 if found, 0 otherwise.

Definition at line 35 of file bufr2tac_sqparse.c.

36{
37 size_t i = 0;
38 while ( ( i < nlst ) && ( haystack[i] != needle ) )
39 {
40 i++;
41 }
42 return ( i < nlst );
43}

Referenced by parse_subset_sequence().

Here is the caller graph for this function:

◆ find_descriptor_interval()

int find_descriptor_interval ( int *  haystack,
size_t  nlst,
int  needlemin,
int  needlemax 
)

Definition at line 59 of file bufr2tac_sqparse.c.

60{
61 size_t i = 0;
62
63 while ( ( i < nlst ) && ( haystack[i] > needlemax || haystack[i] < needlemin ) )
64 {
65 i++;
66 }
67 return ( i < nlst );
68}

Referenced by parse_subset_sequence().

Here is the caller graph for this function:

◆ parse_subset_sequence()

int parse_subset_sequence ( struct metreport m,
struct bufr_subset_sequence_data sq,
struct bufr2tac_subset_state st,
int *  kdtlst,
size_t  nlst,
int *  ksec1,
char *  err 
)

Parse a sequence of expanded descriptors for a subset.

Parameters
mpointer to a struct metreport where to set the data
sqpointer to a struct bufr_subset_sequence_data where the values for sequence of descriptors for a subset has been decoded
stpointer to a struct bufr2tac_subset_state
kdtlstarray of integers with descriptors
nlstnumber of descriptors in kdtlst
ksec1array of auxiliar integers decoded by bufrdc ECMWF library
errstring where to write errors if any

Definition at line 81 of file bufr2tac_sqparse.c.

82{
83 /* Clean the state */
84 memset ( st, 0, sizeof ( struct bufr2tac_subset_state ) );
85
86 /* First task to do is figure out the type of report */
87 switch ( ksec1[5] )
88 {
89 case 0:
90 if ( find_descriptor_interval ( kdtlst, nlst, 307071, 307073 ) )
91 {
92 strcpy ( st->type_report, "CLIMAT" ); // FM-71 CLIMAT
93 }
94 else if ( find_descriptor_interval ( kdtlst, nlst, 307079, 307086 ) ||
95 find_descriptor ( kdtlst, nlst,307091 ) ||
96 find_descriptor ( kdtlst, nlst,307092 ) ||
97 find_descriptor ( kdtlst, nlst,307096 ) ||
98 find_descriptor ( kdtlst, nlst,307182 ) ||
99 ksec1[6] == 0 || ksec1[6] == 1 || ksec1[6] == 2 )
100 {
101 strcpy ( st->type_report,"AAXX" ); // FM-12 synop
102 }
103 else if ( find_descriptor ( kdtlst, nlst,307090 ) ||
104 find_descriptor ( kdtlst, nlst,301092 ) ||
105 ksec1[6] == 3 || ksec1[6] == 4 || ksec1[6] == 5 )
106 {
107 strcpy ( st->type_report,"OOXX" ); // FM-14 synop-mobil
108 }
109 break;
110 case 1:
111 if ( find_descriptor_interval ( kdtlst, nlst, 308004, 308005 ) ||
112 find_descriptor ( kdtlst, nlst,301093 ) ||
113 find_descriptor ( kdtlst, nlst,308009 ) ||
114 find_descriptor ( kdtlst, nlst,1011 ) )
115 {
116 strcpy ( st->type_report,"BBXX" ); // FM-13 ship
117 }
118 else if ( find_descriptor_interval ( kdtlst, nlst, 308001, 308003 ) ||
119 find_descriptor ( kdtlst, nlst,315008 ) ||
120 find_descriptor ( kdtlst, nlst,315009 ) ||
121 find_descriptor ( kdtlst, nlst,1005 ) ||
122 find_descriptor ( kdtlst, nlst,2036 ) ||
123 find_descriptor ( kdtlst, nlst,2149 ) ||
124 ksec1[6] == 25 )
125 {
126 strcpy ( st->type_report,"ZZYY" ); // FM-18 buoy
127 }
128 else if ( find_descriptor_interval ( kdtlst, nlst, 308011, 308013 ) )
129 {
130 strcpy ( st->type_report, "CLIMAT SHIP" ); // FM-71 CLIMAT SHIP
131 }
132 else if ( find_descriptor ( kdtlst, nlst,307090 ) )
133 {
134 // FIXME Some FM-14 are coded as category 1
135 strcpy ( st->type_report,"OOXX" ); // FM-14 synop-mobil
136 }
137 break;
138 case 2:
139 if ( find_descriptor_interval ( kdtlst, nlst, 309050, 309051 ) )
140 {
141 strcpy ( st->type_report,"PPXX" ); // PILOT, PILOT SHIP, PILOT DROP or PILOT MOBIL
142 }
143 else if ( find_descriptor ( kdtlst, nlst, 309052 ) ||
144 find_descriptor ( kdtlst, nlst, 309057 )
145 )
146 {
147 strcpy ( st->type_report,"TTXX" ); // TEMP, TEMP SHIP, TEMP MOBIL
148 }
149 break;
150 default:
151 sprintf ( err, "The data category %d is not parsed at the moment", ksec1[5] );
152 return 1;
153 }
154
155
156 if ( st->type_report[0] == '\0' )
157 {
158 sprintf ( err, "Cannot find the report type\n" );
159 return 1;
160 }
161
162 //if(DEBUG)
163 // printf("Going to parse a %s report\n", st->type_report);
164
165
166 if ( strcmp ( st->type_report,"AAXX" ) == 0 || strcmp ( st->type_report,"BBXX" ) == 0 || strcmp ( st->type_report,"OOXX" ) == 0 )
167 {
168 // Parse FM-12, FM-13 and FM-14
169 if ( parse_subset_as_synop ( m, st, sq, err ) == 0 )
170 {
173 return print_synop_report ( m );
174 }
175
176 }
177 else if ( strcmp ( st->type_report,"ZZYY" ) == 0 )
178 {
179 // parse BUOY
180 if ( parse_subset_as_buoy ( m, st, sq, err ) == 0 )
181 {
184 return print_buoy_report ( m );
185 }
186 }
187 else if ( strcmp ( st->type_report,"TTXX" ) == 0 )
188 {
189 // psrse TEMP
190 if ( parse_subset_as_temp ( m, st, sq, err ) == 0 )
191 {
194 return print_temp_report ( m );
195 }
196 }
197 else if ( strcmp ( st->type_report,"CLIMAT" ) == 0 )
198 {
199 // psrse CLIMAT
200 if ( parse_subset_as_climat ( m, st, sq, err ) == 0 )
201 {
204 return print_climat_report ( m );
205 }
206 }
207
208 // when reached this point we have han error
211 return 1;
212}
int BUFR2TAC_DEBUG_LEVEL
Definition: bufr2tac.c:31
int parse_subset_as_synop(struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
parses a subset sequence as an Land fixed SYNOP FM-12, SHIP FM-13 or SYNOP-mobil FM-14 report
int print_buoy_report(struct metreport *m)
prints a buoy into a string
int parse_subset_as_temp(struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
Definition: bufr2tac_temp.c:75
int print_climat_report(struct metreport *m)
prints a climat into a string
int parse_subset_as_climat(struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
int print_synop_report(struct metreport *m)
prints a synop into a string
int bufr2tac_print_error(struct bufr2tac_error_stack *e)
int parse_subset_as_buoy(struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
Definition: bufr2tac_buoy.c:74
int print_temp_report(struct metreport *m)
print the four parts of a decoded TEMP report from a BUFR file into strings
int find_descriptor(int *haystack, size_t nlst, int needle)
Try to find a descriptor in an array.
int find_descriptor_interval(int *haystack, size_t nlst, int needlemin, int needlemax)
stores information needed to parse a sequential list of expanded descriptors for a subset
Definition: bufr2tac.h:246
char type_report[16]
Definition: bufr2tac.h:247
struct bufr2tac_error_stack e
Definition: bufr2tac.h:248

References BUFR2TAC_DEBUG_LEVEL, bufr2tac_print_error(), bufr2tac_subset_state::e, find_descriptor(), find_descriptor_interval(), parse_subset_as_buoy(), parse_subset_as_climat(), parse_subset_as_synop(), parse_subset_as_temp(), print_buoy_report(), print_climat_report(), print_synop_report(), print_temp_report(), and bufr2tac_subset_state::type_report.

Referenced by bufrtotac_parse_subset_sequence().

Here is the call graph for this function:
Here is the caller graph for this function: