bufr2synop 0.24.0
bufr2tac_print_temp.c
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013-2022 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_temp.c
22 \brief file with the code to print the results in case of temp reposrt
23 */
24#include "bufr2tac.h"
25
26/*!
27 \fn int print_temp_raw_data ( struct temp_raw_data *r )
28 \brief Prints for debug a struct \ref temp_raw_data
29 \param r the pointer of struct to print
30
31 This is used mainly for debug
32*/
34{
35 size_t i;
36
37 printf ( "raw points %lu\n", r->n );
38 for ( i = 0; i < r->n ; i++ )
39 {
40 if ( r->raw[i].T != MISSING_REAL &&
41 r->raw[i].Td != MISSING_REAL &&
42 r->raw[i].dd != MISSING_REAL &&
43 r->raw[i].ff != MISSING_REAL )
44 printf ( "i=%3ld, dt=%4d, flags=%08X, P=%6.1lf, h=%6.0lf, dlat=%7.4lf, dlon=%7.4lf, T=%6.1lf, Td=%6.1lf, dd=%03.0lf, ff=%5.1lf\n",
45 i, r->raw[i].dt, r->raw[i].flags, r->raw[i].p * 0.01, r->raw[i].h, r->raw[i].dlat, r->raw[i].dlon,
46 r->raw[i].T - 273.15, r->raw[i].Td - 273.15, r->raw[i].dd, r->raw[i].ff );
47 else
48 {
49 printf ( "i=%3ld, dt=%4d, flags=%08X, P=%6.1lf, h=%6.0lf, dlat=%7.4lf, dlon=%7.4lf, ",
50 i, r->raw[i].dt, r->raw[i].flags, r->raw[i].p * 0.01, r->raw[i].h, r->raw[i].dlat, r->raw[i].dlon );
51 if ( r->raw[i].T != MISSING_REAL )
52 {
53 printf ( "T=%6.1lf, ", r->raw[i].T - 273.15 );
54 }
55 else
56 {
57 printf ( "T= ///./, " );
58 }
59
60 if ( r->raw[i].Td != MISSING_REAL )
61 {
62 printf ( "T=%6.1lf, ", r->raw[i].Td - 273.15 );
63 }
64 else
65 {
66 printf ( "Td= ///./, " );
67 }
68
69 if ( r->raw[i].dd != MISSING_REAL )
70 {
71 printf ( "dd=%03.0lf, ", r->raw[i].dd );
72 }
73 else
74 {
75 printf ( "dd=///, " );
76 }
77
78 if ( r->raw[i].dd != MISSING_REAL )
79 {
80 printf ( "ff=%5.1lf\n", r->raw[i].ff );
81 }
82 else
83 {
84 printf ( "ff= //./\n" );
85 }
86 }
87 }
88 return 0;
89}
90
91/*!
92 \fn int print_temp_raw_wind_shear_data ( struct temp_raw_wind_shear_data *w )
93 \brief Prints for debug a struct \ref temp_raw_data
94 \param w the pointer of struct to print
95
96 Used in debug stage
97*/
99{
100 size_t i;
101
102 printf ( "raw share wind points %lu\n", w->n );
103 for ( i = 0; i < w->n ; i++ )
104 {
105 if ( w->raw[i].ws_blw != MISSING_REAL && w->raw[i].ws_abv != MISSING_REAL )
106 printf ( "i=%3ld, dt=%4d, flags=%08X, P=%6.1lf, dlat=%7.4lf, dlon=%7.4lf, ws_blw=%5.1lf, ws_abv=%5.1lf\n",
107 i, w->raw[i].dt, w->raw[i].flags, w->raw[i].p * 0.01, w->raw[i].dlat, w->raw[i].dlon,
108 w->raw[i].ws_blw, w->raw[i].ws_abv );
109 else
110 {
111 printf ( "i=%3ld, dt=%4d, flags=%08X, P=%6.1lf, dlat=%7.4lf, dlon=%7.4lf, ",
112 i, w->raw[i].dt, w->raw[i].flags, w->raw[i].p * 0.01, w->raw[i].dlat, w->raw[i].dlon );
113
114 if ( w->raw[i].ws_blw != MISSING_REAL )
115 {
116 printf ( "ws_blw=%5.1lf, ", w->raw[i].ws_blw );
117 }
118 else
119 {
120 printf ( "ws_blw= ///./, " );
121 }
122
123 if ( w->raw[i].ws_abv != MISSING_REAL )
124 {
125 printf ( "ws_abv=%5.1lf\n", w->raw[i].ws_abv );
126 }
127 else
128 {
129 printf ( "ws_abv= ///./\n" );
130 }
131 }
132 }
133 return 0;
134}
135
136/*!
137 \fn size_t print_temp_a_sec1 (char **sec1, size_t lmax, struct temp_chunks *t)
138 \brief Prints the section 1 of part A of a TEMP report
139 \param sec1 the pointer where to print section
140 \param lmax max length permited
141 \param t pointer to s atruct \ref temp_chunks where the parse results are set
142
143 returns the string sec1
144*/
145size_t print_temp_a_sec1 ( char **sec1, size_t lmax, struct temp_chunks *t )
146{
147 size_t used = 0;
148 char *c = *sec1;
149
150 used += snprintf ( c + used, lmax - used, "%s", t->t.datime );
151
152 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s1.MiMi, t->a.s1.MjMj );
153
154 if ( t->a.s1.D_D[0] && t->a.s1.II[0] == 0 )
155 {
156 used += snprintf ( c + used, lmax - used, " %s", t->a.s1.D_D );
157 }
158
159 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s1.YYGG, t->a.s1.id );
160
161 // print IIiii
162 if ( t->a.s1.II[0] )
163 {
164 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s1.II, t->a.s1.iii );
165 }
166 else
167 {
168 if ( t->a.s1.LaLaLa[0] )
169 {
170 used += snprintf ( c + used, lmax - used, " 99%s", t->a.s1.LaLaLa );
171 }
172 else
173 {
174 used += snprintf ( c + used, lmax - used, " 99///" );
175 }
176
177 if ( t->a.s1.Qc[0] && t->a.s1.LoLoLoLo[0] )
178 {
179 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s1.Qc, t->a.s1.LoLoLoLo );
180 }
181 else
182 {
183 used += snprintf ( c + used, lmax - used, " /////" );
184 }
185
186 if ( t->a.s1.MMM[0] && t->a.s1.Ula[0] && t->a.s1.Ulo[0] )
187 {
188 used += snprintf ( c + used, lmax - used, " %s%s%s", t->a.s1.MMM, t->a.s1.Ula, t->a.s1.Ulo );
189 }
190
191 if ( t->a.s1.h0h0h0h0[0] )
192 {
193 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s1.h0h0h0h0, t->a.s1.im );
194 }
195 }
196
197 *sec1 = c + used;
198 return used;
199}
200
201
202/*!
203 \fn size_t print_temp_a_sec2 (char **sec2, size_t lmax, struct temp_chunks *t)
204 \brief Prints the section 2 of part A of a TEMP report
205 \param sec2 the pointer where to print section
206 \param lmax max length permited
207 \param t pointer to s atruct \ref temp_chunks where the parse results are set
208
209 returns the string sec2
210*/
211size_t print_temp_a_sec2 ( char **sec2, size_t lmax, struct temp_chunks *t )
212{
213 size_t i;
214 size_t used = 0;
215 char *c = *sec2;
216
217 //Surface level
218 used += snprintf ( c + used, lmax - used, " 99%s", t->a.s2.lev0.PnPnPn );
219 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s2.lev0.TnTnTan, t->a.s2.lev0.DnDn );
220 used += snprintf ( c + used, lmax - used, " %s", t->a.s2.lev0.dndnfnfnfn );
221
222 for ( i = 0; i < t->a.s2.n ; i++ )
223 {
224 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s2.std[i].PnPn, t->a.s2.std[i].hnhnhn );
225 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s2.std[i].TnTnTan, t->a.s2.std[i].DnDn );
226 used += snprintf ( c + used, lmax - used, " %s", t->a.s2.std[i].dndnfnfnfn );
227 }
228
229 *sec2 = c + used;
230 return used;
231}
232
233/*!
234 \fn size_t print_temp_a_sec3 (char **sec3, size_t lmax, struct temp_chunks *t)
235 \brief Prints the section 3 of part A of a TEMP report
236 \param sec3 the pointer where to print section
237 \param lmax max length permited
238 \param t pointer to s atruct \ref temp_chunks where the parse results are set
239
240 returns the string sec3
241*/
242size_t print_temp_a_sec3 ( char **sec3, size_t lmax, struct temp_chunks *t )
243{
244 size_t i;
245 size_t used = 0;
246 char *c = *sec3;
247
248 if ( t->a.s3.n == 0 )
249 {
250 used += snprintf ( c + used, lmax - used, " 88999" );
251 }
252 else
253 {
254 for ( i = 0; i < t->a.s3.n ; i++ )
255 {
256 used += snprintf ( c + used, lmax - used, " 88%s", t->a.s3.trop[i].PnPnPn );
257 used += snprintf ( c + used, lmax - used, " %s%s", t->a.s3.trop[i].TnTnTan, t->a.s3.trop[i].DnDn );
258 used += snprintf ( c + used, lmax - used, " %s", t->a.s3.trop[i].dndnfnfnfn );
259 }
260 }
261
262 *sec3 = c + used;
263 return used;
264
265}
266
267/*!
268 \fn size_t print_temp_a_sec4 (char **sec4, size_t lmax, struct temp_chunks *t)
269 \brief Prints the section 4 of part A of a TEMP report
270 \param sec4 the pointer where to print section
271 \param lmax max length permited
272 \param t pointer to s atruct \ref temp_chunks where the parse results are set
273
274 returns the string sec1
275*/
276size_t print_temp_a_sec4 ( char **sec4, size_t lmax, struct temp_chunks *t )
277{
278 size_t i;
279 size_t used = 0;
280 char *c = *sec4;
281
282 if ( t->a.s4.n == 0 )
283 {
284 used += snprintf ( c + used, lmax - used, " 77999" );
285 }
286 else
287 {
288 for ( i = 0; i < t->a.s4.n ; i++ )
289 {
290 if ( t->a.s4.windx[i].no_last_wind )
291 {
292 used += snprintf ( c + used, lmax - used, " 77%s", t->a.s4.windx[i].PmPmPm );
293 }
294 else
295 {
296 used += snprintf ( c + used, lmax - used, " 66%s", t->a.s4.windx[i].PmPmPm );
297 }
298 used += snprintf ( c + used, lmax - used, " %s", t->a.s4.windx[i].dmdmfmfmfm );
299
300 if ( t->a.s4.windx[i].vbvb[0] && t->a.s4.windx[i].vava[0] )
301 {
302 used += snprintf ( c + used, lmax - used, " 4%s%s", t->a.s4.windx[i].vbvb, t->a.s4.windx[i].vava );
303 }
304 }
305 }
306
307 *sec4 = c + used;
308 return used;
309
310}
311
312/*!
313 \fn size_t print_temp_a_sec7 (char **sec7, size_t lmax, struct temp_chunks *t)
314 \brief Prints the section 7 of part A of a TEMP report
315 \param sec7 the pointer where to print section
316 \param lmax max length permited
317 \param t pointer to s atruct \ref temp_chunks where the parse results are set
318
319 returns the string sec7
320*/
321size_t print_temp_a_sec7 ( char **sec7, size_t lmax, struct temp_chunks *t )
322{
323 size_t used = 0;
324 char *c = *sec7;
325
326 used += snprintf ( c + used, lmax - used, " 31313" );
327 used += snprintf ( c + used, lmax - used, " %s%s%s", t->a.s7.sr, t->a.s7.rara, t->a.s7.sasa );
328 used += snprintf ( c + used, lmax - used, " 8%s%s", t->a.s7.GG, t->a.s7.gg );
329
330 if ( t->a.s7.TwTwTw[0] )
331 {
332 used += snprintf ( c + used, lmax - used, " 9%s%s", t->a.s7.sn, t->a.s7.TwTwTw );
333 }
334
335 *sec7 = c + used;
336 return used;
337}
338
339/*!
340 \fn size_t print_temp_a (struct metreport *m )
341 \brief Prints the part A of a TEMP report into a string
342 \param m pointer to struct \ref metreport where are both target and source
343
344 If OK returns 0, otherwise 1
345*/
346int print_temp_a ( struct metreport *m )
347{
348 char *c = &(m->alphanum[0]);
349 size_t used = 0;
350 size_t lmax = sizeof(m->alphanum);
351 struct temp_chunks *t = &m->temp;
352
353
354 // Needs time extension
355 if ( t->a.e.YYYY[0] == 0 || t->a.e.YYYY[0] == '0')
356 {
357 return 1;
358 }
359
361 {
362 used += print_wigos_id ( &c, lmax, m );
363 }
364
365 if ( m->print_mask & PRINT_BITMASK_GEO )
366 {
367 used += print_geo ( &c, lmax, m );
368 }
369
370 used += print_temp_a_sec1 ( &c, lmax - used, t );
371 used += print_temp_a_sec2 ( &c, lmax - used, t );
372 used += print_temp_a_sec3 ( &c, lmax - used, t );
373 used += print_temp_a_sec4 ( &c, lmax - used, t );
374 used += print_temp_a_sec7 ( &c, lmax - used, t );
375 used += snprintf ( c, lmax - used, "=" );
376 return 0;
377}
378
379/*!
380 \fn size_t print_temp_b_sec1 (char **sec1, size_t lmax, struct temp_chunks *t)
381 \brief Prints the section 1 of part B of a TEMP report
382 \param sec1 the pointer where to print section
383 \param lmax max length permited
384 \param t pointer to s atruct \ref temp_chunks where the parse results are set
385
386 returns the string sec1
387*/
388size_t print_temp_b_sec1 ( char **sec1, size_t lmax, struct temp_chunks *t )
389{
390 size_t used = 0;
391 char *c = *sec1;
392
393 used += snprintf ( c + used, lmax - used, "%s", t->t.datime );
394
395 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s1.MiMi, t->b.s1.MjMj );
396
397 if ( t->b.s1.D_D[0] && t->a.s1.II[0] == 0 )
398 {
399 used += snprintf ( c + used, lmax - used, " %s", t->b.s1.D_D );
400 }
401
402 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s1.YYGG, t->b.s1.a4 );
403
404 // print IIiii
405 if ( t->b.s1.II[0] )
406 {
407 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s1.II, t->b.s1.iii );
408 }
409 else
410 {
411 if ( t->b.s1.LaLaLa[0] )
412 {
413 used += snprintf ( c + used, lmax - used, " 99%s", t->b.s1.LaLaLa );
414 }
415 else
416 {
417 used += snprintf ( c + used, lmax - used, " 99///" );
418 }
419
420 if ( t->b.s1.Qc[0] && t->b.s1.LoLoLoLo[0] )
421 {
422 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s1.Qc, t->b.s1.LoLoLoLo );
423 }
424 else
425 {
426 used += snprintf ( c + used, lmax - used, " /////" );
427 }
428
429 if ( t->b.s1.MMM[0] && t->b.s1.Ula[0] && t->b.s1.Ulo[0] )
430 {
431 used += snprintf ( c + used, lmax - used, " %s%s%s", t->b.s1.MMM, t->b.s1.Ula, t->b.s1.Ulo );
432 }
433
434 if ( t->b.s1.h0h0h0h0[0] )
435 {
436 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s1.h0h0h0h0, t->b.s1.im );
437 }
438 }
439
440 *sec1= c + used;
441 return used;
442}
443
444/*!
445 \fn size_t print_temp_b_sec5 (char **sec5, size_t lmax, struct temp_chunks *t)
446 \brief Prints the section 5 of part B of a TEMP report
447 \param sec5 the pointer where to print section
448 \param lmax max length permited
449 \param t pointer to s atruct \ref temp_chunks where the parse results are set
450
451 returns the string sec5
452*/
453size_t print_temp_b_sec5 ( char **sec5, size_t lmax, struct temp_chunks *t )
454{
455 size_t used = 0;
456 size_t i;
457 char *c = *sec5;
458
459 for ( i = 0; i < t->b.s5.n && i < TEMP_NMAX_POINTS ; i++ )
460 {
461 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s5.th[i].nini, t->b.s5.th[i].PnPnPn );
462 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s5.th[i].TnTnTan, t->b.s5.th[i].DnDn );
463 }
464
465 *sec5 = c + used;
466 return used;
467}
468
469/*!
470 \fn size_t print_temp_b_sec6 (char **sec6, size_t lmax, struct temp_chunks *t)
471 \brief Prints the section 6 of part B of a TEMP report
472 \param sec6 the pointer where to print section
473 \param lmax max length permited
474 \param t pointer to s atruct \ref temp_chunks where the parse results are set
475
476 returns the string sec6
477*/
478size_t print_temp_b_sec6 ( char **sec6, size_t lmax, struct temp_chunks *t )
479{
480 size_t i;
481 size_t used = 0;
482 char *c = *sec6;
483
484 used += snprintf ( c + used, lmax - used, " 21212" );
485
486 for ( i = 0; i < t->b.s6.n && i < TEMP_NMAX_POINTS ; i++ )
487 {
488 used += snprintf ( c + used, lmax - used, " %s%s", t->b.s6.wd[i].nini, t->b.s6.wd[i].PnPnPn );
489 used += snprintf ( c + used, lmax - used, " %s", t->b.s6.wd[i].dndnfnfnfn );
490 }
491
492 *sec6 = c + used;
493 return used;
494}
495
496/*!
497 \fn size_t print_temp_b_sec7 (char **sec7, size_t lmax, struct temp_chunks *t)
498 \brief Prints the section 7 of part B of a TEMP report
499 \param sec7 the pointer where to print section
500 \param lmax max length permited
501 \param t pointer to s atruct \ref temp_chunks where the parse results are set
502
503 returns the string sec7
504*/
505size_t print_temp_b_sec7 ( char **sec7, size_t lmax, struct temp_chunks *t )
506{
507 size_t used = 0;
508 char *c = *sec7;
509
510 used += snprintf ( c + used, lmax - used, " 31313" );
511 used += snprintf ( c + used, lmax - used, " %s%s%s", t->b.s7.sr, t->b.s7.rara, t->b.s7.sasa );
512 used += snprintf ( c + used, lmax - used, " 8%s%s", t->b.s7.GG, t->b.s7.gg );
513
514 if ( t->b.s7.TwTwTw[0] )
515 {
516 used += snprintf ( c + used, lmax - used, " 9%s%s", t->b.s7.sn, t->b.s7.TwTwTw );
517 }
518
519 *sec7 = c + used;
520 return used;
521}
522
523/*!
524 \fn size_t print_temp_b_sec8 (char **sec8, size_t lmax, struct temp_chunks *t)
525 \brief Prints the section 8 of part B of a TEMP report
526 \param sec8 the pointer where to print section
527 \param lmax max length permited
528 \param t pointer to s atruct \ref temp_chunks where the parse results are set
529
530 returns the string sec8
531*/
532size_t print_temp_b_sec8 ( char **sec8, size_t lmax, struct temp_chunks *t )
533{
534 size_t used = 0;
535 char *c = *sec8;
536
537 if ( t->b.s8.h[0] )
538 {
539 used += snprintf ( c + used, lmax - used, " 41414 " );
540 if ( t->b.s8.Nh[0] )
541 {
542 used += snprintf ( c + used, lmax - used, "%s", t->b.s8.Nh );
543 }
544 else
545 {
546 used += snprintf ( c + used, lmax - used, "/" );
547 }
548
549 if ( t->b.s8.Cl[0] )
550 {
551 used += snprintf ( c + used, lmax - used, "%s", t->b.s8.Cl );
552 }
553 else
554 {
555 used += snprintf ( c + used, lmax - used, "/" );
556 }
557
558 if ( t->b.s8.h[0] )
559 {
560 used += snprintf ( c + used, lmax - used, "%s", t->b.s8.h );
561 }
562 else
563 {
564 used += snprintf ( c + used, lmax - used, "/" );
565 }
566
567 if ( t->b.s8.Cm[0] )
568 {
569 used += snprintf ( c + used, lmax - used, "%s", t->b.s8.Cm );
570 }
571 else
572 {
573 used += snprintf ( c + used, lmax - used, "/" );
574 }
575
576 if ( t->b.s8.Ch[0] )
577 {
578 used += snprintf ( c + used, lmax - used, "%s", t->b.s8.Ch );
579 }
580 else
581 {
582 used += snprintf ( c + used, lmax - used, "/" );
583 }
584
585 //used += snprintf ( c + used, lmax - used, " %s%s%s%s%s", t->b.s8.Nh, t->b.s8.Cl, t->b.s8.h, t->b.s8.Cm, t->b.s8.Ch );
586 }
587
588 *sec8 = c + used;
589 return used;
590}
591
592
593/*!
594 \fn int print_temp_b (struct metreport *m )
595 \brief Prints the part B of a TEMP report into a string
596 \param m pointer to struct \ref metreport where are both target and source
597
598 If OK returns 0, otherwise 1
599 */
600int print_temp_b ( struct metreport *m )
601{
602 char *c = &(m->alphanum2[0]);
603 size_t used = 0;
604 size_t lmax = sizeof(m->alphanum);
605 struct temp_chunks *t = &m->temp;
606
607
608 // Needs time extension
609 if ( t->b.e.YYYY[0] == 0 || t->b.e.YYYY[0] == '0')
610 {
611 return 1;
612 }
613
615 {
616 used += print_wigos_id ( &c, lmax, m );
617 }
618
619 if ( m->print_mask & PRINT_BITMASK_GEO )
620 {
621 used += print_geo ( &c, lmax, m );
622 }
623
624 used += print_temp_b_sec1 ( &c, lmax - used, t );
625 used += print_temp_b_sec5 ( &c, lmax - used, t );
626 used += print_temp_b_sec6 ( &c, lmax - used, t );
627 used += print_temp_b_sec7 ( &c, lmax - used, t );
628 used += print_temp_b_sec8 ( &c, lmax - used, t );
629 used += snprintf ( c, lmax - used, "=" );
630 return 0;
631}
632
633
634/*!
635 \fn size_t print_temp_c_sec1 (char **sec1, size_t lmax, struct temp_chunks *t)
636 \brief Prints the section 1 of part C of a TEMP report
637 \param sec1 the pointer where to print section
638 \param lmax max length permited
639 \param t pointer to s atruct \ref temp_chunks where the parse results are set
640
641 returns the string sec1
642*/
643size_t print_temp_c_sec1 ( char **sec1, size_t lmax, struct temp_chunks *t )
644{
645 size_t used = 0;
646 char *c = *sec1;
647
648 used += snprintf ( c + used, lmax - used, "%s", t->t.datime );
649
650 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s1.MiMi, t->c.s1.MjMj );
651
652 if ( t->c.s1.D_D[0] && t->a.s1.II[0] == 0 )
653 {
654 used += snprintf ( c + used, lmax - used, " %s", t->c.s1.D_D );
655 }
656
657 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s1.YYGG, t->c.s1.id );
658
659 // print IIiii
660 if ( t->c.s1.II[0] )
661 {
662 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s1.II, t->c.s1.iii );
663 }
664 else
665 {
666 if ( t->c.s1.LaLaLa[0] )
667 {
668 used += snprintf ( c + used, lmax - used, " 99%s", t->c.s1.LaLaLa );
669 }
670 else
671 {
672 used += snprintf ( c + used, lmax - used, " 99///" );
673 }
674
675 if ( t->c.s1.Qc[0] && t->c.s1.LoLoLoLo[0] )
676 {
677 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s1.Qc, t->c.s1.LoLoLoLo );
678 }
679 else
680 {
681 used += snprintf ( c + used, lmax - used, " /////" );
682 }
683
684 if ( t->c.s1.MMM[0] && t->c.s1.Ula[0] && t->c.s1.Ulo[0] )
685 {
686 used += snprintf ( c + used, lmax - used, " %s%s%s", t->c.s1.MMM, t->c.s1.Ula, t->c.s1.Ulo );
687 }
688
689 if ( t->c.s1.h0h0h0h0[0] )
690 {
691 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s1.h0h0h0h0, t->c.s1.im );
692 }
693 }
694
695 *sec1 = c + used;
696 return used;
697}
698
699/*!
700 \fn size_t print_temp_c_sec2 (char **sec2, size_t lmax, struct temp_chunks *t)
701 \brief Prints the section 2 of part C of a TEMP report
702 \param sec2 the pointer where to print section
703 \param lmax max length permited
704 \param t pointer to s atruct \ref temp_chunks where the parse results are set
705
706 returns the string sec2
707*/
708size_t print_temp_c_sec2 ( char **sec2, size_t lmax, struct temp_chunks *t )
709{
710 size_t i;
711 size_t used = 0;
712 char *c = *sec2;
713
714 for ( i = 0; i < t->c.s2.n ; i++ )
715 {
716 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s2.std[i].PnPn, t->c.s2.std[i].hnhnhn );
717 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s2.std[i].TnTnTan, t->c.s2.std[i].DnDn );
718 used += snprintf ( c + used, lmax - used, " %s", t->c.s2.std[i].dndnfnfnfn );
719 }
720
721 *sec2 = c + used;
722 return used;
723
724}
725
726/*!
727 \fn size_t print_temp_c_sec3 (char **sec3, size_t lmax, struct temp_chunks *t)
728 \brief Prints the section 3 of part C of a TEMP report
729 \param sec3 the pointer where to print section
730 \param lmax max length permited
731 \param t pointer to s atruct \ref temp_chunks where the parse results are set
732
733 returns the string sec3
734*/
735size_t print_temp_c_sec3 ( char **sec3, size_t lmax, struct temp_chunks *t )
736{
737 size_t i;
738 size_t used = 0;
739 char *c = *sec3;
740
741 if ( t->c.s3.n == 0 )
742 {
743 used += snprintf ( c + used, lmax - used, " 88999" );
744 }
745 else
746 {
747 for ( i = 0; i < t->c.s3.n ; i++ )
748 {
749 used += snprintf ( c + used, lmax - used, " 88%s", t->c.s3.trop[i].PnPnPn );
750 used += snprintf ( c + used, lmax - used, " %s%s", t->c.s3.trop[i].TnTnTan, t->c.s3.trop[i].DnDn );
751 used += snprintf ( c + used, lmax - used, " %s", t->c.s3.trop[i].dndnfnfnfn );
752 }
753 }
754
755 *sec3 = c + used;
756 return used;
757
758}
759
760/*!
761 \fn size_t print_temp_c_sec4 (char **sec4, size_t lmax, struct temp_chunks *t)
762 \brief Prints the section 4 of part C of a TEMP report
763 \param sec4 the pointer where to print section
764 \param lmax max length permited
765 \param t pointer to s atruct \ref temp_chunks where the parse results are set
766
767 returns the string sec4
768*/
769size_t print_temp_c_sec4 ( char **sec4, size_t lmax, struct temp_chunks *t )
770{
771 size_t i;
772 size_t used = 0;
773 char *c = *sec4;
774
775 if ( t->c.s4.n == 0 )
776 {
777 used += snprintf ( c + used, lmax - used, " 77999" );
778 }
779 else
780 {
781 for ( i = 0; i < t->c.s4.n ; i++ )
782 {
783 if ( t->c.s4.windx[i].no_last_wind )
784 {
785 used += snprintf ( c + used, lmax - used, " 77%s", t->c.s4.windx[i].PmPmPm );
786 }
787 else
788 {
789 used += snprintf ( c + used, lmax - used, " 66%s", t->c.s4.windx[i].PmPmPm );
790 }
791 used += snprintf ( c + used, lmax - used, " %s", t->c.s4.windx[i].dmdmfmfmfm );
792 if ( t->c.s4.windx[i].vbvb[0] && t->c.s4.windx[i].vava[0] )
793 {
794 used += snprintf ( c + used, lmax - used, " 4%s%s", t->c.s4.windx[i].vbvb, t->c.s4.windx[i].vava );
795 }
796 }
797 }
798
799 *sec4 = c + used;
800 return used;
801
802}
803
804/*!
805 \fn size_t print_temp_c_sec7 (char **sec7, size_t lmax, struct temp_chunks *t)
806 \brief Prints the section 7 of part C of a TEMP report
807 \param sec7 the pointer where to print section
808 \param lmax max length permited
809 \param t pointer to s atruct \ref temp_chunks where the parse results are set
810
811 returns the string sec7
812*/
813size_t print_temp_c_sec7 ( char **sec7, size_t lmax, struct temp_chunks *t )
814{
815 size_t used = 0;
816 char *c = *sec7;
817
818 used += snprintf ( c + used, lmax - used, " 31313" );
819 used += snprintf ( c + used, lmax - used, " %s%s%s", t->c.s7.sr, t->c.s7.rara, t->c.s7.sasa );
820 used += snprintf ( c + used, lmax - used, " 8%s%s", t->c.s7.GG, t->c.s7.gg );
821
822 if ( t->c.s7.TwTwTw[0] )
823 {
824 used += snprintf ( c + used, lmax - used, " 9%s%s", t->c.s7.sn, t->c.s7.TwTwTw );
825 }
826
827 *sec7 = c + used;
828 return used;
829}
830
831/*!
832 \fn int print_temp_c (struct metreport *m )
833 \brief Prints the part C of a TEMP report into a string
834 \param m pointer to struct \ref metreport where are both target and source
835
836 If OK returns 0, otherwise 1
837*/
838int print_temp_c ( struct metreport *m )
839{
840 char *c = &(m->alphanum3[0]);
841 size_t used = 0;
842 size_t lmax = sizeof(m->alphanum);
843 struct temp_chunks *t = &m->temp;
844
845
846 // Needs time extension
847 if ( t->c.e.YYYY[0] == 0 || t->c.e.YYYY[0] == '0')
848 {
849 return 1;
850 }
851
853 {
854 used += print_wigos_id ( &c, lmax, m );
855 }
856
857 if ( m->print_mask & PRINT_BITMASK_GEO )
858 {
859 used += print_geo ( &c, lmax, m );
860 }
861
862 used += print_temp_c_sec1 ( &c, lmax - used, t );
863 used += print_temp_c_sec2 ( &c, lmax - used, t );
864 used += print_temp_c_sec3 ( &c, lmax - used, t );
865 used += print_temp_c_sec4 ( &c, lmax - used, t );
866 used += print_temp_c_sec7 ( &c, lmax - used, t );
867 used += snprintf ( c, lmax - used, "=" );
868 return 0;
869}
870
871/*!
872 \fn size_t print_temp_d_sec1 (char **sec1, size_t lmax, struct temp_chunks *t)
873 \brief Prints the section 1 of part D of a TEMP report
874 \param sec1 the pointer where to print section
875 \param lmax max length permited
876 \param t pointer to s atruct \ref temp_chunks where the parse results are set
877
878 returns the string sec1
879*/
880size_t print_temp_d_sec1 ( char **sec1, size_t lmax, struct temp_chunks *t )
881{
882 size_t used = 0;
883 char *c = *sec1;
884
885 used += snprintf ( c + used, lmax - used, "%s", t->t.datime );
886
887 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s1.MiMi, t->d.s1.MjMj );
888
889 if ( t->d.s1.D_D[0] && t->a.s1.II[0] == 0 )
890 {
891 used += snprintf ( c + used, lmax - used, " %s", t->d.s1.D_D );
892 }
893
894 used += snprintf ( c + used, lmax - used, " %s/", t->d.s1.YYGG );
895
896 // print IIiii
897 if ( t->d.s1.II[0] )
898 {
899 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s1.II, t->d.s1.iii );
900 }
901 else
902 {
903 if ( t->d.s1.LaLaLa[0] )
904 {
905 used += snprintf ( c + used, lmax - used, " 99%s", t->d.s1.LaLaLa );
906 }
907 else
908 {
909 used += snprintf ( c + used, lmax - used, " 99///" );
910 }
911
912 if ( t->d.s1.Qc[0] && t->d.s1.LoLoLoLo[0] )
913 {
914 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s1.Qc, t->d.s1.LoLoLoLo );
915 }
916 else
917 {
918 used += snprintf ( c + used, lmax - used, " /////" );
919 }
920
921 if ( t->d.s1.MMM[0] && t->d.s1.Ula[0] && t->d.s1.Ulo[0] )
922 {
923 used += snprintf ( c + used, lmax - used, " %s%s%s", t->d.s1.MMM, t->d.s1.Ula, t->d.s1.Ulo );
924 }
925
926 if ( t->d.s1.h0h0h0h0[0] )
927 {
928 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s1.h0h0h0h0, t->d.s1.im );
929 }
930 }
931
932 *sec1 = c + used;
933 return used;
934}
935
936/*!
937 \fn size_t print_temp_d_sec5 (char **sec5, size_t lmax, struct temp_chunks *t)
938 \brief Prints the section 5 of part D of a TEMP report
939 \param sec5 the pointer where to print section
940 \param lmax max length permited
941 \param t pointer to s atruct \ref temp_chunks where the parse results are set
942
943 returns the string sec5
944*/
945size_t print_temp_d_sec5 ( char **sec5, size_t lmax, struct temp_chunks *t )
946{
947 size_t i;
948 size_t used = 0;
949 char *c = *sec5;
950
951 for ( i = 0; i < t->d.s5.n && i < TEMP_NMAX_POINTS ; i++ )
952 {
953 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s5.th[i].nini, t->d.s5.th[i].PnPnPn );
954 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s5.th[i].TnTnTan, t->d.s5.th[i].DnDn );
955 }
956
957 *sec5 = c + used;
958 return used;
959}
960
961/*!
962 \fn size_t print_temp_d_sec6 (char **sec6, size_t lmax, struct temp_chunks *t)
963 \brief Prints the section 6 of part D of a TEMP report
964 \param sec6 the pointer where to print section
965 \param lmax max length permited
966 \param t pointer to s atruct \ref temp_chunks where the parse results are set
967
968 returns the string sec6
969*/
970size_t print_temp_d_sec6 ( char **sec6, size_t lmax, struct temp_chunks *t )
971{
972 size_t i;
973 size_t used = 0;
974 char *c = *sec6;
975
976 used += snprintf ( c + used, lmax - used, " 21212" );
977
978 for ( i = 0; i < t->d.s6.n && i < TEMP_NMAX_POINTS ; i++ )
979 {
980 used += snprintf ( c + used, lmax - used, " %s%s", t->d.s6.wd[i].nini, t->d.s6.wd[i].PnPnPn );
981 used += snprintf ( c + used, lmax - used, " %s", t->d.s6.wd[i].dndnfnfnfn );
982 }
983
984 *sec6 = c + used;
985 return used;
986}
987
988/*!
989 \fn size_t print_temp_d_sec7 (char **sec7, size_t lmax, struct temp_chunks *t)
990 \brief Prints the section 7 of part D of a TEMP report
991 \param sec7 the pointer where to print section
992 \param lmax max length permited
993 \param t pointer to s atruct \ref temp_chunks where the parse results are set
994
995 returns the string sec7
996*/
997size_t print_temp_d_sec7 ( char **sec7, size_t lmax, struct temp_chunks *t )
998{
999 size_t used = 0;
1000 char *c = *sec7;
1001
1002 used += snprintf ( c + used, lmax - used, " 31313" );
1003 used += snprintf ( c + used, lmax - used, " %s%s%s", t->d.s7.sr, t->d.s7.rara, t->d.s7.sasa );
1004 used += snprintf ( c + used, lmax - used, " 8%s%s", t->d.s7.GG, t->d.s7.gg );
1005
1006 if ( t->d.s7.TwTwTw[0] )
1007 {
1008 used += snprintf ( c + used, lmax - used, " 9%s%s", t->d.s7.sn, t->d.s7.TwTwTw );
1009 }
1010
1011 *sec7 = c + used;
1012 return used;
1013}
1014
1015/*!
1016 \fn int print_temp_d (struct metreport *m)
1017 \brief Prints the part D of a TEMP report into a string
1018 \param m pointer to struct \ref metreport where are both target and source
1019
1020 If OK returns 0, otherwise 1
1021*/
1022int print_temp_d ( struct metreport *m )
1023{
1024 char *c = &(m->alphanum4[0]);
1025 size_t used = 0;
1026 size_t lmax = sizeof(m->alphanum);
1027 struct temp_chunks *t = &m->temp;
1028
1029 // Needs time extension
1030 if ( t->d.e.YYYY[0] == 0 || t->d.e.YYYY[0] == '0')
1031 {
1032 return 1;
1033 }
1034
1036 {
1037 used += print_wigos_id ( &c, lmax, m );
1038 }
1039
1040 if ( m->print_mask & PRINT_BITMASK_GEO )
1041 {
1042 used += print_geo ( &c, lmax, m );
1043 }
1044
1045 used += print_temp_d_sec1 ( &c, lmax - used, t );
1046 used += print_temp_d_sec5 ( &c, lmax - used, t );
1047 used += print_temp_d_sec6 ( &c, lmax - used, t );
1048 used += print_temp_d_sec7 ( &c, lmax - used, t );
1049 used += snprintf ( c, lmax - used, "=" );
1050 return 0;
1051}
1052
1053/*!
1054 \fn int print_temp_report ( struct metreport *m )
1055 \brief print the four parts of a decoded TEMP report from a BUFR file into strings
1056 \param m pointer to a struct \ref metreport in which alphanumeric string members stores the reults
1057*/
1059{
1060 // It is required that al lesat a standard level where decoded in SEC A
1061 if ( m->temp.a.mask & TEMP_SEC_2 )
1062 {
1063 print_temp_a ( m );
1064 }
1065
1066 // It is required a significant TH or wind poind for sec B
1067 if ( m->temp.b.mask & ( TEMP_SEC_5 | TEMP_SEC_6 ) )
1068 {
1069 print_temp_b ( m );
1070 }
1071
1072 // It is required a standard level for SEC C
1073 if ( m->temp.c.mask & TEMP_SEC_2 )
1074 {
1075 print_temp_c ( m );
1076 }
1077
1078 // It is required a significant TH or wind poind for sec B
1079 if ( m->temp.d.mask & ( TEMP_SEC_5 | TEMP_SEC_6 ) )
1080 {
1081 print_temp_d ( m );
1082 }
1083
1084 return 0;
1085}
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_temp_b_sec5(char **sec5, size_t lmax, struct temp_chunks *t)
Prints the section 5 of part B of a TEMP report.
size_t print_temp_c_sec2(char **sec2, size_t lmax, struct temp_chunks *t)
Prints the section 2 of part C of a TEMP report.
size_t print_temp_d_sec5(char **sec5, size_t lmax, struct temp_chunks *t)
Prints the section 5 of part D of a TEMP report.
size_t print_temp_c_sec4(char **sec4, size_t lmax, struct temp_chunks *t)
Prints the section 4 of part C of a TEMP report.
size_t print_temp_c_sec7(char **sec7, size_t lmax, struct temp_chunks *t)
Prints the section 7 of part C of a TEMP report.
size_t print_temp_b_sec6(char **sec6, size_t lmax, struct temp_chunks *t)
Prints the section 6 of part B of a TEMP report.
size_t print_temp_b_sec8(char **sec8, size_t lmax, struct temp_chunks *t)
Prints the section 8 of part B of a TEMP report.
int print_temp_d(struct metreport *m)
Prints the part D of a TEMP report into a string.
size_t print_temp_a_sec2(char **sec2, size_t lmax, struct temp_chunks *t)
Prints the section 2 of part A of a TEMP report.
int print_temp_raw_wind_shear_data(struct temp_raw_wind_shear_data *w)
Prints for debug a struct temp_raw_data.
size_t print_temp_d_sec7(char **sec7, size_t lmax, struct temp_chunks *t)
Prints the section 7 of part D of a TEMP report.
size_t print_temp_c_sec1(char **sec1, size_t lmax, struct temp_chunks *t)
Prints the section 1 of part C of a TEMP report.
size_t print_temp_d_sec6(char **sec6, size_t lmax, struct temp_chunks *t)
Prints the section 6 of part D of a TEMP report.
size_t print_temp_b_sec7(char **sec7, size_t lmax, struct temp_chunks *t)
Prints the section 7 of part B of a TEMP report.
size_t print_temp_b_sec1(char **sec1, size_t lmax, struct temp_chunks *t)
Prints the section 1 of part B of a TEMP report.
size_t print_temp_a_sec4(char **sec4, size_t lmax, struct temp_chunks *t)
Prints the section 4 of part A of a TEMP report.
size_t print_temp_a_sec1(char **sec1, size_t lmax, struct temp_chunks *t)
Prints the section 1 of part A of a TEMP report.
size_t print_temp_c_sec3(char **sec3, size_t lmax, struct temp_chunks *t)
Prints the section 3 of part C of a TEMP report.
int print_temp_a(struct metreport *m)
Prints the part A of a TEMP report into a string.
size_t print_temp_d_sec1(char **sec1, size_t lmax, struct temp_chunks *t)
Prints the section 1 of part D of a TEMP report.
int print_temp_c(struct metreport *m)
Prints the part C of a TEMP report into a string.
size_t print_temp_a_sec3(char **sec3, size_t lmax, struct temp_chunks *t)
Prints the section 3 of part A of a TEMP report.
int print_temp_raw_data(struct temp_raw_data *r)
Prints for debug a struct temp_raw_data.
int print_temp_report(struct metreport *m)
print the four parts of a decoded TEMP report from a BUFR file into strings
int print_temp_b(struct metreport *m)
Prints the part B of a TEMP report into a string.
size_t print_temp_a_sec7(char **sec7, size_t lmax, struct temp_chunks *t)
Prints the section 7 of part A of a TEMP report.
#define MISSING_REAL
The missing default value for real values.
Definition: bufrdeco.h:78
#define TEMP_SEC_6
mask bit meaning sec 6 of a part of TEMP report parsed with success
Definition: mettemp.h:89
#define TEMP_SEC_5
mask bit meaning sec 5 of a part of TEMP report parsed with success
Definition: mettemp.h:83
#define TEMP_SEC_2
mask bit meaning sec 2 of a part of TEMP report parsed with success
Definition: mettemp.h:65
#define TEMP_NMAX_POINTS
maximum number of significant points
Definition: mettemp.h:138
char datime[16]
Definition: metcommon.h:63
time_t t
Definition: metcommon.h:61
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
struct temp_chunks temp
Definition: bufr2tac.h:318
int print_mask
Definition: bufr2tac.h:312
char alphanum3[REPORT_LENGTH]
Definition: bufr2tac.h:325
char alphanum2[REPORT_LENGTH]
Definition: bufr2tac.h:323
char alphanum4[REPORT_LENGTH]
Definition: bufr2tac.h:327
struct temp_main_level_data lev0
Definition: mettemp.h:365
size_t n
Definition: mettemp.h:364
struct temp_std_level_data std[TEMP_NSTAND_MAX]
Definition: mettemp.h:366
int mask
Definition: mettemp.h:453
struct temp_ac_sec3 s3
Definition: mettemp.h:457
struct temp_acd_sec1 s1
Definition: mettemp.h:455
struct temp_ac_sec4 s4
Definition: mettemp.h:458
struct temp_a_sec2 s2
Definition: mettemp.h:456
struct temp_sec7 s7
Definition: mettemp.h:459
struct temp_main_level_data trop[TEMP_NTROP_MAX]
Definition: mettemp.h:386
size_t n
Definition: mettemp.h:385
struct temp_max_wind_data windx[TEMP_NMAXWIND_MAX]
Definition: mettemp.h:396
size_t n
Definition: mettemp.h:395
char MiMi[4]
Definition: mettemp.h:310
char h0h0h0h0[6]
Definition: mettemp.h:327
char YYGG[8]
Definition: mettemp.h:315
char LoLoLoLo[6]
Definition: mettemp.h:323
char MMM[4]
Definition: mettemp.h:324
char II[4]
Definition: mettemp.h:317
char LaLaLa[4]
Definition: mettemp.h:321
char D_D[10]
Definition: mettemp.h:314
char id[2]
Definition: mettemp.h:316
char Ulo[2]
Definition: mettemp.h:326
char MjMj[4]
Definition: mettemp.h:311
char im[2]
Definition: mettemp.h:328
char Qc[2]
Definition: mettemp.h:322
char Ula[2]
Definition: mettemp.h:325
char iii[4]
Definition: mettemp.h:318
int mask
Definition: mettemp.h:468
int mask
Definition: mettemp.h:483
Store the whole TEMP report.
Definition: mettemp.h:511
struct temp_c c
Definition: mettemp.h:517
struct met_datetime t
Definition: mettemp.h:513
struct temp_d d
Definition: mettemp.h:518
struct temp_b b
Definition: mettemp.h:516
struct temp_a a
Definition: mettemp.h:515
int mask
Definition: mettemp.h:498
char dndnfnfnfn[8]
Definition: mettemp.h:252
char PmPmPm[4]
Definition: mettemp.h:275
char dmdmfmfmfm[8]
Definition: mettemp.h:276
Stores the array of all data profile points as it in bufr sequence.
Definition: mettemp.h:213
struct temp_raw_point_data raw[TEMP_NMAX_POINTS *4]
Definition: mettemp.h:215
size_t n
Definition: mettemp.h:214
array of Wind shear data points at a pressure level
Definition: mettemp.h:238
struct temp_raw_wind_shear_point raw[TEMP_NMAX_POINTS]
Definition: mettemp.h:240
char rara[4]
Definition: mettemp.h:406
char sn[2]
Definition: mettemp.h:410
char TwTwTw[4]
Definition: mettemp.h:411
char sr[2]
Definition: mettemp.h:405
char sasa[4]
Definition: mettemp.h:407
char GG[4]
Definition: mettemp.h:408
char gg[4]
Definition: mettemp.h:409
char dndnfnfnfn[8]
Definition: mettemp.h:265