bufr2synop 0.24.0
bufr2tac_print_climat.c
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013-2018 by Guillermo Ballester Valor *
3 * gbv@ogimet.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20/*!
21 \file bufr2tac_print_climat.c
22 \brief file with the code to print the results for climat reports
23 */
24#include "bufr2tac.h"
25
26/*!
27 \fn size_t print_climat_sec0 (char **sec0, size_t lmax, struct climat_chunks *cl)
28 \brief Prints the climat section 0 (header)
29 \param sec0 the pointer where to print section
30 \param lmax max length permited
31 \param cl pointer to s atruct \ref climat_chunks where the parse results are set
32*/
33size_t print_climat_sec0 ( char **sec0, size_t lmax, struct climat_chunks *cl )
34{
35 char *c = *sec0;
36 size_t used = 0;
37
38 used += snprintf ( c + used, lmax - used, "%s%s%s%s%s", cl->e.YYYY, cl->e.MM, cl->e.DD, cl->e.HH, cl->e.mm );
39
40 // Print type
41 used += snprintf ( c + used, lmax - used, " CLIMAT" );
42
43 // print MMJJJ
44 used += snprintf ( c + used, lmax - used, " %s%s", cl->s0.MM, cl->s0.JJJ );
45
46
47 // print IIiii
48 if ( cl->s0.II[0] )
49 {
50 used += snprintf ( c + used, lmax - used, " %s%s", cl->s0.II, cl->s0.iii );
51 }
52
53 *sec0 = c + used;
54 return used;
55}
56
57/*!
58 \fn size_t print_climat_sec1 (char **sec1, size_t lmax, struct climat_chunks *cl)
59 \brief Prints the climat section 1
60 \param sec1 the pointer where to print section
61 \param lmax max length permited
62 \param cl pointer to s atruct \ref climat_chunks where the parse results are set
63*/
64size_t print_climat_sec1 ( char **sec1, size_t lmax, struct climat_chunks *cl )
65{
66 char *c = *sec1;
67 size_t used = 0;
68
69 if ( cl->mask & SYNOP_SEC1 )
70 {
71 used += snprintf ( c + used, lmax - used, " 111" );
72
73 if ( cl->s1.PoPoPoPo[0] )
74 {
75 used += snprintf ( c + used, lmax - used, " 1%s", cl->s1.PoPoPoPo );
76 }
77
78 if ( cl->s1.PPPP[0] )
79 {
80 used += snprintf ( c + used, lmax - used, " 2%s", cl->s1.PPPP );
81 }
82
83 if ( cl->s1.TTT[0] || cl->s1.ststst[0] )
84 {
85 if ( cl->s1.TTT[0] == 0 )
86 {
87 strcpy ( cl->s1.s, "/" );
88 strcpy ( cl->s1.TTT, "///" );
89 }
90 if ( cl->s1.ststst[0] == 0 )
91 {
92 strcpy ( cl->s1.ststst, "///" );
93 }
94 used += snprintf ( c + used, lmax - used, " 3%s%s%s", cl->s1.s, cl->s1.TTT, cl->s1.ststst );
95 }
96
97 if ( cl->s1.TxTxTx[0] || cl->s1.TnTnTn[0] )
98 {
99 if ( cl->s1.TxTxTx[0] == 0 )
100 {
101 strcpy ( cl->s1.sx, "/" );
102 strcpy ( cl->s1.TxTxTx, "///" );
103 }
104 if ( cl->s1.TnTnTn[0] == 0 )
105 {
106 strcpy ( cl->s1.sn, "/" );
107 strcpy ( cl->s1.TnTnTn, "///" );
108 }
109 used += snprintf ( c + used, lmax - used, " 4%s%s%s%s", cl->s1.sx, cl->s1.TxTxTx, cl->s1.sn, cl->s1.TnTnTn );
110 }
111
112 if ( cl->s1.eee[0] )
113 {
114 used += snprintf ( c + used, lmax - used, " 5%s", cl->s1.eee );
115 }
116
117 if ( cl->s1.R1R1R1R1[0] || cl->s1.Rd[0] || cl->s1.nrnr[0] )
118 {
119 if ( cl->s1.R1R1R1R1[0] == 0 )
120 {
121 strcpy ( cl->s1.R1R1R1R1, "////" );
122 }
123 if ( cl->s1.Rd[0] == 0 )
124 {
125 strcpy ( cl->s1.Rd, "/" );
126 }
127 if ( cl->s1.nrnr[0] == 0 )
128 {
129 strcpy ( cl->s1.nrnr, "//" );
130 }
131 used += snprintf ( c + used, lmax - used, " 6%s%s%s", cl->s1.R1R1R1R1, cl->s1.Rd, cl->s1.nrnr );
132 }
133
134 if ( cl->s1.S1S1S1[0] || cl->s1.pspsps[0] )
135 {
136 if ( cl->s1.S1S1S1[0] == 0 )
137 {
138 strcpy ( cl->s1.S1S1S1, "///" );
139 }
140 if ( cl->s1.pspsps[0] == 0 )
141 {
142 strcpy ( cl->s1.pspsps, "///" );
143 }
144 used += snprintf ( c + used, lmax - used, " 7%s%s", cl->s1.S1S1S1, cl->s1.pspsps );
145 }
146
147 if ( cl->s1.mpmp[0] || cl->s1.mtmt[0] || cl->s1.mtx[0] || cl->s1.mtn[0] )
148 {
149 if ( cl->s1.mpmp[0] == 0 )
150 {
151 strcpy ( cl->s1.mpmp, "//" );
152 }
153 if ( cl->s1.mtmt[0] == 0 )
154 {
155 strcpy ( cl->s1.mtmt, "//" );
156 }
157 if ( cl->s1.mtx[0] == 0 )
158 {
159 strcpy ( cl->s1.mtx, "/" );
160 }
161 if ( cl->s1.mtn[0] == 0 )
162 {
163 strcpy ( cl->s1.mtn, "/" );
164 }
165 used += snprintf ( c + used, lmax - used, " 8%s%s%s%s", cl->s1.mpmp, cl->s1.mtmt, cl->s1.mtx, cl->s1.mtn );
166 }
167
168
169 if ( cl->s1.meme[0] || cl->s1.mrmr[0] || cl->s1.msms[0] )
170 {
171 if ( cl->s1.meme[0] == 0 )
172 {
173 strcpy ( cl->s1.meme, "//" );
174 }
175 if ( cl->s1.mrmr[0] == 0 )
176 {
177 strcpy ( cl->s1.mrmr, "//" );
178 }
179 if ( cl->s1.msms[0] == 0 )
180 {
181 strcpy ( cl->s1.msms, "//" );
182 }
183 used += snprintf ( c + used, lmax - used, " 9%s%s%s", cl->s1.meme, cl->s1.mrmr, cl->s1.msms );
184 }
185 }
186
187 *sec1 = c + used;
188 return used;
189}
190
191/*!
192 \fn size_t print_climat_sec2 (char **sec2, size_t lmax, struct climat_chunks *cl)
193 \brief Prints the climat section 2
194 \param sec2 the pointer where to print section
195 \param lmax max length permited
196 \param cl pointer to s atruct \ref climat_chunks where the parse results are set
197*/
198size_t print_climat_sec2 ( char **sec2, size_t lmax, struct climat_chunks *cl )
199{
200 char *c = *sec2;
201 size_t used = 0, used0 = 0;
202
203 if ( cl->mask & SYNOP_SEC2 )
204 {
205 //used += snprintf ( c + used, lmax - used, "\r\n 222" );
206 used += snprintf ( c + used, lmax - used, " 222" );
207
208 // init point to write info.
209 // in case we finally write nothing in this section
210 used0 = used;
211
212 if ( cl->s2.YbYb[0] || cl->s2.YcYc[0] )
213 {
214 if ( cl->s2.YbYb[0] == 0 )
215 {
216 strcpy ( cl->s2.YbYb, "//" );
217 }
218 if ( cl->s2.YcYc[0] == 0 )
219 {
220 strcpy ( cl->s2.YcYc, "//" );
221 }
222 used += snprintf ( c + used, lmax - used, " 0%s%s", cl->s2.YbYb, cl->s2.YcYc );
223 }
224
225 if ( cl->s2.PoPoPoPo[0] )
226 {
227 used += snprintf ( c + used, lmax - used, " 1%s", cl->s2.PoPoPoPo );
228 }
229
230 if ( cl->s2.PPPP[0] )
231 {
232 used += snprintf ( c + used, lmax - used, " 2%s", cl->s2.PPPP );
233 }
234
235 if ( cl->s2.s[0] || cl->s2.TTT[0] || cl->s2.ststst[0] )
236 {
237 if ( cl->s2.s[0] == 0 )
238 {
239 strcpy ( cl->s2.s, "/" );
240 }
241 if ( cl->s2.TTT[0] == 0 )
242 {
243 strcpy ( cl->s2.TTT, "///" );
244 }
245 if ( cl->s2.ststst[0] == 0 )
246 {
247 strcpy ( cl->s2.ststst, "///" );
248 }
249
250 used += snprintf ( c + used, lmax - used, " 3%s%s%s", cl->s2.s, cl->s2.TTT, cl->s2.ststst );
251 }
252
253 if ( cl->s2.sx[0] || cl->s2.TxTxTx[0] || cl->s2.sn[0] || cl->s2.TnTnTn[0] )
254 {
255 if ( cl->s2.sx[0] == 0 )
256 {
257 strcpy ( cl->s2.sx, "/" );
258 }
259 if ( cl->s2.TxTxTx[0] == 0 )
260 {
261 strcpy ( cl->s2.TxTxTx, "///" );
262 }
263 if ( cl->s2.sn[0] == 0 )
264 {
265 strcpy ( cl->s2.sn, "/" );
266 }
267 if ( cl->s2.TnTnTn[0] == 0 )
268 {
269 strcpy ( cl->s2.TnTnTn, "///" );
270 }
271
272 used += snprintf ( c + used, lmax - used, " 4%s%s%s%s", cl->s2.sx, cl->s2.TxTxTx, cl->s2.sn, cl->s2.TnTnTn );
273 }
274
275 if ( cl->s2.eee[0] )
276 {
277 used += snprintf ( c + used, lmax - used, " 5%s", cl->s2.eee );
278 }
279
280 if ( cl->s2.R1R1R1R1[0] || cl->s2.nrnr[0] )
281 {
282 if ( cl->s2.R1R1R1R1[0] == 0 )
283 {
284 strcpy ( cl->s2.R1R1R1R1, "////" );
285 }
286 if ( cl->s2.nrnr[0] == 0 )
287 {
288 strcpy ( cl->s2.nrnr, "//" );
289 }
290 used += snprintf ( c + used, lmax - used, " 6%s%s", cl->s2.R1R1R1R1, cl->s2.nrnr );
291 }
292
293 if ( cl->s2.S1S1S1[0] )
294 {
295 used += snprintf ( c + used, lmax - used, " 7%s", cl->s2.S1S1S1 );
296 }
297
298 if ( cl->s2.ypyp[0] || cl->s2.ytyt[0] || cl->s2.ytxytx[0] )
299 {
300 if ( cl->s2.ypyp[0] == 0 )
301 {
302 strcpy ( cl->s2.ypyp, "//" );
303 }
304 if ( cl->s2.ytyt[0] == 0 )
305 {
306 strcpy ( cl->s2.ytyt, "//" );
307 }
308 if ( cl->s2.ytxytx[0] == 0 )
309 {
310 strcpy ( cl->s2.ytxytx, "//" );
311 }
312
313 used += snprintf ( c + used, lmax - used, " 8%s%s%s", cl->s2.ypyp, cl->s2.ytyt, cl->s2.ytxytx );
314 }
315
316 if ( cl->s2.yeye[0] || cl->s2.yryr[0] || cl->s2.ysys[0] )
317 {
318 if ( cl->s2.yeye[0] == 0 )
319 {
320 strcpy ( cl->s2.yeye, "//" );
321 }
322 if ( cl->s2.yryr[0] == 0 )
323 {
324 strcpy ( cl->s2.yryr, "//" );
325 }
326 if ( cl->s2.ysys[0] == 0 )
327 {
328 strcpy ( cl->s2.ysys, "//" );
329 }
330
331 used += snprintf ( c + used, lmax - used, " 9%s%s%s", cl->s2.yeye, cl->s2.yryr, cl->s2.ysys );
332 }
333
334 }
335
336 if ( used != used0 )
337 {
338 *sec2 = c + used;
339 }
340 else
341 used = 0;
342
343 return used;
344}
345
346
347/*!
348 \fn size_t print_climat_sec3 (char **sec3, size_t lmax, struct climat_chunks *cl)
349 \brief Prints the climat section 3
350 \param sec3 the pointer where to print section
351 \param lmax max length permited
352 \param cl pointer to s atruct \ref climat_chunks where the parse results are set
353*/
354size_t print_climat_sec3 ( char **sec3, size_t lmax, struct climat_chunks *cl )
355{
356 char *c = *sec3;
357 size_t used0 = 0, used = 0;
358
359 if ( cl->mask & SYNOP_SEC3 )
360 {
361 //used += snprintf ( c + used, lmax - used, "\r\n 333" );
362 used += snprintf ( c + used, lmax - used, " 333" );
363
364 // init point to write info.
365 // in case we finally write nothing in this section
366 used0 = used;
367
368 if ( ( cl->s3.T25[0] && strcmp ( cl->s3.T25, "00" ) ) ||
369 ( cl->s3.T30[0] && strcmp ( cl->s3.T30, "00" ) )
370 )
371 {
372 if ( cl->s3.T25[0] == 0 )
373 {
374 strcpy ( cl->s3.T25,"//" );
375 }
376 if ( cl->s3.T30[0] == 0 )
377 {
378 strcpy ( cl->s3.T30,"//" );
379 }
380 used += snprintf ( c + used, lmax - used, " 0%s%s", cl->s3.T25, cl->s3.T30 );
381 }
382
383 if (
384 ( cl->s3.T35[0] && strcmp ( cl->s3.T35, "00" ) ) ||
385 ( cl->s3.T40[0] && strcmp ( cl->s3.T40, "00" ) )
386 )
387 {
388 if ( cl->s3.T35[0] == 0 )
389 {
390 strcpy ( cl->s3.T35,"//" );
391 }
392 if ( cl->s3.T40[0] == 0 )
393 {
394 strcpy ( cl->s3.T40,"//" );
395 }
396 used += snprintf ( c + used, lmax - used, " 1%s%s", cl->s3.T35, cl->s3.T40 );
397 }
398
399 if (
400 ( cl->s3.Tn0[0] && strcmp ( cl->s3.Tn0, "00" ) ) ||
401 ( cl->s3.Tx0[0] && strcmp ( cl->s3.Tx0, "00" ) )
402 )
403 {
404 if ( cl->s3.Tn0[0] == 0 )
405 {
406 strcpy ( cl->s3.Tn0,"//" );
407 }
408 if ( cl->s3.Tx0[0] == 0 )
409 {
410 strcpy ( cl->s3.Tx0,"//" );
411 }
412 used += snprintf ( c + used, lmax - used, " 2%s%s", cl->s3.Tn0, cl->s3.Tx0 );
413 }
414
415 if ( ( cl->s3.R01[0] && strcmp ( cl->s3.R01, "00" ) ) ||
416 ( cl->s3.R05[0] && strcmp ( cl->s3.R05, "00" ) )
417
418 )
419 {
420 if ( cl->s3.R01[0] == 0 )
421 {
422 strcpy ( cl->s3.R01,"//" );
423 }
424 if ( cl->s3.R05[0] == 0 )
425 {
426 strcpy ( cl->s3.R05,"//" );
427 }
428 used += snprintf ( c + used, lmax - used, " 3%s%s", cl->s3.R01, cl->s3.R05 );
429 }
430
431 if ( ( cl->s3.R10[0] && strcmp ( cl->s3.R10, "00" ) ) ||
432 ( cl->s3.R50[0] && strcmp ( cl->s3.R50, "00" ) )
433
434 )
435 {
436 if ( cl->s3.R10[0] == 0 )
437 {
438 strcpy ( cl->s3.R10,"//" );
439 }
440 if ( cl->s3.R50[0] == 0 )
441 {
442 strcpy ( cl->s3.R50,"//" );
443 }
444 used += snprintf ( c + used, lmax - used, " 4%s%s", cl->s3.R10, cl->s3.R50 );
445 }
446
447 if ( ( cl->s3.R100[0] && strcmp ( cl->s3.R100, "00" ) ) ||
448 ( cl->s3.R150[0] && strcmp ( cl->s3.R150, "00" ) )
449
450 )
451 {
452 if ( cl->s3.R100[0] == 0 )
453 {
454 strcpy ( cl->s3.R100,"//" );
455 }
456 if ( cl->s3.R150[0] == 0 )
457 {
458 strcpy ( cl->s3.R150,"//" );
459 }
460 used += snprintf ( c + used, lmax - used, " 5%s%s", cl->s3.R100, cl->s3.R150 );
461 }
462
463 if ( ( cl->s3.s00[0] && strcmp ( cl->s3.s00, "00" ) ) ||
464 ( cl->s3.s01[0] && strcmp ( cl->s3.s01, "00" ) )
465 )
466 {
467 if ( cl->s3.s00[0] == 0 )
468 {
469 strcpy ( cl->s3.s00,"//" );
470 }
471 if ( cl->s3.s01[0] == 0 )
472 {
473 strcpy ( cl->s3.s01,"//" );
474 }
475 used += snprintf ( c + used, lmax - used, " 6%s%s", cl->s3.s00, cl->s3.s01 );
476 }
477
478 if ( ( cl->s3.s10[0] && strcmp ( cl->s3.s10, "00" ) ) ||
479 ( cl->s3.s50[0] && strcmp ( cl->s3.s50, "00" ) )
480
481 )
482 {
483 if ( cl->s3.s10[0] == 0 )
484 {
485 strcpy ( cl->s3.s10,"//" );
486 }
487 if ( cl->s3.s50[0] == 0 )
488 {
489 strcpy ( cl->s3.s50,"//" );
490 }
491 used += snprintf ( c + used, lmax - used, " 7%s%s", cl->s3.s10, cl->s3.s50 );
492 }
493
494 if (
495 ( cl->s3.f10[0] && strcmp ( cl->s3.f10, "00" ) ) ||
496 ( cl->s3.f20[0] && strcmp ( cl->s3.f20, "00" ) ) ||
497 ( cl->s3.f30[0] && strcmp ( cl->s3.f30, "00" ) )
498 )
499 {
500 if ( cl->s3.f10[0] == 0 )
501 {
502 strcpy ( cl->s3.f10,"//" );
503 }
504 if ( cl->s3.f20[0] == 0 )
505 {
506 strcpy ( cl->s3.f20,"//" );
507 }
508 if ( cl->s3.f30[0] == 0 )
509 {
510 strcpy ( cl->s3.f30,"//" );
511 }
512 used += snprintf ( c + used, lmax - used, " 8%s%s%s", cl->s3.f10, cl->s3.f20, cl->s3.f30 );
513 }
514
515 if (
516 ( cl->s3.V1[0] && strcmp ( cl->s3.V1, "00" ) ) ||
517 ( cl->s3.V2[0] && strcmp ( cl->s3.V2, "00" ) ) ||
518 ( cl->s3.V3[0] && strcmp ( cl->s3.V3, "00" ) )
519 )
520 {
521 if ( cl->s3.V1[0] == 0 )
522 {
523 strcpy ( cl->s3.V1,"//" );
524 }
525 if ( cl->s3.V2[0] == 0 )
526 {
527 strcpy ( cl->s3.V2,"//" );
528 }
529 if ( cl->s3.V3[0] == 0 )
530 {
531 strcpy ( cl->s3.V3,"//" );
532 }
533 used += snprintf ( c + used, lmax - used, " 9%s%s%s", cl->s3.V1, cl->s3.V2, cl->s3.V3 );
534 }
535
536 }
537
538 if ( used != used0 )
539 {
540 *sec3 = c + used;
541 }
542 used = 0;
543
544 return used;
545
546}
547
548/*!
549 \fn size_t print_climat_sec4 (char **sec4, size_t lmax, struct climat_chunks *cl)
550 \brief Prints the climat section 4
551 \param sec4 the pointer where to print section
552 \param lmax max length permited
553 \param cl pointer to s atruct \ref climat_chunks where the parse results are set
554*/
555size_t print_climat_sec4 ( char **sec4, size_t lmax, struct climat_chunks *cl )
556{
557 char *c = *sec4;
558 size_t used0 = 0, used = 0;
559
560 if ( cl->mask & CLIMAT_SEC4 )
561 {
562 //used += snprintf ( c + used, lmax - used, "\r\n 444" );
563 used += snprintf ( c + used, lmax - used, " 444" );
564
565 // init point to write info.
566 // in case we finally write nothing in this section
567 used0 = used;
568
569 if ( cl->s4.sx[0] || cl->s4.Txd[0] || cl->s4.yx[0] )
570 {
571 if ( cl->s4.sx[0] == 0 )
572 {
573 strcpy ( cl->s4.sx, "/" );
574 }
575 if ( cl->s4.Txd[0] == 0 )
576 {
577 strcpy ( cl->s4.Txd, "///" );
578 }
579 if ( cl->s4.yx[0] == 0 )
580 {
581 strcpy ( cl->s4.yx, "//" );
582 }
583 used += snprintf ( c + used, lmax - used, " 0%s%s%s", cl->s4.sx, cl->s4.Txd, cl->s4.yx );
584 }
585
586 if ( cl->s4.sn[0] || cl->s4.Tnd[0] || cl->s4.yn[0] )
587 {
588 if ( cl->s4.sn[0] == 0 )
589 {
590 strcpy ( cl->s4.sn, "/" );
591 }
592 if ( cl->s4.Tnd[0] == 0 )
593 {
594 strcpy ( cl->s4.Tnd, "///" );
595 }
596 if ( cl->s4.yn[0] == 0 )
597 {
598 strcpy ( cl->s4.yn, "//" );
599 }
600 used += snprintf ( c + used, lmax - used, " 1%s%s%s", cl->s4.sn, cl->s4.Tnd, cl->s4.yn );
601 }
602
603 if ( cl->s4.sax[0] || cl->s4.Tax[0] || cl->s4.yax[0] )
604 {
605 if ( cl->s4.sax[0] == 0 )
606 {
607 strcpy ( cl->s4.sax, "/" );
608 }
609 if ( cl->s4.Tax[0] == 0 )
610 {
611 strcpy ( cl->s4.Tax, "///" );
612 }
613 if ( cl->s4.yax[0] == 0 )
614 {
615 strcpy ( cl->s4.yax, "//" );
616 }
617 used += snprintf ( c + used, lmax - used, " 2%s%s%s", cl->s4.sax, cl->s4.Tax, cl->s4.yax );
618 }
619
620 if ( cl->s4.san[0] || cl->s4.Tan[0] || cl->s4.yan[0] )
621 {
622 if ( cl->s4.san[0] == 0 )
623 {
624 strcpy ( cl->s4.san, "/" );
625 }
626 if ( cl->s4.Tan[0] == 0 )
627 {
628 strcpy ( cl->s4.Tan, "///" );
629 }
630 if ( cl->s4.yan[0] == 0 )
631 {
632 strcpy ( cl->s4.yan, "//" );
633 }
634 used += snprintf ( c + used, lmax - used, " 3%s%s%s", cl->s4.san, cl->s4.Tan, cl->s4.yan );
635 }
636
637 if ( cl->s4.RxRxRxRx[0] || cl->s4.yr[0] )
638 {
639 if ( cl->s4.RxRxRxRx[0] == 0 )
640 {
641 strcpy ( cl->s4.RxRxRxRx, "////" );
642 }
643 if ( cl->s4.yx[0] == 0 )
644 {
645 strcpy ( cl->s4.Tan, "//" );
646 }
647 used += snprintf ( c + used, lmax - used, " 4%s%s", cl->s4.RxRxRxRx, cl->s4.yr );
648 }
649
650 if ( cl->s4.fxfxfx[0] || cl->s4.yfx[0] )
651 {
652 if ( cl->s4.iw[0] == 0 )
653 {
654 strcpy ( cl->s4.iw, "/" );
655 }
656 if ( cl->s4.fxfxfx[0] == 0 )
657 {
658 strcpy ( cl->s4.fxfxfx, "///" );
659 }
660 if ( cl->s4.yfx[0] == 0 )
661 {
662 strcpy ( cl->s4.yfx, "//" );
663 }
664 used += snprintf ( c + used, lmax - used, " 5%s%s%s", cl->s4.iw, cl->s4.fxfxfx, cl->s4.yfx );
665 }
666
667 if ( cl->s4.Dts[0] || cl->s4.Dgr[0] )
668 {
669 if ( cl->s4.Dts[0] == 0 )
670 {
671 strcpy ( cl->s4.Dts,"//" );
672 }
673 if ( cl->s4.Dgr[0] == 0 )
674 {
675 strcpy ( cl->s4.Dgr,"//" );
676 }
677 used += snprintf ( c + used, lmax - used, " 6%s%s", cl->s4.Dts, cl->s4.Dgr );
678 }
679
680 if ( cl->s4.iy[0] || cl->s4.GxGx[0] || cl->s4.GnGn[0] )
681 {
682 if ( cl->s4.iw[0] == 0 )
683 {
684 strcpy ( cl->s4.iy, "/" );
685 }
686 if ( cl->s4.GxGx[0] == 0 )
687 {
688 strcpy ( cl->s4.GxGx, "///" );
689 }
690 if ( cl->s4.GnGn[0] == 0 )
691 {
692 strcpy ( cl->s4.GnGn, "//" );
693 }
694 used += snprintf ( c + used, lmax - used, " 7%s%s%s", cl->s4.iy, cl->s4.GxGx, cl->s4.GnGn );
695 }
696
697
698 }
699
700 if ( used != used0 )
701 {
702 *sec4 = c + used;
703 }
704 else
705 used = 0;
706
707 return used;
708}
709
710
711/*!
712 \fn int print_climat_report ( struct metreport *m )
713 \brief prints a climat into a string
714 \param m pointer to struct \ref metreport where are both target and source
715
716 If OK returns 0, otherwise 1
717*/
719{
720 char *c = &(m->alphanum[0]);
721 size_t used = 0;
722 size_t lmax = sizeof(m->alphanum);
723 struct climat_chunks *cl = &m->climat;
724
725 // Needs time extension
726 if ( cl->e.YYYY[0] == 0 || cl->e.YYYY[0] == '0' || cl->e.MM[0] == 0 )
727 {
728 return 1;
729 }
730
732 {
733 used += print_wigos_id ( &c, lmax, m );
734 }
735
736 if ( m->print_mask & PRINT_BITMASK_GEO )
737 {
738 used += print_geo ( &c, lmax, m );
739 }
740
741 used += print_climat_sec0 ( &c, lmax - used, cl );
742
743 if ( cl->mask & ( CLIMAT_SEC1 | CLIMAT_SEC2 | CLIMAT_SEC3 | CLIMAT_SEC4 ) )
744 {
745 used += print_climat_sec1 ( &c, lmax - used, cl );
746
747 used += print_climat_sec2 ( &c, lmax - used, cl );
748
749 used += print_climat_sec3 ( &c, lmax - used, cl );
750
751 used += print_climat_sec4 ( &c, lmax - used, cl );
752 }
753 else
754 {
755 c += snprintf ( c, lmax - used, " NIL" );
756 }
757 snprintf ( c, lmax - used - 1, "=" );
758
759 return 0;
760
761}
Include header file for binary bufr2tac.
size_t print_wigos_id(char **wid, size_t lmax, struct metreport *m)
#define PRINT_BITMASK_WIGOS
Bit mask to member print_mask in struct metreport to print WIGOS Identifier.
Definition: bufr2tac.h:208
size_t print_geo(char **geo, size_t lmax, struct metreport *m)
#define PRINT_BITMASK_GEO
Bit mask to member print_mask in struct metreport to print geographic position.
Definition: bufr2tac.h:214
size_t print_climat_sec3(char **sec3, size_t lmax, struct climat_chunks *cl)
Prints the climat section 3.
size_t print_climat_sec1(char **sec1, size_t lmax, struct climat_chunks *cl)
Prints the climat section 1.
size_t print_climat_sec4(char **sec4, size_t lmax, struct climat_chunks *cl)
Prints the climat section 4.
size_t print_climat_sec2(char **sec2, size_t lmax, struct climat_chunks *cl)
Prints the climat section 2.
int print_climat_report(struct metreport *m)
prints a climat into a string
size_t print_climat_sec0(char **sec0, size_t lmax, struct climat_chunks *cl)
Prints the climat section 0 (header)
#define CLIMAT_SEC4
mask bit meaning section 4 of climat is solicited to or parsed with success
Definition: metclimat.h:52
#define CLIMAT_SEC3
mask bit meaning section 3 of climat is solicited to or parsed with success
Definition: metclimat.h:47
#define CLIMAT_SEC2
mask bit meaning section 2 of climat is solicited to or parsed with success
Definition: metclimat.h:42
#define CLIMAT_SEC1
mask bit meaning section 1 of climat is solicited to or parsed with success
Definition: metclimat.h:37
#define SYNOP_SEC1
mask bit meaning section 1 or synop is solicited to or parsed with success
Definition: metsynop.h:39
#define SYNOP_SEC3
mask bit meaning section 3 or synop is solicited to or parsed with success
Definition: metsynop.h:49
#define SYNOP_SEC2
mask bit meaning section 2 or synop is solicited to or parsed with success
Definition: metsynop.h:44
contains all possible substrings from a synop report is parsed with success
Definition: metclimat.h:213
struct climat_sec4 s4
Definition: metclimat.h:221
struct report_date_ext e
Definition: metclimat.h:215
struct climat_sec1 s1
Definition: metclimat.h:218
struct climat_sec0 s0
Definition: metclimat.h:217
struct climat_sec2 s2
Definition: metclimat.h:219
struct climat_sec3 s3
Definition: metclimat.h:220
char JJJ[4]
Definition: metclimat.h:71
char iii[4]
Definition: metclimat.h:73
char II[4]
Definition: metclimat.h:72
char MM[4]
Definition: metclimat.h:70
char mtmt[4]
Definition: metclimat.h:98
char mtx[2]
Definition: metclimat.h:99
char R1R1R1R1[6]
Definition: metclimat.h:92
char s[2]
Definition: metclimat.h:84
char sx[2]
Definition: metclimat.h:87
char nrnr[4]
Definition: metclimat.h:94
char pspsps[4]
Definition: metclimat.h:96
char S1S1S1[4]
Definition: metclimat.h:95
char PoPoPoPo[8]
Definition: metclimat.h:82
char mrmr[4]
Definition: metclimat.h:102
char TxTxTx[4]
Definition: metclimat.h:88
char eee[4]
Definition: metclimat.h:91
char mtn[2]
Definition: metclimat.h:100
char PPPP[8]
Definition: metclimat.h:83
char mpmp[4]
Definition: metclimat.h:97
char Rd[2]
Definition: metclimat.h:93
char TTT[4]
Definition: metclimat.h:85
char sn[2]
Definition: metclimat.h:89
char ststst[4]
Definition: metclimat.h:86
char msms[4]
Definition: metclimat.h:103
char TnTnTn[4]
Definition: metclimat.h:90
char meme[4]
Definition: metclimat.h:101
char TTT[4]
Definition: metclimat.h:116
char nrnr[4]
Definition: metclimat.h:124
char R1R1R1R1[6]
Definition: metclimat.h:123
char S1S1S1[4]
Definition: metclimat.h:125
char TnTnTn[4]
Definition: metclimat.h:121
char yryr[4]
Definition: metclimat.h:130
char TxTxTx[4]
Definition: metclimat.h:119
char ytxytx[4]
Definition: metclimat.h:128
char PPPP[8]
Definition: metclimat.h:114
char eee[4]
Definition: metclimat.h:122
char ststst[4]
Definition: metclimat.h:117
char YbYb[4]
Definition: metclimat.h:111
char PoPoPoPo[8]
Definition: metclimat.h:113
char sn[2]
Definition: metclimat.h:120
char YcYc[4]
Definition: metclimat.h:112
char ypyp[4]
Definition: metclimat.h:126
char ytyt[4]
Definition: metclimat.h:127
char sx[2]
Definition: metclimat.h:118
char s[2]
Definition: metclimat.h:115
char ysys[4]
Definition: metclimat.h:131
char yeye[4]
Definition: metclimat.h:129
char Tx0[4]
Definition: metclimat.h:144
char T25[4]
Definition: metclimat.h:139
char R50[4]
Definition: metclimat.h:148
char f20[4]
Definition: metclimat.h:156
char f30[4]
Definition: metclimat.h:157
char s10[4]
Definition: metclimat.h:153
char R150[4]
Definition: metclimat.h:150
char T35[4]
Definition: metclimat.h:141
char Tn0[4]
Definition: metclimat.h:143
char V2[4]
Definition: metclimat.h:159
char R100[4]
Definition: metclimat.h:149
char s01[4]
Definition: metclimat.h:152
char R10[4]
Definition: metclimat.h:147
char T30[4]
Definition: metclimat.h:140
char R05[4]
Definition: metclimat.h:146
char s00[4]
Definition: metclimat.h:151
char V1[4]
Definition: metclimat.h:158
char V3[4]
Definition: metclimat.h:160
char T40[4]
Definition: metclimat.h:142
char R01[4]
Definition: metclimat.h:145
char s50[4]
Definition: metclimat.h:154
char f10[4]
Definition: metclimat.h:155
char RxRxRxRx[8]
Definition: metclimat.h:180
char sax[2]
Definition: metclimat.h:174
char sx[2]
Definition: metclimat.h:168
char Tnd[4]
Definition: metclimat.h:172
char iw[2]
Definition: metclimat.h:182
char yx[4]
Definition: metclimat.h:170
char san[2]
Definition: metclimat.h:177
char Dgr[4]
Definition: metclimat.h:186
char yn[4]
Definition: metclimat.h:173
char yfx[4]
Definition: metclimat.h:184
char GnGn[4]
Definition: metclimat.h:189
char Tax[4]
Definition: metclimat.h:175
char iy[2]
Definition: metclimat.h:187
char GxGx[4]
Definition: metclimat.h:188
char yax[4]
Definition: metclimat.h:176
char Dts[4]
Definition: metclimat.h:185
char fxfxfx[4]
Definition: metclimat.h:183
char yr[4]
Definition: metclimat.h:181
char Tan[4]
Definition: metclimat.h:178
char yan[4]
Definition: metclimat.h:179
char Txd[4]
Definition: metclimat.h:169
char sn[2]
Definition: metclimat.h:171
all the information for a meteorological report in WMO text format from a BUFR file
Definition: bufr2tac.h:309
char alphanum[REPORT_LENGTH]
Definition: bufr2tac.h:321
int print_mask
Definition: bufr2tac.h:312
struct climat_chunks climat
Definition: bufr2tac.h:319
char mm[4]
Definition: metcommon.h:37
char HH[4]
Definition: metcommon.h:36
char DD[4]
Definition: metcommon.h:35
char MM[4]
Definition: metcommon.h:34
char YYYY[6]
Definition: metcommon.h:33