bufr2synop 0.24.0
Data Structures | Macros | Functions | Variables
bufr2tac.h File Reference

Include header file for binary bufr2tac. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <time.h>
#include <math.h>
#include <sys/stat.h>
#include "bufrdeco.h"
#include "metsynop.h"
#include "metbuoy.h"
#include "mettemp.h"
#include "metclimat.h"
Include dependency graph for bufr2tac.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bufr2tac_error
 Store an error/warning/info and its severity. More...
 
struct  bufr2tac_error_stack
 A stack of structs bufr2tac_error. More...
 
struct  bufr2tac_subset_state
 stores information needed to parse a sequential list of expanded descriptors for a subset More...
 
struct  met_geo
 Geographic meta information. More...
 
struct  metreport
 all the information for a meteorological report in WMO text format from a BUFR file More...
 

Macros

#define _GNU_SOURCE
 
#define SUBSET_MASK_LATITUDE_SOUTH   (1)
 Bit mask to mark a struct bufr_subset_sequence_data with south latitude. More...
 
#define SUBSET_MASK_LONGITUDE_WEST   (2)
 Bit mask to mark a struct bufr_subset_sequence_data with west longitude. More...
 
#define SUBSET_MASK_HAVE_TYPE_STATION   (4)
 Bit mask to mark a struct bufr_subset_sequence_data having type station information. More...
 
#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_WW   (8)
 Bit mask to mark a struct bufr_subset_sequence_data without WW information. More...
 
#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_W1   (16)
 Bit mask to mark a struct bufr_subset_sequence_data without W1 information. More...
 
#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_W2   (32)
 Bit mask to mark a struct bufr_subset_sequence_data without W1 information. More...
 
#define SUBSET_MASK_HAVE_LATITUDE   (64)
 Bit mask to mark a struct bufr_subset_sequence_data having latitude. More...
 
#define SUBSET_MASK_HAVE_LONGITUDE   (128)
 Bit mask to mark a struct bufr_subset_sequence_data having longitude. More...
 
#define SUBSET_MASK_HAVE_ALTITUDE   (256)
 Bit mask to mark a struct bufr_subset_sequence_data having altitude. More...
 
#define SUBSET_MASK_HAVE_NAME   (512)
 Bit mask to mark a struct bufr_subset_sequence_data having station name. More...
 
#define SUBSET_MASK_HAVE_COUNTRY   (1024)
 Bit mask to mark a struct bufr_subset_sequence_data having country name. More...
 
#define SUBSET_MASK_HAVE_YEAR   (2048)
 Bit mask to mark a struct bufr_subset_sequence_data having observation year. More...
 
#define SUBSET_MASK_HAVE_MONTH   (4096)
 Bit mask to mark a struct bufr_subset_sequence_data having observation month. More...
 
#define SUBSET_MASK_HAVE_DAY   (8192)
 Bit mask to mark a struct bufr_subset_sequence_data having observation day in a month. More...
 
#define SUBSET_MASK_HAVE_HOUR   (16384)
 Bit mask to mark a struct bufr_subset_sequence_data having observation hour. More...
 
#define SUBSET_MASK_HAVE_MINUTE   (32768)
 Bit mask to mark a struct bufr_subset_sequence_data having observation minute. More...
 
#define SUBSET_MASK_HAVE_SECOND   (65536)
 Bit mask to mark a struct bufr_subset_sequence_data having observation second. More...
 
#define SUBSET_MASK_HAVE_GUST   (131072)
 Bit mask to mark a struct bufr_subset_sequence_data having wind gust observation other than 10 minutes. More...
 
#define SUBSET_MASK_HAVE_GUST10   ( 2 * 131072)
 Bit mask to mark a struct bufr_subset_sequence_data having wind gust observation other than 10 minutes. More...
 
#define SUBSET_MASK_HAVE_WIGOS_ID   ( 4 * 131072)
 Bit mask to mark if a subset has a WIGOS ID. More...
 
#define BUFR2TAC_ERROR_STACK_DIM   16
 set de dimension of a struct bufr2tac_error_stack More...
 
#define BUFR2TAC_ERROR_DESCRIPTION_LENGTH   1024
 set de dimension of member description of a struct bufr2tac_error More...
 
#define REPORT_LENGTH   (16384)
 
#define PRINT_BITMASK_WIGOS   (1)
 Bit mask to member print_mask in struct metreport to print WIGOS Identifier. More...
 
#define PRINT_BITMASK_GEO   (2)
 Bit mask to member print_mask in struct metreport to print geographic position. More...
 
#define bufr_subset_sequence_data   bufrdeco_subset_sequence_data
 To use bufrdeco library with legacy old code using ECMWF library which is not used currently. More...
 

Functions

char * bufr2tac_get_version (char *version, size_t dversion, char *build, size_t dbuild, char *builder, size_t dbuilder, int *version_major, int *version_minor, int *version_patch)
 
int bufr2tac_push_error (struct bufr2tac_error_stack *e, int severity, char *description)
 
int bufr2tac_clean_error_stack (struct bufr2tac_error_stack *e)
 
int bufr2tac_set_error (struct bufr2tac_subset_state *s, int severity, char *origin, char *explanation)
 
int bufr2tac_print_error (struct bufr2tac_error_stack *e)
 
int bufr2tac_set_debug_level (int level)
 
void bufr2tac_clean_buoy_chunks (struct buoy_chunks *b)
 cleans a buoy_chunks struct More...
 
void bufr2tac_clean_synop_chunks (struct synop_chunks *s)
 
void bufr2tac_clean_temp_chunks (struct temp_chunks *t)
 cleans a buoy_chunks struct More...
 
void bufr2tac_clean_climat_chunks (struct climat_chunks *c)
 cleans a climat_chunks struct More...
 
void bufr2tac_clean_metreport (struct metreport *m)
 
int set_environment (char *default_bufrtables, char *bufrtables_dir)
 
int integer_to_descriptor (struct bufr_descriptor *d, int id)
 parse an integer with a descriptor fom bufr ECWMF libary More...
 
int descriptor_to_integer (int *id, struct bufr_descriptor *d)
 parse a descriptor and sets an integer in the decimal formas fxxyyy More...
 
unsigned int three_bytes_to_uint (const unsigned char *source)
 returns the integer value from an array of three bytes, most significant first More...
 
char * charray_to_string (char *s, unsigned char *buf, size_t size)
 get a null termitated c-string from an array of unsigned chars More...
 
char * adjust_string (char *s)
 Supress trailing blanks of a string. More...
 
char * get_explained_table_val (char *expl, size_t dim, char tablec[MAXLINES_TABLEC][92], size_t nlines_tablec, struct bufr_descriptor *d, int ival)
 
char * get_explained_flag_val (char *expl, size_t dim, char tablec[MAXLINES_TABLEC][92], size_t nlines_tablec, struct bufr_descriptor *d, unsigned long ival)
 
char * get_ecmwf_tablename (char *target, char type, char *bufrtables_dir, int ksec1[40])
 Get the complete pathname of a table file needed by a bufr message. More...
 
int parse_subset_as_buoy (struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
 
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 More...
 
int parse_subset_as_temp (struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
 
int parse_subset_as_climat (struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
 
int YYYYMMDDHHmm_to_met_datetime (struct met_datetime *t, const char *source)
 Parse the string YYYYMMDDHHmm[ss] and set a struct met_datetime. More...
 
int round_met_datetime_to_hour (struct met_datetime *target, struct met_datetime *source)
 
int synop_YYYYMMDDHHmm_to_YYGG (struct synop_chunks *syn)
 Sets YYGG from YYYYMMDDHHmm extended group. More...
 
char * met_datetime_to_YYGG (char *target, struct met_datetime *t)
 Get YYGG from a struct met_datetime. More...
 
int buoy_YYYYMMDDHHmm_to_JMMYYGGgg (struct buoy_chunks *b)
 Sets YYGG from YYYYMMDDHHmm extended group. More...
 
int check_date_from_future (struct metreport *m)
 Check a estructure metreport not from future. More...
 
char * guess_WMO_region (char *A1, char *Reg, const char *II, const char *iii)
 get WMO region A1 and Reg items from II and iii (WMO index) More...
 
char * guess_WMO_region_synop (struct synop_chunks *syn)
 Try to find WMO region if it is not already set and WMO Block and number index are known. More...
 
char * guess_WMO_region_temp (struct temp_chunks *temp)
 
int read_table_c (char tablec[MAXLINES_TABLEC][92], size_t *nlines_tablec, char *bufrtables_dir, int ksec1[40])
 
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...
 
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 bufr_set_environment (char *default_bufrtables, char *bufrtables_dir)
 set the environment vars needed to work properly with ECMWF bufrdc library More...
 
int guess_gts_header (struct gts_header *h, const char *f)
 Guess the WMO GTS header from filename. More...
 
int read_bufr (unsigned char *bufr, char *filename, int *length)
 read a bufr file as an array of unsigned chars More...
 
int time_period_duration (struct bufr2tac_subset_state *s)
 Get time period duration in seconds. More...
 
int hour_rounded (struct synop_chunks *syn)
 Get the rounded hour of a given date. More...
 
char * latlon_to_MMM (char *target, double lat, double lon)
 convert latitude and longitude to a MMM string More...
 
char * kelvin_to_TTTT (char *target, double T)
 converts a kelvin temperature value into a TTTT string More...
 
char * kelvin_to_snTTT (char *target, double T)
 converts a kelvin temperature value into a snTTT string More...
 
char * kelvin_to_snTT (char *target, double T)
 converts a kelvin temperature value into a snTT string More...
 
char * kelvin_to_TT (char *target, double T)
 converts a kelvin temperature value into a TT string More...
 
char * kelvin_to_TTTa (char *target, double T)
 Set temperature TTTa. More...
 
char * dewpoint_depression_to_DnDn (char *target, double T, double Td)
 Set DnDn (dewpoint depression) More...
 
char * m_to_h (char *target, double h)
 converts the altitude of cloud layer into h string code More...
 
char * m_to_hh (char *target, double h)
 converts the altitude of cloud layer into hh string code More...
 
char * m_to_9h (char *target, double h)
 converts the altitude of cloud layer into 9h string code More...
 
char * m_to_RR (char *target, double m)
 Convert distance (m) in RR code (3570) More...
 
char * pascal_to_ppp (char *target, double P)
 Converts pascal values (variation) into a ppp string. More...
 
char * pascal_to_pnpnpn (char *target, double P)
 
char * pascal_to_PPPP (char *target, double P)
 Converts pascal values into a PPPP string. More...
 
char * percent_to_okta (char *target, double perc)
 Converts percent cloud cover into okta. More...
 
char * prec_to_RRR (char *target, double r)
 converts a precipitation in Kg/m2 into a RRR string More...
 
char * prec_to_RRRR24 (char *target, double r)
 converts a precipitation in Kg/m2 into a RRRR24 string More...
 
char * secs_to_tt (char *tt, int secs)
 get tt code from seconds More...
 
char * vism_to_VV (char *target, double V)
 Convert horizontal visibilty in meters to a VV string. More...
 
char * recent_snow_to_ss (char *target, double r)
 converts recent snow in m to ss (code table 3870) More...
 
char * total_snow_depth_to_sss (char *target, double r)
 converts tatal snow depth in m to sss (code table 3889) More...
 
char * wind_to_dndnfnfnfn (char *target, double dd, double ff)
 
char * grad_to_D (char *D, double grad)
 Converts true direction in grads to D (code table 0700) More...
 
char * grad_to_ec (char *target, double grad)
 Converts elevation in grads to ec (code table 1004) More...
 
int check_kj_m2 (double val)
 Check if a radiation value can be wrote in Kj/m2 using up to 4 chars. More...
 
int check_j_cm2 (double val)
 Check if a radiation value can be wrote in J/cm2 using up to 4 chars. More...
 
size_t print_geo (char **geo, size_t lmax, struct metreport *m)
 
size_t print_wigos_id (char **wid, size_t lmax, struct metreport *m)
 
int print_synop_report (struct metreport *m)
 prints a synop into a string More...
 
size_t print_synop_sec0 (char **sec0, size_t lmax, struct synop_chunks *syn)
 Prints the synop section 0 (header) More...
 
size_t print_synop_sec1 (char **sec1, size_t lmax, struct synop_chunks *syn)
 Prints the synop section 1. More...
 
size_t print_synop_sec2 (char **sec2, size_t lmax, struct synop_chunks *syn)
 Prints the synop section 2. More...
 
size_t print_synop_sec3 (char **sec3, size_t lmax, struct synop_chunks *syn)
 Prints the synop section 3. More...
 
size_t print_synop_wigos_id (char **wid, size_t lmax, struct synop_chunks *syn)
 
int print_buoy_report (struct metreport *m)
 prints a buoy into a string More...
 
size_t print_buoy_sec0 (char **sec0, size_t lmax, struct buoy_chunks *b)
 Prints the buoy section 1. More...
 
size_t print_buoy_sec1 (char **sec1, size_t lmax, struct buoy_chunks *b)
 Prints the buoy section 1. More...
 
size_t print_buoy_sec2 (char **sec2, size_t lmax, struct buoy_chunks *b)
 Prints the buoy section 1. More...
 
size_t print_buoy_sec3 (char **sec3, size_t lmax, struct buoy_chunks *b)
 Prints the buoy section 3. More...
 
size_t print_buoy_wigos_id (char **wid, size_t lmax, struct buoy_chunks *b)
 
int print_climat_report (struct metreport *m)
 prints a climat into a string More...
 
size_t print_climat_sec0 (char **sec0, size_t lmax, struct climat_chunks *cl)
 Prints the climat section 0 (header) More...
 
size_t print_climat_sec1 (char **sec1, size_t lmax, struct climat_chunks *cl)
 Prints the climat section 1. More...
 
size_t print_climat_sec2 (char **sec2, size_t lmax, struct climat_chunks *cl)
 Prints the climat section 2. More...
 
size_t print_climat_sec3 (char **sec3, size_t lmax, struct climat_chunks *cl)
 Prints the climat section 3. More...
 
size_t print_climat_sec4 (char **sec4, size_t lmax, struct climat_chunks *cl)
 Prints the climat section 4. More...
 
size_t print_climat_wigos_id (char **wid, size_t lmax, struct climat_chunks *cl)
 
int print_temp_report (struct metreport *m)
 print the four parts of a decoded TEMP report from a BUFR file into strings More...
 
int print_temp_a (struct metreport *m)
 Prints the part A of a TEMP report into a string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int print_temp_b (struct metreport *m)
 Prints the part B of a TEMP report into a string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int print_temp_c (struct metreport *m)
 Prints the part C of a TEMP report into a string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int print_temp_d (struct metreport *m)
 Prints the part D of a TEMP report into a string. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
size_t print_temp_d_sec8 (char **sec8, size_t lmax, struct temp_chunks *t)
 
size_t print_temp_wigos_id (char **wid, size_t lmax, struct temp_chunks *t)
 
int parse_temp_raw_data (struct temp_chunks *t, struct temp_raw_data *r)
 parse a struct temp_raw_data to fill chunks in a struct temp_chunks More...
 
int parse_temp_raw_wind_shear_data (struct temp_chunks *t, struct temp_raw_wind_shear_data *w)
 
int print_temp_raw_data (struct temp_raw_data *r)
 Prints for debug a struct temp_raw_data. More...
 
int print_temp_raw_wind_shear_data (struct temp_raw_wind_shear_data *w)
 Prints for debug a struct temp_raw_data. More...
 
int print_csv (FILE *f, struct metreport *m)
 prints a struct metreport in labeled csv format More...
 
int print_json (FILE *f, struct metreport *m)
 prints a struct metreport in json format More...
 
int print_xml (FILE *f, struct metreport *m)
 prints a struct metreport in xml format More...
 
int print_plain (FILE *f, struct metreport *m)
 Print in a file the report decoded to Traditional Alphanumeric Code in plain text format. A line per report. More...
 
int print_html (FILE *f, struct metreport *m)
 Print in a file the report decoded to Traditional Alphanumeric Code in plain html format. A line per report. More...
 
int syn_parse_x01 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 01. More...
 
int syn_parse_x02 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 02. More...
 
int syn_parse_x04 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 04. More...
 
int syn_parse_x05 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 05. More...
 
int syn_parse_x06 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 06. More...
 
int syn_parse_x07 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 07. More...
 
int syn_parse_x08 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 08. More...
 
int syn_parse_x10 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 10. More...
 
int syn_parse_x11 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 11. More...
 
int syn_parse_x12 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 12. More...
 
int syn_parse_x13 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 13. More...
 
int syn_parse_x14 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 14. More...
 
int syn_parse_x20 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 20. More...
 
int syn_parse_x22 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 01. More...
 
int syn_parse_x31 (struct synop_chunks *syn, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 31. More...
 
int buoy_parse_x01 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 01. More...
 
int buoy_parse_x02 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 02. More...
 
int buoy_parse_x04 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 04. More...
 
int buoy_parse_x05 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 05. More...
 
int buoy_parse_x06 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 06. More...
 
int buoy_parse_x07 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 07. More...
 
int buoy_parse_x08 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 08. More...
 
int buoy_parse_x10 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 10. More...
 
int buoy_parse_x11 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 11. More...
 
int buoy_parse_x12 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 12. More...
 
int buoy_parse_x13 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 13. More...
 
int buoy_parse_x14 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 14. More...
 
int buoy_parse_x20 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 20. More...
 
int buoy_parse_x22 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 22. More...
 
int buoy_parse_x31 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 31. More...
 
int buoy_parse_x33 (struct buoy_chunks *b, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 33. More...
 
int climat_parse_x01 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 01. More...
 
int climat_parse_x02 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 02. More...
 
int climat_parse_x04 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 04. More...
 
int climat_parse_x05 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 05. More...
 
int climat_parse_x06 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 06. More...
 
int climat_parse_x07 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 
int climat_parse_x08 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 08. More...
 
int climat_parse_x10 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 10. More...
 
int climat_parse_x11 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 11. More...
 
int climat_parse_x12 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 12. More...
 
int climat_parse_x13 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 13. More...
 
int climat_parse_x14 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 14. More...
 
int climat_parse_x20 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 
int climat_parse_x22 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 
int climat_parse_x31 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 
int climat_parse_x33 (struct climat_chunks *c, struct bufr2tac_subset_state *s)
 
int temp_parse_x01 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 01. More...
 
int temp_parse_x02 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 02. More...
 
int temp_parse_x04 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 04. More...
 
int temp_parse_x05 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 
int temp_parse_x06 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 
int temp_parse_x07 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 
int temp_parse_x08 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 08. More...
 
int temp_parse_x10 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 10. More...
 
int temp_parse_x11 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 11. More...
 
int temp_parse_x12 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 12. More...
 
int temp_parse_x20 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 20. More...
 
int temp_parse_x22 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 22. More...
 
int temp_parse_x31 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 31. More...
 
int temp_parse_x33 (struct temp_chunks *t, struct bufr2tac_subset_state *s)
 Parse a expanded descriptor with X = 33. More...
 
int bus012_ (int *, unsigned int *, int *, int *, int *, int *, int *)
 
int buprs0_ (int *)
 
int buprs1_ (int *)
 
int buprs3_ (int *, int *, int *, int *, int *, int *, char **)
 
int bufrex_ (int *, int *, int *, int *, int *, int *, int *, int *, int *, char **, char **, int *, double *, char **, int *)
 
int busel_ (int *, int *, int *, int *, int *)
 
int busel2_ (int *, int *, int *, char **, int *, char **, char **, char **, int *)
 
int buukey_ (int *, int *, int *, int *, int *)
 
int buprt_ (int *, int *, int *, int *, char **, char **, char **, int *, double *, int *, int *, int *)
 

Variables

int BUFR2TAC_DEBUG_LEVEL
 

Detailed Description

Include header file for binary bufr2tac.

Definition in file bufr2tac.h.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 28 of file bufr2tac.h.

◆ BUFR2TAC_ERROR_DESCRIPTION_LENGTH

#define BUFR2TAC_ERROR_DESCRIPTION_LENGTH   1024

set de dimension of member description of a struct bufr2tac_error

Definition at line 199 of file bufr2tac.h.

◆ BUFR2TAC_ERROR_STACK_DIM

#define BUFR2TAC_ERROR_STACK_DIM   16

set de dimension of a struct bufr2tac_error_stack

Definition at line 194 of file bufr2tac.h.

◆ bufr_subset_sequence_data

#define bufr_subset_sequence_data   bufrdeco_subset_sequence_data

To use bufrdeco library with legacy old code using ECMWF library which is not used currently.

Definition at line 220 of file bufr2tac.h.

◆ PRINT_BITMASK_GEO

#define PRINT_BITMASK_GEO   (2)

Bit mask to member print_mask in struct metreport to print geographic position.

Definition at line 214 of file bufr2tac.h.

◆ PRINT_BITMASK_WIGOS

#define PRINT_BITMASK_WIGOS   (1)

Bit mask to member print_mask in struct metreport to print WIGOS Identifier.

Definition at line 208 of file bufr2tac.h.

◆ REPORT_LENGTH

#define REPORT_LENGTH   (16384)

Definition at line 202 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_ALTITUDE

#define SUBSET_MASK_HAVE_ALTITUDE   (256)

Bit mask to mark a struct bufr_subset_sequence_data having altitude.

Definition at line 122 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_COUNTRY

#define SUBSET_MASK_HAVE_COUNTRY   (1024)

Bit mask to mark a struct bufr_subset_sequence_data having country name.

Definition at line 134 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_DAY

#define SUBSET_MASK_HAVE_DAY   (8192)

Bit mask to mark a struct bufr_subset_sequence_data having observation day in a month.

Definition at line 152 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_GUST

#define SUBSET_MASK_HAVE_GUST   (131072)

Bit mask to mark a struct bufr_subset_sequence_data having wind gust observation other than 10 minutes.

Definition at line 176 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_GUST10

#define SUBSET_MASK_HAVE_GUST10   ( 2 * 131072)

Bit mask to mark a struct bufr_subset_sequence_data having wind gust observation other than 10 minutes.

Definition at line 182 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_HOUR

#define SUBSET_MASK_HAVE_HOUR   (16384)

Bit mask to mark a struct bufr_subset_sequence_data having observation hour.

Definition at line 158 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_LATITUDE

#define SUBSET_MASK_HAVE_LATITUDE   (64)

Bit mask to mark a struct bufr_subset_sequence_data having latitude.

Definition at line 110 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_LONGITUDE

#define SUBSET_MASK_HAVE_LONGITUDE   (128)

Bit mask to mark a struct bufr_subset_sequence_data having longitude.

Definition at line 116 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_MINUTE

#define SUBSET_MASK_HAVE_MINUTE   (32768)

Bit mask to mark a struct bufr_subset_sequence_data having observation minute.

Definition at line 164 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_MONTH

#define SUBSET_MASK_HAVE_MONTH   (4096)

Bit mask to mark a struct bufr_subset_sequence_data having observation month.

Definition at line 146 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_NAME

#define SUBSET_MASK_HAVE_NAME   (512)

Bit mask to mark a struct bufr_subset_sequence_data having station name.

Definition at line 128 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_NO_SIGNIFICANT_W1

#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_W1   (16)

Bit mask to mark a struct bufr_subset_sequence_data without W1 information.

Definition at line 98 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_NO_SIGNIFICANT_W2

#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_W2   (32)

Bit mask to mark a struct bufr_subset_sequence_data without W1 information.

Definition at line 104 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_NO_SIGNIFICANT_WW

#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_WW   (8)

Bit mask to mark a struct bufr_subset_sequence_data without WW information.

Definition at line 92 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_SECOND

#define SUBSET_MASK_HAVE_SECOND   (65536)

Bit mask to mark a struct bufr_subset_sequence_data having observation second.

Definition at line 170 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_TYPE_STATION

#define SUBSET_MASK_HAVE_TYPE_STATION   (4)

Bit mask to mark a struct bufr_subset_sequence_data having type station information.

Definition at line 86 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_WIGOS_ID

#define SUBSET_MASK_HAVE_WIGOS_ID   ( 4 * 131072)

Bit mask to mark if a subset has a WIGOS ID.

Definition at line 188 of file bufr2tac.h.

◆ SUBSET_MASK_HAVE_YEAR

#define SUBSET_MASK_HAVE_YEAR   (2048)

Bit mask to mark a struct bufr_subset_sequence_data having observation year.

Definition at line 140 of file bufr2tac.h.

◆ SUBSET_MASK_LATITUDE_SOUTH

#define SUBSET_MASK_LATITUDE_SOUTH   (1)

Bit mask to mark a struct bufr_subset_sequence_data with south latitude.

Definition at line 74 of file bufr2tac.h.

◆ SUBSET_MASK_LONGITUDE_WEST

#define SUBSET_MASK_LONGITUDE_WEST   (2)

Bit mask to mark a struct bufr_subset_sequence_data with west longitude.

Definition at line 80 of file bufr2tac.h.

Function Documentation

◆ adjust_string()

char * adjust_string ( char *  s)

Supress trailing blanks of a string.

Parameters
sstring to process

Definition at line 99 of file bufr2tac_utils.c.

100{
101 size_t l;
102 l = strlen ( s );
103 while ( l && s[--l] == ' ' )
104 s[l] = '\0';
105 return s;
106}

Referenced by buoy_parse_x01(), climat_parse_x01(), syn_parse_x01(), and temp_parse_x01().

Here is the caller graph for this function:

◆ bufr2tac_clean_buoy_chunks()

void bufr2tac_clean_buoy_chunks ( struct buoy_chunks b)

cleans a buoy_chunks struct

Parameters
bpointer to the struct to clean

Definition at line 178 of file bufr2tac_mrproper.c.

179{
180 b->mask = 0;
181 clean_report_date_ext ( & ( b->e ) );
182 clean_wigos_id ( & ( b->wid ) );
183 clean_buoy_sec0 ( & ( b->s0 ) );
184 clean_buoy_sec1 ( & ( b->s1 ) );
185 clean_buoy_sec2 ( & ( b->s2 ) );
186 clean_buoy_sec3 ( & ( b->s3 ) );
187 clean_buoy_sec4 ( & ( b->s4 ) );
188
189 b->error[0] = '\0';
190}
void clean_buoy_sec2(struct buoy_sec2 *s)
clean a buoy_sec2 struct
void clean_buoy_sec1(struct buoy_sec1 *s)
clean a buoy_sec1 struct
void clean_wigos_id(struct wigos_id *w)
clean a synop_ext struct
void clean_buoy_sec0(struct buoy_sec0 *s)
clean a buoy_sec0 struct
void clean_buoy_sec4(struct buoy_sec4 *s)
clean a buoy_sec4 struct
void clean_buoy_sec3(struct buoy_sec3 *s)
clean a buoy_sec3 struct
void clean_report_date_ext(struct report_date_ext *s)
clean a synop_ext struct
struct buoy_sec3 s3
Definition: metbuoy.h:204
struct wigos_id wid
Definition: metbuoy.h:200
char error[128]
Definition: metbuoy.h:206
struct buoy_sec2 s2
Definition: metbuoy.h:203
struct report_date_ext e
Definition: metbuoy.h:199
int mask
Definition: metbuoy.h:198
struct buoy_sec1 s1
Definition: metbuoy.h:202
struct buoy_sec4 s4
Definition: metbuoy.h:205
struct buoy_sec0 s0
Definition: metbuoy.h:201

References clean_buoy_sec0(), clean_buoy_sec1(), clean_buoy_sec2(), clean_buoy_sec3(), clean_buoy_sec4(), clean_report_date_ext(), clean_wigos_id(), buoy_chunks::e, buoy_chunks::error, buoy_chunks::mask, buoy_chunks::s0, buoy_chunks::s1, buoy_chunks::s2, buoy_chunks::s3, buoy_chunks::s4, and buoy_chunks::wid.

Referenced by parse_subset_as_buoy().

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

◆ bufr2tac_clean_climat_chunks()

void bufr2tac_clean_climat_chunks ( struct climat_chunks c)

cleans a climat_chunks struct

Parameters
cpointer to the struct to clean

Definition at line 262 of file bufr2tac_mrproper.c.

263{
264 c->mask = 0;
265 clean_report_date_ext ( & ( c->e ) );
266 clean_wigos_id ( & ( c->wid ) );
267 clean_climat_sec0 ( & ( c->s0 ) );
268 clean_climat_sec1 ( & ( c->s1 ) );
269 clean_climat_sec2 ( & ( c->s2 ) );
270 clean_climat_sec3 ( & ( c->s3 ) );
271 clean_climat_sec4 ( & ( c->s4 ) );
272 clean_climat_old ( & ( c->o ) );
273 c->error[0] = '\0';
274}
void clean_climat_old(struct climat_old *s)
clean a climat_sec4 struct
void clean_climat_sec1(struct climat_sec1 *s)
clean a climat_sec1 struct
void clean_climat_sec0(struct climat_sec0 *s)
clean a climat_sec0 struct
void clean_climat_sec2(struct climat_sec2 *s)
clean a climat_sec2 struct
void clean_climat_sec3(struct climat_sec3 *s)
clean a climat_sec3 struct
void clean_climat_sec4(struct climat_sec4 *s)
clean a climat_sec4 struct
struct climat_old o
Definition: metclimat.h:222
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 wigos_id wid
Definition: metclimat.h:216
char error[128]
Definition: metclimat.h:223
struct climat_sec2 s2
Definition: metclimat.h:219
struct climat_sec3 s3
Definition: metclimat.h:220

References clean_climat_old(), clean_climat_sec0(), clean_climat_sec1(), clean_climat_sec2(), clean_climat_sec3(), clean_climat_sec4(), clean_report_date_ext(), clean_wigos_id(), climat_chunks::e, climat_chunks::error, climat_chunks::mask, climat_chunks::o, climat_chunks::s0, climat_chunks::s1, climat_chunks::s2, climat_chunks::s3, climat_chunks::s4, and climat_chunks::wid.

Referenced by parse_subset_as_climat().

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

◆ bufr2tac_clean_error_stack()

int bufr2tac_clean_error_stack ( struct bufr2tac_error_stack e)

Definition at line 49 of file bufr2tac_error.c.

50{
51 if ( e != NULL )
52 {
53 memset ( e, 0, sizeof ( struct bufr2tac_error_stack ) );
54 return 0;
55 }
56 return -1;
57}
A stack of structs bufr2tac_error.
Definition: bufr2tac.h:235

◆ bufr2tac_clean_metreport()

void bufr2tac_clean_metreport ( struct metreport m)

Definition at line 276 of file bufr2tac_mrproper.c.

277{
278 if (m != NULL)
279 memset(m, 0, sizeof (struct metreport));
280}
all the information for a meteorological report in WMO text format from a BUFR file
Definition: bufr2tac.h:309

Referenced by bufrtotac_parse_subset_sequence().

Here is the caller graph for this function:

◆ bufr2tac_clean_synop_chunks()

void bufr2tac_clean_synop_chunks ( struct synop_chunks s)

Definition at line 104 of file bufr2tac_mrproper.c.

105{
106 syn->mask = 0;
107 clean_report_date_ext ( & ( syn->e ) );
108 clean_wigos_id ( & ( syn->wid ) );
109 clean_syn_sec0 ( & ( syn->s0 ) );
110 clean_syn_sec1 ( & ( syn->s1 ) );
111 clean_syn_sec2 ( & ( syn->s2 ) );
112 clean_syn_sec3 ( & ( syn->s3 ) );
113 clean_syn_sec5 ( & ( syn->s5 ) );
114
115 // default
116 strcpy ( syn->s0.iw,"/" );
117 strcpy ( syn->s1.ir,"/" );
118 strcpy ( syn->s1.ix,"/" );
119 strcpy ( syn->s1.h,"/" );
120 strcpy ( syn->s1.VV,"//" );
121 strcpy ( syn->s1.N,"/" );
122 strcpy ( syn->s1.dd,"//" );
123 strcpy ( syn->s1.ff,"//" );
124
125 syn->error[0] = '\0';
126}
void clean_syn_sec2(struct synop_sec2 *s)
clean a synop_sec2 struct
void clean_syn_sec1(struct synop_sec1 *s)
clean a synop_sec1 struct
void clean_syn_sec0(struct synop_sec0 *s)
clean a synop_sec0 struct
void clean_syn_sec5(struct synop_sec5 *s)
clean a synop_sec5 struct
void clean_syn_sec3(struct synop_sec3 *s)
clean a synop_sec3 struct

References clean_report_date_ext(), clean_syn_sec0(), clean_syn_sec1(), clean_syn_sec2(), clean_syn_sec3(), clean_syn_sec5(), clean_wigos_id(), synop_sec1::dd, synop_chunks::e, synop_chunks::error, synop_sec1::ff, synop_sec1::h, synop_sec1::ir, synop_sec0::iw, synop_sec1::ix, synop_chunks::mask, synop_sec1::N, synop_chunks::s0, synop_chunks::s1, synop_chunks::s2, synop_chunks::s3, synop_chunks::s5, synop_sec1::VV, and synop_chunks::wid.

Referenced by parse_subset_as_synop().

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

◆ bufr2tac_clean_temp_chunks()

void bufr2tac_clean_temp_chunks ( struct temp_chunks t)

cleans a buoy_chunks struct

Parameters
tpointer to the struct to clean

Definition at line 197 of file bufr2tac_mrproper.c.

198{
199 memset ( t, 0, sizeof ( struct temp_chunks ) );
200}
Store the whole TEMP report.
Definition: mettemp.h:511

Referenced by parse_subset_as_temp().

Here is the caller graph for this function:

◆ bufr2tac_get_version()

char * bufr2tac_get_version ( char *  version,
size_t  dversion,
char *  build,
size_t  dbuild,
char *  builder,
size_t  dbuilder,
int *  version_major,
int *  version_minor,
int *  version_patch 
)

Definition at line 48 of file bufr2tac.c.

50{
51 int major = 0, minor = 0, patch = 0;
52 size_t used;
53
54 if (version == NULL)
55 return NULL;
56 snprintf(version, dversion, "%s", VERSION);
57 // default
58 sscanf(version, "%d.%d.%d", &major, &minor, &patch);
59
60 if (build)
61 {
62 used = 0;
63#if defined(__INTEL_COMPILER)
64 used += snprintf(build + used, dbuild - used, "using INTEL C compiler icc %d.%d ", __INTEL_COMPILER, __INTEL_COMPILER_UPDATE);
65#elif defined(__clang_version__)
66 used += snprintf(build + used, dbuild - used, "using clang C compiler ", __clang_version__);
67#elif defined(__GNUC__)
68 used += snprintf(build + used, dbuild - used, "using GNU C compiler gcc %d.%d.%d ", __GNUC__ , __GNUC_MINOR__ , __GNUC_PATCHLEVEL__);
69#elif defined(_MSC_VER)
70 used += snprintf(build + used, dbuild - used, "using MICROSOFT C compiler %d ", _MSC_VER);
71#else
72 used += snprintf(build + used, dbuild - used, "using an unknown C compiler ");
73#endif
74 snprintf(build + used, dbuild - used,"at %s %s",__DATE__,__TIME__);
75 }
76
77 if (builder)
78#ifdef BUILD_USING_CMAKE
79 strncpy(builder, "cmake", dbuilder);
80#else
81 strncpy(builder, "autotools", dbuilder);
82#endif
83 if (version_major)
84 *version_major = major;
85 if (version_minor)
86 *version_minor = minor;
87 if (version_patch)
88 *version_patch = patch;
89 return version;
90}
#define VERSION
Definition: config.h:8

References VERSION.

Referenced by bufrtotac_print_version().

Here is the caller graph for this function:

◆ bufr2tac_print_error()

int bufr2tac_print_error ( struct bufr2tac_error_stack e)

Definition at line 87 of file bufr2tac_error.c.

88{
89 unsigned int i;
90 if ( e->ne == 0 )
91 {
92 printf ( "# No info/warning/error \n" );
93 return 0;
94 }
95
96 for ( i = 0; i < e->ne ; i++ )
97 {
98 if ( e->err[i].severity == 0 )
99 printf ( "# INFO: " );
100 else if ( e->err[i].severity == 1 )
101 printf ( "# WARNING: " );
102 else if ( e->err[i].severity == 2 )
103 printf ( "# ERROR: " );
104 else
105 {
106 printf ( "# %d\n", e->err[i].severity );
107 return 1;
108 }
109 printf ( "%s\n", e->err[i].description );
110 }
111 if ( e->full > 0 )
112 printf ( "# More debug info follows, stack of logs full\n" );
113 return 0;
114}
struct bufr2tac_error err[BUFR2TAC_ERROR_STACK_DIM]
Definition: bufr2tac.h:238
char description[BUFR2TAC_ERROR_DESCRIPTION_LENGTH]
Definition: bufr2tac.h:228

References bufr2tac_error::description, bufr2tac_error_stack::err, bufr2tac_error_stack::full, bufr2tac_error_stack::ne, and bufr2tac_error::severity.

Referenced by parse_subset_sequence().

Here is the caller graph for this function:

◆ bufr2tac_push_error()

int bufr2tac_push_error ( struct bufr2tac_error_stack e,
int  severity,
char *  description 
)

Definition at line 26 of file bufr2tac_error.c.

27{
28 // avoid segfaults
29 if ( e == NULL )
30 return -1; // Fatal error
31
33 {
34 e->err[e->ne].severity = severity;
35 strcpy ( e->err[e->ne].description, description );
36 ( e->ne )++;
37 return 1;
38 }
39 else if ( e->ne == BUFR2TAC_ERROR_STACK_DIM )
40 {
41 // Do not pull error, but annotate the stack as rebased
42 if ( e->full < severity )
43 e->full = severity;
44 return 0;
45 }
46 return -1; // bad e->ne
47}
#define BUFR2TAC_ERROR_STACK_DIM
set de dimension of a struct bufr2tac_error_stack
Definition: bufr2tac.h:194

References BUFR2TAC_ERROR_STACK_DIM, bufr2tac_error::description, bufr2tac_error_stack::err, bufr2tac_error_stack::full, bufr2tac_error_stack::ne, and bufr2tac_error::severity.

Referenced by bufr2tac_set_error().

Here is the caller graph for this function:

◆ bufr2tac_set_debug_level()

int bufr2tac_set_debug_level ( int  level)

Definition at line 93 of file bufr2tac.c.

94{
95 if (level < 0 || level > 2)
96 return 1; // Bad debug level
97
98 // Here we set
100 return 0;
101}
int BUFR2TAC_DEBUG_LEVEL
Definition: bufr2tac.c:31

References BUFR2TAC_DEBUG_LEVEL.

Referenced by bufrtotac_read_args().

Here is the caller graph for this function:

◆ bufr2tac_set_error()

int bufr2tac_set_error ( struct bufr2tac_subset_state s,
int  severity,
char *  origin,
char *  explanation 
)

Definition at line 59 of file bufr2tac_error.c.

60{
61 char description[BUFR2TAC_ERROR_DESCRIPTION_LENGTH], *c;
62
63 c = description;
64 c += sprintf ( c, "%s: ", origin );
65 c += sprintf ( c, " Descriptor: %u %02u %03u: \"%s\"",s->a->desc.f, s->a->desc.x, s->a->desc.y, s->a->name );
66
68 {
69 c+= sprintf ( c, " = MISSING. " );
70 }
71 else
72 {
73 if ( s->a->cval[0] )
74 c += sprintf ( c, " = '%s'. ", s->a->cval );
75 else if ( s->a->desc.x == 2 )
76 c += sprintf ( c, " = '%s'. ", s->a->ctable );
77 else
78 c += sprintf ( c, " = %lf . ", s->a->val );
79 }
80
81 c += sprintf ( c, "%s", explanation );
82
83
84 return bufr2tac_push_error ( &s->e, severity, description );
85}
#define BUFR2TAC_ERROR_DESCRIPTION_LENGTH
set de dimension of member description of a struct bufr2tac_error
Definition: bufr2tac.h:199
int bufr2tac_push_error(struct bufr2tac_error_stack *e, int severity, char *description)
#define DESCRIPTOR_VALUE_MISSING
Bit mask for a missing value in a struct bufr_atom_data.
Definition: bufrdeco.h:140
struct bufr_atom_data * a
Definition: bufr2tac.h:249
struct bufr2tac_error_stack e
Definition: bufr2tac.h:248
uint32_t mask
Definition: bufrdeco.h:437
char name[BUFR_TABLEB_NAME_LENGTH]
Definition: bufrdeco.h:438
char ctable[BUFR_EXPLAINED_LENGTH]
Definition: bufrdeco.h:444
struct bufr_descriptor desc
Definition: bufrdeco.h:436
double val
Definition: bufrdeco.h:440
char cval[BUFR_CVAL_LENGTH]
Definition: bufrdeco.h:443

References bufr2tac_subset_state::a, BUFR2TAC_ERROR_DESCRIPTION_LENGTH, bufr2tac_push_error(), bufr_atom_data::ctable, bufr_atom_data::cval, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::e, bufr_descriptor::f, bufr_atom_data::mask, bufr_atom_data::name, bufr_atom_data::val, bufr_descriptor::x, and bufr_descriptor::y.

Referenced by buoy_parse_x01(), buoy_parse_x02(), buoy_parse_x04(), buoy_parse_x05(), buoy_parse_x06(), buoy_parse_x07(), buoy_parse_x08(), buoy_parse_x10(), buoy_parse_x11(), buoy_parse_x12(), buoy_parse_x13(), buoy_parse_x14(), buoy_parse_x20(), buoy_parse_x22(), buoy_parse_x31(), buoy_parse_x33(), climat_parse_x01(), climat_parse_x02(), climat_parse_x04(), climat_parse_x05(), climat_parse_x06(), climat_parse_x07(), climat_parse_x08(), climat_parse_x10(), climat_parse_x11(), climat_parse_x12(), climat_parse_x13(), climat_parse_x14(), syn_parse_x01(), syn_parse_x02(), syn_parse_x04(), syn_parse_x05(), syn_parse_x06(), syn_parse_x07(), syn_parse_x08(), syn_parse_x10(), syn_parse_x11(), syn_parse_x12(), syn_parse_x13(), syn_parse_x14(), syn_parse_x20(), syn_parse_x22(), syn_parse_x31(), temp_parse_x01(), temp_parse_x02(), temp_parse_x04(), temp_parse_x05(), temp_parse_x06(), temp_parse_x07(), temp_parse_x08(), temp_parse_x10(), temp_parse_x11(), temp_parse_x12(), temp_parse_x20(), temp_parse_x22(), temp_parse_x31(), and temp_parse_x33().

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

◆ bufr_set_environment()

int bufr_set_environment ( char *  default_bufrtables,
char *  bufrtables_dir 
)

set the environment vars needed to work properly with ECMWF bufrdc library

Parameters
default_bufrtablesdefaut bufr tables dir. ususally '/usr/local/lib/bufrtables/'
bufrtables_diralternative char with bufr tables dir

During decoding Bufr table path and the names are printed. If user doeas not want that, set: VARIABLE PRINT_TABLE_NAMES=false

During decoding code/flag tables could be read if code figure meaning is needed. If user want to use code and flag tables set: VARIABLE USE TABLE C=true

Then we set the proper environment here

Definition at line 41 of file bufr2tac_env.c.

42{
43 int i;
44 char aux[256], *c;
45 struct stat s;
46
47 i = stat ( default_bufrtables, &s );
48
49 if ( putenv ( "PRINT_TABLE_NAMES=false" ) || putenv ( "USE_TABLE_C=true" ) )
50 {
51 fprintf ( stderr, "bufr2tac: Failure setting the environment\n" );
52 exit ( EXIT_FAILURE );
53 }
54
55 /*
56 Default path for Bufr Tables is hard coded in the software. To change the path set environmental variable
57 BUFR_TABLES . The path must end with '/'
58 */
59 if ( bufrtables_dir[0] )
60 {
61 sprintf ( aux,"BUFR_TABLES=%s", bufrtables_dir );
62 if ( putenv ( aux ) )
63 {
64 fprintf ( stderr, "bufr2tac: Failure setting the environment\n" );
65 exit ( EXIT_FAILURE );
66 }
67 }
68 else if ( ( c = getenv ( "BUFR_TABLES" ) ) != NULL )
69 {
70 strcpy ( bufrtables_dir, c ); // otherwise check if BUFRRABLES_DIR if is on environment
71 }
72 else if ( i == 0 && S_ISDIR ( s.st_mode ) ) // last chance, the default dir
73 {
74 strcpy ( bufrtables_dir, default_bufrtables );
75 sprintf ( aux,"BUFR_TABLES=%s", bufrtables_dir );
76 if ( putenv ( aux ) )
77 {
78 fprintf ( stderr, "bufr2tac: Failure setting the environment\n" );
79 exit ( EXIT_FAILURE );
80 }
81 }
82 else
83 {
84 fprintf ( stderr,"bufr2tac: Unable to find bufrtables directory\n" );
85 fprintf ( stderr," Please set the proper enviromnet 'BUFR_TABLES=my_bufrtables_dir' or\n" );
86 fprintf ( stderr," use '-t' argument . i. e.'-t my_bufrtables_dir/'\n" );
87 exit ( EXIT_FAILURE );
88 }
89 return 0;
90}

◆ bufrex_()

int bufrex_ ( int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
char **  ,
char **  ,
int *  ,
double *  ,
char **  ,
int *   
)

◆ buoy_parse_x01()

int buoy_parse_x01 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 01.

Parameters
bpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 205 of file bufr2tac_x01.c.

206{
207 char aux[80];
208
209 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
210 return 0;
211
212 switch ( s->a->desc.y )
213 {
214 case 3: // 0 01 003
215 if ( s->ival > 0 )
216 sprintf ( b->s0.A1, "%d", s->ival % 10 );
217 else if ( s->ival == 0 )
218 sprintf ( b->s0.A1, "7" );
219 break;
220
221 case 4: // 0 01 004
222 case 20: // 0 01 004
223 sprintf ( b->s0.bw, "%d", s->ival );
224 break;
225
226 case 5: // 0 01 005
227 if ( s->ival < 1000 )
228 sprintf ( b->s0.nbnbnb, "%03d", s->ival % 1000 );
229 else
230 sprintf ( b->s0.nbnbnb, "%05d", s->ival % 100000 ); // note this is a nnnnn extension
231 break;
232
233 case 15: // 0 01 015. Station or site name
234 if ( strlen ( s->a->cval ) <= 80 )
235 {
236 strcpy ( aux, s->a->cval );
237 adjust_string ( aux );
238 strcpy ( s->name, aux );
240 }
241 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
242 {
243 bufr2tac_set_error ( s, 1, "buoy_parse_x01()", "Station or site name length > 80. Cannot set s->name" );
244 }
245 break;
246
247 case 87: // 0 01 087. WMO marine observing platform extended identifier
248 // See https://community.wmo.int/rules-allocating-wmo-numbers
249 // A1bwnnn is equivalent to A1Bwnnnnn when nnnnn < 1000
250 if ( s->a->val < 100000000 )
251 {
252 sprintf ( aux, "%07.0lf", s->a->val );
253 b->s0.A1[0] = aux[0];
254 b->s0.A1[1] = 0;
255 b->s0.bw[0] = aux[1];
256 b->s0.bw[1] = 0;
257 if ( ( ( int ) ( s->a->val ) % 100000 ) < 1000 )
258 strcpy ( b->s0.nbnbnb, & aux[4] );
259 else
260 strcpy ( b->s0.nbnbnb, & aux[2] );
261 }
262 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
263 {
264 bufr2tac_set_error ( s, 1, "buoy_parse_x01()",
265 "WMO marine observing platform extended identifier >= 100000000. Cannot set s0.A1, s0.bw, s0.nbnbnb" );
266 }
267 break;
268
269 case 101: // 0 01 101 . State identifier
270 if ( strlen ( s->a->ctable ) <= 256 )
271 {
272 strcpy ( aux, s->a->ctable );
273 adjust_string ( aux );
274 strcpy ( s->country, aux );
276 }
277 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
278 {
279 bufr2tac_set_error ( s, 1, "buoy_parse_x01()", "State identifier length > 256. Cannot set s->country" );
280 }
281 break;
282
283 case 125: // 0 01 125 . WIGOS identifier series
284 b->wid.series = ( uint8_t ) s->ival;
285 break;
286
287 case 126: // 0 01 126 . WIGOS issuer of identifier
288 b->wid.issuer = ( uint16_t ) s->ival;
289 break;
290
291 case 127: // 0 01 127 , WIGOS issue number
292 b->wid.issue = ( uint16_t ) s->ival;
293 break;
294
295 case 128: // 0 01 128 . WIGOS local identifier (character)
296 if ( strlen ( s->a->cval ) <= 16 )
297 {
298 adjust_string ( s->a->cval );
299 if ( check_wigos_local_id ( s->a->cval ) )
300 {
301 bufr2tac_set_error ( s, 1, "buoy_parse_x01()","Bad WIGOS Local identifier" );
302 }
303 strcpy ( b->wid.local_id, s->a->cval );
305 }
306 break;
307
308 default:
309 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
310 bufr2tac_set_error ( s, 0, "buoy_parse_x01()", "Descriptor not parsed" );
311 break;
312 }
313 return 0;
314}
#define SUBSET_MASK_HAVE_COUNTRY
Bit mask to mark a struct bufr_subset_sequence_data having country name.
Definition: bufr2tac.h:134
int bufr2tac_set_error(struct bufr2tac_subset_state *s, int severity, char *origin, char *explanation)
#define SUBSET_MASK_HAVE_NAME
Bit mask to mark a struct bufr_subset_sequence_data having station name.
Definition: bufr2tac.h:128
#define SUBSET_MASK_HAVE_WIGOS_ID
Bit mask to mark if a subset has a WIGOS ID.
Definition: bufr2tac.h:188
char * adjust_string(char *s)
Supress trailing blanks of a string.
int check_wigos_local_id(char *local_id)
Definition: bufr2tac_x01.c:27
char nbnbnb[8]
Definition: metbuoy.h:70
char A1[2]
Definition: metbuoy.h:68
char bw[2]
Definition: metbuoy.h:69
uint16_t issue
Definition: metcommon.h:49
uint16_t issuer
Definition: metcommon.h:48
uint8_t series
Definition: metcommon.h:47
char local_id[24]
Definition: metcommon.h:50

References bufr2tac_subset_state::a, buoy_sec0::A1, adjust_string(), BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), buoy_sec0::bw, check_wigos_local_id(), bufr2tac_subset_state::country, bufr_atom_data::ctable, bufr_atom_data::cval, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, wigos_id::issue, wigos_id::issuer, bufr2tac_subset_state::ival, wigos_id::local_id, bufr_atom_data::mask, bufr2tac_subset_state::mask, bufr2tac_subset_state::name, buoy_sec0::nbnbnb, buoy_chunks::s0, wigos_id::series, SUBSET_MASK_HAVE_COUNTRY, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_WIGOS_ID, bufr_atom_data::val, buoy_chunks::wid, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x02()

int buoy_parse_x02 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 02.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 83 of file bufr2tac_x02.c.

84{
85 char caux[16];
87 return 0;
88
89 switch ( s->a->desc.y )
90 {
91 case 1: // 0 02 001 . Type of station
92 s->type = s->ival;
94 break;
95
96 case 2: // 0 02 002 . Type of instrumentation for wind measurement
97 if ( s->ival & 4 )
98 strcpy ( b->s0.iw, "4" );
99 else
100 strcpy ( b->s0.iw, "1" );
101 break;
102
103 case 31: // 0 02 031 . Duration and time of current measurement
104 if ( b->s3.k3[0] == 0 && s->ival < 10 )
105 {
106 sprintf ( caux, "%d", s->ival );
107 b->s3.k3[0] = caux[0];
108 b->s3.k3[1] = 0;
109 }
110 b->mask |= BUOY_SEC3;
111 break;
112
113 case 33: // 0 02 033 . Method of salinity depth measure
114 sprintf ( caux, "%d", s->ival );
115 b->s3.k2[0] = caux[0];
116 b->s3.k2[1] = 0;
117 b->mask |= BUOY_SEC3;
118 break;
119
120 case 40: // 0 02 040 .Method of removing velocity and motion of platform from current
121 if ( b->s3.k6[0] == 0 )
122 {
123 sprintf ( caux, "%d", s->ival );
124 b->s3.k6[0] = caux[0];
125 b->s3.k6[1] = 0;
126 }
127 b->mask |= BUOY_SEC3;
128 break;
129
130 default:
131 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
132 bufr2tac_set_error ( s, 0, "buoy_parse_x02()", "Descriptor not parsed" );
133 break;
134 }
135 return 0;
136}
#define SUBSET_MASK_HAVE_TYPE_STATION
Bit mask to mark a struct bufr_subset_sequence_data having type station information.
Definition: bufr2tac.h:86
#define BUOY_SEC3
mask bit meaning section 3 of buoy is solicited to or parsed with success
Definition: metbuoy.h:48
char iw[2]
Definition: metbuoy.h:77
char k2[2]
Definition: metbuoy.h:151
char k6[2]
Definition: metbuoy.h:153
char k3[2]
Definition: metbuoy.h:152

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), BUOY_SEC3, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::ival, buoy_sec0::iw, buoy_sec3::k2, buoy_sec3::k3, buoy_sec3::k6, bufr_atom_data::mask, bufr2tac_subset_state::mask, buoy_chunks::mask, buoy_chunks::s0, buoy_chunks::s3, SUBSET_MASK_HAVE_TYPE_STATION, bufr2tac_subset_state::type, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x04()

int buoy_parse_x04 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 04.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 254 of file bufr2tac_x04.c.

255{
256
257 switch ( s->a->desc.y )
258 {
259 case 1: // 0 04 001 . Year
260 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
261 {
262 return 0;
263 }
264 else if ( s->ival < 2000 || s->ival > 2050 )
265 {
266 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
267 bufr2tac_set_error ( s, 2, "buoy_parse_x04()", "Bad year" );
268 return 1;
269 }
270
271 if ( b->e.YYYY[0] == 0 )
272 {
273 sprintf ( b->e.YYYY, "%04d", s->ival );
274 }
276 break;
277
278 case 2: // 0 04 002 . Month
279 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
280 {
281 return 0;
282 }
283 if ( b->e.MM[0] == 0 )
284 {
285 sprintf ( b->e.MM, "%02d", s->ival );
286 }
288 break;
289
290 case 3: // 0 04 003 . Day of month
291 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
292 {
293 return 0;
294 }
295 if ( b->e.DD[0] == 0 )
296 {
297 sprintf ( b->e.DD, "%02d", s->ival );
298 }
300 //sprintf(b->s0.YY, "%02d", (int) sq->sequence[is].val);
301 break;
302
303 case 4: // 0 04 004 . Hour
304 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
305 {
306 return 0;
307 }
308 if ( b->e.HH[0] == 0 )
309 {
310 sprintf ( b->e.HH, "%02d", s->ival );
311 }
313 //sprintf(b->s0.GG, "%02d", (int) sq->sequence[is].val);
314 break;
315
316 case 5: // 0 04 005 . Minute
317 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
318 {
319 return 0;
320 }
321 if ( b->e.mm[0] == 0 )
322 {
323 sprintf ( b->e.mm, "%02d", s->ival );
324 }
326 break;
327
328 // store latest displacement in seconds
329 case 23: // 0 04 023 . Time period of displacement (days)
330 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
331 {
332 s->k_jtval = s->k_itval;
333 s->jtval = s->itval;
334 s->k_itval = s->i;
335 s->itval = 0;
336 return 0;
337 }
338 s->k_jtval = s->k_itval;
339 s->jtval = s->itval;
340 s->k_itval = s->i;
341 s->itval = s->ival * 86400;
342 break;
343
344 case 24: // 0 04 024 . Time period of displacement (hours)
345 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
346 {
347 s->k_jtval = s->k_itval;
348 s->jtval = s->itval;
349 s->k_itval = s->i;
350 s->itval = 0;
351 return 0;
352 }
353 s->k_jtval = s->k_itval;
354 s->jtval = s->itval;
355 s->k_itval = s->i;
356 s->itval = s->ival * 3600;
357 break;
358
359 case 25: // 0 04 025 . Time period of displacement (minutes)
360 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
361 {
362 s->k_jtval = s->k_itval;
363 s->jtval = s->itval;
364 s->k_itval = s->i;
365 s->itval = 0;
366 return 0;
367 }
368 s->k_jtval = s->k_itval;
369 s->jtval = s->itval;
370 s->k_itval = s->i;
371 s->itval = s->ival * 60;
372 break;
373
374 case 26: // 0 04 026 . Time period of displacement (seconds)
375 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
376 {
377 s->k_jtval = s->k_itval;
378 s->jtval = s->itval;
379 s->k_itval = s->i;
380 s->itval = 0;
381 return 0;
382 }
383 s->k_jtval = s->k_itval;
384 s->jtval = s->itval;
385 s->k_itval = s->i;
386 s->itval = s->ival;
387 break;
388
389 default:
390 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
391 bufr2tac_set_error ( s, 0, "buoy_parse_x04()", "Descriptor not parsed" );
392 break;
393 }
394 return 0;
395}
#define SUBSET_MASK_HAVE_MONTH
Bit mask to mark a struct bufr_subset_sequence_data having observation month.
Definition: bufr2tac.h:146
#define SUBSET_MASK_HAVE_MINUTE
Bit mask to mark a struct bufr_subset_sequence_data having observation minute.
Definition: bufr2tac.h:164
#define SUBSET_MASK_HAVE_YEAR
Bit mask to mark a struct bufr_subset_sequence_data having observation year.
Definition: bufr2tac.h:140
#define SUBSET_MASK_HAVE_DAY
Bit mask to mark a struct bufr_subset_sequence_data having observation day in a month.
Definition: bufr2tac.h:152
#define SUBSET_MASK_HAVE_HOUR
Bit mask to mark a struct bufr_subset_sequence_data having observation hour.
Definition: bufr2tac.h:158
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

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), report_date_ext::DD, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, buoy_chunks::e, report_date_ext::HH, bufr2tac_subset_state::i, bufr2tac_subset_state::itval, bufr2tac_subset_state::ival, bufr2tac_subset_state::jtval, bufr2tac_subset_state::k_itval, bufr2tac_subset_state::k_jtval, bufr_atom_data::mask, bufr2tac_subset_state::mask, report_date_ext::MM, report_date_ext::mm, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_MINUTE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_YEAR, bufr_descriptor::y, and report_date_ext::YYYY.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x05()

int buoy_parse_x05 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 05.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 134 of file bufr2tac_x05.c.

135{
136 int ia;
137
138 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
139 return 0;
140
141 switch ( s->a->desc.y )
142 {
143 case 1: // 0 05 001 . Latitude (High accuracy)
144 case 2: // 0 05 002 . Latitude (Coarse accuracy)
145 if ( s->val < 0.0 )
146 s->mask |= SUBSET_MASK_LATITUDE_SOUTH; // Sign for latitude
148 ia = ( int ) ( fabs ( s->val ) * 1000.0 + 0.5 );
149 sprintf ( b->s0.LaLaLaLaLa, "%05d",ia );
150 s->lat = s->val;
151 break;
152
153 default:
154 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
155 bufr2tac_set_error ( s, 0, "buoy_parse_x05()", "Descriptor not parsed" );
156 break;
157 }
158
159 return 0;
160}
#define SUBSET_MASK_LATITUDE_SOUTH
Bit mask to mark a struct bufr_subset_sequence_data with south latitude.
Definition: bufr2tac.h:74
#define SUBSET_MASK_HAVE_LATITUDE
Bit mask to mark a struct bufr_subset_sequence_data having latitude.
Definition: bufr2tac.h:110
char LaLaLaLaLa[8]
Definition: metbuoy.h:79

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, buoy_sec0::LaLaLaLaLa, bufr2tac_subset_state::lat, bufr_atom_data::mask, bufr2tac_subset_state::mask, buoy_chunks::s0, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_LATITUDE_SOUTH, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x06()

int buoy_parse_x06 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 06.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 129 of file bufr2tac_x06.c.

130{
131 int ia;
132
133 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
134 return 0;
135
136 switch ( s->a->desc.y )
137 {
138 case 1: // 0 06 001 . Longitude (High accuracy)
139 case 2: // 0 06 002 . Longitude (Coarse accuracy)
140 if ( s->val < 0.0 )
141 s->mask |= SUBSET_MASK_LONGITUDE_WEST; // Sign for longitude
143 s->lon = s->val;
144 ia = ( int ) ( fabs ( s->val ) * 1000.0 + 0.5 );
145 sprintf ( b->s0.LoLoLoLoLoLo, "%06d",ia );
146 break;
147
148 default:
149 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
150 bufr2tac_set_error ( s, 0, "buoy_parse_x06()", "Descriptor not parsed" );
151 break;
152 }
153 return 0;
154}
#define SUBSET_MASK_LONGITUDE_WEST
Bit mask to mark a struct bufr_subset_sequence_data with west longitude.
Definition: bufr2tac.h:80
#define SUBSET_MASK_HAVE_LONGITUDE
Bit mask to mark a struct bufr_subset_sequence_data having longitude.
Definition: bufr2tac.h:116
char LoLoLoLoLoLo[8]
Definition: metbuoy.h:80

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, buoy_sec0::LoLoLoLoLoLo, bufr2tac_subset_state::lon, bufr_atom_data::mask, bufr2tac_subset_state::mask, buoy_chunks::s0, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_LONGITUDE_WEST, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x07()

int buoy_parse_x07 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 07.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 164 of file bufr2tac_x07.c.

165{
166
167 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
168 {
169 return 0;
170 }
171
172 if ( b == NULL )
173 {
174 return 1;
175 }
176
177 switch ( s->a->desc.y )
178 {
179 case 62: // 0 07 062 Depth below sea/water surface
180 case 63: // 0 07 063 Profundity below sea/water level
181 if ( s->k_rep == ( s->i - 1 ) ) // Case of first layer after a replicator
182 {
183 s->layer = 0;
184 }
185 else
186 {
187 ( s->layer ) ++;
188 }
189 s->deep = ( int ) ( s->val + 0.5 );
190 break;
191
192 default:
193 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
194 bufr2tac_set_error ( s, 0, "buoy_parse_x07()", "Descriptor not parsed" );
195 break;
196 }
197 return 0;
198}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr2tac_subset_state::deep, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::i, bufr2tac_subset_state::k_rep, bufr2tac_subset_state::layer, bufr_atom_data::mask, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x08()

int buoy_parse_x08 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 08.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 121 of file bufr2tac_x08.c.

122{
123 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
124 {
125 return 0;
126 }
127
128 if ( b == NULL )
129 {
130 return 1;
131 }
132
133 switch ( s->a->desc.y )
134 {
135 case 22: // 0 08 022 . Total number
136 case 23: // 0 08 023 . First-order statistics
137 case 24: // 0 08 024 . Difference statistics
138 if ( s->isq )
139 {
140 s->isq = 0;
141 }
142 else
143 {
144 s->isq = 1;
145 }
146 break;
147
148 default:
149 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
150 bufr2tac_set_error ( s, 0, "buoy_parse_x08()", "Descriptor not parsed" );
151 break;
152 }
153 return 0;
154}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::isq, bufr_atom_data::mask, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x10()

int buoy_parse_x10 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 10.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 161 of file bufr2tac_x10.c.

162{
163 char aux[16];
164
165 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
166 {
167 return 0;
168 }
169
170 switch ( s->a->desc.y )
171 {
172
173 case 4: // 0 10 004 . Pressure
174 pascal_to_PPPP ( aux, s->val );
175 strcpy ( b->s1.PoPoPoPo, aux );
176 b->mask |= BUOY_SEC1;
177 break;
178
179 case 51: // 0 10 051 . Pressure reduced to mean sea level
180 pascal_to_PPPP ( aux, s->val );
181 strcpy ( b->s1.PPPP, aux );
182 b->mask |= BUOY_SEC1;
183 break;
184
185 case 63: // 0 10 063 . Characteristic of pressure tendency
186 sprintf ( b->s1.a, "%1d",s->ival );
187 b->mask |= BUOY_SEC1;
188 break;
189
190 case 61: // 0 10 061 . 3-hour pressure change
191 pascal_to_ppp ( aux, s->val );
192 memcpy( b->s1.ppp, aux, 3 );
193 b->s1.ppp[3] = 0;
194 b->mask |= BUOY_SEC1;
195 break;
196
197 default:
198 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
199 bufr2tac_set_error ( s, 0, "buoy_parse_x10()", "Descriptor not parsed" );
200 break;
201 }
202 return 0;
203}
char * pascal_to_ppp(char *target, double P)
Converts pascal values (variation) into a ppp string.
Definition: bufr2tac_x10.c:32
char * pascal_to_PPPP(char *target, double P)
Converts pascal values into a PPPP string.
Definition: bufr2tac_x10.c:69
#define BUOY_SEC1
mask bit meaning section 1 of buoy is solicited to or parsed with success
Definition: metbuoy.h:38
char a[2]
Definition: metbuoy.h:103
char PoPoPoPo[6]
Definition: metbuoy.h:101
char ppp[4]
Definition: metbuoy.h:104
char PPPP[6]
Definition: metbuoy.h:102

References bufr2tac_subset_state::a, buoy_sec1::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), BUOY_SEC1, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::ival, bufr_atom_data::mask, buoy_chunks::mask, pascal_to_ppp(), pascal_to_PPPP(), buoy_sec1::PoPoPoPo, buoy_sec1::ppp, buoy_sec1::PPPP, buoy_chunks::s1, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x11()

int buoy_parse_x11 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 11.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 387 of file bufr2tac_x11.c.

388{
389
390 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
391 {
392 return 0;
393 }
394
395 switch ( s->a->desc.y )
396 {
397 case 1: // 0 11 001 . Wind direction
398 case 11: // 0 11 011 . Wind direction at 10m
399 sprintf ( b->s1.dd, "%02d", abs((s->ival + 5 ) / 10) % 100 );
400 b->mask |= BUOY_SEC1;
401 break;
402
403 case 2: // 0 11 002 . Wind speed
404 case 12: // 0 11 012 . Wind speed at 10 meters
405 if ( b->s0.iw[0] == '4' )
406 {
407 s->val *= 1.94384449;
408 }
409 if ( s->val < 100.0 )
410 {
411 sprintf ( b->s1.ff, "%02d", ( int ) ( s->val + 0.5 ) );
412 }
413 else
414 {
415 sprintf ( b->s1.ff,"99" );
416 sprintf ( b->s1.fff, "%03d", ( int ) ( s->val + 0.5 ) );
417 }
418 b->mask |= BUOY_SEC1;
419 break;
420
421 case 84: // 0 11 084 (wind in knots)
422 if ( b->s0.iw[0] == '1' )
423 {
424 s->val /= 1.94384449;
425 }
426 if ( s->val < 100.0 )
427 {
428 sprintf ( b->s1.ff, "%02d", ( int ) ( s->val + 0.5 ) );
429 }
430 else
431 {
432 sprintf ( b->s1.ff,"99" );
433 sprintf ( b->s1.fff, "%03d", ( int ) ( s->val + 0.5 ) );
434 }
435 b->mask |= BUOY_SEC1;
436 break;
437
438 default:
439 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
440 bufr2tac_set_error ( s, 0, "buoy_parse_x11()", "Descriptor not parsed" );
441 break;
442 }
443 return 0;
444}
char fff[4]
Definition: metbuoy.h:95
char dd[4]
Definition: metbuoy.h:93
char ff[4]
Definition: metbuoy.h:94

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), BUOY_SEC1, buoy_sec1::dd, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, buoy_sec1::ff, buoy_sec1::fff, bufr2tac_subset_state::ival, buoy_sec0::iw, bufr_atom_data::mask, buoy_chunks::mask, buoy_chunks::s0, buoy_chunks::s1, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x12()

int buoy_parse_x12 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 12.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 466 of file bufr2tac_x12.c.

467{
468 char aux[16];
469
470 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
471 {
472 return 0;
473 }
474
475 switch ( s->a->desc.y )
476 {
477 case 1: // 0 12 001 . Air temperature
478 case 4: // 0 12 004 . Air temperatura at 2 m
479 case 101: // 0 12 101 . Air temperature
480 case 104: // 0 12 104 . Air temperature at 2 m
481 if ( b->s1.TTT[0] == 0 )
482 {
483 if ( kelvin_to_snTTT ( aux, s->val ) )
484 {
485 b->s1.sn1[0] = aux[0];
486 strcpy ( b->s1.TTT, aux + 1 );
487 b->mask |= BUOY_SEC1;
488 }
489 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
490 bufr2tac_set_error ( s, 1, "buoy_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
491 }
492 break;
493 case 3: // 0 12 003 . Dewpoint temperature
494 case 6: // 0 12 006 . Dewpoint temperature at 2 m
495 case 103: // 0 12 103 . Dewpoint temperature
496 case 106: // 0 12 106 . Dewpoint temperature at 2 m
497 if ( b->s1.TdTdTd[0] == 0 )
498 {
499 if ( kelvin_to_snTTT ( aux, s->val ) )
500 {
501 b->s1.sn2[0] = aux[0];
502 strcpy ( b->s1.TdTdTd, aux + 1 );
503 b->mask |= BUOY_SEC1;
504 }
505 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
506 bufr2tac_set_error ( s, 1, "buoy_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
507 }
508 break;
509
510 default:
511 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
512 bufr2tac_set_error ( s, 0, "buoy_parse_x12()", "Descriptor not parsed" );
513 break;
514 }
515 return 0;
516}
char * kelvin_to_snTTT(char *target, double T)
converts a kelvin temperature value into a snTTT string
Definition: bufr2tac_x12.c:32
char sn2[2]
Definition: metbuoy.h:98
char TTT[4]
Definition: metbuoy.h:97
char TdTdTd[4]
Definition: metbuoy.h:99
char sn1[2]
Definition: metbuoy.h:96

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), BUOY_SEC1, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, kelvin_to_snTTT(), bufr_atom_data::mask, buoy_chunks::mask, buoy_chunks::s1, buoy_sec1::sn1, buoy_sec1::sn2, buoy_sec1::TdTdTd, buoy_sec1::TTT, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x13()

int buoy_parse_x13 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 13.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 877 of file bufr2tac_x13.c.

878{
879
880 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
881 {
882 return 0;
883 }
884
885 if ( b == NULL )
886 {
887 return 1;
888 }
889
890
891 switch ( s->a->desc.y )
892 {
893 default:
894 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
895 bufr2tac_set_error ( s, 0, "buoy_parse_x13()", "Descriptor not parsed" );
896 break;
897 }
898 return 0;
899}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr_atom_data::mask, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x14()

int buoy_parse_x14 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 14.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 467 of file bufr2tac_x14.c.

468{
469 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
470 {
471 return 0;
472 }
473
474 if ( b == NULL )
475 {
476 return 1;
477 }
478
479 switch ( s->a->desc.y )
480 {
481 default:
482 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
483 bufr2tac_set_error ( s, 0, "buoy_parse_x14()", "Descriptor not parsed" );
484 break;
485 }
486 return 0;
487}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr_atom_data::mask, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x20()

int buoy_parse_x20 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 20.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 1324 of file bufr2tac_x20.c.

1325{
1326 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1327 {
1328 return 0;
1329 }
1330
1331 if ( b == NULL )
1332 {
1333 return 1;
1334 }
1335
1336 switch ( s->a->desc.y )
1337 {
1338 default:
1339 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
1340 bufr2tac_set_error ( s, 0, "buoy_parse_x20()", "Descriptor not parsed" );
1341 break;
1342 }
1343 return 0;
1344}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr_atom_data::mask, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x22()

int buoy_parse_x22 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 22.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 148 of file bufr2tac_x22.c.

149{
150 char aux[16];
151
152 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
153 return 0;
154
155 switch ( s->a->desc.y )
156 {
157 case 4: // 0 22 004 Direction of current
158 if ( s->layer < 32 ) // only 32 max layers
159 {
160 if ( b->s3.l2[s->layer].dd[0] == 0 )
161 {
162 sprintf ( b->s3.l2[s->layer].dd, "%02d", ( int ) ( s->val + 5.0 ) / 10 ) ;
163 b->mask |= BUOY_SEC3;
164 }
165 if ( b->s3.l2[s->layer].zzzz[0] == 0 ) // also stores pendent deep
166 {
167 sprintf ( b->s3.l2[s->layer].zzzz, "%04d", s->deep );
168 b->mask |= BUOY_SEC3;
169 }
170 }
171 break;
172
173 case 12: // 0 22 012 wind wave period in seconds
174 case 74: // 0 22 074 significant wave period in seconds
175 if ( b->s2.PwaPwa[0] == 0 )
176 {
177 sprintf ( b->s2.PwaPwa, "%02d", ( int ) ( s->val ) );
178 b->mask |= BUOY_SEC2; // have sec2 data
179 if ( b->s2.PwaPwaPwa[0] == 0 )
180 sprintf ( b->s2.PwaPwaPwa, "%03d", ( int ) ( s->val * 10 + 0.5 ) );
181
182 }
183 break;
184
185 case 22: // 0 22 022 wind wave heigh in meters
186 case 70: // 0 22 070 significant wave height in meters
187 if ( b->s2.HwaHwa[0] == 0 )
188 {
189 sprintf ( b->s2.HwaHwa, "%02d", ( int ) ( s->val * 2.0 + 0.01 ) ); // 0.5 m units
190 b->mask |= BUOY_SEC2; // have sec2 data
191 }
192 if ( b->s2.HwaHwaHwa[0] == 0 )
193 {
194 sprintf ( b->s2.HwaHwaHwa, "%03d", ( int ) ( s->val * 10.0 + 0.01 ) ); // 0.1 m units
195 b->mask |= BUOY_SEC2; // have sec2 data
196 }
197 break;
198
199 case 31: // 0 22 033 current speed
200 if ( s->layer < 32 ) // only 32 max layers
201 {
202 if ( b->s3.l2[s->layer].dd[0] == 0 )
203 {
204 sprintf ( b->s3.l2[s->layer].dd, "%03d", ( int ) ( s->val * 100.0 + 0.5 ) ) ;
205 b->mask |= BUOY_SEC3;
206 }
207 if ( b->s3.l2[s->layer].zzzz[0] == 0 ) // also stores pendent deep
208 {
209 sprintf ( b->s3.l2[s->layer].zzzz, "%04d", s->deep );
210 b->mask |= BUOY_SEC3;
211 }
212 }
213 break;
214
215 case 42:
216 case 43:
217 if ( s->deep == 0 )
218 {
219 if ( b->s2.TwTwTw[0] == 0 )
220 {
221 if ( kelvin_to_snTTT ( aux, s->val ) )
222 {
223 b->s2.sn[0] = aux[0];
224 strcpy ( b->s2.TwTwTw, aux + 1 );
225 b->mask |= BUOY_SEC2; // have sec2 data
226 }
227 }
228 }
229 if ( s->layer < 32 ) // only 32 max layers
230 {
231 if ( b->s3.l1[s->layer].TTTT[0] == 0 )
232 {
233 kelvin_to_TTTT ( b->s3.l1[s->layer].TTTT, s->val );
234 b->mask |= BUOY_SEC3;
235 }
236 if ( b->s3.l1[s->layer].zzzz[0] == 0 ) // also stores pendent deep
237 {
238 sprintf ( b->s3.l1[s->layer].zzzz, "%04d", s->deep );
239 b->mask |= BUOY_SEC3;
240 }
241 }
242 break;
243
244 case 45:
245 case 49: // 0 22 049 Sea surface temperature
246 if ( b->s2.TwTwTw[0] == 0 )
247 {
248 if ( kelvin_to_snTTT ( aux, s->val ) )
249 {
250 b->s2.sn[0] = aux[0];
251 strcpy ( b->s2.TwTwTw, aux + 1 );
252 b->mask |= BUOY_SEC2; // have sec2 data
253 }
254 }
255 break;
256
257 case 62: // 0 22 062 Salinity
258 if ( s->layer < 32 ) // only 32 max layers
259 {
260 if ( b->s3.l1[s->layer].SSSS[0] == 0 )
261 {
262 sprintf ( b->s3.l1[s->layer].SSSS, "%04d", ( int ) ( s->val * 100.0 + 0.5 ) );
263 b->mask |= BUOY_SEC3;
264 }
265 if ( b->s3.l1[s->layer].zzzz[0] == 0 ) // also stores pendent deep
266 {
267 sprintf ( b->s3.l1[s->layer].zzzz, "%04d", s->deep );
268 b->mask |= BUOY_SEC3;
269 }
270 }
271 break;
272
273 default:
274 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
275 bufr2tac_set_error ( s, 0, "buoy_parse_x22()", "Descriptor not parsed" );
276 break;
277 }
278 return 0;
279}
char * kelvin_to_TTTT(char *target, double T)
converts a kelvin temperature value into a TTTT string
Definition: bufr2tac_x12.c:123
char * kelvin_to_snTTT(char *target, double T)
converts a kelvin temperature value into a snTTT string
Definition: bufr2tac_x12.c:32
#define BUOY_SEC2
mask bit meaning section 2 of buoy is solicited to or parsed with success
Definition: metbuoy.h:43
char zzzz[6]
Definition: metbuoy.h:128
char TTTT[6]
Definition: metbuoy.h:129
char SSSS[6]
Definition: metbuoy.h:130
char dd[4]
Definition: metbuoy.h:140
char zzzz[6]
Definition: metbuoy.h:139
char PwaPwaPwa[6]
Definition: metbuoy.h:118
char HwaHwa[4]
Definition: metbuoy.h:117
char TwTwTw[4]
Definition: metbuoy.h:115
char HwaHwaHwa[6]
Definition: metbuoy.h:119
char sn[2]
Definition: metbuoy.h:114
char PwaPwa[4]
Definition: metbuoy.h:116
struct b_sec3_layer2 l2[32]
Definition: metbuoy.h:155
struct b_sec3_layer1 l1[32]
Definition: metbuoy.h:154

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), BUOY_SEC2, BUOY_SEC3, b_sec3_layer2::dd, bufr2tac_subset_state::deep, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, buoy_sec2::HwaHwa, buoy_sec2::HwaHwaHwa, kelvin_to_snTTT(), kelvin_to_TTTT(), buoy_sec3::l1, buoy_sec3::l2, bufr2tac_subset_state::layer, bufr_atom_data::mask, buoy_chunks::mask, buoy_sec2::PwaPwa, buoy_sec2::PwaPwaPwa, buoy_chunks::s2, buoy_chunks::s3, buoy_sec2::sn, b_sec3_layer1::SSSS, b_sec3_layer1::TTTT, buoy_sec2::TwTwTw, bufr2tac_subset_state::val, bufr_descriptor::y, b_sec3_layer1::zzzz, and b_sec3_layer2::zzzz.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x31()

int buoy_parse_x31 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 31.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 81 of file bufr2tac_x31.c.

82{
84 {
85 return 0;
86 }
87
88 if ( b == NULL )
89 {
90 return 1;
91 }
92
93 switch ( s->a->desc.y )
94 {
95 case 0: // 0 31 000 . Short delayed descriptor replication factor
96 // It is no meaning here
97 break;
98
99 case 1:
100 s->rep = s->ival;
101 s->k_rep = s->i;
102 break;
103
104 default:
105 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
106 bufr2tac_set_error ( s, 0, "buoy_parse_x31()", "Descriptor not parsed" );
107 break;
108 }
109 return 0;
110}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::i, bufr2tac_subset_state::ival, bufr2tac_subset_state::k_rep, bufr_atom_data::mask, bufr2tac_subset_state::rep, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_parse_x33()

int buoy_parse_x33 ( struct buoy_chunks b,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 33.

Parameters
bpointer to a struct buoy_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 34 of file bufr2tac_x33.c.

35{
36
38 return 0;
39
40
41 switch ( s->a->desc.y )
42 {
43 case 20: // 0 33 020. Quality control indication of followinf value
44 sprintf ( b->s0.Qt, "%d", s->ival );
45 b->mask |= BUOY_SEC1;
46 break;
47
48 case 21: // 0 33 021. Quality control of following value
49 sprintf ( b->s4.Qp, "%d", s->ival );
50 b->mask |= BUOY_SEC1;
51 break;
52
53 case 22: // 0 33 022. Quality of buoy satellite transmission
54 if ( s->ival == 0 )
55 {
56 if ( b->s0.Qt[0] == 0 )
57 sprintf ( b->s0.Qt, "1" );
58 if ( b->s1.Qd[0] == 0 )
59 sprintf ( b->s1.Qd, "1" );
60 if ( b->s2.Qd[0] == 0 )
61 sprintf ( b->s2.Qd, "1" );
62 }
63 if ( s->ival == 2 )
64 {
65 if ( b->s0.Qt[0] == 0 )
66 sprintf ( b->s0.Qt, "3" );
67 if ( b->s1.Qd[0] == 0 )
68 sprintf ( b->s1.Qd, "3" );
69 if ( b->s2.Qd[0] == 0 )
70 sprintf ( b->s2.Qd, "3" );
71 }
72 break;
73
74 case 23: // 0 33 023 . Quality of buoy location
75 sprintf ( b->s0.Ql, "%d", s->ival );
76 sprintf ( b->s4.QL, "%d", s->ival );
77 break;
78
79 case 27: // 0 33 027. Location quality class (range of ratiuos of 66% confidence)
80 sprintf ( b->s0.QA, "%d", s->ival );
81 sprintf ( b->s4.QA, "%d", s->ival );
82 break;
83
84 default:
85 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
86 bufr2tac_set_error ( s, 0, "syn_parse_x33()", "Descriptor not parsed" );
87 break;
88 }
89 return 0;
90}
char Ql[2]
Definition: metbuoy.h:81
char Qt[2]
Definition: metbuoy.h:82
char QA[2]
Definition: metbuoy.h:83
char Qd[2]
Definition: metbuoy.h:91
char Qd[2]
Definition: metbuoy.h:112
char QL[2]
Definition: metbuoy.h:169
char Qp[2]
Definition: metbuoy.h:163
char QA[2]
Definition: metbuoy.h:170

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), BUOY_SEC1, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::ival, bufr_atom_data::mask, buoy_chunks::mask, buoy_sec0::QA, buoy_sec4::QA, buoy_sec1::Qd, buoy_sec2::Qd, buoy_sec0::Ql, buoy_sec4::QL, buoy_sec4::Qp, buoy_sec0::Qt, buoy_chunks::s0, buoy_chunks::s1, buoy_chunks::s2, buoy_chunks::s4, and bufr_descriptor::y.

Referenced by parse_subset_as_buoy().

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

◆ buoy_YYYYMMDDHHmm_to_JMMYYGGgg()

int buoy_YYYYMMDDHHmm_to_JMMYYGGgg ( struct buoy_chunks b)

Sets YYGG from YYYYMMDDHHmm extended group.

Parameters
bpointer to the target struct buoy_chunks

Definition at line 31 of file bufr2tac_buoy.c.

32{
33 char aux[20];
34 time_t t;
35 struct tm tim;
36
37 if ( strlen ( b->e.YYYY ) &&
38 strlen ( b->e.MM ) &&
39 strlen ( b->e.DD ) &&
40 strlen ( b->e.HH ) &&
41 strlen ( b->e.MM ) )
42 {
43 sprintf ( aux,"%s%s%s%s%s", b->e.YYYY, b->e.MM, b->e.DD, b->e.HH, b->e.mm );
44 }
45
46 if ( strlen ( aux ) != 12 )
47 {
48 return 1;
49 }
50
51 memset ( &tim, 0, sizeof ( struct tm ) );
52 strptime ( aux, "%Y%m%d%H%M", &tim );
53
54 t = mktime ( &tim );
55 gmtime_r ( &t, &tim );
56 sprintf ( b->s0.YY, "%02d", tim.tm_mday );
57 sprintf ( b->s0.GG, "%02d", tim.tm_hour );
58 sprintf ( b->s0.MM, "%02d", (tim.tm_mon + 1) % 100 );
59 sprintf ( b->s0.J, "%d", tim.tm_year % 10 );
60 sprintf ( b->s0.gg, "%02d", tim.tm_min );
61
62 return 0;
63}
char YY[4]
Definition: metbuoy.h:72
char J[4]
Definition: metbuoy.h:74
char gg[4]
Definition: metbuoy.h:76
char MM[4]
Definition: metbuoy.h:73
char GG[4]
Definition: metbuoy.h:75

References report_date_ext::DD, buoy_chunks::e, buoy_sec0::GG, buoy_sec0::gg, report_date_ext::HH, buoy_sec0::J, buoy_sec0::MM, report_date_ext::MM, report_date_ext::mm, buoy_chunks::s0, buoy_sec0::YY, and report_date_ext::YYYY.

Referenced by parse_subset_as_buoy().

Here is the caller graph for this function:

◆ buprs0_()

int buprs0_ ( int *  )

◆ buprs1_()

int buprs1_ ( int *  )

◆ buprs3_()

int buprs3_ ( int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
char **   
)

◆ buprt_()

int buprt_ ( int *  ,
int *  ,
int *  ,
int *  ,
char **  ,
char **  ,
char **  ,
int *  ,
double *  ,
int *  ,
int *  ,
int *   
)

◆ bus012_()

int bus012_ ( int *  ,
unsigned int *  ,
int *  ,
int *  ,
int *  ,
int *  ,
int *   
)

◆ busel2_()

int busel2_ ( int *  ,
int *  ,
int *  ,
char **  ,
int *  ,
char **  ,
char **  ,
char **  ,
int *   
)

◆ busel_()

int busel_ ( int *  ,
int *  ,
int *  ,
int *  ,
int *   
)

◆ buukey_()

int buukey_ ( int *  ,
int *  ,
int *  ,
int *  ,
int *   
)

◆ charray_to_string()

char * charray_to_string ( char *  s,
unsigned char *  buf,
size_t  size 
)

get a null termitated c-string from an array of unsigned chars

Parameters
sresulting string
bufpointer to first element in array
sizenumber of chars in array

Definition at line 85 of file bufr2tac_utils.c.

86{
87 // copy
88 memcpy ( s , buf, size );
89 // add final string mark
90 s[size] = '\0';
91 return s;
92}

◆ check_date_from_future()

int check_date_from_future ( struct metreport m)

Check a estructure metreport not from future.

Parameters
mpointer to a struct metreport to check about date and time

It resturns 1 if date/time is from future, and likely wrong Returns 0 otherwise

Definition at line 292 of file bufr2tac_utils.c.

293{
294 time_t now;
295
296 now = time ( NULL );
297 if ( m->t.t > ( now + 1800 ) ) // Still 1/2 hour courtesy
298 return 1;
299 else
300 return 0;
301}
time_t t
Definition: metcommon.h:61
struct met_datetime t
Definition: bufr2tac.h:314

References metreport::t, and met_datetime::t.

Referenced by parse_subset_as_climat(), and parse_subset_as_synop().

Here is the caller graph for this function:

◆ check_j_cm2()

int check_j_cm2 ( double  val)

Check if a radiation value can be wrote in J/cm2 using up to 4 chars.

Parameters
valradiation value in J/m2

Returns 1 if success, 0 otherwise

Definition at line 45 of file bufr2tac_x14.c.

46{
47 return ( fabs ( val ) < 1.0e8 ) ? 1 : 0;
48}

Referenced by syn_parse_x14().

Here is the caller graph for this function:

◆ check_kj_m2()

int check_kj_m2 ( double  val)

Check if a radiation value can be wrote in Kj/m2 using up to 4 chars.

Parameters
valradiation value in J/m2

Returns 1 if success, 0 otherwise

Definition at line 33 of file bufr2tac_x14.c.

34{
35 return ( fabs ( val ) < 1.0e7 ) ? 1 : 0;
36}

Referenced by syn_parse_x14().

Here is the caller graph for this function:

◆ climat_parse_x01()

int climat_parse_x01 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 01.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 324 of file bufr2tac_x01.c.

325{
326 char aux[80];
327
328 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
329 return 0;
330
331 switch ( s->a->desc.y )
332 {
333
334 case 1: // 0 01 001 . WMO block number
335 sprintf ( c->s0.II, "%02d", s->ival );
336 break;
337
338 case 2: // 0 01 002 . WMO station number
339 sprintf ( c->s0.iii, "%03d", s->ival );
340 break;
341
342 case 3: // 0 01 003 . WMO Region
343 if ( s->ival == 1 )
344 strcpy ( c->s0.Reg, "I" );
345 else if ( s->ival == 2 )
346 strcpy ( c->s0.Reg, "II" );
347 else if ( s->ival == 3 )
348 strcpy ( c->s0.Reg, "III" );
349 else if ( s->ival == 4 )
350 strcpy ( c->s0.Reg, "IV" );
351 else if ( s->ival == 5 )
352 strcpy ( c->s0.Reg, "V" );
353 else if ( s->ival == 6 )
354 strcpy ( c->s0.Reg, "VI" );
355 break;
356
357 case 15: // 0 01 015 . Station or site name
358 case 18: // 0 01 018 . Short station or site name
359 case 19: // 0 01 019 . Long station or site name
360 if ( strlen ( s->a->cval ) <= 80 )
361 {
362 strcpy ( aux, s->a->cval );
363 adjust_string ( aux );
364 strcpy ( s->name, aux );
366 }
367 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
368 {
369 bufr2tac_set_error ( s, 1, "climat_parse_x01()", "Station or site name length > 80. Cannot set s->name" );
370 }
371 break;
372
373 case 125: // 0 01 125 . WIGOS identifier series
374 c->wid.series = ( uint8_t ) s->ival;
375 break;
376
377 case 126: // 0 01 126 . WIGOS issuer of identifier
378 c->wid.issuer = ( uint16_t ) s->ival;
379 break;
380
381 case 127: // 0 01 127 , WIGOS issue number
382 c->wid.issue = ( uint16_t ) s->ival;
383 break;
384
385 case 128: // 0 01 128 . WIGOS local identifier (character)
386 if ( strlen ( s->a->cval ) <= 16 )
387 {
388 strcpy ( c->wid.local_id, s->a->cval );
389 if ( check_wigos_local_id ( s->a->cval ) )
390 {
391 bufr2tac_set_error ( s, 1, "climat_parse_x01()","Bad WIGOS Local identifier" );
392 }
394 }
395 break;
396
397
398
399 default:
400 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
401 bufr2tac_set_error ( s, 0, "climat_parse_x01()", "Descriptor not parsed" );
402 break;
403 }
404 return 0;
405}
char iii[4]
Definition: metclimat.h:73
char II[4]
Definition: metclimat.h:72
char Reg[4]
Definition: metclimat.h:74

References bufr2tac_subset_state::a, adjust_string(), BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), check_wigos_local_id(), bufr_atom_data::cval, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, climat_sec0::II, climat_sec0::iii, wigos_id::issue, wigos_id::issuer, bufr2tac_subset_state::ival, wigos_id::local_id, bufr_atom_data::mask, bufr2tac_subset_state::mask, bufr2tac_subset_state::name, climat_sec0::Reg, climat_chunks::s0, wigos_id::series, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_WIGOS_ID, climat_chunks::wid, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x02()

int climat_parse_x02 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 02.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 146 of file bufr2tac_x02.c.

147{
148 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
149 return 0;
150
151 if ( c == NULL )
152 return 1;
153
154 switch ( s->a->desc.y )
155 {
156 case 1: // 0 02 001 . Type of station
157 s->type = s->ival;
159 break;
160
161 case 2: // 0 02 002 . Type of instrumentation for wind measurement
162 if ( s->ival & 4 )
163 strcpy ( c->s4.iw, "4" );
164 else
165 strcpy ( c->s4.iw, "1" );
166 break;
167
168 case 51: // 0 02 051 . Observing method for extreme temperatures
169 sprintf ( c->s4.iy,"%d",s->ival );
170 break;
171 default:
172 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
173 bufr2tac_set_error ( s, 0, "climat_parse_x02()", "Descriptor not parsed" );
174 break;
175 }
176 return 0;
177}
char iw[2]
Definition: metclimat.h:182
char iy[2]
Definition: metclimat.h:187

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::ival, climat_sec4::iw, climat_sec4::iy, bufr_atom_data::mask, bufr2tac_subset_state::mask, climat_chunks::s4, SUBSET_MASK_HAVE_TYPE_STATION, bufr2tac_subset_state::type, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x04()

int climat_parse_x04 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 04.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 405 of file bufr2tac_x04.c.

406{
407 if ( c == NULL )
408 {
409 return 1;
410 }
411
412
413 switch ( s->a->desc.y )
414 {
415 case 1: // 0 04 001 .Year
416 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
417 {
418 return 0;
419 }
420 else if ( s->ival < 2000 || s->ival > 2050 )
421 {
422 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
423 bufr2tac_set_error ( s, 2, "climat_parse_x04()", "Bad year" );
424 return 1;
425 }
426
427 if ( s->i && ( s->a1->desc.x == 4 ) && ( s->a1->desc.y == 1 ) )
428 {
429 // this is the final year of a normal period
430 s->is_normal = 1;
431 sprintf ( c->s2.YcYc, "%02d", s->ival % 100 );
432 // then we fill the begin from tatest descriptor
433 sprintf ( c->s2.YbYb, "%02d", ( int ) s->a1->val % 100 );
434 }
435 else if ( c->e.YYYY[0] == '\0' )
436 {
437 sprintf ( c->e.YYYY, "%04d", s->ival );
439 sprintf ( c->s0.JJJ, "%03d", abs ( s->ival ) % 1000 );
440 c->mask |= CLIMAT_SEC0;
441 }
442 break;
443
444 case 2: // 0 04 002 . Month
445 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
446 {
447 return 0;
448 }
449 sprintf ( c->e.MM, "%02d", s->ival );
451 sprintf ( c->s0.MM, "%02d", s->ival );
452 c->mask |= CLIMAT_SEC0;
453 break;
454
455 case 3: // 0 04 003 . Day of month
456 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
457 {
458 return 0;
459 }
460 if ( c->e.DD[0] == 0 )
461 {
462 sprintf ( c->e.DD, "%02d", s->ival );
463 }
464 if ( s->a1->desc.x == 8 && s->a1->desc.y == 53 )
465 {
466 s->more_days = s->isq_val;
467 }
468 s->day = s->ival;
470 break;
471
472 case 4: // 0 04 004 . Hour
473 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
474 {
475 return 0;
476 }
477 if ( c->e.HH[0] == 0 )
478 {
479 sprintf ( c->e.HH, "%02d", s->ival );
480 }
482 break;
483
484 case 5: // 0 04 005 . Minute
485 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
486 {
487 return 0;
488 }
489 if ( c->e.mm[0] == 0 )
490 {
491 sprintf ( c->e.mm, "%02d", s->ival );
492 }
494 break;
495
496 case 22: // 0 04 022 . Num month. Case of sec2 with normals
497 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
498 {
499 return 0;
500 }
501 s->month = s->ival;
502 break;
503
504 case 23: // 0 04 023 . Num days in month
505 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
506 {
507 return 0;
508 }
509 if ( s->nday == 0 )
510 {
511 s->nday = s->ival;
512 }
513 break;
514
515 case 51: // 0 04 051 . Principal time of daily reading of maximum
516 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
517 {
518 return 0;
519 }
520 sprintf ( c->s4.GxGx, "%02d", s->ival );
521 s->mask |= CLIMAT_SEC4;
522 break;
523
524 case 52: // 0 04 052 . Principal time of daily reading of minimum
525 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
526 {
527 return 0;
528 }
529 sprintf ( c->s4.GnGn, "%02d", s->ival );
530 s->mask |= CLIMAT_SEC4;
531 break;
532
533 case 53: // 0 04 053 . Number of days with precipitation equal to or more than 1 mm
534 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
535 {
536 return 0;
537 }
538 if ( s->is_normal == 0 )
539 {
540 sprintf ( c->s1.nrnr, "%02d", s->ival );
541 s->mask |= CLIMAT_SEC1;
542 }
543 else
544 {
545 sprintf ( c->s2.nrnr, "%02d", s->ival );
546 s->mask |= CLIMAT_SEC2;
547 }
548 break;
549
550
551 case 74: // 0 04 074 . (UTC - LST)
552 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
553 {
554 return 0;
555 }
556 s->dift = s->ival;
557 break;
558
559 default:
560 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
561 bufr2tac_set_error ( s, 0, "climat_parse_x04()", "Descriptor not parsed" );
562 break;
563 }
564 return 0;
565}
#define CLIMAT_SEC0
mask bit meaning section 0 of climat is solicited to or parsed with success
Definition: metclimat.h:32
#define CLIMAT_SEC4
mask bit meaning section 4 of climat is solicited to or parsed with success
Definition: metclimat.h:52
#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
struct bufr_atom_data * a1
Definition: bufr2tac.h:250
char JJJ[4]
Definition: metclimat.h:71
char MM[4]
Definition: metclimat.h:70
char nrnr[4]
Definition: metclimat.h:94
char nrnr[4]
Definition: metclimat.h:124
char YbYb[4]
Definition: metclimat.h:111
char YcYc[4]
Definition: metclimat.h:112
char GnGn[4]
Definition: metclimat.h:189
char GxGx[4]
Definition: metclimat.h:188

References bufr2tac_subset_state::a, bufr2tac_subset_state::a1, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC0, CLIMAT_SEC1, CLIMAT_SEC2, CLIMAT_SEC4, bufr2tac_subset_state::day, report_date_ext::DD, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::dift, climat_chunks::e, climat_sec4::GnGn, climat_sec4::GxGx, report_date_ext::HH, bufr2tac_subset_state::i, bufr2tac_subset_state::is_normal, bufr2tac_subset_state::isq_val, bufr2tac_subset_state::ival, climat_sec0::JJJ, bufr_atom_data::mask, bufr2tac_subset_state::mask, climat_chunks::mask, climat_sec0::MM, report_date_ext::MM, report_date_ext::mm, bufr2tac_subset_state::month, bufr2tac_subset_state::more_days, bufr2tac_subset_state::nday, climat_sec1::nrnr, climat_sec2::nrnr, climat_chunks::s0, climat_chunks::s1, climat_chunks::s2, climat_chunks::s4, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_MINUTE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_YEAR, bufr_atom_data::val, bufr_descriptor::x, bufr_descriptor::y, climat_sec2::YbYb, climat_sec2::YcYc, and report_date_ext::YYYY.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x05()

int climat_parse_x05 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 05.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 170 of file bufr2tac_x05.c.

171{
172 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
173 return 0;
174
175 // this is to avoid warning
176 if ( c == NULL )
177 return 1;
178
179 switch ( s->a->desc.y )
180 {
181 case 1: // 0 05 001 . Latitude (High accuracy)
182 case 2: // 0 05 002 . Latitude (Coarse accuracy)
183 if ( s->val < 0.0 )
184 s->mask |= SUBSET_MASK_LATITUDE_SOUTH; // Sign for latitude
186 s->lat = s->val;
187 break;
188 default:
189 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
190 bufr2tac_set_error ( s, 0, "climat_parse_x05()", "Descriptor not parsed" );
191 break;
192 }
193 return 0;
194}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::lat, bufr_atom_data::mask, bufr2tac_subset_state::mask, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_LATITUDE_SOUTH, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x06()

int climat_parse_x06 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 06.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 165 of file bufr2tac_x06.c.

166{
167 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
168 return 0;
169
170 // this is to avoid warning
171 if ( c == NULL )
172 return 1;
173
174 switch ( s->a->desc.y )
175 {
176 case 1: // 0 06 001 . Longitude (High accuracy)
177 case 2: // 0 06 002 . Longitude (Coarse accuracy)
178 if ( s->val < 0.0 )
179 s->mask |= SUBSET_MASK_LONGITUDE_WEST; // Sign for longitude
181 s->lon = s->val;
182 break;
183
184 default:
185 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
186 bufr2tac_set_error ( s, 0, "climat_parse_x06()", "Descriptor not parsed" );
187 break;
188 }
189 return 0;
190}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::lon, bufr_atom_data::mask, bufr2tac_subset_state::mask, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_LONGITUDE_WEST, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x07()

int climat_parse_x07 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Definition at line 208 of file bufr2tac_x07.c.

209{
210 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
211 {
212 return 0;
213 }
214
215 // this is to avoid warning
216 if ( c == NULL )
217 {
218 return 1;
219 }
220
221 switch ( s->a->desc.y )
222 {
223 case 1: // 0 07 001 . Heigh of station
224 case 30: // 0 07 030 . Height of station ground above msl
225 case 31: // 0 07 031 . Height of barometer above msl
226 s->alt = s->val;
227 break;
228
229 case 32: // 0 07 032 . Pressure of standard level
230 // Not a useful value for alphanumeric climat
231 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
232 bufr2tac_set_error ( s, 0, "climat_parse_x07()", "Descriptor not parsed" );
233 break;
234
235 case 4: // Pressure of standard level
236 // Not a useful value for alphanumeric climat
237 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
238 bufr2tac_set_error ( s, 0, "climat_parse_x07()", "Descriptor not parsed" );
239 break;
240
241 default:
242 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
243 bufr2tac_set_error ( s, 0, "climat_parse_x07()", "Descriptor not parsed" );
244 break;
245 }
246
247 return 0;
248}

References bufr2tac_subset_state::a, bufr2tac_subset_state::alt, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr_atom_data::mask, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x08()

int climat_parse_x08 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 08.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 164 of file bufr2tac_x08.c.

165{
166 char caux[16];
167
168 if ( c == NULL )
169 {
170 return 1;
171 }
172
173 switch ( s->a->desc.y )
174 {
175 case 20: // 0 08 020 . Total number of missing entities (days)
176 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
177 {
178 return 0;
179 }
180 if ( s->is_normal == 0 )
181 {
182 switch ( s->isq_val )
183 {
184 // days of missing data
185 case 1: // pressure
186 sprintf ( c->s1.mpmp, "%02d", s->ival );
187 c->mask |= CLIMAT_SEC1;
188 break;
189 case 2: // temperature
190 sprintf ( c->s1.mtmt, "%02d", s->ival );
191 c->mask |= CLIMAT_SEC1;
192 break;
193 case 4: // vapour pressure
194 sprintf ( c->s1.meme, "%02d", s->ival );
195 c->mask |= CLIMAT_SEC1;
196 break;
197 case 5: // precipitation
198 sprintf ( c->s1.mrmr, "%02d", s->ival );
199 c->mask |= CLIMAT_SEC1;
200 break;
201 case 6: // sunshine duration
202 sprintf ( c->s1.msms, "%02d", s->ival );
203 c->mask |= CLIMAT_SEC1;
204 break;
205 case 7: // Maximum temperature
206 if ( s->ival < 10 )
207 {
208 sprintf ( caux, "%d", s->ival );
209 c->s1.mtx[0] = caux[0];
210 c->s1.mtx[1] = 0;
211 }
212 else
213 {
214 c->s1.mtx[0] = '9';
215 }
216 c->mask |= CLIMAT_SEC1;
217 break;
218 case 8: // Minimum temperature
219 if ( s->ival < 10 )
220 {
221 sprintf ( caux, "%d", s->ival );
222 c->s1.mtn[0] = caux[0];
223 c->s1.mtn[1] = 0;
224 }
225 else
226 {
227 c->s1.mtn[0] = '9';
228 }
229 c->mask |= CLIMAT_SEC1;
230 break;
231 default:
232 break;
233 }
234 }
235 else
236 {
237 switch ( s->isq_val )
238 {
239 // years of missing data
240 case 1: // pressure
241 sprintf ( c->s2.ypyp, "%02d", s->ival );
242 c->mask |= CLIMAT_SEC2;
243 break;
244 case 2: // temperature
245 sprintf ( c->s2.ytyt, "%02d", s->ival );
246 c->mask |= CLIMAT_SEC2;
247 break;
248 case 3: // extreme temperature
249 sprintf ( c->s2.ytxytx, "%02d", s->ival );
250 c->mask |= CLIMAT_SEC2;
251 break;
252 case 4: // vapour pressure
253 sprintf ( c->s2.yeye, "%02d", s->ival );
254 c->mask |= CLIMAT_SEC2;
255 break;
256 case 5: // precipitation
257 sprintf ( c->s2.yryr, "%02d", s->ival );
258 c->mask |= CLIMAT_SEC2;
259 break;
260 case 6: // sunshine duration
261 sprintf ( c->s2.ysys, "%02d", s->ival );
262 c->mask |= CLIMAT_SEC2;
263 break;
264 default:
265 break;
266 }
267 }
268 break;
269
270 case 22:
271 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
272 {
273 return 0;
274 }
275 switch ( s->isq_val )
276 {
277 case 0:
278 sprintf ( c->s3.f10, "%02d", s->ival );
279 c->mask |= CLIMAT_SEC3;
280 break;
281 case 1:
282 sprintf ( c->s3.f20, "%02d", s->ival );
283 c->mask |= CLIMAT_SEC3;
284 break;
285 case 2:
286 sprintf ( c->s3.f30, "%02d", s->ival );
287 c->mask |= CLIMAT_SEC3;
288 break;
289 case 3:
290 sprintf ( c->s3.Tx0, "%02d", s->ival );
291 c->mask |= CLIMAT_SEC3;
292 break;
293 case 4:
294 sprintf ( c->s3.T25, "%02d", s->ival );
295 c->mask |= CLIMAT_SEC3;
296 break;
297 case 5:
298 sprintf ( c->s3.T30, "%02d", s->ival );
299 c->mask |= CLIMAT_SEC3;
300 break;
301 case 6:
302 sprintf ( c->s3.T35, "%02d", s->ival );
303 c->mask |= CLIMAT_SEC3;
304 break;
305 case 7:
306 sprintf ( c->s3.T40, "%02d", s->ival );
307 c->mask |= CLIMAT_SEC3;
308 break;
309 case 8:
310 sprintf ( c->s3.Tn0, "%02d", s->ival );
311 c->mask |= CLIMAT_SEC3;
312 break;
313 case 10:
314 sprintf ( c->s3.R01, "%02d", s->ival );
315 c->mask |= CLIMAT_SEC3;
316 break;
317 case 11:
318 sprintf ( c->s3.R05, "%02d", s->ival );
319 c->mask |= CLIMAT_SEC3;
320 break;
321 case 12:
322 sprintf ( c->s3.R10, "%02d", s->ival );
323 c->mask |= CLIMAT_SEC3;
324 break;
325 case 13:
326 sprintf ( c->s3.R50, "%02d", s->ival );
327 c->mask |= CLIMAT_SEC3;
328 break;
329 case 14:
330 sprintf ( c->s3.R100, "%02d", s->ival );
331 c->mask |= CLIMAT_SEC3;
332 break;
333 case 15:
334 sprintf ( c->s3.R150, "%02d", s->ival );
335 c->mask |= CLIMAT_SEC3;
336 break;
337 case 16:
338 sprintf ( c->s3.s00, "%02d", s->ival );
339 c->mask |= CLIMAT_SEC3;
340 break;
341 case 17:
342 sprintf ( c->s3.s01, "%02d", s->ival );
343 c->mask |= CLIMAT_SEC3;
344 break;
345 case 18:
346 sprintf ( c->s3.s10, "%02d", s->ival );
347 c->mask |= CLIMAT_SEC3;
348 break;
349 case 19:
350 sprintf ( c->s3.s50, "%02d", s->ival );
351 c->mask |= CLIMAT_SEC3;
352 break;
353 case 20:
354 sprintf ( c->s3.V1, "%02d", s->ival );
355 c->mask |= CLIMAT_SEC3;
356 break;
357 case 21:
358 sprintf ( c->s3.V2, "%02d", s->ival );
359 c->mask |= CLIMAT_SEC3;
360 break;
361 case 22:
362 sprintf ( c->s3.V3, "%02d", s->ival );
363 c->mask |= CLIMAT_SEC3;
364 break;
365 case 23:
366 sprintf ( c->s4.Dgr, "%02d", s->ival );
367 c->mask |= CLIMAT_SEC4;
368 break;
369 case 24:
370 sprintf ( c->s4.Dts, "%02d", s->ival );
371 c->mask |= CLIMAT_SEC4;
372 break;
373 default:
374 break;
375 }
376 break;
377
378 case 23: // 0 08 023 . First-order statistics.
379 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
380 {
381 s->isq = 0;
382 s->isq_val = 0;
383 }
384 else
385 {
386 s->isq = 1;
387 s->isq_val = s->ival;
388 }
389 break;
390
391 case 50: // 0 08 050 . Qualifier for number of missing values in calculation of statistic
392 case 52: // 0 08 052 . Conditions for which number of days of occurrence follows
393 case 53: // 0 08 053 . Day of occurrence qualifier (= 0; on 1 day only) (= 1; on 2 or more days)
394 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
395 {
396 s->isq = 0;
397 s->isq_val = -1;
398 return 0;
399 }
400 s->isq = 1;
401 s->isq_val = s->ival;
402 break;
403
404 default:
405 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
406 bufr2tac_set_error ( s, 0, "climat_parse_x08()", "Descriptor not parsed" );
407 break;
408 }
409
410 return 0;
411}
#define CLIMAT_SEC3
mask bit meaning section 3 of climat is solicited to or parsed with success
Definition: metclimat.h:47
char mtmt[4]
Definition: metclimat.h:98
char mtx[2]
Definition: metclimat.h:99
char mrmr[4]
Definition: metclimat.h:102
char mtn[2]
Definition: metclimat.h:100
char mpmp[4]
Definition: metclimat.h:97
char msms[4]
Definition: metclimat.h:103
char meme[4]
Definition: metclimat.h:101
char yryr[4]
Definition: metclimat.h:130
char ytxytx[4]
Definition: metclimat.h:128
char ypyp[4]
Definition: metclimat.h:126
char ytyt[4]
Definition: metclimat.h:127
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 Dgr[4]
Definition: metclimat.h:186
char Dts[4]
Definition: metclimat.h:185

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC1, CLIMAT_SEC2, CLIMAT_SEC3, CLIMAT_SEC4, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, climat_sec4::Dgr, climat_sec4::Dts, climat_sec3::f10, climat_sec3::f20, climat_sec3::f30, bufr2tac_subset_state::is_normal, bufr2tac_subset_state::isq, bufr2tac_subset_state::isq_val, bufr2tac_subset_state::ival, bufr_atom_data::mask, climat_chunks::mask, climat_sec1::meme, climat_sec1::mpmp, climat_sec1::mrmr, climat_sec1::msms, climat_sec1::mtmt, climat_sec1::mtn, climat_sec1::mtx, climat_sec3::R01, climat_sec3::R05, climat_sec3::R10, climat_sec3::R100, climat_sec3::R150, climat_sec3::R50, climat_sec3::s00, climat_sec3::s01, climat_chunks::s1, climat_sec3::s10, climat_chunks::s2, climat_chunks::s3, climat_chunks::s4, climat_sec3::s50, climat_sec3::T25, climat_sec3::T30, climat_sec3::T35, climat_sec3::T40, climat_sec3::Tn0, climat_sec3::Tx0, climat_sec3::V1, climat_sec3::V2, climat_sec3::V3, bufr_descriptor::y, climat_sec2::yeye, climat_sec2::ypyp, climat_sec2::yryr, climat_sec2::ysys, climat_sec2::ytxytx, and climat_sec2::ytyt.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x10()

int climat_parse_x10 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 10.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 214 of file bufr2tac_x10.c.

215{
216 char aux[16];
217
218 if ( c == NULL || s == NULL )
219 {
220 return 1;
221 }
222
223 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
224 {
225 return 0;
226 }
227
228 switch ( s->a->desc.y )
229 {
230 case 4: // 0 10 004 . Pressure
231 if ( s->isq_val == 4 )
232 {
233 pascal_to_PPPP ( aux, s->val );
234 if ( s->is_normal == 0 )
235 {
236 strcpy ( c->s1.PoPoPoPo, aux );
237 c->mask |= CLIMAT_SEC1;
238 }
239 else
240 {
241 strcpy ( c->s2.PoPoPoPo, aux );
242 c->mask |= CLIMAT_SEC2;
243 }
244 }
245 break;
246
247 case 9: // 0 10 009 . Heigh of geopotential
248 if ( s->isq_val == 4 )
249 {
250 if ( s->is_normal == 0 )
251 {
252 sprintf ( c->s1.PPPP, "%04d", s->ival );
253 c->mask |= CLIMAT_SEC1;
254 }
255 else
256 {
257 sprintf ( c->s1.PPPP, "%04d", s->ival );
258 c->mask |= CLIMAT_SEC2;
259 }
260 }
261 break;
262
263 case 51: // 0 10 051 . Pressure reduced to mean sea level
264 if ( s->isq_val == 4 )
265 {
266 pascal_to_PPPP ( aux, s->val );
267 if ( s->is_normal == 0 )
268 {
269 strcpy ( c->s1.PPPP, aux );
270 c->mask |= CLIMAT_SEC1;
271 }
272 else
273 {
274 strcpy ( c->s2.PPPP, aux );
275 c->mask |= CLIMAT_SEC2;
276 }
277 }
278 break;
279
280 default:
281 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
282 bufr2tac_set_error ( s, 0, "climat_parse_x10()", "Descriptor not parsed" );
283 break;
284
285 }
286 return 0;
287}
char PoPoPoPo[8]
Definition: metclimat.h:82
char PPPP[8]
Definition: metclimat.h:83
char PPPP[8]
Definition: metclimat.h:114
char PoPoPoPo[8]
Definition: metclimat.h:113

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC1, CLIMAT_SEC2, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::is_normal, bufr2tac_subset_state::isq_val, bufr2tac_subset_state::ival, bufr_atom_data::mask, climat_chunks::mask, pascal_to_PPPP(), climat_sec1::PoPoPoPo, climat_sec2::PoPoPoPo, climat_sec1::PPPP, climat_sec2::PPPP, climat_chunks::s1, climat_chunks::s2, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x11()

int climat_parse_x11 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 11.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 454 of file bufr2tac_x11.c.

455{
456
457 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
458 {
459 return 0;
460 }
461
462 switch ( s->a->desc.y )
463 {
464 case 46: // 0 11 046 . Maximum wind speed
465 if ( c->s4.iw[0] == '4' )
466 {
467 sprintf ( c->s4.fxfxfx, "%03d", ( int ) ( s->val * 10.0 * 1.94384449 + 0.5 ) );
468 }
469 else
470 {
471 sprintf ( c->s4.fxfxfx, "%03d", ( int ) ( s->val * 10.0 + 0.5 ) );
472 }
473 if ( s->isq_val == 0 )
474 {
475 sprintf ( c->s4.yfx, "%02d", s->day );
476 }
477 else
478 {
479 sprintf ( c->s4.yfx, "%02d", (s->day + 50) % 100 );
480 }
481 c->mask |= CLIMAT_SEC4;
482 break;
483
484 default:
485 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
486 bufr2tac_set_error ( s, 0, "climat_parse_x11()", "Descriptor not parsed" );
487 break;
488 }
489 return 0;
490}
char yfx[4]
Definition: metclimat.h:184
char fxfxfx[4]
Definition: metclimat.h:183

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC4, bufr2tac_subset_state::day, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, climat_sec4::fxfxfx, bufr2tac_subset_state::isq_val, climat_sec4::iw, bufr_atom_data::mask, climat_chunks::mask, climat_chunks::s4, bufr2tac_subset_state::val, bufr_descriptor::y, and climat_sec4::yfx.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x12()

int climat_parse_x12 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 12.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 526 of file bufr2tac_x12.c.

527{
528 char aux[16];
529
530 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
531 {
532 return 0;
533 }
534
535 if ( c == NULL )
536 {
537 return 1;
538 }
539
540 switch ( s->a->desc.y )
541 {
542 case 101:
543 if ( s->is_normal == 0 )
544 {
545 if ( s->isq_val == 4 ) // mean value
546 {
547 if ( kelvin_to_snTTT ( aux, s->val ) )
548 {
549 c->s1.s[0] = aux[0];
550 strcpy ( c->s1.TTT, aux + 1 );
551 c->mask |= CLIMAT_SEC1;
552 }
553 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
554 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
555 }
556 else if ( s->isq_val == 2 ) // maximum value
557 {
558 if ( kelvin_to_snTTT ( aux, s->val ) )
559 {
560 c->s4.sax[0] = aux[0];
561 strcpy ( c->s4.Tax, aux + 1 );
562 if ( s->more_days == 0 )
563 {
564 sprintf ( c->s4.yax, "%02d", s->day );
565 }
566 else
567 {
568 sprintf ( c->s4.yax, "%02d", ( s->day + 50 ) % 100 );
569 }
570 c->mask |= CLIMAT_SEC4;
571 }
572 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
573 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
574
575 }
576 else if ( s->isq_val == 3 ) // minimum value
577 {
578 if ( kelvin_to_snTTT ( aux, s->val ) )
579 {
580 c->s4.san[0] = aux[0];
581 strcpy ( c->s4.Tan, aux + 1 );
582 if ( s->more_days == 0 )
583 {
584 sprintf ( c->s4.yan, "%02d", s->day );
585 }
586 else
587 {
588 sprintf ( c->s4.yan, "%02d", ( s->day + 50 ) % 100 );
589 }
590 c->mask |= CLIMAT_SEC4;
591 }
592 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
593 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
594 }
595 }
596 else
597 {
598 if ( c->s2.TTT[0] == 0 )
599 {
600 if ( kelvin_to_snTTT ( aux, s->val ) )
601 {
602 c->s2.s[0] = aux[0];
603 strcpy ( c->s2.TTT, aux + 1 );
604 c->mask |= CLIMAT_SEC2;
605 }
606 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
607 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
608 }
609
610 }
611 break;
612
613 case 118: // 0 12 118 . Maximum temperature at heigh specified, past 24 h
614 if ( s->is_normal == 0 )
615 {
616 if ( c->s1.TxTxTx[0] == 0 )
617 {
618 if ( kelvin_to_snTTT ( aux, s->val ) )
619 {
620 c->s1.sx[0] = aux[0];
621 strcpy ( c->s1.TxTxTx, aux + 1 );
622 c->mask |= CLIMAT_SEC1;
623 }
624 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
625 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
626 }
627 }
628 else
629 {
630 if ( c->s2.TxTxTx[0] == 0 )
631 {
632 if ( kelvin_to_snTTT ( aux, s->val ) )
633 {
634 c->s2.sx[0] = aux[0];
635 strcpy ( c->s2.TxTxTx, aux + 1 );
636 c->mask |= CLIMAT_SEC2;
637 }
638 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
639 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
640 }
641 }
642 break;
643
644 case 119: // 0 12 119 . Minimum temperature at heigh specified, past 24 h
645 if ( s->is_normal == 0 )
646 {
647 if ( c->s1.TnTnTn[0] == 0 )
648 {
649 if ( kelvin_to_snTTT ( aux, s->val ) )
650 {
651 c->s1.sn[0] = aux[0];
652 strcpy ( c->s1.TnTnTn, aux + 1 );
653 c->mask |= CLIMAT_SEC1;
654 }
655 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
656 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
657 }
658 }
659 else
660 {
661 if ( c->s2.TnTnTn[0] == 0 )
662 {
663 if ( kelvin_to_snTTT ( aux, s->val ) )
664 {
665 c->s2.sn[0] = aux[0];
666 strcpy ( c->s2.TnTnTn, aux + 1 );
667 c->mask |= CLIMAT_SEC2;
668 }
669 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
670 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
671 }
672 }
673 break;
674
675 case 151: // 0 12 151 . Standard deviation of daily mean temperature
676 sprintf ( aux, "%03d", ( int ) ( s->val * 10.0 + 0.5 ) );
677 if ( s->is_normal == 0 )
678 {
679 strcpy ( c->s1.ststst, aux );
680 c->mask |= CLIMAT_SEC1;
681 }
682 else
683 {
684 strcpy ( c->s2.ststst, aux );
685 c->mask |= CLIMAT_SEC2;
686 }
687 break;
688
689 case 152: // 0 12 152 . Highest daily mean temperature
690 if ( s->a1->desc.x == 4 && s->a1->desc.y == 3 )
691 {
692 if ( kelvin_to_snTTT ( aux, s->val ) )
693 {
694 c->s4.sx[0] = aux[0];
695 strcpy ( c->s4.Txd, aux + 1 );
696 }
697 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
698 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
699
700 if ( s->isq_val == 0 )
701 {
702 sprintf ( c->s4.yx, "%02d", s->day );
703 }
704 else
705 {
706 sprintf ( c->s4.yx, "%02d", ( s->day + 50 ) % 100 );
707 }
708 c->mask |= CLIMAT_SEC4;
709 }
710 break;
711
712 case 153: // 0 12 153 . Lowest daily mean temperature
713 if ( s->a1->desc.x == 4 && s->a1->desc.y == 3 )
714 {
715 if ( kelvin_to_snTTT ( aux, s->val ) )
716 {
717 c->s4.sn[0] = aux[0];
718 strcpy ( c->s4.Tnd, aux + 1 );
719 }
720 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
721 bufr2tac_set_error ( s, 1, "climat_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
722
723 if ( s->isq_val == 0 )
724 {
725 sprintf ( c->s4.yn, "%02d", s->day );
726 }
727 else
728 {
729 sprintf ( c->s4.yn, "%02d", ( s->day + 50 ) % 100 );
730 }
731 c->mask |= CLIMAT_SEC4;
732 }
733 break;
734
735 default:
736 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
737 bufr2tac_set_error ( s, 0, "climat_parse_x12()", "Descriptor not parsed" );
738 break;
739 }
740 return 0;
741}
char s[2]
Definition: metclimat.h:84
char sx[2]
Definition: metclimat.h:87
char TxTxTx[4]
Definition: metclimat.h:88
char TTT[4]
Definition: metclimat.h:85
char sn[2]
Definition: metclimat.h:89
char ststst[4]
Definition: metclimat.h:86
char TnTnTn[4]
Definition: metclimat.h:90
char TTT[4]
Definition: metclimat.h:116
char TnTnTn[4]
Definition: metclimat.h:121
char TxTxTx[4]
Definition: metclimat.h:119
char ststst[4]
Definition: metclimat.h:117
char sn[2]
Definition: metclimat.h:120
char sx[2]
Definition: metclimat.h:118
char s[2]
Definition: metclimat.h:115
char sax[2]
Definition: metclimat.h:174
char sx[2]
Definition: metclimat.h:168
char Tnd[4]
Definition: metclimat.h:172
char yx[4]
Definition: metclimat.h:170
char san[2]
Definition: metclimat.h:177
char yn[4]
Definition: metclimat.h:173
char Tax[4]
Definition: metclimat.h:175
char yax[4]
Definition: metclimat.h:176
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

References bufr2tac_subset_state::a, bufr2tac_subset_state::a1, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC1, CLIMAT_SEC2, CLIMAT_SEC4, bufr2tac_subset_state::day, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::is_normal, bufr2tac_subset_state::isq_val, kelvin_to_snTTT(), bufr_atom_data::mask, climat_chunks::mask, bufr2tac_subset_state::more_days, climat_sec1::s, climat_sec2::s, climat_chunks::s1, climat_chunks::s2, climat_chunks::s4, climat_sec4::san, climat_sec4::sax, climat_sec1::sn, climat_sec2::sn, climat_sec4::sn, climat_sec1::ststst, climat_sec2::ststst, climat_sec1::sx, climat_sec2::sx, climat_sec4::sx, climat_sec4::Tan, climat_sec4::Tax, climat_sec4::Tnd, climat_sec1::TnTnTn, climat_sec2::TnTnTn, climat_sec1::TTT, climat_sec2::TTT, climat_sec4::Txd, climat_sec1::TxTxTx, climat_sec2::TxTxTx, bufr2tac_subset_state::val, bufr_descriptor::x, bufr_descriptor::y, climat_sec4::yan, climat_sec4::yax, climat_sec4::yn, and climat_sec4::yx.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x13()

int climat_parse_x13 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 13.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 909 of file bufr2tac_x13.c.

910{
911
912 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
913 {
914 return 0;
915 }
916
917 if ( c == NULL )
918 {
919 return 1;
920 }
921
922
923 switch ( s->a->desc.y )
924 {
925 case 4: // 0 13 004 . Mean vapor pressure in tenths of hectopascal
926 if ( s->is_normal == 0 )
927 {
928 sprintf ( c->s1.eee,"%03d", ( int ) ( s->val * 0.1 + 0.5 ) );
929 c->mask |= CLIMAT_SEC1;
930 }
931 else
932 {
933 sprintf ( c->s2.eee,"%03d", ( int ) ( s->val * 0.1 + 0.5 ) );
934 c->mask |= CLIMAT_SEC2;
935 }
936 break;
937
938 case 51: // 0 13 051 . Frequency group precipitation
939 if ( s->ival >= 0 && s->ival <= 6 )
940 {
941 sprintf ( c->s1.Rd, "%d", s->ival );
942 }
943 break;
944
945 case 52: // 0 13 052 . Highest daily amount of precipitation
946 prec_to_RxRxRxRx ( c->s4.RxRxRxRx, s->val );
947 if ( s->more_days == 0 )
948 {
949 sprintf ( c->s4.yr, "%02d", s->day );
950 }
951 else
952 {
953 sprintf ( c->s4.yr, "%02d", (s->day + 50) % 50 );
954 }
955 c->mask |= CLIMAT_SEC4;
956 break;
957
958 case 60: // 0 13 060 . Total acumulated precipitation
959 if ( s->is_normal == 0 )
960 {
961 prec_to_RRRR ( c->s1.R1R1R1R1, s->val );
962 c->mask |= CLIMAT_SEC1;
963 }
964 else
965 {
966 prec_to_RRRR ( c->s2.R1R1R1R1, s->val );
967 c->mask |= CLIMAT_SEC2;
968 }
969 break;
970
971 default:
972 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
973 bufr2tac_set_error ( s, 0, "climat_parse_x13()", "Descriptor not parsed" );
974 break;
975 }
976 return 0;
977}
char * prec_to_RxRxRxRx(char *target, double r)
converts a precipitation in Kg/m2 into a RxRxRxRx string
Definition: bufr2tac_x13.c:110
char * prec_to_RRRR(char *target, double r)
converts a precipitation in Kg/m2 into a RRRR string (code table 3596)
Definition: bufr2tac_x13.c:64
char R1R1R1R1[6]
Definition: metclimat.h:92
char eee[4]
Definition: metclimat.h:91
char Rd[2]
Definition: metclimat.h:93
char R1R1R1R1[6]
Definition: metclimat.h:123
char eee[4]
Definition: metclimat.h:122
char RxRxRxRx[8]
Definition: metclimat.h:180
char yr[4]
Definition: metclimat.h:181

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC1, CLIMAT_SEC2, CLIMAT_SEC4, bufr2tac_subset_state::day, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, climat_sec1::eee, climat_sec2::eee, bufr2tac_subset_state::is_normal, bufr2tac_subset_state::ival, bufr_atom_data::mask, climat_chunks::mask, bufr2tac_subset_state::more_days, prec_to_RRRR(), prec_to_RxRxRxRx(), climat_sec1::R1R1R1R1, climat_sec2::R1R1R1R1, climat_sec1::Rd, climat_sec4::RxRxRxRx, climat_chunks::s1, climat_chunks::s2, climat_chunks::s4, bufr2tac_subset_state::val, bufr_descriptor::y, and climat_sec4::yr.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x14()

int climat_parse_x14 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 14.

Parameters
cpointer to a struct climat_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 497 of file bufr2tac_x14.c.

498{
499 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
500 {
501 return 0;
502 }
503
504 if ( c == NULL )
505 {
506 return 1;
507 }
508
509 switch ( s->a->desc.y )
510 {
511 case 32: // 0 14 032 . Total sunshine
512 if ( s->is_normal == 0 )
513 {
514 sprintf ( c->s1.S1S1S1, "%03d", s->ival );
515 c->mask |= CLIMAT_SEC1;
516 }
517 else
518 {
519 sprintf ( c->s2.S1S1S1, "%03d", s->ival );
520 c->mask |= CLIMAT_SEC2;
521 }
522 break;
523
524 case 33: // 0 14 033 . total sunshine percentage
525 sprintf ( c->s1.pspsps, "%03d", s->ival );
526 c->mask |= CLIMAT_SEC1;
527 break;
528
529 default:
530 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
531 bufr2tac_set_error ( s, 0, "climat_parse_x14()", "Descriptor not parsed" );
532 break;
533 }
534 return 0;
535}
char pspsps[4]
Definition: metclimat.h:96
char S1S1S1[4]
Definition: metclimat.h:95
char S1S1S1[4]
Definition: metclimat.h:125

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), CLIMAT_SEC1, CLIMAT_SEC2, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::is_normal, bufr2tac_subset_state::ival, bufr_atom_data::mask, climat_chunks::mask, climat_sec1::pspsps, climat_chunks::s1, climat_sec1::S1S1S1, climat_sec2::S1S1S1, climat_chunks::s2, and bufr_descriptor::y.

Referenced by parse_subset_as_climat().

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

◆ climat_parse_x20()

int climat_parse_x20 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

◆ climat_parse_x22()

int climat_parse_x22 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

◆ climat_parse_x31()

int climat_parse_x31 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

◆ climat_parse_x33()

int climat_parse_x33 ( struct climat_chunks c,
struct bufr2tac_subset_state s 
)

◆ descriptor_to_integer()

int descriptor_to_integer ( int *  id,
struct bufr_descriptor d 
)

parse a descriptor and sets an integer in the decimal formas fxxyyy

Parameters
idpointer to target integer
dpointer to a struct bufr_descriptor with the source

Definition at line 58 of file bufr2tac_utils.c.

59{
60 if ( d == NULL )
61 return 1;
62 *id = 100000 * d->f + 1000 * d->x + d->y;
63 return 0;
64}

References bufr_descriptor::f, bufr_descriptor::x, and bufr_descriptor::y.

Referenced by bufrtotac_parse_subset_sequence().

Here is the caller graph for this function:

◆ dewpoint_depression_to_DnDn()

char * dewpoint_depression_to_DnDn ( char *  target,
double  T,
double  Td 
)

Set DnDn (dewpoint depression)

Parameters
targetstring to set as result
Ttemperature (Kelvin)
Tddewpoint (Kelvin)

Definition at line 179 of file bufr2tac_x12.c.

180{
181 int ix;
182 double dpd = T - Td;
183
184 if ( T == MISSING_REAL || Td == MISSING_REAL )
185 {
186 strcpy ( target, "//" );
187 return target;
188 }
189
190 if ( dpd < 0.0 )
191 {
192 return NULL;
193 }
194
195 if ( dpd > 50.0 )
196 {
197 strcpy ( target, "//" );
198 return target;
199 }
200
201 ix = ( int ) ( 10.0 * dpd );
202
203 if ( ix >= 55 )
204 {
205 ix = 50 + ( ix + 5 ) / 10;
206 }
207 sprintf ( target, "%02d", ix );
208
209 return target;
210}
#define MISSING_REAL
The missing default value for real values.
Definition: bufrdeco.h:78

References MISSING_REAL.

Referenced by parse_temp_raw_data().

Here is the caller graph for this function:

◆ 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:

◆ get_ecmwf_tablename()

char * get_ecmwf_tablename ( char *  target,
char  type,
char *  bufrtables_dir,
int  ksec1[40] 
)

Get the complete pathname of a table file needed by a bufr message.

Parameters
targetthe resulting name
typea char with type, i.e, 'B', 'C', or 'D'
bufrtables_dirstring with path to bufr file tables dir
ksec1array of integer processed prevoiously by ecmwf bufr library In ECMWF library the name of a table file is Kssswwwwwxxxxxyyyzzz.TXT , where
  • K - type of table, i.e, 'B', 'C', or 'D'
  • sss - Master table number (zero for WMO meteorological tables)
  • wwwww - Originating sub-centre
  • xxxxx - Originating centre
  • yyy - Version number of master table used
  • zzz - Version number of local table used

If standard WMO tables are used, the Originating centre xxxxx will be set to

Definition at line 43 of file bufr2tac_tablec.c.

44{
45 if ( 0 )
46 {
47 if ( ksec1[13] != 0 ) // case of not WMO tables
48 sprintf ( target,"%s%c%03d%05d%05d%03d%03d.TXT", bufrtables_dir, type, ksec1[13], ksec1[15], ksec1[2], ksec1[14], ksec1[7] );
49 else
50 sprintf ( target,"%s%c000%05d00000%03d%03d.TXT", bufrtables_dir, type, ksec1[15], ksec1[14], ksec1[7] );
51 }
52 else
53 {
54 //FIXME Some countries uses latest C tables instead of the version they said in bufr
55 sprintf ( target,"%s%c0000000000000019000.TXT", bufrtables_dir, type );
56 }
57 return target;
58}

Referenced by read_table_c().

Here is the caller graph for this function:

◆ get_explained_flag_val()

char * get_explained_flag_val ( char *  expl,
size_t  dim,
char  tablec[MAXLINES_TABLEC][92],
size_t  nlines_tablec,
struct bufr_descriptor d,
unsigned long  ival 
)

Definition at line 181 of file bufr2tac_tablec.c.

182{
183 char *c, *s;
184 unsigned long test, test0;
185 unsigned long nb, nx, v, nl;
186 size_t i, j;
187
188 // Find first line for descriptor
189 for ( i = 0; i < nlines_tablec; i++ )
190 {
191 if ( tablec[i][0] != d->c[0] ||
192 tablec[i][1] != d->c[1] ||
193 tablec[i][2] != d->c[2] ||
194 tablec[i][3] != d->c[3] ||
195 tablec[i][4] != d->c[4] ||
196 tablec[i][5] != d->c[5] )
197 continue;
198 else
199 break;
200 }
201
202 if ( i == nlines_tablec )
203 {
204 //printf("Descriptor %s No encontrado\n", d->c);
205 return NULL;
206 }
207 //printf("Descriptor %s en linea %d\n", d->c, i);
208
209 // reads the amount of possible bits
210 if ( tablec[i][7] != ' ' )
211 nb = strtol ( &tablec[i][7], &c, 10 );
212 else
213 return NULL;
214
215 // read a value
216 s = expl;
217 s[0] = '\0';
218
219 for ( j = 0, test0 = 2; j < nb && i < nlines_tablec ; i++ )
220 {
221 if ( tablec[i][12] != ' ' )
222 {
223 v = strtol ( &tablec[i][12], &c, 10 ); // v is the bit number
224 j++;
225
226 // case 0 with meaning
227 if ( v == 0 )
228 {
229 test0 = 1;
230 if ( ival == 0 )
231 {
232 nl = strtol ( &tablec[i][21], &c, 10 );
233 if ( strlen ( expl ) && ( strlen ( expl ) + 1 ) < dim )
234 s += sprintf ( s, "|" );
235 s += sprintf ( s,"%s", &tablec[i][24] );
236 if ( nl > 1 )
237 {
238 for ( nx = 1 ; nx < nl; nx++ )
239 if ( ( strlen ( expl ) + strlen ( &tablec[i + nx][22] ) ) < dim )
240 {
241 s += sprintf ( s, "%s", &tablec[i + nx][22] );
242 }
243 }
244 return expl;
245 }
246 }
247
248 test = test0 << ( nb - v );
249
250 if ( v && ( test & ival ) != 0 )
251 {
252 // bit match
253 // read how many lines for the descriptors
254 nl = strtol ( &tablec[i][21], &c, 10 );
255 if ( strlen ( expl ) && ( strlen ( expl ) + 1 ) < dim )
256 s += sprintf ( s, "|" );
257 s += sprintf ( s,"%s", &tablec[i][24] );
258 if ( nl > 1 )
259 {
260 for ( nx = 1 ; nx < nl; nx++ )
261 if ( ( strlen ( expl ) + strlen ( &tablec[i + nx][22] ) ) < dim )
262 {
263 s += sprintf ( s, "%s", &tablec[i + nx][22] );
264 }
265 }
266
267 }
268 else
269 continue;
270 }
271 }
272
273 // if match then we have finished the search
274
275 return expl;
276}
char c[12]
Definition: bufrdeco.h:414

References bufr_descriptor::c.

◆ get_explained_table_val()

char * get_explained_table_val ( char *  expl,
size_t  dim,
char  tablec[MAXLINES_TABLEC][92],
size_t  nlines_tablec,
struct bufr_descriptor d,
int  ival 
)

Definition at line 103 of file bufr2tac_tablec.c.

104{
105 char *c;
106 long nv, v, nl;
107 size_t i, j;
108
109 // Find first line for descriptor
110 for ( i = 0; i < nlines_tablec; i++ )
111 {
112 if ( tablec[i][0] != d->c[0] ||
113 tablec[i][1] != d->c[1] ||
114 tablec[i][2] != d->c[2] ||
115 tablec[i][3] != d->c[3] ||
116 tablec[i][4] != d->c[4] ||
117 tablec[i][5] != d->c[5] )
118 continue;
119 else
120 break;
121 }
122
123 if ( i == nlines_tablec )
124 {
125 //printf("Descriptor %s No encontrado\n", d->c);
126 return NULL;
127 }
128 //printf("Descriptor %s en linea %d\n", d->c, i);
129
130 // reads the amount of possible values
131 if ( tablec[i][7] != ' ' )
132 nv = strtol ( &tablec[i][7], &c, 10 );
133 else
134 return NULL;
135
136 // read a value
137 for ( j = 0; ( long ) j < nv && i < nlines_tablec ; i++ )
138 {
139 if ( tablec[i][12] != ' ' )
140 {
141 v = strtol ( &tablec[i][12], &c, 10 );
142 j++;
143 if ( v != ival )
144 continue;
145 break;
146 }
147 }
148
149 if ( ( long ) j == nv || i == nlines_tablec )
150 return NULL; // Value not found
151
152 // read how many lines for the descriptors
153 nl = strtol ( &tablec[i][21], &c, 10 );
154
155
156 // if match then we have finished the search
157 strcpy ( expl, &tablec[i][24] );
158 if ( nl > 1 )
159 {
160 for ( nv = 1 ; nv < nl; nv++ )
161 if ( ( strlen ( expl ) + strlen ( &tablec[i + nv][22] ) ) < dim )
162 strcat ( expl, &tablec[i + nv][22] );
163 }
164
165 return expl;
166}

References bufr_descriptor::c.

◆ grad_to_D()

char * grad_to_D ( char *  D,
double  grad 
)

Converts true direction in grads to D (code table 0700)

Parameters
gradthe true direction (degrees)
Dthe resulting code

Definition at line 32 of file bufr2tac_x05.c.

33{
34 if ( grad >= 22.5 && grad < 67.5 )
35 strcpy ( D, "1" );
36 else if ( grad >= 67.5 && grad < 112.5 )
37 strcpy ( D, "2" );
38 else if ( grad >= 112.5 && grad < 157.5 )
39 strcpy ( D, "3" );
40 else if ( grad >= 157.5 && grad < 202.5 )
41 strcpy ( D, "4" );
42 else if ( grad >= 202.5 && grad < 247.5 )
43 strcpy ( D, "5" );
44 else if ( grad >= 247.5 && grad < 292.5 )
45 strcpy ( D, "6" );
46 else if ( grad >= 292.5 && grad < 337.5 )
47 strcpy ( D, "7" );
48 else if ( ( grad >= 337.5 && grad <= 360.0 ) ||
49 ( grad >0.0 && grad < 22.5 ) )
50 strcpy ( D, "8" );
51 else if ( grad == 0.0 )
52 strcpy ( D, "0" );
53 else
54 strcpy ( D, "9" );
55 return D;
56}

Referenced by syn_parse_x05(), and syn_parse_x20().

Here is the caller graph for this function:

◆ grad_to_ec()

char * grad_to_ec ( char *  target,
double  grad 
)

Converts elevation in grads to ec (code table 1004)

Parameters
gradthe elevation angle (degrees)
targetthe resulting code

Definition at line 32 of file bufr2tac_x07.c.

33{
34 if ( grad < 5.0 )
35 strcpy ( target, "9" );
36 else if ( grad < 6.5 )
37 strcpy ( target, "8" );
38 else if ( grad < 8.0 )
39 strcpy ( target, "7" );
40 else if ( grad < 10.5 )
41 strcpy ( target, "6" );
42 else if ( grad < 13.5 )
43 strcpy ( target, "5" );
44 else if ( grad < 17.5 )
45 strcpy ( target, "4" );
46 else if ( grad < 25.0 )
47 strcpy ( target, "3" );
48 else if ( grad < 40.0 )
49 strcpy ( target, "2" );
50 else if ( grad >= 45.0 )
51 strcpy ( target, "1" );
52 else
53 strcpy ( target, "0" );
54 return target;
55}

Referenced by syn_parse_x07().

Here is the caller graph for this function:

◆ guess_gts_header()

int guess_gts_header ( struct gts_header h,
const char *  f 
)

Guess the WMO GTS header from filename.

Parameters
hpointer to a struct gts_header where to set the results
fpathname of bufrfile

It returns 1 if guessed, 0 otherwise

This routine assume the filename format of a bufr file is

  YYYYMMDDHHmmss_BULLNN_ICAO_YYGGgg_ORD.bufr

where

 YYYYMMDDHHmmss

is the timestamp (UTC) of the file in GTS (as example, in NOAA gateway)

BULLNN is the bulletin identifier in GTS. It is a six chars lenght in the form T1 T2 A1 A2 N1 N2

  For observations, T1 is 'I'
  Possible values of T2 for T1 = 'I' are
     O   Oceanographic/limnographic (water properties)
     P   Pictorial
     S   Surface/sea level
     T   Text (plain language information)
     U   Upper air
     X   Other data types
     Z   Mixed data types


  For T1T2 = 'IS' Then A1:

     IS A 01–29 Routinely scheduled observations for n/a 000/006
                distribution from automatic (fixed or mobile)
                land stations (e.g. 0000, 0100, … or 0220, 0240,
                0300, …, or 0715, 0745, ... UTC)
     IS A 30–59 N-minute observations from automatic (fixed n/a 000/007
                or mobile) land stations
     IS B   Radar reports (parts A and B) RADOB 006/003
     IS C 01–45 Climatic observations from land stations CLIMAT 000/020
     IS C 46–59 Climatic observations from marine stations CLIMAT SHIP 001/0202009 edition
                ATTACHmENT II-5 I
     IS D   Radiological observation RADREP 010/001
     IS E   Ozone measurement at surface n/a 008/000
     IS F   Source of atmospherics SFAZI, SFLOC, SFAZU 000/030
     IS I 01–45 Intermediate synoptic observations from fixed SYNOP (SIxx) 000/001
            land stations 000/051
     IS I 46–59 Intermediate synoptic observations from mobile SYNOP mOBIL 000/004
            land stations
     IS M 01–45 Main synoptic observations from fixed land SYNOP (SMxx) 000/002
            stations 000/052
     IS M 46–59 Main synoptic observations from mobile land SYNOP mOBIL 000/005
             stations
     IS N 01–45 Synoptic observations from fixed land stations SYNOP (SNxx) 000/000
            at non-standard time (i.e. 0100, 0200, 0400,   000/050
            0500, ... UTC)
     IS N 46–59 Synoptic observations from mobile land stations SYNOP mOBIL 000/003
            at non-standard time (i.e. 0100, 0200, 0400,
            0500, ... UTC)
     IS R   Hydrologic reports HYDRA 000/040
     IS S 01–19 Synoptic observations from marine stations SHIP 001/000
     IS S 20–39 One-hour observations from automatic marine n/a 001/006
           stations
     IS S 40–59 N-minute observations from automatic marine n/a 001/007
           stations
     IS T 01–19 Tide gauge observations n/a 001/030
     IS T 20–39 Observed water level time series n/a 001/031
     IS V   Special aeronautical observations (SPECI) SPECI 000/011
     IS W   Aviation routine weather observations (mETAR) mETAR 000/010
     IS X   Other surface data IAC, IAC FLEET

  For T1T2 = 'IU'  then A1:
     IU A   Single level aircraft reports (automatic) AmDAR 004/000
     IU A   Single level aircraft reports (manual) AIREP/PIREP 004/001
     IU B   Single level balloon reports n/a
     IU C   (used for single level satellite-derived SAREP/SATOB 005/000
             reports – see Note 3)
     IU D   Dropsonde/Dropwindsondes TEmP DROP 002/007
     IU E   Ozone vertical sounding n/a 008/001
     IU I   Dispersal and transport analysis n/a 009/000
     IU J 01–19 Upper wind from fixed land stations (entire PILOT (parts A, 002/001
            sounding) B, C, D)
     IU J 20–39 Upper wind from mobile land stations (entire PILOT mOBIL 002/003
            sounding) (parts A, B, C, D)
     IU J 40–59 Upper wind from marine stations (entire PILOT SHIP 002/002
           sounding) (parts A, B, C, D)
     IU K 01–19 Radio soundings from fixed land stations TEmP (parts A, B) 002/004
           (up to 100 hPa)
     IU K 20–39 Radio soundings from mobile land stations TEmP mOBIL 002/006
          (up to 100 hPa) (parts A, B)
     IU K 40–59 Radio soundings from marine stations TEmP SHIP (parts A, B) 002/005
           (up to 100 hPa)
     IU M   Model derived sondes
     IU N   Rocketsondes
     IU O   Profiles of aircraft observations in ascending/ AmDAR 002/020
            descending
     IU P   Profilers PILOT 002/010
     IU Q   RASS temperature profilers TEmP 002/011
     IU R   (used for radiance data – see Note 3)
     IU S   01–19 Radiosondes/pibal reports from fixed land TEmP (parts A, B, C, D) 002/004
             stations (entire sounding)
     IU S 20–39 Radio soundings from mobile land stations TEmP mOBIL (parts A, 002/006
             (entire sounding) B, C, D)
     IU S 40–59 Radio soundings from marine stations TEmP SHIP (parts A, 002/005
             (entire sounding) B, C, D)
     IU T   (used for satellite-derived sondes – see Note 3) SATEm, SARAD, SATOB
     IU U 01–45 Monthly statistics of data from upper-air stations CLImAT TEmP 002/025
     IU U 46–59 Monthly statistics of data from marine stations CLImAT TEmP, SHIP 002/026
     IU W 01–19 Upper wind from fixed land stations (up to PILOT (parts A, B) 002/001
             100 hPa)
     IU W 20–39 Upper wind from mobile land stations (up to PILOT mOBIL 002/003
             100 hPa) (parts A, B)
     IU W 40–59 Upper wind from marine stations (up to PILOT SHIP 002/002
             100 hPa) (parts A, B)
     IU X   Other upper-air reports

  for T1T2 = 'IO' then  A1:
     IO B   Buoy observations BUOY 001/025
     IO I   Sea ice
     IO P   Sub-surface profiling floats TESAC 031/004
     IO R   Sea surface observations TRACKOB 031/001
     IO S   Sea surface and below soundings BATHY, TESAC 031/005
     IO T   Sea surface temperature
     IO W   Sea surface waves WAVEOB 031/002
     IO X   Other sea environmental

  About A2
     A   0 - 90W northern hemisphere
     B   90W - 180 northern hemisphere
     C   180 - 90E northern hemisphere
     D   90E - 0 northern hemisphere
     E   0 - 90W tropical belt
     F   90W - 180 tropical belt
     G   180 - 90E tropical belt
     H   90E - 0 tropical belt
     I   0 - 90W southern hemisphere
     J   90W - 180 southern hemisphere
     K   180 - 90E southern hemisphere
     L   90E - 0 southern hemisphere
     M   Lower left 10S 100E/upper right 70N 110W
     N   Northern hemisphere
     P   Area between 64.69N - 136.76W, 55.61N - 13.43W
     64.69N - 156.76W, 55.61N - 33.43W
     S   Southern hemisphere
     T   45W - 180 northern hemisphere
     U   Area between 21.0N - 128.1W, 36.0N - 130.9W
               21.1N - 113.0W, 36.2N - 110.5W
     V   Area between 30.3N - 83.7W, 51.0N - 68.9W
               19.8N - 64.5W, 33.3N - 47.1W
     X   Global Area (area not definable)


 ICAO is the ICAO index for release center.

 YYGGgg is the nominal release time (day, hour, minute) UTC

 ORD is the order sequence as RRA, RRB, CCA .... is optional

Definition at line 466 of file bufr2tac_utils.c.

467{
468 size_t nt;
469 char aux[256], *tk[16], *c;
470
471 // parse file name
472 strcpy ( h->filename, f );
473 strcpy ( aux, f );
474
475 // check latest '/' in filename
476 if ( ( c = strrchr ( aux,'/' ) ) == NULL )
477 c = &aux[0];
478 else
479 c++;
480
481 nt = tokenize_string ( tk, 16, c, strlen ( c ), "_. " );
482 // parse filenames with format as example 'AAAAMMDDHHmmss_ISIE06_SBBR_012100_RRB.bufr'
483
484 // 5 or 6 items
485 if ( nt < 5 || nt > 6 )
486 return 0;
487
488 // extension bufr
489 if ( strcmp ( tk[nt - 1],"bufr" ) )
490 return 0;
491
492 // item 0 the timestamp of file in NOAA GTS gateway
493 if ( strlen ( tk[0] ) != 14 || strspn ( tk[0], "0123456789" ) != 14 )
494 return 0;
495 strcpy ( h->timestamp, tk[0] );
496
497 // item 1
498 if ( strlen ( tk[1] ) != 6 || strspn ( &tk[1][4],"0123456789" ) != 2 )
499 return 0;
500 strcpy ( h->bname, tk[1] );
501
502 // item 2
503 if ( strlen ( tk[2] ) != 4 )
504 return 0;
505 strcpy ( h->center, tk[2] );
506
507 if ( strlen ( tk[3] ) != 6 || strspn ( tk[3], "0123456789" ) != 6 )
508 return 0;
509 strcpy ( h->dtrel, tk[3] );
510
511 if ( nt == 5 )
512 {
513 strcpy ( h->order, "BBB" );
514 }
515 else
516 {
517 if ( strlen ( tk[4] ) == 3 )
518 strcpy ( h->order, tk[4] );
519 else
520 return 0;
521 }
522
523 return 1;
524}
size_t tokenize_string(char *tk[], size_t ntk, char *target, size_t len, char *blanks)
Split the report string into tokens.
char center[8]
Definition: bufrdeco.h:709
char dtrel[16]
Definition: bufrdeco.h:710
char order[8]
Definition: bufrdeco.h:711
char bname[16]
Definition: bufrdeco.h:708
char filename[BUFRDECO_PATH_LENGTH]
Definition: bufrdeco.h:712
char timestamp[16]
Definition: bufrdeco.h:713

References gts_header::bname, gts_header::center, gts_header::dtrel, gts_header::filename, gts_header::order, gts_header::timestamp, and tokenize_string().

Referenced by main().

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

◆ guess_WMO_region()

char * guess_WMO_region ( char *  A1,
char *  Reg,
const char *  II,
const char *  iii 
)

get WMO region A1 and Reg items from II and iii (WMO index)

Parameters
A1string woth resulting A1
Regstring with resulting Reg
IIWMO block number
iiiWMO number

Definition at line 211 of file bufr2tac_utils.c.

212{
213 char aux[8];
214
215 // filter bad inputs
216 if ( II == NULL || iii == NULL )
217 return NULL;
218
219 if ( II[0] == 0 || iii[0] == 0 )
220 return NULL;
221
222 // aux string
223 sprintf ( aux,"%s%s", II, iii );
224
225 if ( ( II[0] == '0' && ( strstr ( aux,"042" ) != aux ) && ( strstr ( aux,"043" ) != aux ) &&
226 ( strstr ( aux,"044" ) != aux ) && ( strstr ( aux,"0858" ) != aux ) && ( strstr ( aux,"0859" ) != aux ) ) ||
227 II[0] == '1' || ( strstr ( aux,"201" ) == aux ) ||
228 strcmp ( II,"22" ) == 0 || strcmp ( II,"26" ) == 0 || strcmp ( II,"27" ) == 0 ||
229 strcmp ( II,"33" ) == 0 || strcmp ( II,"34" ) == 0 || strcmp ( II,"22" ) == 0 ||
230 ( strstr ( aux,"201" ) == aux ) )
231 {
232 // Reg 6. Europe
233 A1[0] = '6';
234 strcpy ( Reg,"VI" );
235 }
236 else if ( II[0] == '6' || ( strstr ( aux,"0858" ) == aux ) || ( strstr ( aux,"0859" ) == aux ) )
237 {
238 // Reg 1. Africa
239 A1[0] = '1';
240 strcpy ( Reg,"I" );
241 }
242 else if ( II[0] == '5' || ( strcmp ( II,"49" ) == 0 ) || ( strcmp ( II,"21" ) == 0 ) ||
243 ( strcmp ( II,"23" ) == 0 ) || ( strcmp ( II,"24" ) == 0 ) || ( strcmp ( II,"25" ) == 0 ) ||
244 ( strcmp ( II,"28" ) == 0 ) || ( strcmp ( II,"29" ) == 0 ) || ( strcmp ( II,"30" ) == 0 ) ||
245 ( strcmp ( II,"31" ) == 0 ) || ( strcmp ( II,"32" ) == 0 ) || ( strcmp ( II,"38" ) == 0 ) ||
246 ( strcmp ( II,"35" ) == 0 ) || ( strcmp ( II,"36" ) == 0 ) || ( strcmp ( II,"39" ) == 0 ) ||
247 ( strcmp ( aux, "20200" ) >= 0 && strcmp ( aux, "20999" ) <= 0 ) ||
248 ( strcmp ( aux, "40000" ) >= 0 && strcmp ( aux, "48599" ) <= 0 ) ||
249 ( strcmp ( aux, "48800" ) >= 0 && strcmp ( aux, "49999" ) <= 0 ) )
250 {
251 // Reg 2. Asia
252 A1[0] = '2';
253 strcpy ( Reg,"II" );
254 }
255 else if ( strcmp ( aux, "80000" ) >= 0 && strcmp ( aux, "88999" ) <= 0 )
256 {
257 // Reg 3. South america
258 A1[0] = '3';
259 strcpy ( Reg,"III" );
260 }
261 else if ( II[0] == '7' || strstr ( aux,"042" ) == aux ||
262 strstr ( aux,"043" ) == aux || strstr ( aux,"044" ) == aux )
263 {
264 // Reg 4. North and central america
265 A1[0] = '4';
266 strcpy ( Reg,"IV" );
267 }
268 else if ( ( strcmp ( aux, "48600" ) >= 0 && strcmp ( aux, "48799" ) <= 0 ) ||
269 ( strcmp ( aux, "90000" ) >= 0 && strcmp ( aux, "98999" ) <= 0 ) )
270 {
271 // Reg 5. Pacific South
272 A1[0] = '5';
273 strcpy ( Reg,"V" );
274 }
275 else if ( strcmp ( II,"89" ) == 0 )
276 {
277 // Reg 0. Antarctica
278 A1[0] = '0';
279 strcpy ( Reg,"0" );
280 }
281 return A1;
282}

Referenced by guess_WMO_region_synop(), guess_WMO_region_temp(), and syn_parse_x01().

Here is the caller graph for this function:

◆ guess_WMO_region_synop()

char * guess_WMO_region_synop ( struct synop_chunks syn)

Try to find WMO region if it is not already set and WMO Block and number index are known.

Parameters
synpointer to the struct synop_chunks with all known data for a synop

It returns a pointer to the string with WMO region

Definition at line 93 of file bufr2tac_synop.c.

94{
95 if ( syn->s0.A1[0] )
96 {
97 return syn->s0.A1;
98 }
99
100 if ( syn->s0.II[0] == 0 || syn->s0.iii[0] == 0 )
101 {
102 return syn->s0.A1;
103 }
104
105 return guess_WMO_region ( syn->s0.A1, syn->s0.Reg, syn->s0.II, syn->s0.iii );
106}
char * guess_WMO_region(char *A1, char *Reg, const char *II, const char *iii)
get WMO region A1 and Reg items from II and iii (WMO index)
struct synop_sec0 s0
Definition: metsynop.h:297
char iii[4]
Definition: metsynop.h:102
char Reg[4]
Definition: metsynop.h:103
char II[4]
Definition: metsynop.h:101
char A1[2]
Definition: metsynop.h:94

References synop_sec0::A1, guess_WMO_region(), synop_sec0::II, synop_sec0::iii, synop_sec0::Reg, and synop_chunks::s0.

Here is the call graph for this function:

◆ guess_WMO_region_temp()

char * guess_WMO_region_temp ( struct temp_chunks temp)

Definition at line 34 of file bufr2tac_temp.c.

35{
36 if ( t->a.s1.A1[0] )
37 {
38 return t->a.s1.A1;
39 }
40
41 if ( t->a.s1.II[0] == 0 || t->a.s1.iii[0] == 0 )
42 {
43 return t->a.s1.A1;
44 }
45
46 if ( guess_WMO_region ( t->a.s1.A1, t->a.s1.Reg, t->a.s1.II, t->a.s1.iii ) != NULL )
47 {
48 // copy the results in part A to parts A,B and C
49 strcpy ( t->b.s1.A1, t->a.s1.A1 );
50 strcpy ( t->c.s1.A1, t->a.s1.A1 );
51 strcpy ( t->d.s1.A1, t->a.s1.A1 );
52 strcpy ( t->b.s1.Reg, t->a.s1.Reg );
53 strcpy ( t->c.s1.Reg, t->a.s1.Reg );
54 strcpy ( t->d.s1.Reg, t->a.s1.Reg );
55 return t->a.s1.A1;
56 }
57 else
58 {
59 return NULL;
60 }
61}

References temp_chunks::a, temp_acd_sec1::A1, temp_b_sec1::A1, temp_chunks::b, temp_chunks::c, temp_chunks::d, guess_WMO_region(), temp_acd_sec1::II, temp_acd_sec1::iii, temp_acd_sec1::Reg, temp_b_sec1::Reg, temp_a::s1, temp_b::s1, temp_c::s1, and temp_d::s1.

Here is the call graph for this function:

◆ hour_rounded()

int hour_rounded ( struct synop_chunks syn)

Get the rounded hour of a given date.

Parameters
synpointer to the synop_chunks struct

It returns the rounded hour if >= 0. If < 0 problems

Definition at line 78 of file bufr2tac_x04.c.

79{
80 time_t t;
81 struct tm tim;
82 char aux[32];
83
84 sprintf ( aux, "%s%s%s%s%s", syn->e.YYYY,syn->e.MM,syn->e.DD,syn->e.HH, syn->e.mm );
85 memset ( &tim, 0, sizeof ( struct tm ) );
86 if ( strlen ( aux ) == 12 )
87 {
88 strptime ( aux, "%Y%m%d%H%M", &tim );
89 t = mktime ( &tim );
90 t += 1800;
91 gmtime_r ( &t, &tim );
92 return tim.tm_hour;
93 }
94 else if ( syn->e.mm[0] == 0 && syn->e.HH[0] )
95 {
96 return atoi ( syn->e.HH );
97 }
98 else
99 return -1;
100}
struct report_date_ext e
Definition: metsynop.h:295

References report_date_ext::DD, synop_chunks::e, report_date_ext::HH, report_date_ext::MM, report_date_ext::mm, and report_date_ext::YYYY.

Referenced by syn_parse_x13().

Here is the caller graph for this function:

◆ integer_to_descriptor()

int integer_to_descriptor ( struct bufr_descriptor d,
int  id 
)

parse an integer with a descriptor fom bufr ECWMF libary

Parameters
dpointer to a struct bufr_descriptor where to set the result on output
idinteger with the descriptor from ewcwf

Definition at line 41 of file bufr2tac_utils.c.

42{
43 if ( d == NULL )
44 return 1;
45 d->f = id / 100000;
46 d->x = ( id % 100000 ) / 1000;
47 d->y = id % 1000;
48 sprintf ( d->c, "%06d", id );
49 return 0;
50}

References bufr_descriptor::c, bufr_descriptor::f, bufr_descriptor::x, and bufr_descriptor::y.

◆ kelvin_to_snTT()

char * kelvin_to_snTT ( char *  target,
double  T 
)

converts a kelvin temperature value into a snTT string

Parameters
Tthe temperature ( Kelvin )
targetstring with the result

Definition at line 69 of file bufr2tac_x12.c.

70{
71 int ic;
72 if ( T < 173.65 || T > 340.0 )
73 {
74 return NULL;
75 }
76
77 // Whole degrees (Celsius)
78 ic = ( int ) ( floor ( ( T - 273.15 ) + 0.5 ) );
79 if ( ic < 0 )
80 {
81 sprintf ( target, "1%02d", -ic );
82 }
83 else
84 {
85 sprintf ( target, "%03d", ic );
86 }
87 return target;
88}

Referenced by syn_parse_x12().

Here is the caller graph for this function:

◆ kelvin_to_snTTT()

char * kelvin_to_snTTT ( char *  target,
double  T 
)

converts a kelvin temperature value into a snTTT string

Parameters
Tthe temperature ( Kelvin )
targetstring with the result

Definition at line 32 of file bufr2tac_x12.c.

33{
34 int ic;
35 double Tx = T;
36
37 if ( Tx > 15 && Tx < 34.0 ) // guess there is an scale error on coding , we better manage T * 10
38 {
39 Tx *= 10.0;
40 }
41 if ( Tx < 173.205 || Tx > 340.0 )
42 {
43 return NULL;
44 }
45
46 // tenths of degree (Celsius)
47 // Patch introduced on 22-Dec-2019 due to some roundings errors from India and Australia
48 // not converting properly from Kelvin to Celsius for Tmax and Tmin
49 // Changed '0.5' to '0.45'
50 //ic = ( int ) ( floor ( 10.0 * ( Tx - 273.15 ) + 0.5 ) );
51 ic = ( int ) ( floor ( 10.0 * ( Tx - 273.15 ) + 0.45 ) );
52 if ( ic < 0 )
53 {
54 sprintf ( target, "1%03d", -ic );
55 }
56 else
57 {
58 sprintf ( target, "0%03d", ic );
59 }
60 return target;
61}

Referenced by buoy_parse_x12(), buoy_parse_x22(), climat_parse_x12(), syn_parse_x12(), syn_parse_x22(), and temp_parse_x22().

Here is the caller graph for this function:

◆ kelvin_to_TT()

char * kelvin_to_TT ( char *  target,
double  T 
)

converts a kelvin temperature value into a TT string

Parameters
Tthe temperature ( Kelvin )
targetstring with the result

Definition at line 96 of file bufr2tac_x12.c.

97{
98 int ic;
99 if ( T < 150.0 || T > 340.0 )
100 {
101 return NULL;
102 }
103
104 // Whole degrees (Celsius)
105 ic = ( int ) ( floor ( ( T - 273.15 ) + 0.5 ) );
106 if ( ic < 0 )
107 {
108 sprintf ( target, "%02d", 50 - ic );
109 }
110 else
111 {
112 sprintf ( target, "%02d", ic );
113 }
114 return target;
115}

Referenced by syn_parse_x12().

Here is the caller graph for this function:

◆ kelvin_to_TTTa()

char * kelvin_to_TTTa ( char *  target,
double  T 
)

Set temperature TTTa.

Parameters
targetresult as string
Ttemperature (kelvin)

Definition at line 147 of file bufr2tac_x12.c.

148{
149 int ix;
150
151 if ( T == MISSING_REAL )
152 {
153 sprintf ( target, "///" );
154 return target;
155 }
156
157 ix = ( int ) ( 10.0 * ( T - 273.15 ) );
158
159 if ( ix >= 0 )
160 {
161 ix &= ~1;
162 }
163 else
164 {
165 ix = ( -ix );
166 ix |= 1;
167 }
168 sprintf ( target, "%03d", ix );
169 return target;
170}

References MISSING_REAL.

Referenced by parse_temp_raw_data().

Here is the caller graph for this function:

◆ kelvin_to_TTTT()

char * kelvin_to_TTTT ( char *  target,
double  T 
)

converts a kelvin temperature value into a TTTT string

Parameters
Tthe temperature ( Kelvin )
targetstring with the result

Definition at line 123 of file bufr2tac_x12.c.

124{
125 int ic;
126 if ( T < 150.0 || T > 340.0 )
127 {
128 return NULL;
129 }
130 // hundreth of degrees (Celsius)
131 ic = ( int ) ( floor ( 100.0 * ( T - 273.15 ) + 0.5 ) );
132 if ( ic < 0 )
133 {
134 ic = 5000 - ic;
135 }
136 sprintf ( target, "%04d", ic );
137 return target;
138}

Referenced by buoy_parse_x22().

Here is the caller graph for this function:

◆ latlon_to_MMM()

char * latlon_to_MMM ( char *  target,
double  lat,
double  lon 
)

convert latitude and longitude to a MMM string

Parameters
latlatitude (degree, N positive)
lonlongitude (degree, E positive)
targetresulting MMM string

Definition at line 34 of file bufr2tac_x06.c.

35{
36 int col, row, ori = 0;
37
38 if ( lon < 0.0 )
39 col = ( int ) ( -lat * 0.1 ) + 1;
40 else
41 col = 36 - ( int ) ( lat * 0.1 );
42
43
44 if ( lat >= 80.0 )
45 row = 25;
46 else if ( lat >= 0.0 )
47 row = ( int ) ( lat * 0.1 );
48 else
49 {
50 ori = 299;
51 row = ( int ) ( -lat * 0.1 );
52 }
53
54 sprintf ( target,"%03d", col + ori + row * 36 );
55
56 return target;
57}

Referenced by syn_parse_x05(), syn_parse_x06(), temp_parse_x05(), and temp_parse_x06().

Here is the caller graph for this function:

◆ m_to_9h()

char * m_to_9h ( char *  target,
double  h 
)

converts the altitude of cloud layer into 9h string code

Parameters
hthe altitude in meters
targetthe resulting 9x coded string

Definition at line 135 of file bufr2tac_x20.c.

136{
137 if ( h < 50.0 )
138 {
139 strcpy ( target,"90" );
140 }
141 else if ( h < 100.0 )
142 {
143 strcpy ( target,"91" );
144 }
145 else if ( h < 200.0 )
146 {
147 strcpy ( target,"92" );
148 }
149 else if ( h < 300.0 )
150 {
151 strcpy ( target,"93" );
152 }
153 else if ( h < 600.0 )
154 {
155 strcpy ( target,"94" );
156 }
157 else if ( h < 1000.0 )
158 {
159 strcpy ( target,"95" );
160 }
161 else if ( h < 1500.0 )
162 {
163 strcpy ( target,"96" );
164 }
165 else if ( h < 2000.0 )
166 {
167 strcpy ( target,"97" );
168 }
169 else if ( h < 2500.0 )
170 {
171 strcpy ( target,"98" );
172 }
173 else
174 {
175 strcpy ( target,"99" );
176 }
177 return target;
178
179}

Referenced by syn_parse_x20().

Here is the caller graph for this function:

◆ m_to_h()

char * m_to_h ( char *  target,
double  h 
)

converts the altitude of cloud layer into h string code

Parameters
hthe altitude in meters
targetthe resulting h coded string

Definition at line 83 of file bufr2tac_x20.c.

84{
85 if ( h < 50.0 )
86 {
87 strcpy ( target,"0" );
88 }
89 else if ( h < 100.0 )
90 {
91 strcpy ( target,"1" );
92 }
93 else if ( h < 200.0 )
94 {
95 strcpy ( target,"2" );
96 }
97 else if ( h < 300.0 )
98 {
99 strcpy ( target,"3" );
100 }
101 else if ( h < 600.0 )
102 {
103 strcpy ( target,"4" );
104 }
105 else if ( h < 1000.0 )
106 {
107 strcpy ( target,"5" );
108 }
109 else if ( h < 1500.0 )
110 {
111 strcpy ( target,"6" );
112 }
113 else if ( h < 2000.0 )
114 {
115 strcpy ( target,"7" );
116 }
117 else if ( h < 2500.0 )
118 {
119 strcpy ( target,"8" );
120 }
121 else
122 {
123 strcpy ( target,"9" );
124 }
125 return target;
126
127}

Referenced by syn_parse_x20(), and temp_parse_x20().

Here is the caller graph for this function:

◆ m_to_hh()

char * m_to_hh ( char *  target,
double  h 
)

converts the altitude of cloud layer into hh string code

Parameters
hthe altitude in meters
targetthe resulting h coded string

Definition at line 188 of file bufr2tac_x20.c.

189{
190 int ih = ( int ) h;
191
192 if ( ih <= 1500 )
193 {
194 sprintf ( target, "%02d", ih / 30 );
195 }
196 else if ( ih <= 9000 )
197 {
198 if ( ih < 1800 )
199 {
200 strcpy ( target, "50" );
201 }
202 else
203 {
204 sprintf ( target, "%2d", ( ih / 300 ) + 50 );
205 }
206 }
207 else if ( ih <= 21000 )
208 {
209 sprintf ( target, "%2d", ( ih / 500 ) + 50 );
210 }
211 else
212 {
213 strcpy ( target,"89" );
214 }
215 return target;
216
217}

Referenced by syn_parse_x20().

Here is the caller graph for this function:

◆ m_to_RR()

char * m_to_RR ( char *  target,
double  m 
)

Convert distance (m) in RR code (3570)

Parameters
mthe distance/diameter (m)
targetthe resulting RR string

Definition at line 261 of file bufr2tac_x20.c.

262{
263 int ix;
264 ix = ( int ) ( m * 1000.0 + 0.5 );
265
266 if ( m > 0.4 )
267 {
268 strcpy ( target, "98" );
269 }
270 if ( m > 0.0 && m < 0.00065 )
271 {
272 sprintf ( target, "%02d", ( int ) ( m * 10000.0 + 0.5 ) );
273 }
274 else if ( ix <= 55 )
275 {
276 sprintf ( target, "%02d", ix );
277 }
278 else if ( ix <= 400 )
279 {
280 sprintf ( target, "%02d", ( ix / 10 ) + 50 );
281 }
282 else
283 {
284 strcpy ( target, "99" );
285 }
286 return target;
287}

Referenced by syn_parse_x20().

Here is the caller graph for this function:

◆ met_datetime_to_YYGG()

char * met_datetime_to_YYGG ( char *  target,
struct met_datetime t 
)

Get YYGG from a struct met_datetime.

Parameters
targetstring with result as output
tpointer to source struct met_datetime

Definition at line 180 of file bufr2tac_utils.c.

181{
182 time_t tx;
183 struct tm tim;
184
185 tx = ( ( t->t + 1800 ) / 3600 ) * 3600 ; // rounding to next whole hour
186 memset ( &tim, 0, sizeof ( struct tm ) );
187 gmtime_r ( &tx, &tim );
188
189 strftime ( target, 8, "%d%H", &tim );
190
191 return target;
192}

References met_datetime::t.

Referenced by parse_subset_as_temp().

Here is the caller graph for this function:

◆ parse_subset_as_buoy()

int parse_subset_as_buoy ( struct metreport m,
struct bufr2tac_subset_state s,
struct bufr_subset_sequence_data sq,
char *  err 
)

Definition at line 74 of file bufr2tac_buoy.c.

75{
76 size_t is;
77 char aux[32];
78 struct buoy_chunks *b;
79
80 //
81 b = &m->buoy;
82
83 // clean data
85
86 // reject if still not coded type
87 if ( strcmp ( s->type_report,"ZZYY" ) )
88 {
89 sprintf ( err,"bufr2tac: '%s' report still not decoded in this software", s->type_report );
90 return 1;
91 }
92
93 strcpy ( b->s0.MiMi, "ZZ" );
94 strcpy ( b->s0.MjMj, "YY" );
95
96 b->mask = BUOY_SEC0;
97
98 /**** First pass, sequential analysis *****/
99 for ( is = 0; is < sq->nd; is++ )
100 {
101 // check if is a significance qualifier
102 if ( sq->sequence[is].desc.x == 8 )
103 {
104 s->i = is;
105 s->a = &sq->sequence[is];
106 buoy_parse_x08 ( b, s );
107 }
108
109 if ( sq->sequence[is].mask & DESCRIPTOR_VALUE_MISSING ||
110 s->isq // case of an significance qualifier
111 )
112 {
113 continue;
114 }
115
116 s->i = is;
117 s->ival = ( int ) sq->sequence[is].val;
118 s->val = sq->sequence[is].val;
119 s->a = &sq->sequence[is];
120 if ( is > 0 )
121 {
122 s->a1 = &sq->sequence[is - 1];
123 }
124
125 switch ( sq->sequence[is].desc.x )
126 {
127
128 case 1: //localization descriptors
129 buoy_parse_x01 ( b, s );
130 break;
131
132 case 2: //Date time descriptors
133 buoy_parse_x02 ( b, s );
134 break;
135
136 case 4: //Date time descriptors
137 buoy_parse_x04 ( b, s );
138 break;
139
140 case 5: //Position
141 buoy_parse_x05 ( b, s );
142 break;
143
144 case 6: // Horizontal Position -2
145 buoy_parse_x06 ( b, s );
146 break;
147
148 case 7: // Vertical Position
149 buoy_parse_x07 ( b, s );
150 break;
151
152 case 10: // Air Pressure descriptors
153 buoy_parse_x10 ( b, s );
154 break;
155
156 case 11: // wind data
157 buoy_parse_x11 ( b, s );
158 break;
159
160 case 12: //Temperature descriptors
161 buoy_parse_x12 ( b, s );
162 break;
163
164 case 13: // Humidity and precipitation data
165 buoy_parse_x13 ( b, s );
166 break;
167
168 case 14: // Radiation
169 buoy_parse_x14 ( b, s );
170 break;
171
172 case 20: // Cloud data
173 buoy_parse_x20 ( b, s );
174 break;
175
176 case 22: // Oceanographic data
177 buoy_parse_x22 ( b, s );
178 break;
179
180 case 31: // Replicators
181 buoy_parse_x31 ( b, s );
182 break;
183
184
185 case 33: // Quality data
186 buoy_parse_x33 ( b, s );
187 break;
188
189
190 default:
191 break;
192 }
193
194 }
195
196 if ( ( ( s->mask & SUBSET_MASK_HAVE_LATITUDE ) == 0 ) ||
197 ( ( s->mask & SUBSET_MASK_HAVE_LONGITUDE ) == 0 ) ||
198 ( ( s->mask & SUBSET_MASK_HAVE_YEAR ) == 0 ) ||
199 ( ( s->mask & SUBSET_MASK_HAVE_MONTH ) == 0 ) ||
200 ( ( s->mask & SUBSET_MASK_HAVE_DAY ) == 0 ) ||
201 ( ( s->mask & SUBSET_MASK_HAVE_HOUR ) == 0 ) )
202 {
203 sprintf ( err,"bufr2tac: parse_subset_as_buoy(): lack of mandatory descriptor in sequence" );
204 return 1;
205 }
206
207 // copy WIGOS ID, if any
208 memcpy(&m->g.wid, &m->buoy.wid, sizeof (struct wigos_id) );
209
210 /****** Second pass. Global results and consistence analysis ************/
211
212 // adjust iw
213 if ( b->s0.iw[0] == '/' && b->s1.ff[0] != '/' )
214 {
215 b->s0.iw[0] = '1';
216 }
217
218 // fill date fields YYYYMMDDHHmm
220 b->mask |= BUOY_EXT;
221
222 // Fill some metreport fields
224 {
225 if ( fabs ( s->lat ) <= 90.0 )
226 {
227 m->g.lat = s->lat;
228 }
229 else
230 {
231 return 1; // Bad latitude. Fatal error
232 }
233 }
235 {
236 if ( fabs ( s->lon ) <= 180.0 )
237 {
238 m->g.lon = s->lon;
239 }
240 else
241 {
242 return 1; // bad longitude. Fatal error
243 }
244 }
246 {
247 m->g.alt = s->alt;
248 }
249 if ( s->mask & SUBSET_MASK_HAVE_NAME )
250 {
251 strcpy ( m->g.name, s->name );
252 }
253 sprintf ( aux,"%s%s%s%s%s", b->e.YYYY, b->e.MM, b->e.DD, b->e.HH, b->e.mm );
254 YYYYMMDDHHmm_to_met_datetime ( &m->t, aux );
255
256 // Fill some metreport fields
257 if ( b->s0.A1[0] && b->s0.bw[0] && b->s0.nbnbnb[0] )
258 {
259 sprintf ( m->g.index, "%s%s%s", b->s0.A1, b->s0.bw, b->s0.nbnbnb );
260 }
261
262 // check if set both LaLaLa and LoLoLoLo to set Qc
263 if ( ( b->s0.Qc[0] == 0 ) && b->s0.LaLaLaLaLa[0] && b->s0.LoLoLoLoLoLo[0] )
264 {
266 {
268 {
269 strcpy ( b->s0.Qc, "5" );
270 }
271 else
272 {
273 strcpy ( b->s0.Qc, "3" );
274 }
275 }
276 else
277 {
279 {
280 strcpy ( b->s0.Qc, "7" );
281 }
282 else
283 {
284 strcpy ( b->s0.Qc, "1" );
285 }
286 }
287 }
288
289 // check Qx
290 if ( b->s2.Qd[0] == 0 )
291 {
292 b->s2.Qd[0] = '0';
293 }
294 if ( b->s3.k2[0] == 0 )
295 {
296 b->s3.k2[0] = '0';
297 }
298 if ( b->s1.Qx[0] == 0 && b->s1.Qd[0] )
299 {
300 b->s1.Qx[0] = '9';
301 }
302 if ( b->s2.Qx[0] == 0 && b->s2.Qd[0] )
303 {
304 b->s2.Qx[0] = '9';
305 }
306
307 if ( b->s3.Qd1[0] == 0 )
308 {
309 b->s3.Qd1[0] = '0';
310 }
311 if ( b->s3.Qd2[0] == 0 )
312 {
313 b->s3.Qd2[0] = '0';
314 }
315
316 if ( b->s3.k3[0] == 0 )
317 {
318 b->s3.k3[0] = '/';
319 }
320 if ( b->s3.k6[0] == 0 )
321 {
322 b->s3.k6[0] = '/';
323 }
324
325 return 0;
326}
int buoy_parse_x33(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 33.
Definition: bufr2tac_x33.c:34
int buoy_parse_x07(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 07.
Definition: bufr2tac_x07.c:164
int buoy_parse_x05(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 05.
Definition: bufr2tac_x05.c:134
int buoy_parse_x14(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 14.
Definition: bufr2tac_x14.c:467
int buoy_parse_x01(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 01.
Definition: bufr2tac_x01.c:205
int buoy_parse_x13(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 13.
Definition: bufr2tac_x13.c:877
int buoy_parse_x11(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 11.
Definition: bufr2tac_x11.c:387
#define SUBSET_MASK_HAVE_ALTITUDE
Bit mask to mark a struct bufr_subset_sequence_data having altitude.
Definition: bufr2tac.h:122
int buoy_parse_x22(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 22.
Definition: bufr2tac_x22.c:148
int buoy_parse_x10(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 10.
Definition: bufr2tac_x10.c:161
int buoy_parse_x06(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 06.
Definition: bufr2tac_x06.c:129
int buoy_parse_x02(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:83
int YYYYMMDDHHmm_to_met_datetime(struct met_datetime *t, const char *source)
Parse the string YYYYMMDDHHmm[ss] and set a struct met_datetime.
int buoy_parse_x31(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 31.
Definition: bufr2tac_x31.c:81
int buoy_parse_x04(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 04.
Definition: bufr2tac_x04.c:254
int buoy_parse_x12(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 12.
Definition: bufr2tac_x12.c:466
int buoy_parse_x08(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 08.
Definition: bufr2tac_x08.c:121
void bufr2tac_clean_buoy_chunks(struct buoy_chunks *b)
cleans a buoy_chunks struct
int buoy_parse_x20(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 20.
int buoy_YYYYMMDDHHmm_to_JMMYYGGgg(struct buoy_chunks *b)
Sets YYGG from YYYYMMDDHHmm extended group.
Definition: bufr2tac_buoy.c:31
#define BUOY_EXT
mask bit meaning date extension is parsed with success
Definition: metbuoy.h:58
#define BUOY_SEC0
mask bit meaning section 0 of buoy is solicited to or parsed with success
Definition: metbuoy.h:33
char type_report[16]
Definition: bufr2tac.h:247
contains all possible substrings from a synop report is parsed with success
Definition: metbuoy.h:197
char MjMj[4]
Definition: metbuoy.h:67
char MiMi[4]
Definition: metbuoy.h:66
char Qc[2]
Definition: metbuoy.h:78
char Qx[2]
Definition: metbuoy.h:92
char Qx[2]
Definition: metbuoy.h:113
char Qd2[2]
Definition: metbuoy.h:150
char Qd1[2]
Definition: metbuoy.h:149
double lat
Definition: bufr2tac.h:299
double lon
Definition: bufr2tac.h:300
double alt
Definition: bufr2tac.h:301
struct wigos_id wid
Definition: bufr2tac.h:295
char index[16]
Definition: bufr2tac.h:296
char name[80]
Definition: bufr2tac.h:297
struct buoy_chunks buoy
Definition: bufr2tac.h:317
struct met_geo g
Definition: bufr2tac.h:315
WIGOS station identifier.
Definition: metcommon.h:46

References bufr2tac_subset_state::a, bufr2tac_subset_state::a1, buoy_sec0::A1, bufr2tac_subset_state::alt, met_geo::alt, bufr2tac_clean_buoy_chunks(), metreport::buoy, BUOY_EXT, buoy_parse_x01(), buoy_parse_x02(), buoy_parse_x04(), buoy_parse_x05(), buoy_parse_x06(), buoy_parse_x07(), buoy_parse_x08(), buoy_parse_x10(), buoy_parse_x11(), buoy_parse_x12(), buoy_parse_x13(), buoy_parse_x14(), buoy_parse_x20(), buoy_parse_x22(), buoy_parse_x31(), buoy_parse_x33(), BUOY_SEC0, buoy_YYYYMMDDHHmm_to_JMMYYGGgg(), buoy_sec0::bw, report_date_ext::DD, DESCRIPTOR_VALUE_MISSING, buoy_chunks::e, buoy_sec1::ff, metreport::g, report_date_ext::HH, bufr2tac_subset_state::i, met_geo::index, bufr2tac_subset_state::isq, bufr2tac_subset_state::ival, buoy_sec0::iw, buoy_sec3::k2, buoy_sec3::k3, buoy_sec3::k6, buoy_sec0::LaLaLaLaLa, bufr2tac_subset_state::lat, met_geo::lat, buoy_sec0::LoLoLoLoLoLo, bufr2tac_subset_state::lon, met_geo::lon, bufr2tac_subset_state::mask, buoy_chunks::mask, buoy_sec0::MiMi, buoy_sec0::MjMj, report_date_ext::MM, report_date_ext::mm, bufr2tac_subset_state::name, met_geo::name, buoy_sec0::nbnbnb, buoy_sec0::Qc, buoy_sec1::Qd, buoy_sec2::Qd, buoy_sec3::Qd1, buoy_sec3::Qd2, buoy_sec1::Qx, buoy_sec2::Qx, buoy_chunks::s0, buoy_chunks::s1, buoy_chunks::s2, buoy_chunks::s3, SUBSET_MASK_HAVE_ALTITUDE, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_YEAR, SUBSET_MASK_LATITUDE_SOUTH, SUBSET_MASK_LONGITUDE_WEST, metreport::t, bufr2tac_subset_state::type_report, bufr2tac_subset_state::val, met_geo::wid, buoy_chunks::wid, report_date_ext::YYYY, and YYYYMMDDHHmm_to_met_datetime().

Referenced by parse_subset_sequence().

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

◆ parse_subset_as_climat()

int parse_subset_as_climat ( struct metreport m,
struct bufr2tac_subset_state s,
struct bufr_subset_sequence_data sq,
char *  err 
)

Definition at line 38 of file bufr2tac_climat.c.

39{
40 size_t is;
41 char aux[32];
42 struct climat_chunks *c;
43
44 c = &m->climat;
45
46 // clean data
48
49 // reject if still not coded type
50 if ( strcmp ( s->type_report,"CLIMAT" ) )
51 {
52 sprintf ( err,"bufr2tac: parse_subset_as_climat(): '%s' reports still not decoded in this software", s->type_report );
53 return 1;
54 }
55
56 strcpy ( m->type, s->type_report );
57
58 /**** First pass, sequential analysis *****/
59 for ( is = 0; is < sq->nd; is++ )
60 {
61 s->i = is;
62 s->ival = ( int ) sq->sequence[is].val;
63 s->val = sq->sequence[is].val;
64 s->a = &sq->sequence[is];
65 if ( is > 0 )
66 {
67 s->a1 = &sq->sequence[is - 1];
68 }
69
70 switch ( sq->sequence[is].desc.x )
71 {
72 case 1: //localization descriptors
73 climat_parse_x01 ( c, s );
74 break;
75
76 case 2: //Type of station descriptors
77 climat_parse_x02 ( c, s );
78 break;
79
80 case 4: //Date and time descriptors
81 climat_parse_x04 ( c, s );
82 break;
83
84 case 5: // Horizontal position. Latitude
85 climat_parse_x05 ( c, s );
86 break;
87
88 case 6: // Horizontal position. Longitude
89 climat_parse_x06 ( c, s );
90 break;
91
92 case 7: // Vertical position
93 climat_parse_x07 ( c, s );
94 break;
95
96 case 8: // significance qualifier
97 climat_parse_x08 ( c, s );
98 break;
99
100 case 10: // Air pressure
101 climat_parse_x10 ( c, s );
102 break;
103
104 case 11: // Wind
105 climat_parse_x11 ( c, s );
106 break;
107
108 case 12: // Temperature
109 climat_parse_x12 ( c, s );
110 break;
111
112 case 13: // Humidity and precipitation data
113 climat_parse_x13 ( c, s );
114 break;
115
116 case 14: // Radiation
117 climat_parse_x14 ( c, s );
118 break;
119
120 default:
121 break;
122 }
123
124 }
125
126 // Fill some metreport fields
127 if ( strlen ( c->s0.II ) )
128 {
129 strcpy ( m->g.index, c->s0.II );
130 strcat ( m->g.index, c->s0.iii );
131 }
132
134 {
135 m->g.lat = s->lat;
136 }
138 {
139 m->g.lon = s->lon;
140 }
142 {
143 m->g.alt = s->alt;
144 }
145 if ( s->mask & SUBSET_MASK_HAVE_NAME )
146 {
147 strcpy ( m->g.name, s->name );
148 }
150 {
151 strcpy ( m->g.country, s->country );
152 }
153
154 sprintf ( aux,"%s%s%s%s%s", c->e.YYYY, c->e.MM, c->e.DD, c->e.HH, c->e.mm );
155 YYYYMMDDHHmm_to_met_datetime ( &m->t, aux );
156
157 // copy WIGOS ID
158 memcpy(&m->g.wid, &m->climat.wid, sizeof (struct wigos_id) );
159
160 if ( check_date_from_future ( m ) )
161 {
162 return 1; // Bad date/time . Is a report from future!
163 }
164
165
166 return 0;
167}
int check_date_from_future(struct metreport *m)
Check a estructure metreport not from future.
int climat_parse_x12(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 12.
Definition: bufr2tac_x12.c:526
int climat_parse_x10(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 10.
Definition: bufr2tac_x10.c:214
int climat_parse_x02(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:146
int climat_parse_x05(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 05.
Definition: bufr2tac_x05.c:170
int climat_parse_x06(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 06.
Definition: bufr2tac_x06.c:165
int climat_parse_x13(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 13.
Definition: bufr2tac_x13.c:909
void bufr2tac_clean_climat_chunks(struct climat_chunks *c)
cleans a climat_chunks struct
int climat_parse_x11(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 11.
Definition: bufr2tac_x11.c:454
int climat_parse_x08(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 08.
Definition: bufr2tac_x08.c:164
int climat_parse_x01(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 01.
Definition: bufr2tac_x01.c:324
int climat_parse_x04(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 04.
Definition: bufr2tac_x04.c:405
int climat_parse_x07(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Definition: bufr2tac_x07.c:208
int climat_parse_x14(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 14.
Definition: bufr2tac_x14.c:497
contains all possible substrings from a synop report is parsed with success
Definition: metclimat.h:213
char country[80]
Definition: bufr2tac.h:298
char type[8]
Definition: bufr2tac.h:320
struct climat_chunks climat
Definition: bufr2tac.h:319

References bufr2tac_subset_state::a, bufr2tac_subset_state::a1, bufr2tac_subset_state::alt, met_geo::alt, bufr2tac_clean_climat_chunks(), check_date_from_future(), metreport::climat, climat_parse_x01(), climat_parse_x02(), climat_parse_x04(), climat_parse_x05(), climat_parse_x06(), climat_parse_x07(), climat_parse_x08(), climat_parse_x10(), climat_parse_x11(), climat_parse_x12(), climat_parse_x13(), climat_parse_x14(), bufr2tac_subset_state::country, met_geo::country, report_date_ext::DD, climat_chunks::e, metreport::g, report_date_ext::HH, bufr2tac_subset_state::i, climat_sec0::II, climat_sec0::iii, met_geo::index, bufr2tac_subset_state::ival, bufr2tac_subset_state::lat, met_geo::lat, bufr2tac_subset_state::lon, met_geo::lon, bufr2tac_subset_state::mask, report_date_ext::MM, report_date_ext::mm, bufr2tac_subset_state::name, met_geo::name, climat_chunks::s0, SUBSET_MASK_HAVE_ALTITUDE, SUBSET_MASK_HAVE_COUNTRY, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_HAVE_NAME, metreport::t, metreport::type, bufr2tac_subset_state::type_report, bufr2tac_subset_state::val, met_geo::wid, climat_chunks::wid, report_date_ext::YYYY, and YYYYMMDDHHmm_to_met_datetime().

Referenced by parse_subset_sequence().

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

◆ parse_subset_as_synop()

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

Parameters
mpointer to a struct metreport where set some results
spointer to a struct bufr2tac_subset_state
sqpointer to a struct bufr_subset_sequence_data with the parsed sequence on input
errstring with detected errors, if any

It return 0 if all is OK. Otherwise returns 1 and it also fills the err string

Definition at line 119 of file bufr2tac_synop.c.

120{
121 size_t is;
122 char aux[32];
123 struct synop_chunks *syn;
124
125 // An auxiliar pointer
126 syn = &m->synop;
127
128 // clean data
130
131 // reject if still not coded type
132 if ( strcmp ( s->type_report,"AAXX" ) && strcmp ( s->type_report,"BBXX" ) && strcmp ( s->type_report,"OOXX" ) )
133 {
134 sprintf ( err,"bufr2tac: parse_subset_as_synop(): '%s' reports still not decoded in this software", s->type_report );
135 return 1;
136 }
137
138 syn->s0.MiMi[0] = s->type_report[0];
139 syn->s0.MiMi[1] = s->type_report[1];
140 syn->s0.MjMj[0] = s->type_report[2];
141 syn->s0.MjMj[1] = s->type_report[3];
142
143 strcpy ( m->type, s->type_report );
144
145 /**** First pass, sequential analysis *****/
146 for ( is = 0; is < sq->nd; is++ )
147 {
148 // check if is a significance qualifier
149 if ( sq->sequence[is].desc.x == 8 )
150 {
151 s->i = is;
152 s->a = &sq->sequence[is];
153 s->ival = ( int ) sq->sequence[is].val;
154 s->val = sq->sequence[is].val;
155 syn_parse_x08 ( syn, s );
156 }
157 if ( s->isq ) // case of a significance qualifier
158 {
159 continue;
160 }
161
162 s->i = is;
163 s->ival = ( int ) ( sq->sequence[is].val );
164 s->val = sq->sequence[is].val;
165 s->a = &sq->sequence[is];
166 if ( is > 0 )
167 {
168 s->a1 = &sq->sequence[is - 1];
169 }
170
171 switch ( sq->sequence[is].desc.x )
172 {
173 case 1: //localization descriptors
174 syn_parse_x01 ( syn, s );
175 break;
176
177 case 2: //Type of station descriptors
178 syn_parse_x02 ( syn, s );
179 break;
180
181 case 4: //Date and time descriptors
182 syn_parse_x04 ( syn, s );
183 break;
184
185 case 5: // Horizontal position. Latitude
186 syn_parse_x05 ( syn, s );
187 break;
188
189 case 6: // Horizontal position. Longitude
190 syn_parse_x06 ( syn, s );
191 break;
192
193 case 7: // Vertical position
194 syn_parse_x07 ( syn, s );
195 break;
196
197 case 10: // Air Pressure descriptors
198 syn_parse_x10 ( syn, s );
199 break;
200
201 case 11: // wind data
202 syn_parse_x11 ( syn, s );
203 break;
204
205 case 12: //Temperature descriptors
206 syn_parse_x12 ( syn, s );
207 break;
208
209 case 13: // Humidity and precipitation data
210 syn_parse_x13 ( syn, s );
211 break;
212
213 case 14: // Radiation
214 syn_parse_x14 ( syn, s );
215 break;
216
217 case 20: // Cloud data
218 syn_parse_x20 ( syn, s );
219 break;
220
221 case 22: // Oceanographic data
222 syn_parse_x22 ( syn, s );
223 break;
224
225 case 31: // Replicators
226 syn_parse_x31 ( syn, s );
227 break;
228
229
230 default:
231 break;
232 }
233 }
234
235 /* Check about needed descriptors */
236 if ( ( ( s->mask & SUBSET_MASK_HAVE_LATITUDE ) == 0 ) ||
237 ( ( s->mask & SUBSET_MASK_HAVE_LONGITUDE ) == 0 ) ||
238 ( ( s->mask & SUBSET_MASK_HAVE_YEAR ) == 0 ) ||
239 ( ( s->mask & SUBSET_MASK_HAVE_MONTH ) == 0 ) ||
240 ( ( s->mask & SUBSET_MASK_HAVE_DAY ) == 0 ) ||
241 ( ( s->mask & SUBSET_MASK_HAVE_HOUR ) == 0 ) ||
242 ( ( s->mask & SUBSET_MASK_HAVE_MINUTE ) == 0 )
243 )
244 {
245 sprintf ( err,"bufr2tac: %s(): lack of mandatory descriptor in sequence", __func__ );
246 return 1;
247 }
248
249 // copy WIGOS ID
250 memcpy(&m->g.wid, &m->synop.wid, sizeof (struct wigos_id) );
251
252 if ( strcmp ( s->type_report, "AAXX" ) == 0 && ( syn->s0.II[0] == 0 || syn->s0.iii[0] == 0 ) )
253 {
255 ( syn->wid.issuer != 0 || syn->wid.issue != 0 ) &&
256 syn->wid.local_id[0] )
257 {
258 strcpy ( syn->s0.II, "00" );
259 strcpy ( syn->s0.iii, "000" );
260 }
261 else
262 {
263 sprintf ( err,"bufr2tac: %s(): lack of mandatory index station for AAXX report", __func__ );
264 return 1;
265 }
266 }
267
268
269 /****** Second pass. Global results and consistence analysis ************/
270 // set ir
271 if ( syn->s1.RRR[0] == 0 && syn->s3.RRR[0] == 0 && syn->s3.RRRR24[0] == 0 )
272 {
273 // no prec data case
274 syn->s1.ir[0] = '4';
275 }
276 else if ( syn->s1.RRR[0] == 0 && syn->s3.RRR[0] != 0 )
277 {
278 syn->s1.ir[0] = '2';
279 }
280 else if ( syn->s1.RRR[0] != 0 && syn->s3.RRR[0] == 0 )
281 {
282 syn->s1.ir[0] = '1';
283 }
284 else
285 {
286 syn->s1.ir[0] = '0';
287 }
288
289 // Supress 7wwW1W2 if no significant weather
290 if ( ( syn->s1.ww[0] || syn->s1.W1[0] || syn->s1.W2[0] ) &&
291 ( syn->s1.ww[0] == 0 || syn->s1.ww[0] == '/' || ( strcmp ( syn->s1.ww,"04" ) < 0 ) ) &&
292 ( syn->s1.W1[0] == 0 || syn->s1.W1[0] == '/' || ( strcmp ( syn->s1.W1,"3" ) < 0 ) ) &&
293 ( syn->s1.W2[0] == 0 || syn->s1.W2[0] == '/' || ( strcmp ( syn->s1.W2,"3" ) < 0 ) ) )
294 {
295 syn->s1.ww[0] = 0;
296 syn->s1.W1[0] = 0;
297 syn->s1.W2[0] = 0;
299 if ( syn->s1.ix[0] == '1' )
300 {
301 syn->s1.ix[0] = '2';
302 }
303 }
304
305 // adjust iw
306 if ( syn->s0.iw[0] == '/' && syn->s1.ff[0] != '/' )
307 {
308 syn->s0.iw[0] = '1';
309 }
310
311 // adjust ix
312 if ( syn->s1.ix[0] == '/' /*&& syn->s1.ww[0] == 0*/ )
313 {
317 )
318 {
320 {
321 if ( s->type == 1 || s->type == 2 )
322 {
323 strcpy ( syn->s1.ix,"2" );
324 }
325 else if ( s->type == 0 )
326 {
327 strcpy ( syn->s1.ix,"5" );
328 }
329 }
330 else
331 {
332 strcpy ( syn->s1.ix,"6" ); //NOTE: here we assume an automatic station without W data
333 }
334 }
335 else if ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION )
336 {
337 if ( s->type == 1 )
338 {
339 strcpy ( syn->s1.ix,"3" );
340 }
341 else if ( s->type == 0 )
342 {
343 strcpy ( syn->s1.ix,"6" );
344 }
345 }
346 else
347 {
348 strcpy ( syn->s1.ix,"6" ); //NOTE: here we assume an automatic station without W data
349 }
350 }
351
352 // adjust radiation
353 if ( ( syn->mask & SYNOP_SEC3 ) && ( syn->s3.SS[0] == '\0' ) &&
354 ( syn->s3.j5[0][0] || syn->s3.j5[1][0] ||
355 syn->s3.j5[2][0] || syn->s3.j5[3][0] ||
356 syn->s3.j5[4][0] || syn->s3.j5[5][0] ||
357 syn->s3.j5[6][0] ) )
358 {
359 sprintf ( syn->s3.SS, "//" );
360 }
361
362 if ( ( syn->mask & SYNOP_SEC3 ) && ( syn->s3.SSS[0] == '\0' ) &&
363 ( syn->s3.j524[0][0] || syn->s3.j524[1][0] ||
364 syn->s3.j524[2][0] || syn->s3.j524[3][0] ||
365 syn->s3.j524[4][0] || syn->s3.j524[5][0] ||
366 syn->s3.j524[6][0] ) )
367 {
368 sprintf ( syn->s3.SSS, "///" );
369 }
370
371 /****** Final Adjust ***********/
372
373 // fix YYGG according with YYYYMMDDHHmm
374 if ( syn->e.mm[0] == 0 )
375 sprintf ( syn->e.mm, "00" );
377 if ( strcmp ( syn->e.mm,"00" ) )
378 {
379 strcpy ( syn->s1.GG, syn->e.HH );
380 strcpy ( syn->s1.gg, syn->e.mm );
381 }
382 syn->mask |= SYNOP_EXT;
383
384 // Marc as a synop from bufr
385 syn->mask |= SYNOP_BUFR;
386
387 // Fill some metreport fields
388 if ( strlen ( syn->s0.II ) )
389 {
390 strcpy ( m->g.index, syn->s0.II );
391 strcat ( m->g.index, syn->s0.iii );
392 }
393 else if ( strlen ( syn->s0.D_D ) )
394 {
395 strcpy ( m->g.index, syn->s0.D_D );
396 }
397 else if ( strlen ( syn->s0.IIIII ) )
398 {
399 strcpy ( m->g.index, syn->s0.IIIII );
400 }
401
403 {
404 m->g.lat = s->lat;
405 }
407 {
408 m->g.lon = s->lon;
409 }
411 {
412 m->g.alt = s->alt;
413 }
414 if ( s->mask & SUBSET_MASK_HAVE_NAME )
415 {
416 strcpy ( m->g.name, s->name );
417 }
419 {
420 strcpy ( m->g.country, s->country );
421 }
422
423 sprintf ( aux,"%s%s%s%s%s", syn->e.YYYY, syn->e.MM, syn->e.DD, syn->e.HH, syn->e.mm );
424 YYYYMMDDHHmm_to_met_datetime ( &m->t, aux );
425
426 if ( check_date_from_future ( m ) )
427 {
428 return 1; // Bad date/time . Is a report from future!
429 }
430
431 // If finally we arrive here, It succeded
432 return 0;
433}
void bufr2tac_clean_synop_chunks(struct synop_chunks *s)
int syn_parse_x04(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 04.
Definition: bufr2tac_x04.c:110
int syn_parse_x31(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 31.
Definition: bufr2tac_x31.c:35
int syn_parse_x11(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 11.
Definition: bufr2tac_x11.c:116
#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_WW
Bit mask to mark a struct bufr_subset_sequence_data without WW information.
Definition: bufr2tac.h:92
int syn_parse_x13(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 13.
Definition: bufr2tac_x13.c:201
int syn_parse_x06(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 06.
Definition: bufr2tac_x06.c:67
int syn_parse_x02(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:34
int syn_parse_x20(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 20.
Definition: bufr2tac_x20.c:298
int syn_parse_x01(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 01.
Definition: bufr2tac_x01.c:54
int syn_parse_x12(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 12.
Definition: bufr2tac_x12.c:220
int syn_parse_x10(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 10.
Definition: bufr2tac_x10.c:87
int syn_parse_x08(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 08.
Definition: bufr2tac_x08.c:37
int syn_parse_x14(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 14.
Definition: bufr2tac_x14.c:59
int syn_parse_x22(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 01.
Definition: bufr2tac_x22.c:35
int syn_parse_x05(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 05.
Definition: bufr2tac_x05.c:66
#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_W1
Bit mask to mark a struct bufr_subset_sequence_data without W1 information.
Definition: bufr2tac.h:98
#define SUBSET_MASK_HAVE_NO_SIGNIFICANT_W2
Bit mask to mark a struct bufr_subset_sequence_data without W1 information.
Definition: bufr2tac.h:104
int syn_parse_x07(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 07.
Definition: bufr2tac_x07.c:65
int synop_YYYYMMDDHHmm_to_YYGG(struct synop_chunks *syn)
Sets YYGG from YYYYMMDDHHmm extended group.
#define SYNOP_SEC3
mask bit meaning section 3 or synop is solicited to or parsed with success
Definition: metsynop.h:49
#define SYNOP_EXT
mask bit meaning date extension is parsed with success
Definition: metsynop.h:64
#define SYNOP_BUFR
mask bit meaning date synop is decoded from a BUFR
Definition: metsynop.h:74
struct synop_chunks synop
Definition: bufr2tac.h:316
contains all possible substrings from a synop report is parsed with success
Definition: metsynop.h:293
struct synop_sec1 s1
Definition: metsynop.h:298
struct synop_sec3 s3
Definition: metsynop.h:300
struct wigos_id wid
Definition: metsynop.h:296
char D_D[10]
Definition: metsynop.h:97
char iw[2]
Definition: metsynop.h:100
char MiMi[4]
Definition: metsynop.h:92
char MjMj[4]
Definition: metsynop.h:93
char IIIII[10]
Definition: metsynop.h:104
char ix[2]
Definition: metsynop.h:124
char ff[4]
Definition: metsynop.h:129
char ir[2]
Definition: metsynop.h:123
char GG[4]
Definition: metsynop.h:152
char ww[4]
Definition: metsynop.h:144
char gg[4]
Definition: metsynop.h:153
char RRR[4]
Definition: metsynop.h:142
char W1[2]
Definition: metsynop.h:146
char W2[2]
Definition: metsynop.h:147
char RRRR24[6]
Definition: metsynop.h:257
char SSS[4]
Definition: metsynop.h:237
char j5[7][2]
Definition: metsynop.h:243
char RRR[4]
Definition: metsynop.h:255
char SS[4]
Definition: metsynop.h:238
char j524[7][2]
Definition: metsynop.h:245

References bufr2tac_subset_state::a, bufr2tac_subset_state::a1, bufr2tac_subset_state::alt, met_geo::alt, bufr2tac_clean_synop_chunks(), check_date_from_future(), bufr2tac_subset_state::country, met_geo::country, synop_sec0::D_D, report_date_ext::DD, synop_chunks::e, synop_sec1::ff, metreport::g, synop_sec1::GG, synop_sec1::gg, report_date_ext::HH, bufr2tac_subset_state::i, synop_sec0::II, synop_sec0::iii, synop_sec0::IIIII, met_geo::index, synop_sec1::ir, bufr2tac_subset_state::isq, wigos_id::issue, wigos_id::issuer, bufr2tac_subset_state::ival, synop_sec0::iw, synop_sec1::ix, synop_sec3::j5, synop_sec3::j524, bufr2tac_subset_state::lat, met_geo::lat, wigos_id::local_id, bufr2tac_subset_state::lon, met_geo::lon, bufr2tac_subset_state::mask, synop_chunks::mask, synop_sec0::MiMi, synop_sec0::MjMj, report_date_ext::MM, report_date_ext::mm, bufr2tac_subset_state::name, met_geo::name, synop_sec1::RRR, synop_sec3::RRR, synop_sec3::RRRR24, synop_chunks::s0, synop_chunks::s1, synop_chunks::s3, synop_sec3::SS, synop_sec3::SSS, SUBSET_MASK_HAVE_ALTITUDE, SUBSET_MASK_HAVE_COUNTRY, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_HAVE_MINUTE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_NO_SIGNIFICANT_W1, SUBSET_MASK_HAVE_NO_SIGNIFICANT_W2, SUBSET_MASK_HAVE_NO_SIGNIFICANT_WW, SUBSET_MASK_HAVE_TYPE_STATION, SUBSET_MASK_HAVE_WIGOS_ID, SUBSET_MASK_HAVE_YEAR, syn_parse_x01(), syn_parse_x02(), syn_parse_x04(), syn_parse_x05(), syn_parse_x06(), syn_parse_x07(), syn_parse_x08(), syn_parse_x10(), syn_parse_x11(), syn_parse_x12(), syn_parse_x13(), syn_parse_x14(), syn_parse_x20(), syn_parse_x22(), syn_parse_x31(), metreport::synop, SYNOP_BUFR, SYNOP_EXT, SYNOP_SEC3, synop_YYYYMMDDHHmm_to_YYGG(), metreport::t, bufr2tac_subset_state::type, metreport::type, bufr2tac_subset_state::type_report, bufr2tac_subset_state::val, synop_sec1::W1, synop_sec1::W2, met_geo::wid, synop_chunks::wid, synop_sec1::ww, report_date_ext::YYYY, and YYYYMMDDHHmm_to_met_datetime().

Referenced by parse_subset_sequence().

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

◆ parse_subset_as_temp()

int parse_subset_as_temp ( struct metreport m,
struct bufr2tac_subset_state s,
struct bufr_subset_sequence_data sq,
char *  err 
)

Definition at line 75 of file bufr2tac_temp.c.

76{
77 size_t is;
78 char aux[32];
79 struct temp_chunks *t;
80 struct met_datetime dtm;
81 struct temp_raw_data *r;
83
84 if ( sq == NULL )
85 {
86 return 1;
87 }
88
89 t = &m->temp;
90
91 // clean data
93
94 // allocate memory for array of points in raw form
95 if ( ( r = calloc ( 1, sizeof ( struct temp_raw_data ) ) ) == NULL )
96 {
97 sprintf ( err,"bufr2tac: parse_subset_as_temp(): Cannot allocate memory for raw data" );
98 return 1;
99 }
100
101 if ( ( w = calloc ( 1, sizeof ( struct temp_raw_wind_shear_data ) ) ) == NULL )
102 {
103 sprintf ( err,"bufr2tac: parse_subset_as_temp(): Cannot allocate memory for raw data" );
104 free ( ( void * ) ( r ) );
105 return 1;
106 }
107
108 // set pointers
109 s->r = r;
110 s->w = w;
111
112 // reject if still not coded type
113 if ( strcmp ( s->type_report,"TTXX" ) == 0 && 0 )
114 {
115 // FIXME
116 sprintf ( err,"bufr2tac: parse_subset_as_temp(): '%s' reports still not decoded in this software", s->type_report );
117 free ( ( void * ) ( r ) );
118 free ( ( void * ) ( w ) );
119 return 1;
120 }
121
122 // Set the part. We are sure of this
123 strcpy ( t->a.s1.MjMj, "AA" );
124 strcpy ( t->b.s1.MjMj, "BB" );
125 strcpy ( t->c.s1.MjMj, "CC" );
126 strcpy ( t->d.s1.MjMj, "DD" );
127
128 /**** First pass, sequential analysis *****/
129 for ( is = 0; is < sq->nd; is++ )
130 {
131 s->i = is;
132 s->ival = ( int ) sq->sequence[is].val;
133 s->val = sq->sequence[is].val;
134 s->a = &sq->sequence[is];
135 if ( is > 0 )
136 {
137 s->a1 = &sq->sequence[is - 1];
138 }
139
140 // check if is a significance qualifier
141 if ( sq->sequence[is].desc.x == 8 )
142 {
143 temp_parse_x08 ( t, s );
144 }
145
146 switch ( sq->sequence[is].desc.x )
147 {
148 case 1: //localization descriptors
149 if ( temp_parse_x01 ( t, s ) )
150 {
151 free ( ( void * ) ( r ) );
152 free ( ( void * ) ( w ) );
153 return 1;
154 }
155 break;
156
157 case 2: //Type of station descriptors
158 if ( temp_parse_x02 ( t, s ) )
159 {
160 free ( ( void * ) ( r ) );
161 free ( ( void * ) ( w ) );
162 return 1;
163 }
164 break;
165
166 case 4: //Date and time descriptors
167 if ( temp_parse_x04 ( t, s ) )
168 {
169 free ( ( void * ) ( r ) );
170 free ( ( void * ) ( w ) );
171 return 1;
172 }
173 break;
174
175 case 5: // Horizontal position. Latitude
176 if ( temp_parse_x05 ( t, s ) )
177 {
178 free ( ( void * ) ( r ) );
179 free ( ( void * ) ( w ) );
180 return 1;
181 }
182 break;
183
184 case 6: // Horizontal position. Longitude
185 if ( temp_parse_x06 ( t, s ) )
186 {
187 free ( ( void * ) ( r ) );
188 free ( ( void * ) ( w ) );
189 return 1;
190 }
191 break;
192
193 case 7: // Vertical position
194 if ( temp_parse_x07 ( t, s ) )
195 {
196 free ( ( void * ) ( r ) );
197 free ( ( void * ) ( w ) );
198 return 1;
199 }
200 break;
201
202 case 10: // Air Pressure descriptors
203 if ( temp_parse_x10 ( t, s ) )
204 {
205 free ( ( void * ) ( r ) );
206 free ( ( void * ) ( w ) );
207 return 1;
208 }
209 break;
210
211 case 11: // wind data
212 if ( temp_parse_x11 ( t, s ) )
213 {
214 free ( ( void * ) ( r ) );
215 free ( ( void * ) ( w ) );
216 return 1;
217 }
218 break;
219
220 case 12: //Temperature descriptors
221 if ( temp_parse_x12 ( t, s ) )
222 {
223 free ( ( void * ) ( r ) );
224 free ( ( void * ) ( w ) );
225 return 1;
226 }
227 break;
228
229 case 20: // Cloud data
230 if ( temp_parse_x20 ( t, s ) )
231 {
232 free ( ( void * ) ( r ) );
233 free ( ( void * ) ( w ) );
234 return 1;
235 }
236 break;
237
238 case 22: // Oceanographic data
239 if ( temp_parse_x22 ( t, s ) )
240 {
241 free ( ( void * ) ( r ) );
242 free ( ( void * ) ( w ) );
243 return 1;
244 }
245 break;
246
247 case 31: // Replicators
248 if ( temp_parse_x31 ( t, s ) )
249 {
250 free ( ( void * ) ( r ) );
251 free ( ( void * ) ( w ) );
252 return 1;
253 }
254 break;
255
256 case 33: // Quality data
257 if ( temp_parse_x33 ( t, s ) )
258 {
259 free ( ( void * ) ( r ) );
260 free ( ( void * ) ( w ) );
261 return 1;
262 }
263 break;
264
265 default:
266 break;
267 }
268 }
269
270 /* Check about needed descriptors */
271 if ( ( ( s->mask & SUBSET_MASK_HAVE_LATITUDE ) == 0 ) ||
272 ( ( s->mask & SUBSET_MASK_HAVE_LONGITUDE ) == 0 ) ||
273 ( ( s->mask & SUBSET_MASK_HAVE_YEAR ) == 0 ) ||
274 ( ( s->mask & SUBSET_MASK_HAVE_MONTH ) == 0 ) ||
275 ( ( s->mask & SUBSET_MASK_HAVE_DAY ) == 0 ) ||
276 ( ( s->mask & SUBSET_MASK_HAVE_HOUR ) == 0 ) ||
277 ( ( s->mask & SUBSET_MASK_HAVE_MINUTE ) == 0 )
278 )
279 {
280 sprintf ( err,"bufr2tac: parse_subset_as_temp(): lack of mandatory descriptor in sequence" );
281 free ( ( void * ) ( r ) );
282 free ( ( void * ) ( w ) );
283 return 1;
284 }
285
286 // copy WIGOS ID
287 memcpy(&m->g.wid, &m->temp.wid, sizeof (struct wigos_id) );
288
289 /* Guess the type of TEMP report according with data parsed */
290 if ( t->a.s1.II[0] )
291 {
292 // it seems this is a TEMP report
293 strcpy ( t->a.s1.MiMi, "TT" );
294 strcpy ( t->b.s1.MiMi, "TT" );
295 strcpy ( t->c.s1.MiMi, "TT" );
296 strcpy ( t->d.s1.MiMi, "TT" );
297 }
298 else if ( t->a.s1.h0h0h0h0[0] )
299 {
300 // it seems this is a TEMP MOBIL report
301 strcpy ( t->a.s1.MiMi, "II" );
302 strcpy ( t->b.s1.MiMi, "II" );
303 strcpy ( t->c.s1.MiMi, "II" );
304 strcpy ( t->d.s1.MiMi, "II" );
305 }
306 else if ( t->a.s1.D_D[0] )
307 {
308 // it seems this is a TEMP SHIP report
309 strcpy ( t->a.s1.MiMi, "UU" );
310 strcpy ( t->b.s1.MiMi, "UU" );
311 strcpy ( t->c.s1.MiMi, "UU" );
312 strcpy ( t->d.s1.MiMi, "UU" );
313 }
314 else if ( t->a.s1.Ula[0] )
315 {
316 // it seems this is a TEMP DROP report
317 strcpy ( t->a.s1.MiMi, "XX" );
318 strcpy ( t->b.s1.MiMi, "XX" );
319 strcpy ( t->c.s1.MiMi, "XX" );
320 strcpy ( t->d.s1.MiMi, "XX" );
321 }
322 else
323 {
324 sprintf ( err,"bufr2tac: parse_subset_as_temp(): Unknown type TEMP report" );
325 free ( ( void * ) ( r ) );
326 free ( ( void * ) ( w ) );
327 return 1;
328 }
329 sprintf ( m->type, "%s%s" , t->a.s1.MiMi, t->a.s1.MjMj );
330 sprintf ( m->type2, "%s%s" , t->b.s1.MiMi, t->b.s1.MjMj );
331 sprintf ( m->type3, "%s%s" , t->c.s1.MiMi, t->c.s1.MjMj );
332 sprintf ( m->type4, "%s%s" , t->d.s1.MiMi, t->d.s1.MjMj );
333
334 /****** Second pass. Global results and consistence analysis ************/
335 sprintf ( aux,"%s%s%s%s%s%s", t->a.e.YYYY, t->a.e.MM, t->a.e.DD, t->a.e.HH, t->a.e.mm, t->a.e.ss );
336 YYYYMMDDHHmm_to_met_datetime ( &dtm, aux );
337 round_met_datetime_to_hour ( &m->t, &dtm );
338 memcpy ( &m->temp.t, &m->t, sizeof ( struct met_datetime ) );
339
340 met_datetime_to_YYGG ( t->a.s1.YYGG, &dtm );
341 strcpy ( t->b.s1.YYGG, t->a.s1.YYGG );
342 strcpy ( t->c.s1.YYGG, t->a.s1.YYGG );
343 strcpy ( t->d.s1.YYGG, t->a.s1.YYGG );
344
345 if ( strlen ( t->a.s1.II ) )
346 {
347 strcpy ( m->g.index, t->a.s1.II );
348 strcat ( m->g.index, t->a.s1.iii );
349 }
350 else if ( strlen ( t->a.s1.D_D ) )
351 {
352 strcpy ( m->g.index, t->a.s1.D_D );
353 }
354 else if ( strlen ( t->a.s1.IIIII ) )
355 {
356 strcpy ( m->g.index, t->a.s1.IIIII );
357 }
358
360 {
361 m->g.lat = s->lat;
362 }
364 {
365 m->g.lon = s->lon;
366 }
368 {
369 m->g.alt = s->alt;
370 }
371 if ( s->mask & SUBSET_MASK_HAVE_NAME )
372 {
373 strcpy ( m->g.name, s->name );
374 }
376 {
377 strcpy ( m->g.country, s->country );
378 }
379
380 //print_temp_raw_data ( r );
381 //print_temp_raw_wind_shear_data ( w );
382
383 // Finally parse raw data to fill all needed points for a TEMP
384 if ( parse_temp_raw_data ( t, r ) )
385 {
386 sprintf ( err,"bufr2tac: parse_temp_raw_data(): Too much significant points" );
387 free ( ( void * ) ( r ) );
388 free ( ( void * ) ( w ) );
389 return 1;
390 }
392
393 // Free memory
394 free ( ( void * ) ( r ) );
395 free ( ( void * ) ( w ) );
396 return 0;
397}
char * met_datetime_to_YYGG(char *target, struct met_datetime *t)
Get YYGG from a struct met_datetime.
int temp_parse_x33(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 33.
Definition: bufr2tac_x33.c:100
void bufr2tac_clean_temp_chunks(struct temp_chunks *t)
cleans a buoy_chunks struct
int temp_parse_x11(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 11.
Definition: bufr2tac_x11.c:500
int temp_parse_x05(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Definition: bufr2tac_x05.c:204
int temp_parse_x07(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Definition: bufr2tac_x07.c:258
int temp_parse_x04(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 04.
Definition: bufr2tac_x04.c:575
int temp_parse_x20(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 20.
int temp_parse_x12(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 12.
Definition: bufr2tac_x12.c:751
int temp_parse_x31(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 31.
Definition: bufr2tac_x31.c:120
int round_met_datetime_to_hour(struct met_datetime *target, struct met_datetime *source)
int temp_parse_x01(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 01.
Definition: bufr2tac_x01.c:415
int temp_parse_x22(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 22.
Definition: bufr2tac_x22.c:289
int temp_parse_x02(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:187
int temp_parse_x06(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Definition: bufr2tac_x06.c:200
int temp_parse_x08(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 08.
Definition: bufr2tac_x08.c:421
int temp_parse_x10(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 10.
Definition: bufr2tac_x10.c:297
int parse_temp_raw_data(struct temp_chunks *t, struct temp_raw_data *r)
parse a struct temp_raw_data to fill chunks in a struct temp_chunks
int parse_temp_raw_wind_shear_data(struct temp_chunks *t, struct temp_raw_wind_shear_data *w)
struct temp_raw_wind_shear_data * w
Definition: bufr2tac.h:286
struct temp_raw_data * r
Definition: bufr2tac.h:285
stores date and time reference of a report, commonly the observation time
Definition: metcommon.h:60
char type4[8]
Definition: bufr2tac.h:326
struct temp_chunks temp
Definition: bufr2tac.h:318
char type3[8]
Definition: bufr2tac.h:324
char type2[8]
Definition: bufr2tac.h:322
char ss[4]
Definition: metcommon.h:38
struct temp_acd_sec1 s1
Definition: mettemp.h:455
struct report_date_ext e
Definition: mettemp.h:454
char MiMi[4]
Definition: mettemp.h:310
char h0h0h0h0[6]
Definition: mettemp.h:327
char YYGG[8]
Definition: mettemp.h:315
char II[4]
Definition: mettemp.h:317
char D_D[10]
Definition: mettemp.h:314
char MjMj[4]
Definition: mettemp.h:311
char IIIII[10]
Definition: mettemp.h:320
char Ula[2]
Definition: mettemp.h:325
char iii[4]
Definition: mettemp.h:318
char YYGG[8]
Definition: mettemp.h:342
char MjMj[4]
Definition: mettemp.h:338
char MiMi[4]
Definition: mettemp.h:337
struct temp_b_sec1 s1
Definition: mettemp.h:470
struct temp_acd_sec1 s1
Definition: mettemp.h:485
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 wigos_id wid
Definition: mettemp.h:514
struct temp_a a
Definition: mettemp.h:515
struct temp_acd_sec1 s1
Definition: mettemp.h:500
Stores the array of all data profile points as it in bufr sequence.
Definition: mettemp.h:213
array of Wind shear data points at a pressure level
Definition: mettemp.h:238

References bufr2tac_subset_state::a, temp_chunks::a, bufr2tac_subset_state::a1, bufr2tac_subset_state::alt, met_geo::alt, temp_chunks::b, bufr2tac_clean_temp_chunks(), temp_chunks::c, bufr2tac_subset_state::country, met_geo::country, temp_chunks::d, temp_acd_sec1::D_D, report_date_ext::DD, temp_a::e, metreport::g, temp_acd_sec1::h0h0h0h0, report_date_ext::HH, bufr2tac_subset_state::i, temp_acd_sec1::II, temp_acd_sec1::iii, temp_acd_sec1::IIIII, met_geo::index, bufr2tac_subset_state::ival, bufr2tac_subset_state::lat, met_geo::lat, bufr2tac_subset_state::lon, met_geo::lon, bufr2tac_subset_state::mask, met_datetime_to_YYGG(), temp_acd_sec1::MiMi, temp_b_sec1::MiMi, temp_acd_sec1::MjMj, temp_b_sec1::MjMj, report_date_ext::MM, report_date_ext::mm, bufr2tac_subset_state::name, met_geo::name, parse_temp_raw_data(), parse_temp_raw_wind_shear_data(), bufr2tac_subset_state::r, round_met_datetime_to_hour(), temp_a::s1, temp_b::s1, temp_c::s1, temp_d::s1, report_date_ext::ss, SUBSET_MASK_HAVE_ALTITUDE, SUBSET_MASK_HAVE_COUNTRY, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_HAVE_MINUTE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_YEAR, metreport::t, temp_chunks::t, metreport::temp, temp_parse_x01(), temp_parse_x02(), temp_parse_x04(), temp_parse_x05(), temp_parse_x06(), temp_parse_x07(), temp_parse_x08(), temp_parse_x10(), temp_parse_x11(), temp_parse_x12(), temp_parse_x20(), temp_parse_x22(), temp_parse_x31(), temp_parse_x33(), metreport::type, metreport::type2, metreport::type3, metreport::type4, bufr2tac_subset_state::type_report, temp_acd_sec1::Ula, bufr2tac_subset_state::val, bufr2tac_subset_state::w, met_geo::wid, temp_chunks::wid, temp_acd_sec1::YYGG, temp_b_sec1::YYGG, report_date_ext::YYYY, and YYYYMMDDHHmm_to_met_datetime().

Referenced by parse_subset_sequence().

Here is the call graph for this function:
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 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

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:

◆ parse_temp_raw_data()

int parse_temp_raw_data ( struct temp_chunks t,
struct temp_raw_data r 
)

parse a struct temp_raw_data to fill chunks in a struct temp_chunks

Definition at line 403 of file bufr2tac_temp.c.

404{
405 int ix, is_over_100;
406 size_t i, j, isa = 0, isc = 0, ita = 0, itc = 0; // level counters
407 size_t iwxa = 0, iwxc = 0, itb = 0, itd = 0;
408 size_t iwd = 0, iwb = 0;
409 size_t isav = 0, iscv = 0; // valid data counters for standard levels
410 struct temp_raw_point_data *d;
411
412 if ( t == NULL || r == NULL )
413 {
414 return 1;
415 }
416
417 if ( r->n == 0 )
418 {
419 return 1;
420 }
421
422 // Some default
423 t->a.s1.id[0] = '/';
424 t->c.s1.id[0] = '/';
425 for ( i = 0; i < r->n; i++ )
426 {
427 d = & ( r->raw[i] ); // to make code easy
428
429 if ( d->p < 10000.0 ) // to select which part
430 {
431 is_over_100 = 1;
432 }
433 else
434 {
435 is_over_100 = 0;
436 }
437
438 // Surface data
440 {
441 pascal_to_pnpnpn ( t->a.s2.lev0.PnPnPn, d->p ); //PoPoPo
442 kelvin_to_TTTa ( t->a.s2.lev0.TnTnTan, d->T ); // TnTnTan
443 dewpoint_depression_to_DnDn ( t->a.s2.lev0.DnDn, d->T , d->Td ); // DnDn
444 wind_to_dndnfnfnfn ( t->a.s2.lev0.dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
445 }
446
447 // standard level
449 {
450 ix = ( int ) ( d->p * 0.01 + 0.5 ); // hPa
451 ix = ( ix / 10 ) % 100; // coded
452 if ( is_over_100 )
453 {
454 sprintf ( t->c.s2.std[isc].PnPn, "%02d", ix ); // PnPn
455 }
456 else
457 {
458 sprintf ( t->a.s2.std[isa].PnPn, "%02d", ix ); // PnPn
459 }
460
461 ix = ( int ) ( d->h + 0.5 );
462 if ( d->p <= 50000.0 )
463 {
464 if ( is_over_100 )
465 {
466 sprintf ( t->c.s2.std[isc].hnhnhn, "%03d", ( ( ix + 5 ) / 10 ) % 1000 );
467 }
468 else
469 {
470 sprintf ( t->a.s2.std[isa].hnhnhn, "%03d", ( ( ix + 5 ) / 10 ) % 1000 );
471 }
472 }
473 else
474 {
475 if ( is_over_100 )
476 {
477 sprintf ( t->c.s2.std[isc].hnhnhn, "%03d", ix % 1000 );
478 }
479 else if ( ix >= 0 )
480 {
481 sprintf ( t->a.s2.std[isa].hnhnhn, "%03d", ix % 1000 );
482 }
483 else
484 {
485 sprintf ( t->a.s2.std[isa].hnhnhn, "%03d", ( -ix + 500 ) % 1000 );
486 }
487 }
488 if ( is_over_100 )
489 {
490 kelvin_to_TTTa ( t->c.s2.std[isc].TnTnTan, d->T ); // TnTnTan
491 dewpoint_depression_to_DnDn ( t->c.s2.std[isc].DnDn, d->T, d->Td ); // DnDn
492 wind_to_dndnfnfnfn ( t->c.s2.std[isc].dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
493 // Now update Id
494 if ( d->ff != MISSING_REAL && d->dd != MISSING_REAL )
495 {
496 t->c.s1.id[0] = t->c.s2.std[isc].PnPn[0];
497 }
498 if ( isc < TEMP_NSTAND_MAX )
499 {
500 isc += 1;
501 t->c.s2.n = isc;
502 }
503 else
504 return 1;
505
506 if ( d->T != MISSING_REAL || d->Td != MISSING_REAL ||
507 d->ff != MISSING_REAL || d->dd != MISSING_REAL )
508 {
509 // data present
510 iscv += 1;
511 }
512 }
513 else
514 {
515 kelvin_to_TTTa ( t->a.s2.std[isa].TnTnTan, d->T ); // TnTnTan
516 dewpoint_depression_to_DnDn ( t->a.s2.std[isa].DnDn, d->T , d->Td ); // DnDn
517 wind_to_dndnfnfnfn ( t->a.s2.std[isa].dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
518 // Now update Id
519 if ( d->ff != MISSING_REAL && d->dd != MISSING_REAL )
520 {
521 t->a.s1.id[0] = t->a.s2.std[isa].PnPn[0];
522 }
523 if ( isa < TEMP_NSTAND_MAX )
524 {
525 isa += 1;
526 t->a.s2.n = isa;
527 }
528 else
529 return 1;
530
531 if ( d->T != MISSING_REAL || d->Td != MISSING_REAL ||
532 d->ff != MISSING_REAL || d->dd != MISSING_REAL )
533 {
534 // data present
535 isav += 1;
536 }
537 }
538 }
539
540 // Tropopause level
542 {
543 if ( is_over_100 )
544 {
545 ix = ( int ) ( d->p * 0.1 + 0.5 );
546 sprintf ( t->c.s3.trop[itc].PnPnPn, "%03d", ix % 1000 ); // PnPnPn
547 kelvin_to_TTTa ( t->c.s3.trop[itc].TnTnTan, d->T ); // TnTnTan
548 dewpoint_depression_to_DnDn ( t->c.s3.trop[itc].DnDn, d->T , d->Td ); // DnDn
549 wind_to_dndnfnfnfn ( t->c.s3.trop[itc].dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
550 if ( ix && itc < TEMP_NTROP_MAX )
551 {
552 itc += 1;
553 t->c.s3.n = itc;
554 }
555 else
556 return 1;
557 }
558 else
559 {
560 ix = ( int ) ( d->p * 0.01 + 0.5 );
561 sprintf ( t->a.s3.trop[ita].PnPnPn, "%03d", ix % 1000 ); // PnPnPn.
562 kelvin_to_TTTa ( t->a.s3.trop[ita].TnTnTan, d->T ); // TnTnTan
563 dewpoint_depression_to_DnDn ( t->a.s3.trop[ita].DnDn, d->T , d->Td ); // DnDn
564 wind_to_dndnfnfnfn ( t->a.s3.trop[ita].dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
565 if ( ix && ita < TEMP_NTROP_MAX )
566 {
567 ita += 1;
568 t->a.s3.n = ita;
569 }
570 else
571 return 1;
572 }
573 }
574
575 // Max wind level
577 {
578 if ( is_over_100 )
579 {
580 ix = ( int ) ( d->p * 0.1 + 0.5 );
581 sprintf ( t->c.s4.windx[iwxc].PmPmPm, "%03d", ix % 1000 ); // PnPnPn
582 wind_to_dndnfnfnfn ( t->c.s4.windx[iwxc].dmdmfmfmfm, d->dd, d->ff ); // dndnfnfnfn
583 // check if more wind data
584 for ( j = i + 1; j < r->n ; j++ )
585 {
586 if ( r->raw[j].ff != MISSING_REAL )
587 {
588 t->c.s4.windx[iwxc].no_last_wind = 1;
589 break;
590 }
591 }
592 if ( ix && iwxc < TEMP_NMAXWIND_MAX )
593 {
594 iwxc += 1;
595 t->c.s4.n = iwxc;
596 }
597 else
598 return 1;
599 }
600 else
601 {
602 ix = ( int ) ( d->p * 0.01 + 0.5 );
603 sprintf ( t->a.s4.windx[iwxa].PmPmPm, "%03d", ix % 1000 ); // PnPnPn.
604 wind_to_dndnfnfnfn ( t->a.s4.windx[iwxa].dmdmfmfmfm, d->dd, d->ff ); // dndnfnfnfn
605 for ( j = i + 1; j < r->n ; j++ )
606 {
607 if ( r->raw[j].ff != MISSING_REAL )
608 {
609 t->a.s4.windx[iwxa].no_last_wind = 1;
610 break;
611 }
612 }
613 if ( ix && iwxa < TEMP_NMAXWIND_MAX )
614 {
615 iwxa += 1;
616 t->a.s4.n = iwxa;
617 }
618 else
619 return 1;
620 }
621 }
622
623 // Significant TH points
625 {
626 if ( is_over_100 )
627 {
628 sprintf ( t->d.s5.th[itd].nini, "%d%d", ( ( int ) itd ) %9 + 1, ( ( int ) itd ) %9 + 1 );
629 ix = ( int ) ( d->p * 0.1 + 0.5 );
630 sprintf ( t->d.s5.th[itd].PnPnPn, "%03d", ix ); // PnPnPn
631 kelvin_to_TTTa ( t->d.s5.th[itd].TnTnTan, d->T ); // TnTnTan
632 dewpoint_depression_to_DnDn ( t->d.s5.th[itd].DnDn, d->T , d->Td ); // DnDn
633 if ( ix && itd < TEMP_NMAX_POINTS )
634 {
635 itd += 1;
636 t->d.s5.n = itd;
637 }
638 else
639 return 1;
640 }
641 else
642 {
644 {
645 strcpy ( t->b.s5.th[itb].nini, "00" ); // case of surface level
646 }
647 else
648 {
649 sprintf ( t->b.s5.th[itb].nini, "%d%d", ( ( int ) itb - 1 ) %9 + 1, ( ( int ) itb - 1 ) %9 + 1 );
650 }
651 ix = ( int ) ( d->p * 0.01 + 0.5 );
652 sprintf ( t->b.s5.th[itb].PnPnPn, "%03d", ix % 1000 ); // PnPnPn.
653 kelvin_to_TTTa ( t->b.s5.th[itb].TnTnTan, d->T ); // TnTnTan
654 dewpoint_depression_to_DnDn ( t->b.s5.th[itb].DnDn, d->T , d->Td ); // DnDn
655 if ( ix && itb < TEMP_NMAX_POINTS )
656 {
657 itb += 1;
658 t->b.s5.n = itb;
659 }
660 else
661 return 1;
662 }
663 }
664
665 // Significant wind points
667 {
668 if ( is_over_100 )
669 {
670 sprintf ( t->d.s6.wd[iwd].nini, "%d%d", ( ( int ) iwd ) %9 + 1, ( ( int ) iwd ) %9 + 1 );
671 ix = ( int ) ( d->p * 0.1 + 0.5 );
672 sprintf ( t->d.s6.wd[iwd].PnPnPn, "%03d", ix ); // PnPnPn
673 wind_to_dndnfnfnfn ( t->d.s6.wd[iwd].dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
674 if ( ix && iwd < TEMP_NMAX_POINTS )
675 {
676 iwd += 1;
677 t->d.s6.n = iwd;
678 }
679 else
680 return 1;
681
682 }
683 else
684 {
686 {
687 strcpy ( t->b.s6.wd[iwb].nini, "00" ); // case of surface level
688 }
689 else
690 {
691 sprintf ( t->b.s6.wd[iwb].nini, "%d%d", ( ( int ) iwb - 1 ) %9 + 1, ( ( int ) iwb - 1 ) %9 + 1 );
692 }
693 ix = ( int ) ( d->p * 0.01 + 0.5 );
694 sprintf ( t->b.s6.wd[iwb].PnPnPn, "%03d", ix % 1000 ); // PnPnPn.
695 wind_to_dndnfnfnfn ( t->b.s6.wd[iwb].dndnfnfnfn, d->dd, d->ff ); // dndnfnfnfn
696 if ( ix && iwb < TEMP_NMAX_POINTS )
697 {
698 iwb += 1;
699 t->b.s6.n = iwb;
700 //printf("%lu\n", t->b.s6.n);
701 }
702 else
703 return 1;
704 }
705 }
706 }
707
708 // Now we set some bit masks
709 if ( isav )
710 {
711 t->a.mask |= TEMP_SEC_2;
712 }
713 if ( iscv )
714 {
715 t->c.mask |= TEMP_SEC_2;
716 }
717 if ( ita )
718 {
719 t->a.mask |= TEMP_SEC_3;
720 }
721 if ( itc )
722 {
723 t->c.mask |= TEMP_SEC_3;
724 }
725 if ( iwxa )
726 {
727 t->a.mask |= TEMP_SEC_4;
728 }
729 if ( iwxc )
730 {
731 t->c.mask |= TEMP_SEC_4;
732 }
733 if ( itb )
734 {
735 t->b.mask |= TEMP_SEC_5;
736 }
737 if ( itd )
738 {
739 t->d.mask |= TEMP_SEC_5;
740 }
741 if ( iwb )
742 {
743 t->b.mask |= TEMP_SEC_6;
744 }
745 if ( iwd )
746 {
747 t->d.mask |= TEMP_SEC_6;
748 }
749
750 return 0;
751}
char * dewpoint_depression_to_DnDn(char *target, double T, double Td)
Set DnDn (dewpoint depression)
Definition: bufr2tac_x12.c:179
char * kelvin_to_TTTa(char *target, double T)
Set temperature TTTa.
Definition: bufr2tac_x12.c:147
char * wind_to_dndnfnfnfn(char *target, double dd, double ff)
Definition: bufr2tac_x11.c:93
char * pascal_to_pnpnpn(char *target, double P)
Definition: bufr2tac_x10.c:47
#define TEMP_POINT_MASK_SIGNIFICANT_TEMPERATURE_LEVEL
Definition: mettemp.h:176
#define TEMP_SEC_6
mask bit meaning sec 6 of a part of TEMP report parsed with success
Definition: mettemp.h:89
#define TEMP_NTROP_MAX
Maximum number of standard levels in any part of a TEMP report.
Definition: mettemp.h:125
#define TEMP_POINT_MASK_MAXIMUM_WIND_LEVEL
Definition: mettemp.h:175
#define TEMP_SEC_4
mask bit meaning sec 4 of a part of TEMP report parsed with success
Definition: mettemp.h:77
#define TEMP_SEC_5
mask bit meaning sec 5 of a part of TEMP report parsed with success
Definition: mettemp.h:83
#define TEMP_POINT_MASK_TROPOPAUSE_LEVEL
Definition: mettemp.h:174
#define TEMP_SEC_2
mask bit meaning sec 2 of a part of TEMP report parsed with success
Definition: mettemp.h:65
#define TEMP_POINT_MASK_SIGNIFICANT_WIND_LEVEL
Definition: mettemp.h:178
#define TEMP_POINT_MASK_SURFACE
Definition: mettemp.h:172
#define TEMP_NMAX_POINTS
maximum number of significant points
Definition: mettemp.h:138
#define TEMP_POINT_MASK_SIGNIFICANT_HUMIDITY_LEVEL
Definition: mettemp.h:177
#define TEMP_SEC_3
mask bit meaning sec 3 of a part of TEMP report parsed with success
Definition: mettemp.h:71
#define TEMP_NSTAND_MAX
Maximum number of standard levels in any part of a TEMP report.
Definition: mettemp.h:119
#define TEMP_NMAXWIND_MAX
Maximum number of mwx wind level in any part of a TEMP report.
Definition: mettemp.h:132
#define TEMP_POINT_MASK_STANDARD_LEVEL
Definition: mettemp.h:173
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_ac_sec4 s4
Definition: mettemp.h:458
struct temp_a_sec2 s2
Definition: mettemp.h:456
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 id[2]
Definition: mettemp.h:316
struct temp_bd_sec5 s5
Definition: mettemp.h:471
int mask
Definition: mettemp.h:468
struct temp_bd_sec6 s6
Definition: mettemp.h:472
size_t n
Definition: mettemp.h:420
struct temp_th_point th[TEMP_NMAX_POINTS]
Definition: mettemp.h:421
size_t n
Definition: mettemp.h:430
struct temp_wind_point wd[TEMP_NMAX_POINTS]
Definition: mettemp.h:431
size_t n
Definition: mettemp.h:375
struct temp_std_level_data std[TEMP_NSTAND_MAX]
Definition: mettemp.h:376
struct temp_c_sec2 s2
Definition: mettemp.h:486
struct temp_ac_sec4 s4
Definition: mettemp.h:488
int mask
Definition: mettemp.h:483
struct temp_ac_sec3 s3
Definition: mettemp.h:487
struct temp_bd_sec6 s6
Definition: mettemp.h:502
int mask
Definition: mettemp.h:498
struct temp_bd_sec5 s5
Definition: mettemp.h:501
char dndnfnfnfn[8]
Definition: mettemp.h:252
char PmPmPm[4]
Definition: mettemp.h:275
char dmdmfmfmfm[8]
Definition: mettemp.h:276
struct temp_raw_point_data raw[TEMP_NMAX_POINTS *4]
Definition: mettemp.h:215
size_t n
Definition: mettemp.h:214
Stores data of a sounding profile in raw format, as given in bufr.
Definition: mettemp.h:195
char dndnfnfnfn[8]
Definition: mettemp.h:265
char nini[4]
Definition: mettemp.h:287
char TnTnTan[4]
Definition: mettemp.h:289
char PnPnPn[4]
Definition: mettemp.h:288
char DnDn[4]
Definition: mettemp.h:290
char PnPnPn[4]
Definition: mettemp.h:300
char dndnfnfnfn[8]
Definition: mettemp.h:301
char nini[4]
Definition: mettemp.h:299

References temp_chunks::a, temp_chunks::b, temp_chunks::c, temp_chunks::d, temp_raw_point_data::dd, dewpoint_depression_to_DnDn(), temp_max_wind_data::dmdmfmfmfm, temp_main_level_data::DnDn, temp_std_level_data::DnDn, temp_th_point::DnDn, temp_main_level_data::dndnfnfnfn, temp_std_level_data::dndnfnfnfn, temp_wind_point::dndnfnfnfn, temp_raw_point_data::ff, temp_raw_point_data::flags, temp_raw_point_data::h, temp_std_level_data::hnhnhn, temp_acd_sec1::id, kelvin_to_TTTa(), temp_a_sec2::lev0, temp_a::mask, temp_b::mask, temp_c::mask, temp_d::mask, MISSING_REAL, temp_raw_data::n, temp_a_sec2::n, temp_c_sec2::n, temp_ac_sec3::n, temp_ac_sec4::n, temp_bd_sec5::n, temp_bd_sec6::n, temp_th_point::nini, temp_wind_point::nini, temp_max_wind_data::no_last_wind, temp_raw_point_data::p, pascal_to_pnpnpn(), temp_max_wind_data::PmPmPm, temp_std_level_data::PnPn, temp_main_level_data::PnPnPn, temp_th_point::PnPnPn, temp_wind_point::PnPnPn, temp_raw_data::raw, temp_a::s1, temp_c::s1, temp_a::s2, temp_c::s2, temp_a::s3, temp_c::s3, temp_a::s4, temp_c::s4, temp_b::s5, temp_d::s5, temp_b::s6, temp_d::s6, temp_a_sec2::std, temp_c_sec2::std, temp_raw_point_data::T, temp_raw_point_data::Td, TEMP_NMAX_POINTS, TEMP_NMAXWIND_MAX, TEMP_NSTAND_MAX, TEMP_NTROP_MAX, TEMP_POINT_MASK_MAXIMUM_WIND_LEVEL, TEMP_POINT_MASK_SIGNIFICANT_HUMIDITY_LEVEL, TEMP_POINT_MASK_SIGNIFICANT_TEMPERATURE_LEVEL, TEMP_POINT_MASK_SIGNIFICANT_WIND_LEVEL, TEMP_POINT_MASK_STANDARD_LEVEL, TEMP_POINT_MASK_SURFACE, TEMP_POINT_MASK_TROPOPAUSE_LEVEL, TEMP_SEC_2, TEMP_SEC_3, TEMP_SEC_4, TEMP_SEC_5, TEMP_SEC_6, temp_bd_sec5::th, temp_main_level_data::TnTnTan, temp_std_level_data::TnTnTan, temp_th_point::TnTnTan, temp_ac_sec3::trop, temp_bd_sec6::wd, wind_to_dndnfnfnfn(), and temp_ac_sec4::windx.

Referenced by parse_subset_as_temp().

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

◆ parse_temp_raw_wind_shear_data()

int parse_temp_raw_wind_shear_data ( struct temp_chunks t,
struct temp_raw_wind_shear_data w 
)

Definition at line 757 of file bufr2tac_temp.c.

758{
759 size_t i, j;
760 int ix, is_over_100;
761 char aux[16];
762
764
765 if ( t == NULL || w == NULL )
766 {
767 return 1;
768 }
769
770 if ( w->n == 0 )
771 {
772 return 1;
773 }
774
775 for ( i = 0; i < w->n; i++ )
776 {
777 d = & ( w->raw[i] ); // to make code easy
778
779 if ( d->p < 10000.0 ) // to select which part
780 {
781 is_over_100 = 1;
782 }
783 else
784 {
785 is_over_100 = 0;
786 }
787
788 // set pnpnpn on aux
789 if ( is_over_100 )
790 {
791 if ( t ->c.s4.n == 0 )
792 {
793 continue;
794 }
795
796 ix = ( int ) ( d->p * 0.1 + 0.5 );
797 sprintf ( aux, "%03d", ix % 1000 ); // PnPnPn
798
799 // checks for a significant wind level in section 4 with same pnpnpn
800 for ( j = 0 ; j < t->c.s4.n ; j++ )
801 {
802 if ( strcmp ( t->c.s4.windx[j].PmPmPm , aux ) == 0 )
803 {
804 if ( d->ws_blw != MISSING_REAL )
805 {
806 sprintf ( t->c.s4.windx[j].vbvb, "%02.0lf", d->ws_blw );
807 }
808 if ( d->ws_abv != MISSING_REAL )
809 {
810 sprintf ( t->c.s4.windx[j].vava, "%02.0lf", d->ws_abv );
811 }
812 break;
813 }
814 }
815 }
816 else
817 {
818 if ( t ->a.s4.n == 0 )
819 {
820 continue;
821 }
822 ix = ( int ) ( d->p * 0.01 + 0.5 );
823 sprintf ( aux, "%03d", ix % 1000 ); // PnPnPn.
824 // checks for a significant wind level in section 4 with same pnpnpn
825 for ( j = 0 ; j < t->a.s4.n ; j++ )
826 {
827 if ( strcmp ( t->a.s4.windx[j].PmPmPm , aux ) == 0 )
828 {
829 //printf("%s %s\n", aux, t->a.s4.windx[j].PmPmPm);
830 //printf("%.1lf %.1lf\n", d->ws_blw, d->ws_abv);
831 if ( d->ws_blw != MISSING_REAL )
832 {
833 sprintf ( t->a.s4.windx[j].vbvb, "%02.0lf", d->ws_blw );
834 }
835 if ( d->ws_abv != MISSING_REAL )
836 {
837 sprintf ( t->a.s4.windx[j].vava, "%02.0lf", d->ws_abv );
838 }
839 break;
840 }
841 }
842 }
843 }
844
845 return 0;
846}
struct temp_raw_wind_shear_point raw[TEMP_NMAX_POINTS]
Definition: mettemp.h:240
Wind shear data point at a pressure level.
Definition: mettemp.h:223

References temp_chunks::a, temp_chunks::c, MISSING_REAL, temp_raw_wind_shear_data::n, temp_ac_sec4::n, temp_raw_wind_shear_point::p, temp_max_wind_data::PmPmPm, temp_raw_wind_shear_data::raw, temp_a::s4, temp_c::s4, temp_max_wind_data::vava, temp_max_wind_data::vbvb, temp_ac_sec4::windx, temp_raw_wind_shear_point::ws_abv, and temp_raw_wind_shear_point::ws_blw.

Referenced by parse_subset_as_temp().

Here is the caller graph for this function:

◆ pascal_to_pnpnpn()

char * pascal_to_pnpnpn ( char *  target,
double  P 
)

Definition at line 47 of file bufr2tac_x10.c.

48{
49 int ic;
50 if ( P > 10000.0 )
51 {
52 ic = ( int ) ( P * 0.01 + 0.5 );
53 }
54 else
55 {
56 ic = ( int ) ( P * 0.1 + 0.5 );
57 }
58 sprintf ( target, "%03d", ic % 1000 );
59 return target;
60}

Referenced by parse_temp_raw_data().

Here is the caller graph for this function:

◆ pascal_to_ppp()

char * pascal_to_ppp ( char *  target,
double  P 
)

Converts pascal values (variation) into a ppp string.

Parameters
Pthe pressure variation in Pascal units
targetstring with the result

Definition at line 32 of file bufr2tac_x10.c.

33{
34 int ic;
35 if ( P > 0 )
36 {
37 ic = ( int ) ( P * 0.1 );
38 }
39 else
40 {
41 ic = ( int ) ( -P * 0.1 );
42 }
43 sprintf ( target, "%03d", ic % 1000 );
44 return target;
45}

Referenced by buoy_parse_x10(), and syn_parse_x10().

Here is the caller graph for this function:

◆ pascal_to_PPPP()

char * pascal_to_PPPP ( char *  target,
double  P 
)

Converts pascal values into a PPPP string.

Parameters
Pthe pressure variation in Pascal units
targetstring with the result

Definition at line 69 of file bufr2tac_x10.c.

70{
71 int ic;
72 ic = ( int ) ( P * 0.1 );
73 sprintf ( target, "%04d", ic % 10000 );
74 return target;
75}

Referenced by buoy_parse_x10(), climat_parse_x10(), and syn_parse_x10().

Here is the caller graph for this function:

◆ percent_to_okta()

char * percent_to_okta ( char *  target,
double  perc 
)

Converts percent cloud cover into okta.

Parameters
percthe precent cloud cover
targetthe resulting okta string

Definition at line 32 of file bufr2tac_x20.c.

33{
34 if ( perc == 0.0 )
35 {
36 strcpy ( target,"0" );
37 }
38 else if ( perc < ( 25.0 - 6.25 ) )
39 {
40 strcpy ( target,"1" );
41 }
42 else if ( perc < ( 37.5 - 6.25 ) )
43 {
44 strcpy ( target,"2" );
45 }
46 else if ( perc < ( 50.0 - 6.25 ) )
47 {
48 strcpy ( target,"3" );
49 }
50 else if ( perc < ( 62.5 -6.25 ) )
51 {
52 strcpy ( target,"4" );
53 }
54 else if ( perc < ( 75.0 - 6.25 ) )
55 {
56 strcpy ( target,"5" );
57 }
58 else if ( perc < ( 87.5 - 6.25 ) )
59 {
60 strcpy ( target,"6" );
61 }
62 else if ( perc < 100.0 )
63 {
64 strcpy ( target,"7" );
65 }
66 else if ( perc <= 112.5 )
67 {
68 strcpy ( target,"8" );
69 }
70 else if ( perc == 113.0 )
71 {
72 strcpy ( target,"9" );
73 }
74 return target;
75}

Referenced by syn_parse_x20().

Here is the caller graph for this function:

◆ prec_to_RRR()

char * prec_to_RRR ( char *  target,
double  r 
)

converts a precipitation in Kg/m2 into a RRR string

Parameters
rthe precipitation
targetthe resulting string

Definition at line 32 of file bufr2tac_x13.c.

33{
34 if ( r == 0.0 )
35 {
36 strcpy ( target,"000" );
37 }
38 else if ( r > -0.11 && r < -0.09 ) // this is an approach to -0.1
39 {
40 strcpy ( target,"990" );
41 }
42 else if ( r < 0.95 )
43 {
44 sprintf ( target, "99%d", ( int ) ( r * 10.0 + 0.5 ) );
45 }
46 else if ( r >= 989.0 )
47 {
48 strcpy ( target,"989" );
49 }
50 else
51 {
52 sprintf ( target, "%03d", ( int ) ( r + 0.5 ) );
53 }
54 return target;
55
56}

Referenced by syn_parse_x13().

Here is the caller graph for this function:

◆ prec_to_RRRR24()

char * prec_to_RRRR24 ( char *  target,
double  r 
)

converts a precipitation in Kg/m2 into a RRRR24 string

Parameters
rthe precipitation
targetthe resulting string

Definition at line 87 of file bufr2tac_x13.c.

88{
89 if ( r < 0.0 || ( r > 0.0 && r < 0.1 ) )
90 {
91 strcpy ( target,"9999" );
92 }
93 else if ( r <= 999.8 )
94 {
95 sprintf ( target,"%04d", ( int ) ( r * 10.0 + 0.5 ) );
96 }
97 else
98 {
99 strcpy ( target,"9998" );
100 }
101 return target;
102}

Referenced by syn_parse_x13().

Here is the caller graph for this function:

◆ print_buoy_report()

int print_buoy_report ( struct metreport m)

prints a buoy into a string

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 392 of file bufr2tac_print_buoy.c.

393{
394 char *c = & ( m->alphanum[0] );
395 size_t used = 0;
396 size_t lmax = sizeof ( m->alphanum );
397 struct buoy_chunks *b = &m->buoy;
398
399 // Needs time extension
400 if ( b->e.YYYY[0] == 0 || b->e.YYYY[0] == '0' )
401 {
402 return 1;
403 }
404
406 {
407 used += print_wigos_id ( &c, lmax, m );
408 }
409
410 if ( m->print_mask & PRINT_BITMASK_GEO )
411 {
412 used += print_geo ( &c, lmax, m );
413 }
414
415 print_buoy_sec0 ( &c, lmax, b );
416
417 if ( b->mask & ( BUOY_SEC1 | BUOY_SEC2 | BUOY_SEC3 ) )
418 {
419 used += print_buoy_sec1 ( &c, lmax - used, b );
420
421 used += print_buoy_sec2 ( &c, lmax - used, b );
422
423 used += print_buoy_sec3 ( &c, lmax - used, b );
424 }
425 else
426 {
427 c += snprintf ( c, lmax - used, " NIL" );
428 }
429 snprintf ( c, lmax - used - 1, "=" );
430
431 return 0;
432}
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_buoy_sec1(char **sec1, size_t lmax, struct buoy_chunks *b)
Prints the buoy section 1.
size_t print_buoy_sec0(char **sec0, size_t lmax, struct buoy_chunks *b)
Prints the buoy section 1.
size_t print_buoy_sec2(char **sec2, size_t lmax, struct buoy_chunks *b)
Prints the buoy section 1.
size_t print_buoy_sec3(char **sec3, size_t lmax, struct buoy_chunks *b)
Prints the buoy section 3.
char alphanum[REPORT_LENGTH]
Definition: bufr2tac.h:321
int print_mask
Definition: bufr2tac.h:312

References metreport::alphanum, metreport::buoy, BUOY_SEC1, BUOY_SEC2, BUOY_SEC3, buoy_chunks::e, buoy_chunks::mask, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_buoy_sec0(), print_buoy_sec1(), print_buoy_sec2(), print_buoy_sec3(), print_geo(), metreport::print_mask, print_wigos_id(), and report_date_ext::YYYY.

Referenced by parse_subset_sequence().

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

◆ print_buoy_sec0()

size_t print_buoy_sec0 ( char **  sec0,
size_t  lmax,
struct buoy_chunks b 
)

Prints the buoy section 1.

Parameters
sec0the pointer where to print section
lmaxmax length permited
bpointer to s atruct buoy_chunks where the parse results are set

Definition at line 33 of file bufr2tac_print_buoy.c.

34{
35 size_t used = 0;
36 char *c = *sec0;
37
38 used += snprintf ( c + used, lmax - used, "%s%s%s%s%s", b->e.YYYY, b->e.MM, b->e.DD, b->e.HH, b->e.mm );
39
40 // Print type
41 used += snprintf ( c + used, lmax - used, " %s%s", b->s0.MiMi, b->s0.MjMj );
42
43 if ( b->s0.A1[0] && b->s0.bw[0] && b->s0.nbnbnb[0] )
44 {
45 used += snprintf ( c + used, lmax - used, " %s%s%s", b->s0.A1, b->s0.bw, b->s0.nbnbnb );
46 }
47 else if ( b->s0.D_D[0] )
48 {
49 used += snprintf ( c + used, lmax - used, " %s", b->s0.D_D );
50 }
51
52
53 used += snprintf ( c + used, lmax - used, " %s%s%s", b->s0.YY, b->s0.MM, b->s0.J );
54
55 if ( b->s0.iw[0] )
56 {
57 used += snprintf ( c + used, lmax - used, " %s%s%s", b->s0.GG, b->s0.gg, b->s0.iw );
58 }
59 else
60 {
61 used += snprintf ( c + used, lmax - used, " %s%s/", b->s0.GG, b->s0.gg );
62 }
63
64 used += snprintf ( c + used, lmax - used, " %s%s", b->s0.Qc, b->s0.LaLaLaLaLa );
65
66
67 used += snprintf ( c + used, lmax - used, " %s", b->s0.LoLoLoLoLoLo );
68
69 if ( b->s0.QA[0] || b->s0.Ql[0] || b->s0.Qt[0] )
70 {
71 if ( b->s0.Ql[0] )
72 {
73 used += snprintf ( c + used, lmax - used, " 6%s", b->s0.Ql );
74 }
75 else
76 {
77 used += snprintf ( c + used, lmax - used, " 6/" );
78 }
79
80 if ( b->s0.Qt[0] )
81 {
82 used +=snprintf ( c + used, lmax - used, "%s", b->s0.Qt );
83 }
84 else
85 {
86 used += snprintf ( c + used, lmax - used, "/" );
87 }
88
89 if ( b->s0.QA[0] )
90 {
91 used += snprintf ( c + used, lmax - used, "%s/", b->s0.QA );
92 }
93 else
94 {
95 used += snprintf ( c + used, lmax - used, "//" );
96 }
97 }
98
99 *sec0 = c + used;
100 return used;
101}
char D_D[8]
Definition: metbuoy.h:71

References buoy_sec0::A1, buoy_sec0::bw, buoy_sec0::D_D, report_date_ext::DD, buoy_chunks::e, buoy_sec0::GG, buoy_sec0::gg, report_date_ext::HH, buoy_sec0::iw, buoy_sec0::J, buoy_sec0::LaLaLaLaLa, buoy_sec0::LoLoLoLoLoLo, buoy_sec0::MiMi, buoy_sec0::MjMj, buoy_sec0::MM, report_date_ext::MM, report_date_ext::mm, buoy_sec0::nbnbnb, buoy_sec0::QA, buoy_sec0::Qc, buoy_sec0::Ql, buoy_sec0::Qt, buoy_chunks::s0, buoy_sec0::YY, and report_date_ext::YYYY.

Referenced by print_buoy_report().

Here is the caller graph for this function:

◆ print_buoy_sec1()

size_t print_buoy_sec1 ( char **  sec1,
size_t  lmax,
struct buoy_chunks b 
)

Prints the buoy section 1.

Parameters
sec1the pointer where to print section
lmaxmax length permited
bpointer to s atruct buoy_chunks where the parse results are set

Definition at line 111 of file bufr2tac_print_buoy.c.

112{
113 size_t used = 0;
114 char *c = *sec1;
115
116 if ( b->mask & BUOY_SEC1 )
117 {
118 // 111QdQx
119 used += snprintf ( c + used, lmax - used," 111" );
120
121 if ( b->s1.Qd[0] )
122 {
123 used += snprintf ( c + used, lmax - used,"%s", b->s1.Qd );
124 }
125 else
126 {
127 used += snprintf ( c + used, lmax - used,"/" );
128 }
129
130 if ( b->s1.Qx[0] )
131 {
132 used += snprintf ( c + used, lmax - used,"%s", b->s1.Qx );
133 }
134 else
135 {
136 used += snprintf ( c + used, lmax - used,"/" );
137 }
138
139 // 0ddff
140 if ( b->s1.dd[0] || b->s1.ff[0] )
141 {
142 used += snprintf ( c + used, lmax - used, " 0" );
143 if ( b->s1.dd[0] )
144 {
145 used += snprintf ( c + used, lmax - used, "%s", b->s1.dd );
146 }
147 else
148 {
149 used += snprintf ( c + used, lmax - used, "//" );
150 }
151
152 if ( b->s1.ff[0] )
153 {
154 used += snprintf ( c + used, lmax - used, "%s", b->s1.ff );
155 }
156 else
157 {
158 used += snprintf ( c + used, lmax - used, "//" );
159 }
160 }
161
162 // 1snTTT
163 if ( b->s1.TTT[0] )
164 {
165 used += snprintf ( c + used, lmax - used, " 1%s%s", b->s1.sn1, b->s1.TTT );
166 }
167
168 // 2snTdTdTd
169 if ( b->s1.TdTdTd[0] )
170 {
171 used += snprintf ( c + used, lmax - used, " 2%s%s", b->s1.sn2, b->s1.TdTdTd );
172 }
173
174 // 3PoPoPoPo
175 if ( b->s1.PoPoPoPo[0] )
176 {
177 used += snprintf ( c + used, lmax - used, " 3%s", b->s1.PoPoPoPo );
178 }
179
180 // printf 4PPPP
181 if ( b->s1.PPPP[0] )
182 {
183 used += snprintf ( c + used, lmax - used, " 4%s", b->s1.PPPP );
184 }
185
186 // printf 5appp
187 if ( b->s1.a[0] || b->s1.ppp[0] )
188 {
189 if ( b->s1.a[0] == 0 )
190 {
191 b->s1.a[0] = '/';
192 }
193 if ( b->s1.ppp[0] == 0 )
194 {
195 strcpy ( b->s1.ppp, "///" );
196 }
197 used += snprintf ( c + used, lmax - used, " 5%s%s", b->s1.a, b->s1.ppp );
198 }
199 }
200
201 *sec1 = c + used;
202 return used;
203}

References buoy_sec1::a, BUOY_SEC1, buoy_sec1::dd, buoy_sec1::ff, buoy_chunks::mask, buoy_sec1::PoPoPoPo, buoy_sec1::ppp, buoy_sec1::PPPP, buoy_sec1::Qd, buoy_sec1::Qx, buoy_chunks::s1, buoy_sec1::sn1, buoy_sec1::sn2, buoy_sec1::TdTdTd, and buoy_sec1::TTT.

Referenced by print_buoy_report().

Here is the caller graph for this function:

◆ print_buoy_sec2()

size_t print_buoy_sec2 ( char **  sec2,
size_t  lmax,
struct buoy_chunks b 
)

Prints the buoy section 1.

Parameters
sec2the pointer where to print section
lmaxmax length permited
bpointer to s atruct buoy_chunks where the parse results are set

Definition at line 212 of file bufr2tac_print_buoy.c.

213{
214 size_t used = 0;
215 char *c = *sec2;
216
217 if ( b->mask & BUOY_SEC2 )
218 {
219 // 222QdQx
220 used += snprintf ( c + used, lmax - used," 222" );
221
222 if ( b->s2.Qd[0] )
223 {
224 used += snprintf ( c + used, lmax - used,"%s", b->s2.Qd );
225 }
226 else
227 {
228 used += snprintf ( c + used, lmax - used,"/" );
229 }
230
231 if ( b->s2.Qx[0] )
232 {
233 used += snprintf ( c + used, lmax - used,"%s", b->s2.Qx );
234 }
235 else
236 {
237 used += snprintf ( c + used, lmax - used,"/" );
238 }
239
240 // 0snTwTwTw
241 if ( b->s2.TwTwTw[0] )
242 {
243 used += snprintf ( c + used, lmax - used, " 0%s%s", b->s2.sn, b->s2.TwTwTw );
244 }
245
246 // 1PwaPwaHwaHwa
247 if ( b->s2.PwaPwa[0] || b->s2.HwaHwa[0] )
248 {
249 used += snprintf ( c + used, lmax - used, " 1" );
250 if ( b->s2.PwaPwa[0] )
251 {
252 used += snprintf ( c + used, lmax - used,"%s", b->s2.PwaPwa );
253 }
254 else
255 {
256 used += snprintf ( c + used, lmax - used,"//" );
257 }
258
259 if ( b->s2.HwaHwa[0] )
260 {
261 used += snprintf ( c + used, lmax - used,"%s", b->s2.HwaHwa );
262 }
263 else
264 {
265 used += snprintf ( c + used, lmax - used,"//" );
266 }
267 }
268
269 // 20PwaPwaPwa
270 if ( b->s2.PwaPwaPwa[0] )
271 {
272 used += snprintf ( c + used, lmax - used, " 20%s", b->s2.PwaPwaPwa );
273 }
274
275 // 21HwaHwaHwa
276 if ( b->s2.HwaHwaHwa[0] )
277 {
278 used += snprintf ( c + used, lmax - used, " 21%s", b->s2.HwaHwaHwa );
279 }
280
281
282 }
283
284 *sec2 = c + used;
285 return used;
286}

References BUOY_SEC2, buoy_sec2::HwaHwa, buoy_sec2::HwaHwaHwa, buoy_chunks::mask, buoy_sec2::PwaPwa, buoy_sec2::PwaPwaPwa, buoy_sec2::Qd, buoy_sec2::Qx, buoy_chunks::s2, buoy_sec2::sn, and buoy_sec2::TwTwTw.

Referenced by print_buoy_report().

Here is the caller graph for this function:

◆ print_buoy_sec3()

size_t print_buoy_sec3 ( char **  sec3,
size_t  lmax,
struct buoy_chunks b 
)

Prints the buoy section 3.

Parameters
sec3the pointer where to print section
lmaxmax length permited
bpointer to s atruct buoy_chunks where the parse results are set

Definition at line 295 of file bufr2tac_print_buoy.c.

296{
297 size_t used = 0;
298 char *c = *sec3;
299 size_t l;
300
301 if ( b->mask & BUOY_SEC3 )
302 {
303 used += snprintf ( c + used, lmax - used, " 333%s%s", b->s3.Qd1, b->s3.Qd2 );
304
305 // check if has 8887k2
306 l = 0;
307 while ( b->s3.l1[l].zzzz[0] && l < 32 )
308 {
309 if ( l == 0 )
310 {
311 used += snprintf ( c + used, lmax - used, " 8887%s", b->s3.k2 );
312 }
313 used += snprintf ( c + used, lmax - used, " 2%s", b->s3.l1[l].zzzz );
314
315 if ( b->s3.l1[l].TTTT[0] )
316 {
317 used += snprintf ( c + used, lmax - used, " 3%s", b->s3.l1[l].TTTT );
318 }
319
320 if ( b->s3.l1[l].SSSS[0] )
321 {
322 used += snprintf ( c + used, lmax - used, " 4%s", b->s3.l1[l].SSSS );
323 }
324 l++;
325 }
326
327 l = 0;
328 while ( b->s3.l2[l].zzzz[0] && l < 32 )
329 {
330 if ( l == 0 )
331 {
332 used += snprintf ( c + used, lmax - used, " 66%s9%s", b->s3.k6, b->s3.k3 );
333 }
334 used += snprintf ( c + used, lmax - used, " 2%s", b->s3.l2[l].zzzz );
335
336 if ( b->s3.l2[l].dd[0] || b->s3.l2[l].ccc[0] )
337 {
338 if ( b->s3.l2[l].dd[0] )
339 {
340 used += snprintf ( c + used, lmax - used, " %s", b->s3.l2[l].dd );
341 }
342 else
343 {
344 used += snprintf ( c + used, lmax - used, " //" );
345 }
346 if ( b->s3.l2[l].ccc[0] )
347 {
348 used += snprintf ( c + used, lmax - used, "%s", b->s3.l2[l].ccc );
349 }
350 else
351 {
352 used += snprintf ( c + used, lmax - used, "///" );
353 }
354 }
355 l++;
356 }
357 }
358
359 *sec3 = c + used;
360 return used;
361}
char ccc[6]
Definition: metbuoy.h:141

References BUOY_SEC3, b_sec3_layer2::ccc, b_sec3_layer2::dd, buoy_sec3::k2, buoy_sec3::k3, buoy_sec3::k6, buoy_sec3::l1, buoy_sec3::l2, buoy_chunks::mask, buoy_sec3::Qd1, buoy_sec3::Qd2, buoy_chunks::s3, b_sec3_layer1::SSSS, b_sec3_layer1::TTTT, b_sec3_layer1::zzzz, and b_sec3_layer2::zzzz.

Referenced by print_buoy_report().

Here is the caller graph for this function:

◆ print_buoy_wigos_id()

size_t print_buoy_wigos_id ( char **  wid,
size_t  lmax,
struct buoy_chunks b 
)

Definition at line 367 of file bufr2tac_print_buoy.c.

368{
369 char aux[40];
370 size_t used = 0;
371 char sep = '|';
372
373 if ( b->wid.series == 0 && b->wid.issuer == 0 && b->wid.issue == 0 && b->wid.local_id[0] == '\0' )
374 sprintf ( aux,"0-0-0-MISSING" );
375 else
376 sprintf ( aux,"%d-%d-%d-%s", b->wid.series, b->wid.issuer, b->wid.issue, b->wid.local_id );
377
378 used = snprintf ( *wid, lmax, "%-32s%c", aux, sep );
379 *wid += used;
380 return used;
381}

References wigos_id::issue, wigos_id::issuer, wigos_id::local_id, wigos_id::series, and buoy_chunks::wid.

◆ print_climat_report()

int print_climat_report ( struct metreport m)

prints a climat into a string

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 718 of file bufr2tac_print_climat.c.

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}
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.
size_t print_climat_sec0(char **sec0, size_t lmax, struct climat_chunks *cl)
Prints the climat section 0 (header)

References metreport::alphanum, metreport::climat, CLIMAT_SEC1, CLIMAT_SEC2, CLIMAT_SEC3, CLIMAT_SEC4, climat_chunks::e, climat_chunks::mask, report_date_ext::MM, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_climat_sec0(), print_climat_sec1(), print_climat_sec2(), print_climat_sec3(), print_climat_sec4(), print_geo(), metreport::print_mask, print_wigos_id(), and report_date_ext::YYYY.

Referenced by parse_subset_sequence().

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

◆ print_climat_sec0()

size_t print_climat_sec0 ( char **  sec0,
size_t  lmax,
struct climat_chunks cl 
)

Prints the climat section 0 (header)

Parameters
sec0the pointer where to print section
lmaxmax length permited
clpointer to s atruct climat_chunks where the parse results are set

Definition at line 33 of file bufr2tac_print_climat.c.

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}

References report_date_ext::DD, climat_chunks::e, report_date_ext::HH, climat_sec0::II, climat_sec0::iii, climat_sec0::JJJ, climat_sec0::MM, report_date_ext::MM, report_date_ext::mm, climat_chunks::s0, and report_date_ext::YYYY.

Referenced by print_climat_report().

Here is the caller graph for this function:

◆ print_climat_sec1()

size_t print_climat_sec1 ( char **  sec1,
size_t  lmax,
struct climat_chunks cl 
)

Prints the climat section 1.

Parameters
sec1the pointer where to print section
lmaxmax length permited
clpointer to s atruct climat_chunks where the parse results are set

Definition at line 64 of file bufr2tac_print_climat.c.

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}
#define SYNOP_SEC1
mask bit meaning section 1 or synop is solicited to or parsed with success
Definition: metsynop.h:39

References climat_sec1::eee, climat_chunks::mask, climat_sec1::meme, climat_sec1::mpmp, climat_sec1::mrmr, climat_sec1::msms, climat_sec1::mtmt, climat_sec1::mtn, climat_sec1::mtx, climat_sec1::nrnr, climat_sec1::PoPoPoPo, climat_sec1::PPPP, climat_sec1::pspsps, climat_sec1::R1R1R1R1, climat_sec1::Rd, climat_sec1::s, climat_chunks::s1, climat_sec1::S1S1S1, climat_sec1::sn, climat_sec1::ststst, climat_sec1::sx, SYNOP_SEC1, climat_sec1::TnTnTn, climat_sec1::TTT, and climat_sec1::TxTxTx.

Referenced by print_climat_report().

Here is the caller graph for this function:

◆ print_climat_sec2()

size_t print_climat_sec2 ( char **  sec2,
size_t  lmax,
struct climat_chunks cl 
)

Prints the climat section 2.

Parameters
sec2the pointer where to print section
lmaxmax length permited
clpointer to s atruct climat_chunks where the parse results are set

Definition at line 198 of file bufr2tac_print_climat.c.

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}
#define SYNOP_SEC2
mask bit meaning section 2 or synop is solicited to or parsed with success
Definition: metsynop.h:44

References climat_sec2::eee, climat_chunks::mask, climat_sec2::nrnr, climat_sec2::PoPoPoPo, climat_sec2::PPPP, climat_sec2::R1R1R1R1, climat_sec2::s, climat_sec2::S1S1S1, climat_chunks::s2, climat_sec2::sn, climat_sec2::ststst, climat_sec2::sx, SYNOP_SEC2, climat_sec2::TnTnTn, climat_sec2::TTT, climat_sec2::TxTxTx, climat_sec2::YbYb, climat_sec2::YcYc, climat_sec2::yeye, climat_sec2::ypyp, climat_sec2::yryr, climat_sec2::ysys, climat_sec2::ytxytx, and climat_sec2::ytyt.

Referenced by print_climat_report().

Here is the caller graph for this function:

◆ print_climat_sec3()

size_t print_climat_sec3 ( char **  sec3,
size_t  lmax,
struct climat_chunks cl 
)

Prints the climat section 3.

Parameters
sec3the pointer where to print section
lmaxmax length permited
clpointer to s atruct climat_chunks where the parse results are set

Definition at line 354 of file bufr2tac_print_climat.c.

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}

References climat_sec3::f10, climat_sec3::f20, climat_sec3::f30, climat_chunks::mask, climat_sec3::R01, climat_sec3::R05, climat_sec3::R10, climat_sec3::R100, climat_sec3::R150, climat_sec3::R50, climat_sec3::s00, climat_sec3::s01, climat_sec3::s10, climat_chunks::s3, climat_sec3::s50, SYNOP_SEC3, climat_sec3::T25, climat_sec3::T30, climat_sec3::T35, climat_sec3::T40, climat_sec3::Tn0, climat_sec3::Tx0, climat_sec3::V1, climat_sec3::V2, and climat_sec3::V3.

Referenced by print_climat_report().

Here is the caller graph for this function:

◆ print_climat_sec4()

size_t print_climat_sec4 ( char **  sec4,
size_t  lmax,
struct climat_chunks cl 
)

Prints the climat section 4.

Parameters
sec4the pointer where to print section
lmaxmax length permited
clpointer to s atruct climat_chunks where the parse results are set

Definition at line 555 of file bufr2tac_print_climat.c.

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}

References CLIMAT_SEC4, climat_sec4::Dgr, climat_sec4::Dts, climat_sec4::fxfxfx, climat_sec4::GnGn, climat_sec4::GxGx, climat_sec4::iw, climat_sec4::iy, climat_chunks::mask, climat_sec4::RxRxRxRx, climat_chunks::s4, climat_sec4::san, climat_sec4::sax, climat_sec4::sn, climat_sec4::sx, climat_sec4::Tan, climat_sec4::Tax, climat_sec4::Tnd, climat_sec4::Txd, climat_sec4::yan, climat_sec4::yax, climat_sec4::yfx, climat_sec4::yn, climat_sec4::yr, and climat_sec4::yx.

Referenced by print_climat_report().

Here is the caller graph for this function:

◆ print_climat_wigos_id()

size_t print_climat_wigos_id ( char **  wid,
size_t  lmax,
struct climat_chunks cl 
)

◆ print_csv()

int print_csv ( FILE *  f,
struct metreport m 
)

prints a struct metreport in labeled csv format

Parameters
fpointer to a file already open by caller routine
mpointer to a struct metreport containing the data to print

Definition at line 85 of file bufr2tac_csv.c.

86{
87 // Single report
88 if ( m->alphanum[0] )
89 {
90 print_csv_alphanum ( f, m->type, m->alphanum, m );
91 }
92
93 if ( m->alphanum2[0] ) //TTBB
94 {
95 print_csv_alphanum ( f, m->type2, m->alphanum2, m );
96 }
97
98 if ( m->alphanum3[0] ) //TTCC
99 {
100 print_csv_alphanum ( f, m->type3, m->alphanum3, m );
101 }
102
103 if ( m->alphanum4[0] ) //TTDD
104 {
105 print_csv_alphanum ( f, m->type4, m->alphanum4, m );
106 }
107
108 return 0;
109}
int print_csv_alphanum(FILE *f, char *type, char *alphanum, struct metreport *m)
Definition: bufr2tac_csv.c:26
char alphanum3[REPORT_LENGTH]
Definition: bufr2tac.h:325
char alphanum2[REPORT_LENGTH]
Definition: bufr2tac.h:323
char alphanum4[REPORT_LENGTH]
Definition: bufr2tac.h:327

References metreport::alphanum, metreport::alphanum2, metreport::alphanum3, metreport::alphanum4, print_csv_alphanum(), metreport::type, metreport::type2, metreport::type3, and metreport::type4.

Referenced by main().

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

◆ print_geo()

size_t print_geo ( char **  geo,
size_t  lmax,
struct metreport m 
)

Definition at line 71 of file bufr2tac_print.c.

72{
73 size_t used;
74 char sep = '|';
75
76 used = snprintf(*geo, lmax, "%8.4lf %9.4lf %6.1lf%c", m->g.lat, m->g.lon, m->g.alt, sep);
77 *geo += used;
78 return used;
79}

References met_geo::alt, metreport::g, met_geo::lat, and met_geo::lon.

Referenced by print_buoy_report(), print_climat_report(), print_synop_report(), print_temp_a(), print_temp_b(), print_temp_c(), and print_temp_d().

Here is the caller graph for this function:

◆ print_html()

int print_html ( FILE *  f,
struct metreport m 
)

Print in a file the report decoded to Traditional Alphanumeric Code in plain html format. A line per report.

Parameters
fpointer to file where to write to
mpointer to struct metreport where the decoded report is stored

Definition at line 51 of file bufr2tac_print.c.

52{
53 fprintf(f, "<pre>");
54 if ( m->alphanum[0] )
55 fprintf ( f, "%s\n", m->alphanum );
56 if ( m->alphanum2[0] )
57 fprintf ( f, "%s\n", m->alphanum2 );
58 if ( m->alphanum3[0] )
59 fprintf ( f, "%s\n", m->alphanum3 );
60 if ( m->alphanum4[0] )
61 fprintf ( f, "%s\n", m->alphanum4 );
62 fprintf(f, "</pre>");
63 return 0;
64}

References metreport::alphanum, metreport::alphanum2, metreport::alphanum3, and metreport::alphanum4.

Referenced by main().

Here is the caller graph for this function:

◆ print_json()

int print_json ( FILE *  f,
struct metreport m 
)

prints a struct metreport in json format

Parameters
fpointer to a file already open by caller routine
mpointer to a struct metreport containing the data to print

Definition at line 62 of file bufr2tac_json.c.

63{
64 fprintf ( f, "{\"metreport\" :" );
65 if ( m->alphanum[0] )
66 {
67 print_json_alphanum ( f, m->type, m->alphanum, m );
68 }
69
70 if ( m->alphanum2[0] ) //TTBB
71 {
72 fprintf ( f, "," );
73 print_json_alphanum ( f, m->type2, m->alphanum2, m );
74 }
75
76 if ( m->alphanum3[0] ) //TTCC
77 {
78 fprintf ( f, "," );
79 print_json_alphanum ( f, m->type3, m->alphanum3, m );
80 }
81 if ( m->alphanum4[0] ) //TTDD
82 {
83 fprintf ( f, "," );
84 print_json_alphanum ( f, m->type4, m->alphanum4, m );
85 }
86
87 fprintf ( f, "\n}\n" );
88 return 0;
89}
int print_json_alphanum(FILE *f, char *type, char *alphanum, struct metreport *m)
Definition: bufr2tac_json.c:26

References metreport::alphanum, metreport::alphanum2, metreport::alphanum3, metreport::alphanum4, print_json_alphanum(), metreport::type, metreport::type2, metreport::type3, and metreport::type4.

Referenced by main().

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

◆ print_plain()

int print_plain ( FILE *  f,
struct metreport m 
)

Print in a file the report decoded to Traditional Alphanumeric Code in plain text format. A line per report.

Parameters
fpointer to file where to write to
mpointer to struct metreport where the decoded report is stored

Definition at line 32 of file bufr2tac_print.c.

33{
34 if ( m->alphanum[0] )
35 fprintf ( f, "%s\n", m->alphanum );
36 if ( m->alphanum2[0] )
37 fprintf ( f, "%s\n", m->alphanum2 );
38 if ( m->alphanum3[0] )
39 fprintf ( f, "%s\n", m->alphanum3 );
40 if ( m->alphanum4[0] )
41 fprintf ( f, "%s\n", m->alphanum4 );
42 return 0;
43}

References metreport::alphanum, metreport::alphanum2, metreport::alphanum3, and metreport::alphanum4.

Referenced by main().

Here is the caller graph for this function:

◆ print_synop_report()

int print_synop_report ( struct metreport m)

prints a synop into a string

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 825 of file bufr2tac_print_synop.c.

826{
827 char *c = &(m->alphanum[0]);
828 size_t used = 0;
829 size_t lmax = sizeof(m->alphanum);
830 struct synop_chunks *syn = &m->synop;
831
832 // Needs time extension
833 if ( syn->e.YYYY[0] == 0 || syn->e.YYYY[0] == '0' )
834 {
835 return 1;
836 }
837
839 {
840 used += print_wigos_id ( &c, lmax, m );
841 }
842 else
843 {
844 // Do not print a synop if no IIiii identifier when mode = 0
845 if ( ( strcmp(syn->s0.MiMi, "AA") == 0 && strcmp(syn->s0.MjMj, "XX") == 0) &&
846 ( syn->s0.II[0] == '\0' || syn->s0.iii[0] == '\0' || strcmp ( syn->s0.II, "00" ) == 0 ))
847 return 1;
848 }
849
850 if ( m->print_mask & PRINT_BITMASK_GEO )
851 {
852 used += print_geo ( &c, lmax, m );
853 }
854
855 used += print_synop_sec0 ( &c, lmax - used, syn );
856
857 if ( syn->mask & ( SYNOP_SEC1 | SYNOP_SEC2 | SYNOP_SEC3 | SYNOP_SEC4 | SYNOP_SEC5 ) )
858 {
859 used += print_synop_sec1 ( &c, lmax - used, syn );
860
861 used += print_synop_sec2 ( &c, lmax - used, syn );
862
863 used += print_synop_sec3 ( &c, lmax - used, syn );
864
865 used += print_synop_sec4 ( &c, lmax - used, syn );
866
867 used += print_synop_sec5 ( &c, lmax - used, syn );
868 }
869 else
870 {
871 c += snprintf ( c, lmax - used, " NIL" );
872 }
873 snprintf ( c, lmax - used - 1, "=" );
874
875 return 0;
876}
size_t print_synop_sec0(char **sec0, size_t lmax, struct synop_chunks *syn)
Prints the synop section 0 (header)
size_t print_synop_sec2(char **sec2, size_t lmax, struct synop_chunks *syn)
Prints the synop section 2.
size_t print_synop_sec1(char **sec1, size_t lmax, struct synop_chunks *syn)
Prints the synop section 1.
size_t print_synop_sec5(char **sec5, size_t lmax, struct synop_chunks *syn)
Prints the synop section 5.
size_t print_synop_sec3(char **sec3, size_t lmax, struct synop_chunks *syn)
Prints the synop section 3.
size_t print_synop_sec4(char **sec4, size_t lmax, struct synop_chunks *syn)
Prints the synop section 4.
#define SYNOP_SEC5
mask bit meaning section 5 or synop is solicited to or parsed with success
Definition: metsynop.h:59
#define SYNOP_SEC4
mask bit meaning section 4 or synop is solicited to or parsed with success
Definition: metsynop.h:54

References metreport::alphanum, synop_chunks::e, synop_sec0::II, synop_sec0::iii, synop_chunks::mask, synop_sec0::MiMi, synop_sec0::MjMj, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_geo(), metreport::print_mask, print_synop_sec0(), print_synop_sec1(), print_synop_sec2(), print_synop_sec3(), print_synop_sec4(), print_synop_sec5(), print_wigos_id(), synop_chunks::s0, metreport::synop, SYNOP_SEC1, SYNOP_SEC2, SYNOP_SEC3, SYNOP_SEC4, SYNOP_SEC5, and report_date_ext::YYYY.

Referenced by parse_subset_sequence().

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

◆ print_synop_sec0()

size_t print_synop_sec0 ( char **  sec0,
size_t  lmax,
struct synop_chunks syn 
)

Prints the synop section 0 (header)

Parameters
sec0the pointer where to print section
lmaxmax length permited
synpointer to s atruct synop_chunks where the parse results are set
Returns
Used bytes

Definition at line 34 of file bufr2tac_print_synop.c.

35{
36 char *c = *sec0;
37 size_t used = 0;
38
39 used += snprintf ( c + used, lmax - used, "%s%s%s%s%s", syn->e.YYYY, syn->e.MM, syn->e.DD, syn->e.HH, syn->e.mm );
40
41 // Print type
42 used += snprintf ( c + used, lmax - used, " %s%s", syn->s0.MiMi, syn->s0.MjMj );
43
44 if ( syn->s0.D_D[0] )
45 {
46 used += snprintf ( c + used, lmax - used, " %s", syn->s0.D_D );
47 }
48 else if ( syn->s0.A1[0] && syn->s0.bw[0] && syn->s0.nbnbnb[0] )
49 {
50 used += snprintf ( c + used, lmax - used, " %s%s%s", syn->s0.A1, syn->s0.bw, syn->s0.nbnbnb );
51 }
52
53
54 // print YYGGiw
55 used += snprintf ( c + used, lmax - used, " %s%s%s", syn->s0.YY, syn->s0.GG, syn->s0.iw );
56
57 // print IIiii
58 if ( syn->s0.II[0] )
59 {
60 used += snprintf ( c + used, lmax - used, " %s%s", syn->s0.II, syn->s0.iii );
61 }
62 else
63 {
64 if ( syn->s0.LaLaLa[0] )
65 {
66 used += snprintf ( c + used, lmax - used, " 99%s", syn->s0.LaLaLa );
67 }
68 else
69 {
70 used += snprintf ( c + used, lmax - used, " 99///" );
71 }
72
73 if ( syn->s0.Qc[0] && syn->s0.LoLoLoLo[0] )
74 {
75 used += snprintf ( c + used, lmax - used, " %s%s", syn->s0.Qc, syn->s0.LoLoLoLo );
76 }
77 else
78 {
79 used += snprintf ( c + used, lmax - used, " /////" );
80 }
81 }
82
83 if ( strcmp ( syn->s0.MiMi, "OO" ) == 0 )
84 {
85 if ( syn->s0.MMM[0] && syn->s0.Ula[0] && syn->s0.Ulo[0] )
86 {
87 used += snprintf ( c + used, lmax - used, " %s%s%s", syn->s0.MMM, syn->s0.Ula, syn->s0.Ulo );
88 }
89 if ( syn->s0.h0h0h0h0[0] )
90 {
91 used += snprintf ( c + used, lmax - used, " %s%s", syn->s0.h0h0h0h0, syn->s0.im );
92 }
93
94 }
95
96 *sec0 = c + used;
97 return used;
98}
char nbnbnb[4]
Definition: metsynop.h:96
char LaLaLa[4]
Definition: metsynop.h:105
char Qc[2]
Definition: metsynop.h:106
char h0h0h0h0[6]
Definition: metsynop.h:111
char GG[4]
Definition: metsynop.h:99
char LoLoLoLo[6]
Definition: metsynop.h:107
char im[2]
Definition: metsynop.h:112
char YY[4]
Definition: metsynop.h:98
char bw[2]
Definition: metsynop.h:95
char Ulo[2]
Definition: metsynop.h:110
char Ula[2]
Definition: metsynop.h:109
char MMM[4]
Definition: metsynop.h:108

References synop_sec0::A1, synop_sec0::bw, synop_sec0::D_D, report_date_ext::DD, synop_chunks::e, synop_sec0::GG, synop_sec0::h0h0h0h0, report_date_ext::HH, synop_sec0::II, synop_sec0::iii, synop_sec0::im, synop_sec0::iw, synop_sec0::LaLaLa, synop_sec0::LoLoLoLo, synop_sec0::MiMi, synop_sec0::MjMj, report_date_ext::MM, report_date_ext::mm, synop_sec0::MMM, synop_sec0::nbnbnb, synop_sec0::Qc, synop_chunks::s0, synop_sec0::Ula, synop_sec0::Ulo, synop_sec0::YY, and report_date_ext::YYYY.

Referenced by print_synop_report().

Here is the caller graph for this function:

◆ print_synop_sec1()

size_t print_synop_sec1 ( char **  sec1,
size_t  lmax,
struct synop_chunks syn 
)

Prints the synop section 1.

Parameters
sec1the pointer where to print section
lmaxmax length permited
synpointer to s atruct synop_chunks where the parse results are set
Returns
Used bytes

Definition at line 108 of file bufr2tac_print_synop.c.

109{
110 char *c = *sec1;
111 size_t used = 0;
112
113 if ( syn->mask & SYNOP_SEC1 )
114 {
115 // printf irixhVV
116 used += snprintf ( c + used, lmax - used, " %s%s%s%s", syn->s1.ir, syn->s1.ix, syn->s1.h, syn->s1.VV );
117
118
119 // printf Nddff
120 used += snprintf ( c + used, lmax - used, " %s%s%s", syn->s1.N, syn->s1.dd, syn->s1.ff );
121 if ( strlen ( syn->s1.fff ) )
122 {
123 used += snprintf ( c + used, lmax - used, " 00%s", syn->s1.fff );
124 }
125
126 // printf 1snTTT
127
128 if ( syn->s1.TTT[0] )
129 {
130 used += snprintf ( c + used, lmax - used, " 1%s%s", syn->s1.sn1, syn->s1.TTT );
131 }
132
133 // printf 2snTdTdTd or 29UUU
134 if ( syn->s1.TdTdTd[0] )
135 {
136 used += snprintf ( c + used, lmax - used, " 2%s%s", syn->s1.sn2, syn->s1.TdTdTd );
137 }
138 else if ( syn->s1.UUU[0] )
139 {
140 used += snprintf ( c + used, lmax - used, " 29%s", syn->s1.UUU );
141 }
142
143 // printf 3PoPoPoPo
144 if ( syn->s1.PoPoPoPo[0] )
145 {
146 used += snprintf ( c + used, lmax - used, " 3%s", syn->s1.PoPoPoPo );
147 }
148
149 // printf 4PPPP or 4a3hhh
150 if ( syn->s1.PPPP[0] )
151 {
152 used += snprintf ( c + used, lmax - used, " 4%s", syn->s1.PPPP );
153 }
154 else if ( syn->s1.hhh[0] )
155 {
156 if ( syn->s1.a3[0] == 0 )
157 {
158 syn->s1.a3[0] = '/';
159 }
160 used += snprintf ( c + used, lmax - used, " 4%s%s", syn->s1.a3, syn->s1.hhh );
161 }
162
163 // printf 5appp
164 if ( syn->s1.a[0] || syn->s1.ppp[0] )
165 {
166 if ( syn->s1.a[0] == 0 )
167 {
168 syn->s1.a[0] = '/';
169 }
170 if ( syn->s1.ppp[0] == 0 )
171 {
172 strcpy ( syn->s1.ppp, "///" );
173 }
174 used += snprintf ( c + used, lmax - used, " 5%s%s", syn->s1.a, syn->s1.ppp );
175 }
176
177 // printf 6RRRtr
178 if ( syn->s1.tr[0] || syn->s1.RRR[0] )
179 {
180 if ( syn->s1.tr[0] == 0 )
181 {
182 syn->s1.tr[0] = '/';
183 }
184 if ( syn->s1.RRR[0] == 0 )
185 {
186 strcpy ( syn->s1.RRR, "///" );
187 }
188 used += snprintf ( c + used, lmax - used, " 6%s%s", syn->s1.RRR, syn->s1.tr );
189 }
190
191 if ( syn->s1.ww[0] || syn->s1.W1[0] || syn->s1.W2[0] )
192 {
193 if ( syn->s1.ww[0] == 0 )
194 {
195 strcpy ( syn->s1.ww, "//" );
196 }
197 if ( syn->s1.W1[0] == 0 )
198 {
199 strcpy ( syn->s1.W1, "/" );
200 }
201 if ( syn->s1.W2[0] == 0 )
202 {
203 strcpy ( syn->s1.W2, "/" );
204 }
205 used += snprintf ( c + used, lmax - used, " 7%s%s%s", syn->s1.ww, syn->s1.W1, syn->s1.W2 );
206 }
207
208 if ( ( syn->s1.Nh[0] && syn->s1.Nh[0] != '0' && syn->s1.Nh[0] != '/' ) ||
209 ( syn->s1.Cl[0] && syn->s1.Cl[0] != '0' && syn->s1.Cl[0] != '/' ) ||
210 ( syn->s1.Cm[0] && syn->s1.Cm[0] != '0' && syn->s1.Cm[0] != '/' ) ||
211 ( syn->s1.Ch[0] && syn->s1.Ch[0] != '0' && syn->s1.Ch[0] != '/' ) )
212 {
213 if ( syn->s1.Nh[0] == 0 )
214 {
215 strcpy ( syn->s1.Nh, "/" );
216 }
217 if ( syn->s1.Cl[0] == 0 )
218 {
219 strcpy ( syn->s1.Cl, "/" );
220 }
221 if ( syn->s1.Cm[0] == 0 )
222 {
223 strcpy ( syn->s1.Cm, "/" );
224 }
225 if ( syn->s1.Ch[0] == 0 )
226 {
227 strcpy ( syn->s1.Ch, "/" );
228 }
229 used += snprintf ( c + used, lmax - used, " 8%s%s%s%s", syn->s1.Nh, syn->s1.Cl, syn->s1.Cm, syn->s1.Ch );
230 }
231
232 if ( syn->s1.GG[0] )
233 {
234 used += snprintf ( c + used, lmax - used, " 9%s%s", syn->s1.GG, syn->s1.gg );
235 }
236 }
237 *sec1 = c + used;
238 return used;
239}
char Cl[2]
Definition: metsynop.h:149
char UUU[4]
Definition: metsynop.h:135
char Ch[2]
Definition: metsynop.h:151
char PoPoPoPo[6]
Definition: metsynop.h:136
char fff[4]
Definition: metsynop.h:130
char hhh[4]
Definition: metsynop.h:139
char h[2]
Definition: metsynop.h:125
char sn1[2]
Definition: metsynop.h:131
char PPPP[6]
Definition: metsynop.h:137
char tr[2]
Definition: metsynop.h:143
char N[2]
Definition: metsynop.h:127
char a[2]
Definition: metsynop.h:140
char VV[4]
Definition: metsynop.h:126
char Cm[2]
Definition: metsynop.h:150
char sn2[2]
Definition: metsynop.h:133
char ppp[4]
Definition: metsynop.h:141
char Nh[2]
Definition: metsynop.h:148
char TdTdTd[4]
Definition: metsynop.h:134
char a3[2]
Definition: metsynop.h:138
char dd[4]
Definition: metsynop.h:128
char TTT[4]
Definition: metsynop.h:132

References synop_sec1::a, synop_sec1::a3, synop_sec1::Ch, synop_sec1::Cl, synop_sec1::Cm, synop_sec1::dd, synop_sec1::ff, synop_sec1::fff, synop_sec1::GG, synop_sec1::gg, synop_sec1::h, synop_sec1::hhh, synop_sec1::ir, synop_sec1::ix, synop_chunks::mask, synop_sec1::N, synop_sec1::Nh, synop_sec1::PoPoPoPo, synop_sec1::ppp, synop_sec1::PPPP, synop_sec1::RRR, synop_chunks::s1, synop_sec1::sn1, synop_sec1::sn2, SYNOP_SEC1, synop_sec1::TdTdTd, synop_sec1::tr, synop_sec1::TTT, synop_sec1::UUU, synop_sec1::VV, synop_sec1::W1, synop_sec1::W2, and synop_sec1::ww.

Referenced by print_synop_report().

Here is the caller graph for this function:

◆ print_synop_sec2()

size_t print_synop_sec2 ( char **  sec2,
size_t  lmax,
struct synop_chunks syn 
)

Prints the synop section 2.

Parameters
sec2the pointer where to print section
lmaxmax length permited
synpointer to s atruct synop_chunks where the parse results are set
Returns
Used bytes

Definition at line 250 of file bufr2tac_print_synop.c.

251{
252 char *c = *sec2;
253 size_t used = 0;
254
255 if ( syn->mask & SYNOP_SEC2 )
256 {
257 // 222Dsvs
258 used += snprintf ( c + used, lmax - used, " 222" );
259 if ( syn->s2.Ds[0] )
260 {
261 used += snprintf ( c + used, lmax - used, "%s", syn->s2.Ds );
262 }
263 else
264 {
265 used += snprintf ( c + used, lmax - used, "/" );
266 }
267
268 if ( syn->s2.vs[0] )
269 {
270 used += snprintf ( c + used, lmax - used, "%s", syn->s2.vs );
271 }
272 else
273 {
274 used += snprintf ( c + used, lmax - used, "/" );
275 }
276
277 // printf 0ssTwTwTw
278 if ( syn->s2.TwTwTw[0] )
279 {
280 used += snprintf ( c + used, lmax - used, " 0%s%s", syn->s2.ss, syn->s2.TwTwTw );
281 }
282
283 if ( syn->s2.PwaPwa[0] || syn->s2.HwaHwa[0] )
284 {
285 if ( syn->s2.PwaPwa[0] )
286 {
287 used += snprintf ( c + used, lmax - used, " 1%s", syn->s2.PwaPwa );
288 }
289 else
290 {
291 used += snprintf ( c + used, lmax - used, " 1//" );
292 }
293
294 if ( syn->s2.HwaHwa[0] )
295 {
296 used += snprintf ( c + used, lmax - used, "%s", syn->s2.HwaHwa );
297 }
298 else
299 {
300 used += snprintf ( c + used, lmax - used, "//" );
301 }
302 }
303
304 if ( syn->s2.PwPw[0] || syn->s2.HwHw[0] )
305 {
306 if ( syn->s2.PwPw[0] )
307 {
308 used += snprintf ( c + used, lmax - used, " 2%s", syn->s2.PwPw );
309 }
310 else
311 {
312 used += snprintf ( c + used, lmax - used, " 2//" );
313 }
314
315 if ( syn->s2.HwHw[0] )
316 {
317 used += snprintf ( c + used, lmax - used, "%s", syn->s2.HwHw );
318 }
319 else
320 {
321 used += snprintf ( c + used, lmax - used, "//" );
322 }
323 }
324
325 if ( syn->s2.dw1dw1[0] || syn->s2.dw2dw2[0] )
326 {
327 if ( syn->s2.dw1dw1[0] )
328 {
329 used += snprintf ( c + used, lmax - used, " 3%s", syn->s2.dw1dw1 );
330 }
331 else
332 {
333 used += snprintf ( c + used, lmax - used, " 3//" );
334 }
335
336 if ( syn->s2.dw2dw2[0] )
337 {
338 used += snprintf ( c + used, lmax - used, "%s", syn->s2.dw2dw2 );
339 }
340 else
341 {
342 used += snprintf ( c + used, lmax - used, "//" );
343 }
344 }
345
346 if ( syn->s2.Pw1Pw1[0] || syn->s2.Hw1Hw1[0] )
347 {
348 if ( syn->s2.Pw1Pw1[0] )
349 {
350 used += snprintf ( c + used, lmax - used, " 4%s", syn->s2.Pw1Pw1 );
351 }
352 else
353 {
354 used += snprintf ( c + used, lmax - used, " 4//" );
355 }
356
357 if ( syn->s2.Hw1Hw1[0] )
358 {
359 used += snprintf ( c + used, lmax - used, "%s", syn->s2.Hw1Hw1 );
360 }
361 else
362 {
363 used += snprintf ( c + used, lmax - used, "//" );
364 }
365 }
366
367
368 if ( syn->s2.Pw2Pw2[0] || syn->s2.Hw2Hw2[0] )
369 {
370 if ( syn->s2.Pw2Pw2[0] )
371 {
372 used += snprintf ( c + used, lmax - used, " 5%s", syn->s2.Pw2Pw2 );
373 }
374 else
375 {
376 used += snprintf ( c + used, lmax - used, " 5//" );
377 }
378
379 if ( syn->s2.Hw2Hw2[0] )
380 {
381 used += snprintf ( c + used, lmax - used, "%s", syn->s2.Hw2Hw2 );
382 }
383 else
384 {
385 used += snprintf ( c + used, lmax - used, "//" );
386 }
387 }
388
389 if ( syn->s2.HwaHwaHwa[0] )
390 {
391 used += snprintf ( c + used, lmax - used, " 70%s", syn->s2.HwaHwaHwa );
392 }
393
394
395 if ( syn->s2.TbTbTb[0] )
396 {
397 used += snprintf ( c + used, lmax - used, " 8%s%s", syn->s2.sw, syn->s2.TbTbTb );
398 }
399
400 }
401 *sec2 = c + used;
402 return used;
403}
struct synop_sec2 s2
Definition: metsynop.h:299
char TwTwTw[6]
Definition: metsynop.h:168
char HwaHwaHwa[6]
Definition: metsynop.h:180
char Hw1Hw1[4]
Definition: metsynop.h:176
char Pw2Pw2[4]
Definition: metsynop.h:177
char PwaPwa[4]
Definition: metsynop.h:169
char dw2dw2[4]
Definition: metsynop.h:174
char vs[2]
Definition: metsynop.h:166
char HwHw[4]
Definition: metsynop.h:172
char TbTbTb[6]
Definition: metsynop.h:182
char HwaHwa[4]
Definition: metsynop.h:170
char dw1dw1[4]
Definition: metsynop.h:173
char ss[2]
Definition: metsynop.h:167
char sw[2]
Definition: metsynop.h:181
char Ds[2]
Definition: metsynop.h:165
char PwPw[4]
Definition: metsynop.h:171
char Hw2Hw2[4]
Definition: metsynop.h:178
char Pw1Pw1[4]
Definition: metsynop.h:175

References synop_sec2::Ds, synop_sec2::dw1dw1, synop_sec2::dw2dw2, synop_sec2::Hw1Hw1, synop_sec2::Hw2Hw2, synop_sec2::HwaHwa, synop_sec2::HwaHwaHwa, synop_sec2::HwHw, synop_chunks::mask, synop_sec2::Pw1Pw1, synop_sec2::Pw2Pw2, synop_sec2::PwaPwa, synop_sec2::PwPw, synop_chunks::s2, synop_sec2::ss, synop_sec2::sw, SYNOP_SEC2, synop_sec2::TbTbTb, synop_sec2::TwTwTw, and synop_sec2::vs.

Referenced by print_synop_report().

Here is the caller graph for this function:

◆ print_synop_sec3()

size_t print_synop_sec3 ( char **  sec3,
size_t  lmax,
struct synop_chunks syn 
)

Prints the synop section 3.

Parameters
sec3the pointer where to print section
lmaxmax length permited
synpointer to s atruct synop_chunks where the parse results are set
Returns
Used bytes

Definition at line 413 of file bufr2tac_print_synop.c.

414{
415 size_t i;
416 char *c = *sec3;
417 size_t used = 0, used0;
418
419 if ( syn->mask & SYNOP_SEC3 )
420 {
421 used += snprintf ( c + used, lmax - used, " 333" );
422
423 // init point to write info.
424 // in case we finally write nothing in this section
425 used0 = used;
426
427 // printf 0XoXoXoXo
428 if ( syn->s3.XoXoXoXo[0] && ( strstr ( syn->s3.XoXoXoXo,"///" ) == NULL ) )
429 {
430 if ( syn->s3.XoXoXoXo[0] == 0 )
431 {
432 syn->s3.XoXoXoXo[0] = '/';
433 }
434 if ( syn->s3.XoXoXoXo[1] == 0 )
435 {
436 syn->s3.XoXoXoXo[1] = '/';
437 }
438 if ( syn->s3.XoXoXoXo[2] == 0 )
439 {
440 syn->s3.XoXoXoXo[2] = '/';
441 }
442 if ( syn->s3.XoXoXoXo[3] == 0 )
443 {
444 syn->s3.XoXoXoXo[3] = '/';
445 }
446 used += snprintf ( c + used, lmax - used, " 0%s", syn->s3.XoXoXoXo );
447 }
448
449 // printf 1snxTxTxTx
450 if ( syn->s3.snx[0] )
451 {
452 used += snprintf ( c + used, lmax - used, " 1%s%s", syn->s3.snx, syn->s3.TxTxTx );
453 }
454
455 // printf 1snnTnTnTn
456 if ( syn->s3.snn[0] )
457 {
458 used += snprintf ( c + used, lmax - used, " 2%s%s", syn->s3.snn, syn->s3.TnTnTn );
459 }
460
461 // printf 3Ejjj
462 if ( syn->s3.E[0] || syn->s3.jjj[0] )
463 {
464 if ( syn->s3.E[0] == 0 )
465 {
466 syn->s3.E[0] = '/';
467 }
468 if ( syn->s3.jjj[0] == 0 )
469 {
470 strcpy ( syn->s3.jjj, "///" );
471 }
472 used += snprintf ( c + used, lmax - used, " 3%s%s", syn->s3.E, syn->s3.jjj );
473 }
474
475 // printf 4E1sss
476 if ( syn->s3.E1[0] || syn->s3.sss[0] )
477 {
478 if ( syn->s3.E1[0] == 0 )
479 {
480 syn->s3.E1[0] = '/';
481 }
482 if ( syn->s3.sss[0] == 0 )
483 {
484 strcpy ( syn->s3.sss, "///" );
485 }
486 if ( syn->s3.E1[0] != '/' || strcmp ( syn->s3.sss, "999" ) )
487 {
488 used += snprintf ( c + used, lmax - used, " 4%s%s", syn->s3.E1, syn->s3.sss );
489 }
490 }
491
492 /**** Radiation Sunshine gropus ***/
493
494 // print 55SSS
495 if ( syn->s3.SSS[0] )
496 {
497 if ( strcmp ( syn->s3.SSS, "///" ) )
498 {
499 used += snprintf ( c + used, lmax - used, " 55%s", syn->s3.SSS );
500 }
501 else if ( syn->s3.j524[0][0] || syn->s3.j524[1][0] ||
502 syn->s3.j524[2][0] || syn->s3.j524[3][0] ||
503 syn->s3.j524[4][0] || syn->s3.j524[5][0] ||
504 syn->s3.j524[6][0] )
505 {
506 used += snprintf ( c + used, lmax - used, " 55%s", syn->s3.SSS );
507 }
508
509 for ( i = 0; i < 7; i++ )
510 {
511 if ( syn->s3.j524[i][0] )
512 {
513 used += snprintf ( c + used, lmax - used, " %s%s", syn->s3.j524[i], syn->s3.FFFF24[i] );
514 }
515 }
516 }
517
518 // print 553SS
519 if ( syn->s3.SS[0] )
520 {
521 if ( strcmp ( syn->s3.SS, "//" ) )
522 {
523 used += snprintf ( c + used, lmax - used, " 553%s", syn->s3.SS );
524 }
525 else if ( syn->s3.j5[0][0] || syn->s3.j5[1][0] ||
526 syn->s3.j5[2][0] || syn->s3.j5[3][0] ||
527 syn->s3.j5[4][0] || syn->s3.j5[5][0] ||
528 syn->s3.j5[6][0] )
529 {
530 used += snprintf ( c + used, lmax - used, " 553%s", syn->s3.SS );
531 }
532
533 for ( i = 0; i < 7; i++ )
534 {
535 if ( syn->s3.j5[i][0] )
536 {
537 used += snprintf ( c + used, lmax - used, " %s%s", syn->s3.j5[i], syn->s3.FFFF[i] );
538 }
539 }
540 }
541
542 // print 55407
543 if ( syn->s3.FFFF407[0] )
544 {
545 used += snprintf ( c + used, lmax - used, " 55407 4%s", syn->s3.FFFF407 );
546 }
547
548 // print 55408
549 if ( syn->s3.FFFF408[0] )
550 {
551 used += snprintf ( c + used, lmax - used, " 55408 4%s", syn->s3.FFFF408 );
552 }
553
554 // print 55507
555 if ( syn->s3.FFFF507[0] )
556 {
557 used += snprintf ( c + used, lmax - used, " 55507 4%s", syn->s3.FFFF507 );
558 }
559
560 // print 55507
561 if ( syn->s3.FFFF508[0] )
562 {
563 used += snprintf ( c + used, lmax - used, " 55508 4%s", syn->s3.FFFF508 );
564 }
565
566 // print 56DlDmDh
567 if ( syn->s3.Dl[0] || syn->s3.Dm[0] || syn->s3.Dh[0] )
568 {
569 if ( syn->s3.Dl[0] == 0 )
570 {
571 syn->s3.Dl[0] = '/';
572 }
573 if ( syn->s3.Dm[0] == 0 )
574 {
575 syn->s3.Dm[0] = '/';
576 }
577 if ( syn->s3.Dh[0] == 0 )
578 {
579 syn->s3.Dh[0] = '/';
580 }
581
582 used += snprintf ( c + used, lmax - used, " 56%s%s%s", syn->s3.Dl, syn->s3.Dm, syn->s3.Dh );
583 }
584
585 // print 57CDeec
586 if ( syn->s3.Da[0] || syn->s3.ec[0] )
587 {
588 if ( syn->s3.Da[0] == 0 )
589 {
590 syn->s3.Da[0] = '/';
591 }
592 if ( syn->s3.ec[0] == 0 )
593 {
594 syn->s3.ec[0] = '/';
595 }
596
597 used += snprintf ( c + used, lmax - used, " 57%s%s%s", syn->s3.C, syn->s3.Da, syn->s3.ec );
598 }
599
600 // print 58ppp24 or 59ppo24
601 if ( syn->s3.ppp24[0] )
602 {
603 used += snprintf ( c + used, lmax - used, " 5%s%s", syn->s3.snp24, syn->s3.ppp24 );
604 }
605
606 // printf 6RRRtr
607 if ( syn->s3.tr[0] || syn->s3.RRR[0] )
608 {
609 if ( syn->s3.tr[0] == 0 )
610 {
611 syn->s3.tr[0] = '/';
612 }
613 if ( syn->s3.RRR[0] == 0 )
614 {
615 strcpy ( syn->s3.RRR, "///" );
616 }
617 used += snprintf ( c + used, lmax - used, " 6%s%s", syn->s3.RRR,syn->s3.tr );
618 }
619
620 if ( syn->s3.RRRR24[0] )
621 {
622 used += snprintf ( c + used, lmax - used, " 7%s", syn->s3.RRRR24 );
623 }
624
625 // additional cloud layers
626 for ( i = 0; i < 4 ; i++ )
627 {
628 if ( syn->s3.nub[i].hshs[0] )
629 {
630 if ( syn->s3.nub[i].Ns[0] == 0 && syn->s3.nub[i].C[0] == 0 )
631 {
632 used += snprintf ( c + used, lmax - used, " 8//%s", syn->s3.nub[i].hshs ); // Detected cloud but no anymore info
633 }
634 else
635 {
636 used += snprintf ( c + used, lmax - used, " 8" );
637 if ( syn->s3.nub[i].Ns[0] )
638 {
639 used += snprintf ( c + used, lmax - used, "%s", syn->s3.nub[i].Ns );
640 }
641 else
642 {
643 used += snprintf ( c + used, lmax - used, "/" );
644 }
645
646 if ( syn->s3.nub[i].C[0] )
647 {
648 used += snprintf ( c + used, lmax - used, "%s", syn->s3.nub[i].C );
649 }
650 else
651 {
652 used += snprintf ( c + used, lmax - used, "/" );
653 }
654
655 used += snprintf ( c + used, lmax - used, "%s", syn->s3.nub[i].hshs );
656
657 }
658 }
659 }
660
661 // additional info
662 for ( i = 0; i < syn->s3.d9.n && i < SYNOP_NMISC ; i++ )
663 {
664 if ( syn->s3.d9.misc[i].SpSp[0] && syn->s3.d9.misc[i].spsp[0] )
665 {
666 used += snprintf ( c + used, lmax - used, " %s%s", syn->s3.d9.misc[i].SpSp, syn->s3.d9.misc[i].spsp );
667 }
668 }
669
670
671 // aditional regional info
672 if ( syn->mask & SYNOP_SEC3_8 )
673 {
674 used += snprintf ( c + used, lmax - used, " 80000" );
675 for ( i = 0; i < SYNOP_NMISC; i++ )
676 {
677 if ( syn->s3.R8[i][0] || syn->s3.R8[i][0] || syn->s3.R8[i][0] || syn->s3.R8[i][0] )
678 {
679 if ( syn->s3.R8[i][0] == 0 )
680 {
681 syn->s3.R8[i][0] = '/';
682 }
683 if ( syn->s3.R8[i][1] == 0 )
684 {
685 syn->s3.R8[i][1] = '/';
686 }
687 if ( syn->s3.R8[i][2] == 0 )
688 {
689 syn->s3.R8[i][2] = '/';
690 }
691 if ( syn->s3.R8[i][3] == 0 )
692 {
693 syn->s3.R8[i][3] = '/';
694 }
695 used += snprintf ( c + used, lmax - used, " %ld%s", i, syn->s3.R8[i] );
696 }
697 }
698 }
699
700 if ( used != used0 )
701 {
702 *sec3 = c + used;
703 }
704 else
705 used = 0;
706
707 }
708 return used;
709}
#define SYNOP_SEC3_8
mask bit meaning optional/regional 8 part, section 3 for synop is solicited to or parsed with success
Definition: metsynop.h:69
#define SYNOP_NMISC
number of misc3 struct to store the parsed results of 9SpSpspsp groups
Definition: metsynop.h:84
struct misc3 misc[SYNOP_NMISC]
Definition: metsynop.h:210
size_t n
Definition: metsynop.h:209
char spsp[4]
Definition: metsynop.h:204
char SpSp[4]
Definition: metsynop.h:203
char hshs[4]
Definition: metsynop.h:194
char Ns[2]
Definition: metsynop.h:192
char C[2]
Definition: metsynop.h:193
char Dh[2]
Definition: metsynop.h:249
char TnTnTn[4]
Definition: metsynop.h:226
char E[2]
Definition: metsynop.h:227
char Da[2]
Definition: metsynop.h:251
char FFFF408[6]
Definition: metsynop.h:240
char snp24[2]
Definition: metsynop.h:253
char XoXoXoXo[6]
Definition: metsynop.h:222
char tr[2]
Definition: metsynop.h:256
char ec[2]
Definition: metsynop.h:252
char TxTxTx[4]
Definition: metsynop.h:224
char Dl[2]
Definition: metsynop.h:247
char FFFF[7][6]
Definition: metsynop.h:244
char FFFF507[6]
Definition: metsynop.h:241
char R8[SYNOP_NMISC][6]
Definition: metsynop.h:258
struct nub3 nub[SYNOP_NNUB]
Definition: metsynop.h:259
char sss[4]
Definition: metsynop.h:230
struct data9 d9
Definition: metsynop.h:260
char C[2]
Definition: metsynop.h:250
char FFFF407[6]
Definition: metsynop.h:239
char Dm[2]
Definition: metsynop.h:248
char ppp24[4]
Definition: metsynop.h:254
char snn[2]
Definition: metsynop.h:225
char E1[2]
Definition: metsynop.h:229
char FFFF24[7][6]
Definition: metsynop.h:246
char snx[2]
Definition: metsynop.h:223
char FFFF508[6]
Definition: metsynop.h:242
char jjj[4]
Definition: metsynop.h:228

References nub3::C, synop_sec3::C, synop_sec3::d9, synop_sec3::Da, synop_sec3::Dh, synop_sec3::Dl, synop_sec3::Dm, synop_sec3::E, synop_sec3::E1, synop_sec3::ec, synop_sec3::FFFF, synop_sec3::FFFF24, synop_sec3::FFFF407, synop_sec3::FFFF408, synop_sec3::FFFF507, synop_sec3::FFFF508, nub3::hshs, synop_sec3::j5, synop_sec3::j524, synop_sec3::jjj, synop_chunks::mask, data9::misc, data9::n, nub3::Ns, synop_sec3::nub, synop_sec3::ppp24, synop_sec3::R8, synop_sec3::RRR, synop_sec3::RRRR24, synop_chunks::s3, synop_sec3::snn, synop_sec3::snp24, synop_sec3::snx, misc3::SpSp, misc3::spsp, synop_sec3::SS, synop_sec3::sss, synop_sec3::SSS, SYNOP_NMISC, SYNOP_SEC3, SYNOP_SEC3_8, synop_sec3::TnTnTn, synop_sec3::tr, synop_sec3::TxTxTx, and synop_sec3::XoXoXoXo.

Referenced by print_synop_report().

Here is the caller graph for this function:

◆ print_synop_wigos_id()

size_t print_synop_wigos_id ( char **  wid,
size_t  lmax,
struct synop_chunks syn 
)

◆ print_temp_a()

size_t print_temp_a ( struct metreport m)

Prints the part A of a TEMP report into a string.

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 346 of file bufr2tac_print_temp.c.

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}
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.
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_a_sec3(char **sec3, size_t lmax, struct temp_chunks *t)
Prints the section 3 of part A of a TEMP report.
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.

References metreport::alphanum, temp_chunks::c, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_geo(), metreport::print_mask, print_temp_a_sec1(), print_temp_a_sec2(), print_temp_a_sec3(), print_temp_a_sec4(), print_temp_a_sec7(), print_wigos_id(), temp_chunks::t, and metreport::temp.

Referenced by print_temp_report().

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

◆ print_temp_a_sec1()

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.

Parameters
sec1the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec1

Definition at line 145 of file bufr2tac_print_temp.c.

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}
char datime[16]
Definition: metcommon.h:63
char LoLoLoLo[6]
Definition: mettemp.h:323
char MMM[4]
Definition: mettemp.h:324
char LaLaLa[4]
Definition: mettemp.h:321
char Ulo[2]
Definition: mettemp.h:326
char im[2]
Definition: mettemp.h:328
char Qc[2]
Definition: mettemp.h:322

References temp_chunks::a, temp_acd_sec1::D_D, met_datetime::datime, temp_acd_sec1::h0h0h0h0, temp_acd_sec1::id, temp_acd_sec1::II, temp_acd_sec1::iii, temp_acd_sec1::im, temp_acd_sec1::LaLaLa, temp_acd_sec1::LoLoLoLo, temp_acd_sec1::MiMi, temp_acd_sec1::MjMj, temp_acd_sec1::MMM, temp_acd_sec1::Qc, temp_a::s1, temp_chunks::t, temp_acd_sec1::Ula, temp_acd_sec1::Ulo, and temp_acd_sec1::YYGG.

Referenced by print_temp_a().

Here is the caller graph for this function:

◆ print_temp_a_sec2()

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.

Parameters
sec2the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec2

Definition at line 211 of file bufr2tac_print_temp.c.

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}

References temp_chunks::a, temp_main_level_data::DnDn, temp_std_level_data::DnDn, temp_main_level_data::dndnfnfnfn, temp_std_level_data::dndnfnfnfn, temp_std_level_data::hnhnhn, temp_a_sec2::lev0, temp_a_sec2::n, temp_std_level_data::PnPn, temp_main_level_data::PnPnPn, temp_a::s2, temp_a_sec2::std, temp_main_level_data::TnTnTan, and temp_std_level_data::TnTnTan.

Referenced by print_temp_a().

Here is the caller graph for this function:

◆ print_temp_a_sec3()

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.

Parameters
sec3the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec3

Definition at line 242 of file bufr2tac_print_temp.c.

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}

References temp_chunks::a, temp_main_level_data::DnDn, temp_main_level_data::dndnfnfnfn, temp_ac_sec3::n, temp_main_level_data::PnPnPn, temp_a::s3, temp_main_level_data::TnTnTan, and temp_ac_sec3::trop.

Referenced by print_temp_a().

Here is the caller graph for this function:

◆ print_temp_a_sec4()

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.

Parameters
sec4the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec1

Definition at line 276 of file bufr2tac_print_temp.c.

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}

References temp_chunks::a, temp_max_wind_data::dmdmfmfmfm, temp_ac_sec4::n, temp_max_wind_data::no_last_wind, temp_max_wind_data::PmPmPm, temp_a::s4, temp_max_wind_data::vava, temp_max_wind_data::vbvb, and temp_ac_sec4::windx.

Referenced by print_temp_a().

Here is the caller graph for this function:

◆ print_temp_a_sec7()

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.

Parameters
sec7the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec7

Definition at line 321 of file bufr2tac_print_temp.c.

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}
struct temp_sec7 s7
Definition: mettemp.h:459
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

References temp_chunks::a, temp_sec7::GG, temp_sec7::gg, temp_sec7::rara, temp_a::s7, temp_sec7::sasa, temp_sec7::sn, temp_sec7::sr, and temp_sec7::TwTwTw.

Referenced by print_temp_a().

Here is the caller graph for this function:

◆ print_temp_b()

int print_temp_b ( struct metreport m)

Prints the part B of a TEMP report into a string.

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 600 of file bufr2tac_print_temp.c.

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}
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_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.
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.

References metreport::alphanum, metreport::alphanum2, temp_chunks::c, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_geo(), metreport::print_mask, print_temp_b_sec1(), print_temp_b_sec5(), print_temp_b_sec6(), print_temp_b_sec7(), print_temp_b_sec8(), print_wigos_id(), temp_chunks::t, and metreport::temp.

Referenced by print_temp_report().

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

◆ print_temp_b_sec1()

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.

Parameters
sec1the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec1

Definition at line 388 of file bufr2tac_print_temp.c.

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}
char Qc[2]
Definition: mettemp.h:349
char MMM[4]
Definition: mettemp.h:351
char II[4]
Definition: mettemp.h:344
char D_D[10]
Definition: mettemp.h:341
char Ulo[2]
Definition: mettemp.h:353
char h0h0h0h0[6]
Definition: mettemp.h:354
char im[2]
Definition: mettemp.h:355
char iii[4]
Definition: mettemp.h:345
char LaLaLa[4]
Definition: mettemp.h:348
char a4[2]
Definition: mettemp.h:343
char Ula[2]
Definition: mettemp.h:352
char LoLoLoLo[6]
Definition: mettemp.h:350

References temp_chunks::c, met_datetime::t, and temp_chunks::t.

Referenced by print_temp_b().

Here is the caller graph for this function:

◆ print_temp_b_sec5()

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.

Parameters
sec5the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec5

Definition at line 453 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, temp_chunks::t, and TEMP_NMAX_POINTS.

Referenced by print_temp_b().

Here is the caller graph for this function:

◆ print_temp_b_sec6()

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.

Parameters
sec6the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec6

Definition at line 478 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, temp_chunks::t, and TEMP_NMAX_POINTS.

Referenced by print_temp_b().

Here is the caller graph for this function:

◆ print_temp_b_sec7()

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.

Parameters
sec7the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec7

Definition at line 505 of file bufr2tac_print_temp.c.

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}
struct temp_sec7 s7
Definition: mettemp.h:473

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_b().

Here is the caller graph for this function:

◆ print_temp_b_sec8()

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.

Parameters
sec8the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec8

Definition at line 532 of file bufr2tac_print_temp.c.

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}
char Cm[2]
Definition: mettemp.h:443
char h[2]
Definition: mettemp.h:442
char Ch[2]
Definition: mettemp.h:444
char Cl[2]
Definition: mettemp.h:441
char Nh[2]
Definition: mettemp.h:440
struct temp_b_sec8 s8
Definition: mettemp.h:474

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_b().

Here is the caller graph for this function:

◆ print_temp_c()

int print_temp_c ( struct metreport m)

Prints the part C of a TEMP report into a string.

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 838 of file bufr2tac_print_temp.c.

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}
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_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_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_c_sec3(char **sec3, size_t lmax, struct temp_chunks *t)
Prints the section 3 of part C of a TEMP report.

References metreport::alphanum, metreport::alphanum3, temp_chunks::c, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_geo(), metreport::print_mask, print_temp_c_sec1(), print_temp_c_sec2(), print_temp_c_sec3(), print_temp_c_sec4(), print_temp_c_sec7(), print_wigos_id(), temp_chunks::t, and metreport::temp.

Referenced by print_temp_report().

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

◆ print_temp_c_sec1()

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.

Parameters
sec1the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec1

Definition at line 643 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, met_datetime::t, and temp_chunks::t.

Referenced by print_temp_c().

Here is the caller graph for this function:

◆ print_temp_c_sec2()

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.

Parameters
sec2the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec2

Definition at line 708 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_c().

Here is the caller graph for this function:

◆ print_temp_c_sec3()

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.

Parameters
sec3the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec3

Definition at line 735 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_c().

Here is the caller graph for this function:

◆ print_temp_c_sec4()

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.

Parameters
sec4the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec4

Definition at line 769 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_c().

Here is the caller graph for this function:

◆ print_temp_c_sec7()

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.

Parameters
sec7the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec7

Definition at line 813 of file bufr2tac_print_temp.c.

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}
struct temp_sec7 s7
Definition: mettemp.h:489

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_c().

Here is the caller graph for this function:

◆ print_temp_d()

int print_temp_d ( struct metreport m)

Prints the part D of a TEMP report into a string.

Parameters
mpointer to struct metreport where are both target and source

If OK returns 0, otherwise 1

Definition at line 1022 of file bufr2tac_print_temp.c.

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}
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_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_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_d_sec1(char **sec1, size_t lmax, struct temp_chunks *t)
Prints the section 1 of part D of a TEMP report.

References metreport::alphanum, metreport::alphanum4, temp_chunks::c, PRINT_BITMASK_GEO, PRINT_BITMASK_WIGOS, print_geo(), metreport::print_mask, print_temp_d_sec1(), print_temp_d_sec5(), print_temp_d_sec6(), print_temp_d_sec7(), print_wigos_id(), temp_chunks::t, and metreport::temp.

Referenced by print_temp_report().

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

◆ print_temp_d_sec1()

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.

Parameters
sec1the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec1

Definition at line 880 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, met_datetime::t, and temp_chunks::t.

Referenced by print_temp_d().

Here is the caller graph for this function:

◆ print_temp_d_sec5()

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.

Parameters
sec5the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec5

Definition at line 945 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, temp_chunks::t, and TEMP_NMAX_POINTS.

Referenced by print_temp_d().

Here is the caller graph for this function:

◆ print_temp_d_sec6()

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.

Parameters
sec6the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec6

Definition at line 970 of file bufr2tac_print_temp.c.

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}

References temp_chunks::c, temp_chunks::t, and TEMP_NMAX_POINTS.

Referenced by print_temp_d().

Here is the caller graph for this function:

◆ print_temp_d_sec7()

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.

Parameters
sec7the pointer where to print section
lmaxmax length permited
tpointer to s atruct temp_chunks where the parse results are set

returns the string sec7

Definition at line 997 of file bufr2tac_print_temp.c.

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}
struct temp_sec7 s7
Definition: mettemp.h:503

References temp_chunks::c, and temp_chunks::t.

Referenced by print_temp_d().

Here is the caller graph for this function:

◆ print_temp_d_sec8()

size_t print_temp_d_sec8 ( char **  sec8,
size_t  lmax,
struct temp_chunks t 
)

◆ print_temp_raw_data()

int print_temp_raw_data ( struct temp_raw_data r)

Prints for debug a struct temp_raw_data.

Parameters
rthe pointer of struct to print

This is used mainly for debug

Definition at line 33 of file bufr2tac_print_temp.c.

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}

References temp_raw_point_data::dd, temp_raw_point_data::dlat, temp_raw_point_data::dlon, temp_raw_point_data::dt, temp_raw_point_data::ff, temp_raw_point_data::flags, temp_raw_point_data::h, MISSING_REAL, temp_raw_data::n, temp_raw_point_data::p, temp_raw_data::raw, temp_raw_point_data::T, and temp_raw_point_data::Td.

◆ print_temp_raw_wind_shear_data()

int print_temp_raw_wind_shear_data ( struct temp_raw_wind_shear_data w)

Prints for debug a struct temp_raw_data.

Parameters
wthe pointer of struct to print

Used in debug stage

Definition at line 98 of file bufr2tac_print_temp.c.

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}

References temp_raw_wind_shear_point::dlat, temp_raw_wind_shear_point::dlon, temp_raw_wind_shear_point::dt, temp_raw_wind_shear_point::flags, MISSING_REAL, temp_raw_wind_shear_data::n, temp_raw_wind_shear_point::p, temp_raw_wind_shear_data::raw, temp_raw_wind_shear_point::ws_abv, and temp_raw_wind_shear_point::ws_blw.

◆ print_temp_report()

int print_temp_report ( struct metreport m)

print the four parts of a decoded TEMP report from a BUFR file into strings

Parameters
mpointer to a struct metreport in which alphanumeric string members stores the reults

Definition at line 1058 of file bufr2tac_print_temp.c.

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}
int print_temp_d(struct metreport *m)
Prints the part D of a TEMP report into a string.
int print_temp_a(struct metreport *m)
Prints the part A of a TEMP report into a string.
int print_temp_c(struct metreport *m)
Prints the part C of a TEMP report into a string.
int print_temp_b(struct metreport *m)
Prints the part B of a TEMP report into a string.

References temp_chunks::a, temp_chunks::b, temp_chunks::c, temp_chunks::d, temp_a::mask, temp_b::mask, temp_c::mask, temp_d::mask, print_temp_a(), print_temp_b(), print_temp_c(), print_temp_d(), metreport::temp, TEMP_SEC_2, TEMP_SEC_5, and TEMP_SEC_6.

Referenced by parse_subset_sequence().

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

◆ print_temp_wigos_id()

size_t print_temp_wigos_id ( char **  wid,
size_t  lmax,
struct temp_chunks t 
)

◆ print_wigos_id()

size_t print_wigos_id ( char **  wid,
size_t  lmax,
struct metreport m 
)

Definition at line 86 of file bufr2tac_print.c.

87{
88 char aux[40];
89 size_t used;
90 char sep = '|';
91
92 if (m->g.wid.series == 0 && m->g.wid.issuer == 0 && m->g.wid.issue == 0 && m->g.wid.local_id[0] == '\0')
93 sprintf (aux,"0-0-0-MISSING");
94 else
95 sprintf (aux,"%d-%d-%d-%s", m->g.wid.series, m->g.wid.issuer, m->g.wid.issue, m->g.wid.local_id );
96
97 used = snprintf (*wid, lmax, "%-32s%c", aux, sep);
98 *wid += used;
99 return used;
100}

References metreport::g, wigos_id::issue, wigos_id::issuer, wigos_id::local_id, wigos_id::series, and met_geo::wid.

Referenced by print_buoy_report(), print_climat_report(), print_synop_report(), print_temp_a(), print_temp_b(), print_temp_c(), and print_temp_d().

Here is the caller graph for this function:

◆ print_xml()

int print_xml ( FILE *  f,
struct metreport m 
)

prints a struct metreport in xml format

Parameters
fpointer to a file already open by caller routine
mpointer to a struct metreport containing the data to print

Definition at line 71 of file bufr2tac_xml.c.

72{
73 // Single report
74 if ( m->alphanum[0] )
75 {
76 print_xml_alphanum ( f, m->type, m->alphanum, m );
77 }
78
79 if ( m->alphanum2[0] ) //TTBB
80 {
81 print_xml_alphanum ( f, m->type2, m->alphanum2, m );
82 }
83
84 if ( m->alphanum3[0] ) //TTCC
85 {
86 print_xml_alphanum ( f, m->type3, m->alphanum3, m );
87 }
88
89 if ( m->alphanum4[0] ) //TTDD
90 {
91 print_xml_alphanum ( f, m->type4, m->alphanum4, m );
92 }
93
94 return 0;
95}
int print_xml_alphanum(FILE *f, char *type, char *alphanum, struct metreport *m)
Definition: bufr2tac_xml.c:28

References metreport::alphanum, metreport::alphanum2, metreport::alphanum3, metreport::alphanum4, print_xml_alphanum(), metreport::type, metreport::type2, metreport::type3, and metreport::type4.

Referenced by main().

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

◆ read_bufr()

int read_bufr ( unsigned char *  bufr,
char *  filename,
int *  length 
)

read a bufr file as an array of unsigned chars

Parameters
bufrpointer to an array of unsigned chars. On output it will contain the bufr
filenamestring with complete pathname of bufr file to read
lengthOn input max length allocated by caller. On output real length of bufr

Definition at line 34 of file bufr2tac_io.c.

35{
36 int aux;
37 size_t n = 0;
38 FILE *fp;
39
40 /* Open input file */
41 if ( ( fp = fopen ( filename, "r" ) ) == NULL )
42 {
43 fprintf ( stderr, "cannot open file '%s'\n", filename );
44 exit ( EXIT_FAILURE );
45 }
46
47 while ( ( aux = fgetc ( fp ) ) != EOF && ( int ) n < *length )
48 bufr[n++] = aux;
49 *length = n;
50
51 // close the file
52 fclose ( fp );
53
54 if ( n < 8 ) // we need at least 8 bytes
55 return -4;
56
57 // check if begins with BUFR
58 if ( bufr[0] != 'B' || bufr[1] != 'U' || bufr[2] != 'F' || bufr[3] != 'R' )
59 return -1;
60
61 // check if end with '7777'
62 if ( bufr[n - 4] != '7' || bufr[n - 3] != '7' || bufr[n - 2] != '7'
63 || bufr[n - 1] != '7' )
64 return -2;
65
66 //printf("%d %d\n", n, three_bytes_to_uint(bufr + 4));
67 // check about the expected size
68 if ( n != three_bytes_to_uint ( bufr + 4 ) )
69 return -3;
70
71 return 0;
72}
unsigned int three_bytes_to_uint(const unsigned char *source)
returns the integer value from an array of three bytes, most significant first

References three_bytes_to_uint().

Here is the call graph for this function:

◆ read_table_c()

int read_table_c ( char  tablec[MAXLINES_TABLEC][92],
size_t *  nlines_tablec,
char *  bufrtables_dir,
int  ksec1[40] 
)

Definition at line 64 of file bufr2tac_tablec.c.

65{
66 char *c, file[256];
67 FILE *t;
68 size_t i = 0;
69
70 *nlines_tablec = 0;
71
72 get_ecmwf_tablename ( &file[0], 'C', bufrtables_dir, ksec1 );
73
74 if ( ( t = fopen ( file, "r" ) ) == NULL )
75 {
76 fprintf ( stderr,"Unable to open table C file '%s'\n", file );
77 return 0;
78 }
79
80 while ( fgets ( tablec[i], 90, t ) != NULL && i < MAXLINES_TABLEC )
81 {
82 // supress the newline
83 if ( ( c = strrchr ( tablec[i],'\n' ) ) != NULL )
84 *c = '\0';
85 i++;
86 }
87 fclose ( t );
88 *nlines_tablec = i;
89 //printf("file='%s', NLINES_TABLEC=%d\n", file,NLINES_TABLEC);
90 return i;
91}
char * get_ecmwf_tablename(char *target, char type, char *bufrtables_dir, int ksec1[40])
Get the complete pathname of a table file needed by a bufr message.
#define MAXLINES_TABLEC
The maximum expected lines in a Table C file, legacy def used from ECMWF.
Definition: bufrdeco.h:110

References get_ecmwf_tablename(), and MAXLINES_TABLEC.

Here is the call graph for this function:

◆ recent_snow_to_ss()

char * recent_snow_to_ss ( char *  target,
double  r 
)

converts recent snow in m to ss (code table 3870)

Parameters
rrecent snow depth in meters
targetthe resulting string

Definition at line 157 of file bufr2tac_x13.c.

158{
159 int i;
160 i = ( int ) ( r * 1000.0 + 0.5 ); // convert to mm
161
162 if ( i == 0 )
163 {
164 sprintf ( target,"00" );
165 }
166 else if ( i < 0 )
167 {
168 sprintf ( target,"97" );
169 }
170 else if ( i < 7 )
171 {
172 sprintf ( target,"%02d", i + 90 );
173 }
174 else if ( i < 600 )
175 {
176 sprintf ( target,"%02d", i / 10 );
177 }
178 else if ( i <= 4000 )
179 {
180 sprintf ( target,"%02d", 50 + i/100 );
181 }
182 else if ( i > 4000 )
183 {
184 sprintf ( target,"98" );
185 }
186 else
187 {
188 sprintf ( target,"99" );
189 }
190 return target;
191}

Referenced by syn_parse_x13().

Here is the caller graph for this function:

◆ round_met_datetime_to_hour()

int round_met_datetime_to_hour ( struct met_datetime target,
struct met_datetime source 
)

Definition at line 194 of file bufr2tac_utils.c.

195{
196 target->t = ( ( source->t + 1800 ) / 3600 ) * 3600 ; // rounding to next whole hour
197 memset ( &target->tim, 0, sizeof ( struct tm ) );
198 gmtime_r ( &target->t, &target->tim );
199 strftime ( target->datime, 16, "%Y%m%d%H%M", &target->tim );
200 return 0;
201}
struct tm tim
Definition: metcommon.h:62

References met_datetime::datime, met_datetime::t, and met_datetime::tim.

Referenced by parse_subset_as_temp().

Here is the caller graph for this function:

◆ secs_to_tt()

char * secs_to_tt ( char *  tt,
int  secs 
)

get tt code from seconds

Parameters
ttstring with the resulting table code
secssecond

returns the pointer to tt

Definition at line 34 of file bufr2tac_x11.c.

35{
36 int i;
37
38 if ( secs < 0 )
39 {
40 i = ( -secs ) / 360;
41 }
42 else
43 {
44 i = ( secs ) / 360;
45 }
46
47 if ( i <= 60 )
48 {
49 sprintf ( tt, "%02d", i );
50 }
51 else if ( i < 700 )
52 {
53 sprintf ( tt, "61" );
54 }
55 else if ( i < 800 )
56 {
57 sprintf ( tt, "62" );
58 }
59 else if ( i < 900 )
60 {
61 sprintf ( tt, "63" );
62 }
63 else if ( i < 1000 )
64 {
65 sprintf ( tt, "64" );
66 }
67 else if ( i < 1100 )
68 {
69 sprintf ( tt, "65" );
70 }
71 else if ( i < 1200 )
72 {
73 sprintf ( tt, "66" );
74 }
75 else if ( i < 1800 )
76 {
77 sprintf ( tt, "67" );
78 }
79 else
80 {
81 sprintf ( tt, "68" );
82 }
83 return tt;
84}

Referenced by syn_parse_x11(), and syn_parse_x20().

Here is the caller graph for this function:

◆ set_environment()

int set_environment ( char *  default_bufrtables,
char *  bufrtables_dir 
)

◆ syn_parse_x01()

int syn_parse_x01 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 01.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 54 of file bufr2tac_x01.c.

55{
56 char aux[80];
57
59 return 0;
60
61 switch ( s->a->desc.y )
62 {
63 case 1: // 0 01 001 . WMO block number
64 sprintf ( syn->s0.II, "%02d", s->ival );
65 break;
66
67 case 2: // 0 01 002 . WMO station number
68 sprintf ( syn->s0.iii, "%03d", s->ival );
69 break;
70
71 case 3: // 0 01 003 . WMO Region
72 sprintf ( syn->s0.A1, "%d", s->ival );
73 if ( strcmp ( syn->s0.A1, "1" ) == 0 )
74 strcpy ( syn->s0.Reg, "I" );
75 else if ( strcmp ( syn->s0.A1, "2" ) == 0 )
76 strcpy ( syn->s0.Reg, "II" );
77 else if ( strcmp ( syn->s0.A1, "3" ) == 0 )
78 strcpy ( syn->s0.Reg, "III" );
79 else if ( strcmp ( syn->s0.A1, "4" ) == 0 )
80 strcpy ( syn->s0.Reg, "IV" );
81 else if ( strcmp ( syn->s0.A1, "5" ) == 0 )
82 strcpy ( syn->s0.Reg, "V" );
83 else if ( strcmp ( syn->s0.A1, "6" ) == 0 )
84 strcpy ( syn->s0.Reg, "VI" );
85 break;
86
87 case 4: // 0 01 004 . WMO Subarea
88 case 20: // 0 01 020 . WMO region subarea
89 sprintf ( syn->s0.bw, "%d", s->ival );
90 break;
91
92 case 10: // 0 01 010. Stationary buoy platform identifier
93 if ( strlen ( s->a->cval ) < 16 )
94 {
95 strcpy ( aux, s->a->cval );
96 adjust_string ( aux );
97 if ( aux[0] == '\xff' )
98 break;
99 if ( strlen ( aux ) < 10 )
100 strcpy ( syn->s0.D_D, aux );
101 else
102 bufr2tac_set_error ( s, 1, "syn_parse_x01()", "Ship or mobile land station index length >= 10. Cannot set s0.D_D" );
103 }
104 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
105 {
106 bufr2tac_set_error ( s, 1, "syn_parse_x01()", "Ship or mobile land station index length >= 16" );
107 }
108 break;
109
110 case 11: // 0 01 011. Ship or mobile land station index
111 if ( strlen ( s->a->cval ) < 16 )
112 {
113 strcpy ( aux, s->a->cval );
114 adjust_string ( aux );
115 if ( aux[0] == '\xff' )
116 break;
117 if ( strlen ( aux ) < 10 )
118 strcpy ( syn->s0.D_D, aux );
119 else
120 bufr2tac_set_error ( s, 1, "syn_parse_x01()", "Ship or mobile land station index length >= 10. Cannot set s0.D_D" );
121 }
122 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
123 {
124 bufr2tac_set_error ( s, 1, "syn_parse_x01()", "Ship or mobile land station index length >= 16" );
125 }
126 break;
127
128 case 15: // 0 01 015 . Station or site name
129 case 18: // 0 01 018 . Short station or site name
130 case 19: // 0 01 019 . Long station or site name
131 if ( strlen ( s->a->cval ) <= 80 )
132 {
133 strcpy ( aux, s->a->cval );
134 adjust_string ( aux );
135 strcpy ( s->name, aux );
137 }
138 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
139 {
140 bufr2tac_set_error ( s, 1, "syn_parse_x01()", "Station or site name length > 80. Cannot set s->name" );
141 }
142 break;
143
144 case 101: // 0 01 101 . State identifier
145 if ( strlen ( s->a->ctable ) <= 256 )
146 {
147 strcpy ( aux, s->a->ctable );
148 adjust_string ( aux );
149 strcpy ( s->country, aux );
151 }
152 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
153 {
154 bufr2tac_set_error ( s, 1, "syn_parse_x01()", "State identifier length > 256. Cannot set s->country" );
155 }
156 break;
157
158 case 125: // 0 01 125 . WIGOS identifier series
159 syn->wid.series = ( uint8_t ) s->ival;
160 break;
161
162 case 126: // 0 01 126 . WIGOS issuer of identifier
163 syn->wid.issuer = ( uint16_t ) s->ival;
164 break;
165
166 case 127: // 0 01 127 , WIGOS issue number
167 syn->wid.issue = ( uint16_t ) s->ival;
168 break;
169
170 case 128: // 0 01 128 . WIGOS local identifier (character)
171 if ( strlen ( s->a->cval ) <= 16 )
172 {
173 adjust_string ( s->a->cval );
174 if ( check_wigos_local_id ( s->a->cval ) )
175 {
176 bufr2tac_set_error ( s, 1, "synop_parse_x01()","Bad WIGOS Local identifier" );
177 }
178 strcpy ( syn->wid.local_id, s->a->cval );
180 }
181 break;
182
183 default:
184 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
185 bufr2tac_set_error ( s, 0, "syn_parse_x01()", "Descriptor not parsed" );
186 break;
187 }
188
189 //set WMO region if we know II and iii and still no set A1
190 if ( ( syn->s0.A1[0] == 0 ) && syn->s0.II[0] && syn->s0.iii[0] )
191 {
192 guess_WMO_region ( syn->s0.A1, syn->s0.Reg, syn->s0.II, syn->s0.iii );
193 }
194 return 0;
195}

References bufr2tac_subset_state::a, synop_sec0::A1, adjust_string(), BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), synop_sec0::bw, check_wigos_local_id(), bufr2tac_subset_state::country, bufr_atom_data::ctable, bufr_atom_data::cval, synop_sec0::D_D, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, guess_WMO_region(), synop_sec0::II, synop_sec0::iii, wigos_id::issue, wigos_id::issuer, bufr2tac_subset_state::ival, wigos_id::local_id, bufr_atom_data::mask, bufr2tac_subset_state::mask, bufr2tac_subset_state::name, synop_sec0::Reg, synop_chunks::s0, wigos_id::series, SUBSET_MASK_HAVE_COUNTRY, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_WIGOS_ID, synop_chunks::wid, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x02()

int syn_parse_x02 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 02.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 34 of file bufr2tac_x02.c.

35{
36
37
38 switch ( s->a->desc.y )
39 {
40 case 1: // 0 02 001 Type of station
42 {
43 strcpy ( syn->s1.ix,"/" );
44 return 0;
45 }
46 s->type = s->ival;
48 break;
49 case 2: // 0 02 002 . Type of instrumentation for wind measurement
51 return 0;
52 if ( s->ival == 0 )
53 strcpy ( syn->s0.iw, "0" );
54 else if ( s->ival == 8 )
55 strcpy ( syn->s0.iw, "1" );
56 else if ( s->ival == 4 )
57 strcpy ( syn->s0.iw, "3" );
58 else if ( s->ival == 12 )
59 strcpy ( syn->s0.iw, "4" );
60
61 /*
62 if ( s->ival & 4 )
63 strcpy ( syn->s0.iw, "4" );
64 else
65 strcpy ( syn->s0.iw, "1" );*/
66 break;
67 default:
68 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
69 bufr2tac_set_error ( s, 0, "syn_parse_x02()", "Descriptor not parsed" );
70 break;
71 }
72 return 0;
73}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::ival, synop_sec0::iw, synop_sec1::ix, bufr_atom_data::mask, bufr2tac_subset_state::mask, synop_chunks::s0, synop_chunks::s1, SUBSET_MASK_HAVE_TYPE_STATION, bufr2tac_subset_state::type, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x04()

int syn_parse_x04 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 04.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 110 of file bufr2tac_x04.c.

111{
112 switch ( s->a->desc.y )
113 {
114 case 1: // 0 04 001 .Year
115 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
116 {
117 return 0;
118 }
119 else if ( s->ival < 2000 || s->ival > 2050 )
120 {
121 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
122 bufr2tac_set_error ( s, 2, "syn_parse_x04()", "Bad year" );
123 return 1;
124 }
125 sprintf ( syn->e.YYYY, "%04d", s->ival );
127 break;
128
129 case 2: // 0 04 002 . Month
130 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
131 {
132 return 0;
133 }
134 sprintf ( syn->e.MM, "%02d", s->ival );
136 break;
137
138 case 3: // 0 04 003 . Day of month
139 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
140 {
141 return 0;
142 }
143 sprintf ( syn->e.DD, "%02d", s->ival );
145 break;
146
147 case 4: // 0 04 004 . Hour
148 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
149 {
150 return 0;
151 }
152 sprintf ( syn->e.HH, "%02d", s->ival );
154 break;
155
156 case 5: // 0 04 005 . Minute
157 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
158 {
159 return 0;
160 }
161 sprintf ( syn->e.mm, "%02d", s->ival );
163 break;
164
165 // store latest displacement in seconds
166 case 23: // 0 04 023 . Time period of displacement (days)
167 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
168 {
169 s->k_jtval = s->k_itval;
170 s->jtval = s->itval;
171 s->jtmask = s->itmask;
172 s->k_itval = s->i;
173 s->itval = 0;
174 return 0;
175 }
176 s->k_jtval = s->k_itval;
177 s->jtval = s->itval;
178 s->jtmask = s->itmask;
179 s->k_itval = s->i;
180 s->itmask = s->a->mask;
181 s->itval = s->ival * 86400;
182 break;
183
184 case 24: // 0 04 024 . Time period of displacement (hours)
185 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
186 {
187 s->k_jtval = s->k_itval;
188 s->jtval = s->itval;
189 s->jtmask = s->itmask;
190 s->k_itval = s->i;
191 s->itval = 0;
192 return 0;
193 }
194 s->k_jtval = s->k_itval;
195 s->jtval = s->itval;
196 s->jtmask = s->itmask;
197 s->k_itval = s->i;
198 s->itmask = s->a->mask;
199 s->itval = s->ival * 3600;
200 break;
201
202 case 25: // 0 04 025 Time period of displacement (minutes)
203 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
204 {
205 s->k_jtval = s->k_itval;
206 s->jtval = s->itval;
207 s->jtmask = s->itmask;
208 s->k_itval = s->i;
209 s->itval = 0;
210 return 0;
211 }
212 s->k_jtval = s->k_itval;
213 s->jtval = s->itval;
214 s->jtmask = s->itmask;
215 s->k_itval = s->i;
216 s->itmask = s->a->mask;
217 s->itval = s->ival * 60;
218 break;
219
220 case 26: // 0 04 026 . Time period of displacement (seconds)
221 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
222 {
223 s->k_jtval = s->k_itval;
224 s->jtval = s->itval;
225 s->jtmask = s->itmask;
226 s->k_itval = s->i;
227 s->itval = 0;
228 return 0;
229 }
230 s->k_jtval = s->k_itval;
231 s->jtval = s->itval;
232 s->jtmask = s->itmask;
233 s->k_itval = s->i;
234 s->itmask = s->a->mask;
235 s->itval = s->ival;
236 break;
237
238 default:
239 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
240 bufr2tac_set_error ( s, 0, "syn_parse_x04()", "Descriptor not parsed" );
241 break;
242 }
243 return 0;
244}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), report_date_ext::DD, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_chunks::e, report_date_ext::HH, bufr2tac_subset_state::i, bufr2tac_subset_state::itmask, bufr2tac_subset_state::itval, bufr2tac_subset_state::ival, bufr2tac_subset_state::jtmask, bufr2tac_subset_state::jtval, bufr2tac_subset_state::k_itval, bufr2tac_subset_state::k_jtval, bufr_atom_data::mask, bufr2tac_subset_state::mask, report_date_ext::MM, report_date_ext::mm, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_MINUTE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_YEAR, bufr_descriptor::y, and report_date_ext::YYYY.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x05()

int syn_parse_x05 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 05.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 66 of file bufr2tac_x05.c.

67{
68 int ia;
69
71 return 0;
72
73 switch ( s->a->desc.y )
74 {
75 case 1: // 0 05 001 . Latitude (High accuracy)
76 case 2: // 0 05 002 . Latitude (Coarse accuracy)
77 if ( s->val < 0.0 )
78 s->mask |= SUBSET_MASK_LATITUDE_SOUTH; // Sign for latitude
80 ia = ( int ) ( fabs ( s->val ) * 10.0 + 0.5 );
81 if (ia > 999 || ia < 0)
82 return 1;
83 sprintf ( syn->s0.LaLaLa, "%03d", ia );
84 syn->s0.Ula[0] = syn->s0.LaLaLa[1];
85 s->lat = s->val;
86 break;
87
88 case 21: // 0 05 021 . Bearing or azimut
89 grad_to_D ( syn->s3.Da, s->val );
90 syn->mask |= SYNOP_SEC3;
91 break;
92 default:
93 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
94 bufr2tac_set_error ( s, 0, "syn_parse_x05()", "Descriptor not parsed" );
95 break;
96 }
97
98 // check if set both LaLaLa and LoLoLoLo to set Qc
99 if ( ( syn->s0.Qc[0] == 0 ) && syn->s0.LaLaLa[0] && syn->s0.LoLoLoLo[0] )
100 {
102 {
104 strcpy ( syn->s0.Qc, "5" );
105 else
106 strcpy ( syn->s0.Qc, "3" );
107 }
108 else
109 {
111 strcpy ( syn->s0.Qc, "7" );
112 else
113 strcpy ( syn->s0.Qc, "1" );
114 }
115 }
116
117 // check about Mardsen square
118 if ( ( syn->s0.MMM[0] == 0 ) && syn->s0.LaLaLa[0] && syn->s0.LoLoLoLo[0] )
119 {
120 latlon_to_MMM ( syn->s0.MMM, s->lat, s->lon ); // compute it
121 }
122
123 return 0;
124}
char * latlon_to_MMM(char *target, double lat, double lon)
convert latitude and longitude to a MMM string
Definition: bufr2tac_x06.c:34
char * grad_to_D(char *D, double grad)
Converts true direction in grads to D (code table 0700)
Definition: bufr2tac_x05.c:32

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), synop_sec3::Da, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, grad_to_D(), synop_sec0::LaLaLa, bufr2tac_subset_state::lat, latlon_to_MMM(), synop_sec0::LoLoLoLo, bufr2tac_subset_state::lon, bufr_atom_data::mask, bufr2tac_subset_state::mask, synop_chunks::mask, synop_sec0::MMM, synop_sec0::Qc, synop_chunks::s0, synop_chunks::s3, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_LATITUDE_SOUTH, SUBSET_MASK_LONGITUDE_WEST, SYNOP_SEC3, synop_sec0::Ula, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x06()

int syn_parse_x06 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 06.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 67 of file bufr2tac_x06.c.

68{
69 int ia;
70
72 return 0;
73
74 switch ( s->a->desc.y )
75 {
76 case 1: // 0 06 001 . Longitude (High accuracy)
77 case 2: // 0 06 002 . Longitude (Coarse)
78 if ( s->val < 0.0 )
79 s->mask |= SUBSET_MASK_LONGITUDE_WEST; // Sign for longitude
81 ia = ( int ) ( fabs ( s->val ) * 10.0 + 0.5 );
82 sprintf ( syn->s0.LoLoLoLo, "%04d",ia );
83 syn->s0.Ulo[0] = syn->s0.LoLoLoLo[2];
84 s->lon = s->val;
85 break;
86
87 default:
88 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
89 bufr2tac_set_error ( s, 0, "syn_parse_x06()", "Descriptor not parsed" );
90 break;
91 }
92
93 // check if set both LaLaLa and LoLoLoLo to set Qc
94 if ( ( syn->s0.Qc[0] == 0 ) && syn->s0.LaLaLa[0] && syn->s0.LoLoLoLo[0] )
95 {
97 {
99 strcpy ( syn->s0.Qc, "5" );
100 else
101 strcpy ( syn->s0.Qc, "3" );
102 }
103 else
104 {
106 strcpy ( syn->s0.Qc, "7" );
107 else
108 strcpy ( syn->s0.Qc, "1" );
109 }
110 }
111
112 // check if about MMM
113 if ( ( syn->s0.MMM[0] == 0 ) && syn->s0.LaLaLa[0] && syn->s0.LoLoLoLo[0] )
114 {
115 latlon_to_MMM ( syn->s0.MMM, s->lat, s->lon );
116 }
117
118 return 0;
119}
char * latlon_to_MMM(char *target, double lat, double lon)
convert latitude and longitude to a MMM string
Definition: bufr2tac_x06.c:34

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec0::LaLaLa, bufr2tac_subset_state::lat, latlon_to_MMM(), synop_sec0::LoLoLoLo, bufr2tac_subset_state::lon, bufr_atom_data::mask, bufr2tac_subset_state::mask, synop_sec0::MMM, synop_sec0::Qc, synop_chunks::s0, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_LATITUDE_SOUTH, SUBSET_MASK_LONGITUDE_WEST, synop_sec0::Ulo, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x07()

int syn_parse_x07 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 07.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 65 of file bufr2tac_x07.c.

66{
67 // this is to avoid warning
68 if ( syn == NULL )
69 {
70 return 1;
71 }
72
73 switch ( s->a->desc.y )
74 {
75 case 1: // 0 07 001 . Heigh of station
76 case 30: // 0 07 030 . Height of station ground above msl
77 case 31: // 0 07 031 . Height of barometer above msl
79 {
80 return 0;
81 }
82 if ( syn->s0.h0h0h0h0[0] == 0 )
83 {
84 if (s->ival > 9999 || s->ival < -9999)
85 return 1;
86 sprintf ( syn->s0.h0h0h0h0, "%04d", s->ival );
87 syn->s0.im[0] = '1';// set unit as m
89 }
90 s->alt = s->val;
91 break;
92
93 case 4: // 0 07 004 . Pressure at standard level
95 {
96 return 0;
97 }
98 if ( s->ival == 100000 )
99 {
100 strcpy ( syn->s1.a3, "1" );
101 }
102 else if ( s->ival == 92500 )
103 {
104 strcpy ( syn->s1.a3, "2" );
105 }
106 else if ( s->ival == 85000 )
107 {
108 strcpy ( syn->s1.a3, "8" );
109 }
110 else if ( s->ival == 70000 )
111 {
112 strcpy ( syn->s1.a3, "7" );
113 }
114 else if ( s->ival == 50000 )
115 {
116 strcpy ( syn->s1.a3, "5" );
117 }
118 break;
119
120 case 21: // 0 07 021 . Elevation angle
121 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
122 {
123 return 0;
124 }
125 grad_to_ec ( syn->s3.ec, s->val );
126 syn->mask |= SYNOP_SEC3;
127 break;
128
129 case 32: // 0 07 032 Height of sensor above local ground
130 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
131 {
132 s->hsensor = -999.9; // clean value
133 return 0;
134 }
135 s->hsensor = s->val;
136 break;
137
138 case 33: // 0 07 033 Height of sensor above water surface
139 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
140 {
141 s->hwsensor = -999.9; // clean value
142 return 0;
143 }
144 s->hwsensor = s->val;
145 break;
146
147 default:
148 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
149 bufr2tac_set_error ( s, 0, "syn_parse_x07()", "Descriptor not parsed" );
150 break;
151 }
152
153 return 0;
154}
char * grad_to_ec(char *target, double grad)
Converts elevation in grads to ec (code table 1004)
Definition: bufr2tac_x07.c:32

References bufr2tac_subset_state::a, synop_sec1::a3, bufr2tac_subset_state::alt, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec3::ec, grad_to_ec(), synop_sec0::h0h0h0h0, bufr2tac_subset_state::hsensor, bufr2tac_subset_state::hwsensor, synop_sec0::im, bufr2tac_subset_state::ival, bufr_atom_data::mask, bufr2tac_subset_state::mask, synop_chunks::mask, synop_chunks::s0, synop_chunks::s1, synop_chunks::s3, SUBSET_MASK_HAVE_ALTITUDE, SYNOP_SEC3, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x08()

int syn_parse_x08 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 08.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 37 of file bufr2tac_x08.c.

38{
39 if ( syn == NULL )
40 {
41 return 1;
42 }
43
44 switch ( s->a->desc.y )
45 {
46 case 2: // 0 08 002 . Vertical significance (surface observations)
48 {
49 s->clayer = 0; // clean vertical significance;
50 return 0;
51 }
52
53 if ( s->ival == 21 || s->ival == 1 )
54 {
55 s->clayer = 1; // first cloud layer or first no CB layer
56 }
57 else if ( s->ival == 22 || s->ival == 2 )
58 {
59 s->clayer = 2; // second cloud layer or second no CB layer
60 }
61 else if ( s->ival == 23 || s->ival == 3 )
62 {
63 s->clayer = 3; // third cloud layer or third no CB layer
64 }
65 else if ( s->ival == 24 || s->ival == 4 )
66 {
67 s->clayer = 4; // fourth cloud layer or CB layer
68 }
69 else if ( s->ival == 10 )
70 {
71 s->clayer = -1; // base of cloud layer below level station and top over level station
72 }
73 else if ( s->ival == 11 )
74 {
75 s->clayer = -2; // base and top of cloud layer below level station
76 }
77 else if ( s->ival <= 9 && s->ival >= 7 )
78 {
79 s->clayer = s->ival;
80 }
81 else if ( s->ival == 5 || s->ival == 62 )
82 {
83 // 5 should be used for N = 9 and 62 for N = 0
84 s->clayer = s->ival;
85 }
86 break;
87
88 case 22: // 0 08 022 . Total number
89 case 23: // 0 08 023 . First-order statistics
90 case 24: // 0 08 024 . Difference statistics
92 {
93 return 0;
94 }
95 if ( s->isq )
96 {
97 s->isq = 0;
98 }
99 else
100 {
101 s->isq = 1;
102 }
103 break;
104
105 default:
106 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
107 bufr2tac_set_error ( s, 0, "syn_parse_x08()", "Descriptor not parsed" );
108 break;
109 }
110 return 0;
111}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr2tac_subset_state::clayer, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::isq, bufr2tac_subset_state::ival, bufr_atom_data::mask, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x10()

int syn_parse_x10 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 10.

Parameters
synpointer to a s if ( BUFR2TAC_DEBUG_LEVEL > 0 ) bufr2tac_set_error ( s, 0, "syn_parse_x08()", "Descriptor not parsed" ); truct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 87 of file bufr2tac_x10.c.

88{
89 char aux[16];
90
92 {
93 return 0;
94 }
95
96 switch ( s->a->desc.y )
97 {
98 case 4: // 0 10 004 . Pressure
99 pascal_to_PPPP ( aux, s->val );
100 strcpy ( syn->s1.PoPoPoPo, aux );
101 syn->mask |= SYNOP_SEC1;
102 break;
103
104 case 9: // 0 10 009. Geopotential at standard level
105 sprintf ( syn->s1.hhh, "%03d", abs(s->ival) % 1000 );
106 syn->mask |= SYNOP_SEC1;
107 break;
108
109 case 51: // 0 10 051 . Pressure reduced to mean sea level
110 pascal_to_PPPP ( aux, s->val );
111 memcpy ( syn->s1.PPPP, aux, 4 );
112 syn->s1.PPPP[4] = 0;
113 syn->mask |= SYNOP_SEC1;
114 break;
115
116 case 61: // 0 10 061 . 3-hour pressure change
117 pascal_to_ppp ( aux, s->val );
118 memcpy(syn->s1.ppp, aux, 3);
119 syn->s1.ppp[3] = 0;
120 syn->mask |= SYNOP_SEC1;
121 break;
122
123 case 62: // 0 10 062 . 24-hour pressure change
124 pascal_to_ppp ( aux, s->val );
125 memcpy ( syn->s3.ppp24, aux, 3 );
126 syn->s3.ppp24[3] = 0;
127 if ( s->val >= 0 )
128 {
129 strcpy ( syn->s3.snp24, "8" );
130 }
131 else
132 {
133 strcpy ( syn->s3.snp24, "9" );
134 }
135 syn->mask |= SYNOP_SEC3;
136 break;
137
138 case 63: // 0 10 063 . Characteristic of pressure tendency
139 if ( s->ival > 9 || s->ival < 0)
140 return 1;
141 sprintf ( syn->s1.a, "%1d",s->ival );
142 syn->mask |= SYNOP_SEC1;
143 break;
144
145 default:
146 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
147 bufr2tac_set_error ( s, 0, "syn_parse_x10()", "Descriptor not parsed" );
148 break;
149 }
150 return 0;
151}

References bufr2tac_subset_state::a, synop_sec1::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec1::hhh, bufr2tac_subset_state::ival, bufr_atom_data::mask, synop_chunks::mask, pascal_to_ppp(), pascal_to_PPPP(), synop_sec1::PoPoPoPo, synop_sec1::ppp, synop_sec3::ppp24, synop_sec1::PPPP, synop_chunks::s1, synop_chunks::s3, synop_sec3::snp24, SYNOP_SEC1, SYNOP_SEC3, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x11()

int syn_parse_x11 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 11.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 116 of file bufr2tac_x11.c.

117{
118
119 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
120 {
121 return 0;
122 }
123
124 switch ( s->a->desc.y )
125 {
126 case 1: // 0 11 001 . Wind direction
127 case 11: // 0 11 011 . Wind direction at 10 meters
128 sprintf ( syn->s1.dd, "%02d", abs((s->ival + 5 ) / 10) % 100 );
129 syn->mask |= SYNOP_SEC1;
130 break;
131
132 case 2: // 0 11 002 . Wind speed
133 case 12: // 0 11 012 . Wind speed at 10 meters
134 if ( syn->s0.iw[0] == '4' )
135 {
136 s->val *= 1.94384449;
137 }
138 if ( s->val < 100.0 )
139 {
140 sprintf ( syn->s1.ff, "%02d", ( int ) ( s->val + 0.5 ) );
141 }
142 else
143 {
144 sprintf ( syn->s1.ff,"99" );
145 sprintf ( syn->s1.fff, "%03d", ( int ) ( s->val + 0.5 ) );
146 }
147 syn->mask |= SYNOP_SEC1;
148 break;
149
150 case 41: // 0 11 041 . Max wind gust speed
151 if ( syn->s3.d9.n == SYNOP_NMISC )
152 {
153 return 0; // No more groups space
154 }
155
156 if ( s->itval == -600 )
157 {
158 if ( syn->mask & SUBSET_MASK_HAVE_GUST10 )
159 {
160 break; // Already have gust for 10 minutes
161 }
162 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "910" );
163 s->SnSn = 910;
164 if ( syn->s0.iw[0] == '4' )
165 {
166 s->val *= 1.94384449; // original value was in m/s. So it change to knots
167 }
168 if ( s->val < 100.0 )
169 {
170 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
171 }
172 else
173 {
174 // Case more than 99 knots
175 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp,"99" );
176 syn->s3.d9.n++;
177 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "00" );
178 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
179 }
180 syn->s3.d9.n++;
182 syn->mask |= SYNOP_SEC3;
183 }
184 else if ( s->itval )
185 {
186 if ( s->mask & SUBSET_MASK_HAVE_GUST )
187 {
188 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].SpSp, "907" );
189 secs_to_tt ( syn->s5.d9.misc[syn->s5.d9.n].spsp, s->itval );
190 syn->s5.d9.n++;
191 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].SpSp, "911" );
192 s->SnSn = 911;
193 if ( syn->s0.iw[0] == '4' )
194 {
195 s->val *= 1.94384449;
196 }
197 if ( s->val < 100.0 )
198 {
199 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
200 }
201 else
202 {
203 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].spsp,"99" );
204 syn->s5.d9.n++;
205 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].SpSp, "00" );
206 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
207 }
208 syn->s5.d9.n++;
209 syn->mask |= SYNOP_SEC5;
210 }
211 else
212 {
213 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "907" );
214 secs_to_tt ( syn->s3.d9.misc[syn->s3.d9.n].spsp, s->itval );
215 syn->s3.d9.n++;
216 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "911" );
217 s->SnSn = 911;
218 if ( syn->s0.iw[0] == '4' )
219 {
220 s->val *= 1.94384449;
221 }
222 if ( s->val < 100.0 )
223 {
224 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
225 }
226 else
227 {
228 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp,"99" );
229 syn->s3.d9.n++;
230 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "00" );
231 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
232 }
233 syn->s3.d9.n++;
234 syn->mask |= SYNOP_SEC3;
236 }
237 }
238 break;
239
240 case 42: // 0 11 042 . Max wind speed (10-minutes mean)
241 if ( syn->s3.d9.n == SYNOP_NMISC )
242 {
243 return 0;
244 }
245 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "907" );
246 secs_to_tt ( syn->s3.d9.misc[syn->s3.d9.n].spsp, s->itval );
247 syn->s3.d9.n++;
248 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "912" );
249 s->SnSn = 912;
250 if ( syn->s0.iw[0] == '4' )
251 {
252 s->val *= 1.94384449;
253 }
254 if ( s->val < 100.0 )
255 {
256 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
257 }
258 else
259 {
260 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp,"99" );
261 syn->s3.d9.n++;
262 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "00" );
263 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
264 }
265 syn->s3.d9.n++;
266 syn->mask |= SYNOP_SEC3;
267 break;
268
269 case 43: // 0 11 043 . Max wind gust direction
270 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
271 bufr2tac_set_error ( s, 0, "syn_parse_x11()", "Descriptor not parsed" );
272 break;
273
274 case 84: // 0 11 084 . Wind speed in knots
275 if ( syn->s0.iw[0] == '1' )
276 {
277 s->val /= 1.94384449;
278 }
279 if ( s->val < 100.0 )
280 {
281 sprintf ( syn->s1.ff, "%02d", ( int ) ( s->val + 0.5 ) );
282 }
283 else
284 {
285 sprintf ( syn->s1.ff,"99" );
286 sprintf ( syn->s1.fff, "%03d", ( int ) ( s->val + 0.5 ) );
287 }
288 syn->mask |= SYNOP_SEC1;
289 break;
290
291 case 86: // 0 11 086 . Max wind speed in knots
292 if ( syn->s3.d9.n == SYNOP_NMISC )
293 {
294 return 0;
295 }
296 if ( s->itval == -600 )
297 {
298 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "910" );
299 if ( syn->s0.iw[0] == '1' )
300 {
301 s->val /= 1.94384449; // original values in knots. passed to m/s
302 }
303 if ( s->val < 100.0 )
304 {
305 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
306 }
307 else
308 {
309 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp,"99" );
310 syn->s3.d9.n++;
311 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "00" );
312 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
313 }
314 syn->mask |= SYNOP_SEC3;
315 syn->s3.d9.n++;
316 }
317 else if ( s->itval )
318 {
319 if ( s->mask & SUBSET_MASK_HAVE_GUST )
320 {
321 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].SpSp, "907" );
322 secs_to_tt ( syn->s5.d9.misc[syn->s5.d9.n].spsp, s->itval );
323 syn->s5.d9.n++;
324 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].SpSp, "911" );
325 if ( syn->s0.iw[0] == '1' )
326 {
327 s->val /= 1.94384449;
328 }
329 if ( s->val < 100.0 )
330 {
331 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
332 }
333 else
334 {
335 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].spsp,"99" );
336 syn->s5.d9.n++;
337 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].SpSp, "00" );
338 sprintf ( syn->s5.d9.misc[syn->s5.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
339 }
340 syn->s5.d9.n++;
341 syn->mask |= SYNOP_SEC5;
342 }
343 else
344 {
345 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "907" );
346 secs_to_tt ( syn->s3.d9.misc[syn->s3.d9.n].spsp, s->itval );
347 syn->s3.d9.n++;
348 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "911" );
349 if ( syn->s0.iw[0] == '1' )
350 {
351 s->val /= 1.94384449;
352 }
353 if ( s->val < 100.0 )
354 {
355 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", ( int ) ( s->val + 0.5 ) );
356 }
357 else
358 {
359 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp,"99" );
360 syn->s3.d9.n++;
361 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "00" );
362 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%03d", ( int ) ( s->val + 0.5 ) );
363 }
364 syn->s3.d9.n++;
365 syn->mask |= SYNOP_SEC3;
367 }
368 }
369 break;
370
371 default:
372 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
373 bufr2tac_set_error ( s, 0, "syn_parse_x11()", "Descriptor not parsed" );
374 break;
375 }
376 return 0;
377}
#define SUBSET_MASK_HAVE_GUST
Bit mask to mark a struct bufr_subset_sequence_data having wind gust observation other than 10 minute...
Definition: bufr2tac.h:176
#define SUBSET_MASK_HAVE_GUST10
Bit mask to mark a struct bufr_subset_sequence_data having wind gust observation other than 10 minute...
Definition: bufr2tac.h:182
char * secs_to_tt(char *tt, int secs)
get tt code from seconds
Definition: bufr2tac_x11.c:34
struct synop_sec5 s5
Definition: metsynop.h:302
struct data9 d9
Definition: metsynop.h:286

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), synop_sec3::d9, synop_sec5::d9, synop_sec1::dd, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec1::ff, synop_sec1::fff, bufr2tac_subset_state::itval, bufr2tac_subset_state::ival, synop_sec0::iw, bufr_atom_data::mask, bufr2tac_subset_state::mask, synop_chunks::mask, data9::misc, data9::n, synop_chunks::s0, synop_chunks::s1, synop_chunks::s3, synop_chunks::s5, secs_to_tt(), bufr2tac_subset_state::SnSn, misc3::SpSp, misc3::spsp, SUBSET_MASK_HAVE_GUST, SUBSET_MASK_HAVE_GUST10, SYNOP_NMISC, SYNOP_SEC1, SYNOP_SEC3, SYNOP_SEC5, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x12()

int syn_parse_x12 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 12.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 220 of file bufr2tac_x12.c.

221{
222 char aux[16];
223
224 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
225 {
226 return 0;
227 }
228
229 switch ( s->a->desc.y )
230 {
231 case 1: // 0 12 001 . Air temperature
232 case 4: // 0 12 004 . Air temperatura at 2 m
233 case 101: // 0 12 101 . Air temperature
234 case 104: // 0 12 104 . Air temperature at 2 m
235 if ( syn->s1.TTT[0] == 0 )
236 {
237 if ( kelvin_to_snTTT ( aux, s->val ) )
238 {
239 syn->s1.sn1[0] = aux[0];
240 strcpy ( syn->s1.TTT, aux + 1 );
241 syn->mask |= SYNOP_SEC1;
242 }
243 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
244 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
245 }
246 break;
247
248 case 3: // 0 12 003 . Dewpoint temperature
249 case 6: // 0 12 006 . Dewpoint temperature at 2 m
250 case 103: // 0 12 103 . Dewpoint temperature
251 case 106: // 0 12 106 . Dewpoint temperature at 2 m
252 if ( syn->s1.TdTdTd[0] == 0 )
253 {
254 if ( kelvin_to_snTTT ( aux, s->val ) )
255 {
256 syn->s1.sn2[0] = aux[0];
257 strcpy ( syn->s1.TdTdTd, aux + 1 );
258 syn->mask |= SYNOP_SEC1;
259 }
260 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
261 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
262 }
263 break;
264
265 case 14: // 0 12 014 . Maximum temperature at 2 m , past 12 hours
266 case 21: // 0 12 021 . Maximum temperature.
267 case 114: // 0 12 114 . Maximum temperature at 2 m , past 12 hours
268 case 116: // 0 12 116 . Maximum temperature at 2 m , past 24 hours
269 if ( syn->s3.TxTxTx[0] == 0 && ( s->itval % ( 3 * 3600 ) ) == 0 ) // only for 3, 6 ... hours
270 {
271 if ( kelvin_to_snTTT ( aux, s->val ) )
272 {
273 syn->s3.snx[0] = aux[0];
274 strcpy ( syn->s3.TxTxTx, aux + 1 );
275 syn->mask |= SYNOP_SEC3;
276 }
277 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
278 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
279 }
280 break;
281
282 case 11: // 0 12 011 . Maximum temperature at heigh and over the period specified
283 case 111: // 0 12 111 . Maximum temperature at heigh and over the period specified
284 if ( syn->s3.TxTxTx[0] == 0 &&
285 ( s->hsensor >= 1.0 || s->hsensor <= 0 ) &&
286 ( time_period_duration ( s ) % ( 12 * 3600 ) ) == 0 ) // only for 12 , 24 hours
287 {
288 if ( kelvin_to_snTTT ( aux, s->val ) )
289 {
290 syn->s3.snx[0] = aux[0];
291 strcpy ( syn->s3.TxTxTx, aux + 1 );
292 syn->mask |= SYNOP_SEC3;
293 }
294 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
295 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
296 }
297 break;
298
299
300 case 15: // 0 12 015 . Minimum temperature at 2 m , past 12 hours
301 case 22: // 0 12 022 . Minimum temperature.
302 case 115: // 0 12 115 . Minimum temperature at 2 m , past 12 hours
303 case 117: // 0 12 117 . Minimum temperature at 2 m , past 24 hours
304 if ( syn->s3.TnTnTn[0] == 0 && ( s->itval % ( 3 * 3600 ) ) == 0 ) // only for 3, 6 ... hours
305 {
306 if ( kelvin_to_snTTT ( aux, s->val ) )
307 {
308 syn->s3.snn[0] = aux[0];
309 strcpy ( syn->s3.TnTnTn, aux + 1 );
310 syn->mask |= SYNOP_SEC3;
311 }
312 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
313 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
314 }
315 break;
316
317 case 12: // 0 12 012 . Minimum temperature at heigh and over the period specified
318 case 112: // 0 12 112 . Minimum temperature at heigh and over the period specified
319 if ( syn->s3.TnTnTn[0] == 0 &&
320 ( s->hsensor >= 1.0 || s->hsensor <= 0 ) &&
321 ( time_period_duration ( s ) % ( 12 * 3600 ) ) == 0 ) // only for 12 , 24 hours
322 {
323 if ( kelvin_to_snTTT ( aux, s->val ) )
324 {
325 syn->s3.snn[0] = aux[0];
326 strcpy ( syn->s3.TnTnTn, aux + 1 );
327 syn->mask |= SYNOP_SEC3;
328 }
329 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
330 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
331 }
332 break;
333
334 case 2: // 0 12 002 . Wet bulb temperature
335 case 5: // 0 12 005 . Wet bulb temperature at 2 m
336 case 102: // 0 12 102 . Wet bulb temperature
337 case 105: // 0 12 105 . Wet bulb temperature at 2 m
338 if ( syn->s2.TbTbTb[0] == 0 )
339 {
340 if ( kelvin_to_snTTT ( aux, s->val ) )
341 {
342 syn->s2.sw[0] = aux[0];
343 strcpy ( syn->s2.TbTbTb, aux + 1 );
344 syn->mask |= SYNOP_SEC2;
345 }
346 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
347 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTTT()", "Unspected parse problem" );
348 }
349 break;
350
351 case 113: // 0 12 113 . Ground minimum temperature, past 12 hours
352 if ( strcmp ( "6", syn->s0.A1 ) == 0 ||
353 strcmp ( "3", syn->s0.A1 ) == 0 ||
354 strcmp ( "2", syn->s0.A1 ) == 0
355 ) // region III or VI
356 {
357 if ( kelvin_to_snTT ( aux, s->val ) )
358 {
359 strcpy ( syn->s3.jjj, aux );
360 syn->mask |= SYNOP_SEC3;
361 }
362 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
363 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTT()", "Unspected parse problem" );
364 }
365 else if ( strcmp ( "1", syn->s0.A1 ) == 0 )
366 {
367 if ( kelvin_to_TT ( aux, s->val ) )
368 {
369 syn->s3.XoXoXoXo[0] = aux[0];
370 syn->s3.XoXoXoXo[1] = aux[1];
371 if ( syn->s3.XoXoXoXo[2] == 0 )
372 {
373 syn->s3.XoXoXoXo[2] = '/';
374 }
375 if ( syn->s3.XoXoXoXo[3] == 0 )
376 {
377 syn->s3.XoXoXoXo[3] = '/';
378 }
379 syn->mask |= SYNOP_SEC3;
380 }
381 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
382 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTT()", "Unspected parse problem" );
383 }
384 break;
385
386 case 121: // 0 12 121 . Ground minimum temperature (at the time of observation)
387 if ( strcmp ( "2", syn->s0.A1 ) == 0 ) // region II
388 {
389 if ( kelvin_to_snTT ( aux, s->val ) )
390 {
391 syn->s3.XoXoXoXo[1] = aux[0];
392 syn->s3.XoXoXoXo[2] = aux[1];
393 syn->s3.XoXoXoXo[3] = aux[2];
394 syn->mask |= SYNOP_SEC3;
395 }
396 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
397 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTT()", "Unspected parse problem" );
398 }
399 break;
400
401 case 120: // 0 12 120 . Ground temperature
402 if ( strcmp ( "2", syn->s0.A1 ) == 0 ) // Only for Region II
403 {
404 if ( kelvin_to_snTT ( aux, s->val ) )
405 {
406 if ( syn->s3.E1[0] )
407 syn->s3.XoXoXoXo[0] = '/';
408 else if ( syn->s3.E[0] )
409 syn->s3.XoXoXoXo[0] = syn->s3.E[0];
410 syn->s3.XoXoXoXo[1] = aux[0];
411 syn->s3.XoXoXoXo[2] = aux[1];
412 syn->s3.XoXoXoXo[3] = aux[2];
413 }
414 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
415 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_snTT()", "Unspected parse problem" );
416 }
417 break;
418
419 case 122: // 0 12 122 . Ground minimum temperature during preceding night
420 if ( strcmp ( "1", syn->s0.A1 ) == 0 ) // Only for Region I
421 {
422 if ( kelvin_to_TT ( aux, s->val ) )
423 {
424 syn->s3.XoXoXoXo[0] = aux[0];
425 syn->s3.XoXoXoXo[1] = aux[1];
426 if ( syn->s3.XoXoXoXo[2] == 0 )
427 {
428 syn->s3.XoXoXoXo[2] = '/';
429 }
430 if ( syn->s3.XoXoXoXo[3] == 0 )
431 {
432 syn->s3.XoXoXoXo[3] = '/';
433 }
434 syn->mask |= SYNOP_SEC3;
435 }
436 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
437 bufr2tac_set_error ( s, 1, "syn_parse_x12()->kelvin_to_TT()", "Unspected parse problem" );
438 }
439 else if ( strcmp ( "2", syn->s0.A1 ) == 0 ||
440 strcmp ( "3", syn->s0.A1 ) == 0 ) // Region II and III
441 {
442 if ( kelvin_to_snTT ( aux, s->val ) )
443 {
444 strcpy ( syn->s3.jjj, aux );
445 syn->mask |= SYNOP_SEC3;
446 }
447 }
448 break;
449
450 default:
451 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
452 bufr2tac_set_error ( s, 0, "syn_parse_x12()", "Descriptor not parsed" );
453 break;
454 }
455 return 0;
456}
int time_period_duration(struct bufr2tac_subset_state *s)
Get time period duration in seconds.
Definition: bufr2tac_x04.c:33
char * kelvin_to_TT(char *target, double T)
converts a kelvin temperature value into a TT string
Definition: bufr2tac_x12.c:96
char * kelvin_to_snTT(char *target, double T)
converts a kelvin temperature value into a snTT string
Definition: bufr2tac_x12.c:69

References bufr2tac_subset_state::a, synop_sec0::A1, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec3::E, synop_sec3::E1, bufr2tac_subset_state::hsensor, bufr2tac_subset_state::itval, synop_sec3::jjj, kelvin_to_snTT(), kelvin_to_snTTT(), kelvin_to_TT(), bufr_atom_data::mask, synop_chunks::mask, synop_chunks::s0, synop_chunks::s1, synop_chunks::s2, synop_chunks::s3, synop_sec1::sn1, synop_sec1::sn2, synop_sec3::snn, synop_sec3::snx, synop_sec2::sw, SYNOP_SEC1, SYNOP_SEC2, SYNOP_SEC3, synop_sec2::TbTbTb, synop_sec1::TdTdTd, time_period_duration(), synop_sec3::TnTnTn, synop_sec1::TTT, synop_sec3::TxTxTx, bufr2tac_subset_state::val, synop_sec3::XoXoXoXo, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x13()

int syn_parse_x13 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 13.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 201 of file bufr2tac_x13.c.

202{
203 int tpd, hr;
204 char aux[8];
205
206 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
207 {
208 return 0;
209 }
210
211 switch ( s->a->desc.y )
212 {
213 case 3: // 0 13 003 . Relative humidity %
214 if ( s->ival < 0 || s->ival > 100 )
215 {
216 return 0;
217 }
218 sprintf ( syn->s1.UUU, "%03d", s->ival );
219 syn->mask |= SYNOP_SEC1;
220 break;
221
222 case 11: // 0 13 011 . Total precipitation
223 if ( s->val < 0.0 )
224 {
225 if (s->val < -0.11 || s->val > -0.09)
226 return 0;
227 }
228 tpd = time_period_duration ( s );
229 hr = hour_rounded ( syn );
230 if ( tpd == 3600 )
231 {
232 if ( syn->s3.RRR[0] == 0 )
233 {
234 if ( strcmp ( "1", syn->s0.A1 ) == 0 ||
235 strcmp ( "2", syn->s0.A1 ) == 0 ||
236 strcmp ( "3", syn->s0.A1 ) == 0 ||
237 strcmp ( "4", syn->s0.A1 ) == 0 ||
238 strcmp ( "5", syn->s0.A1 ) == 0 ||
239 strcmp ( "6", syn->s0.A1 ) == 0 )
240 {
241 /*if ( hr % 3)
242 {*/
243 syn->s3.tr[0] = '5'; // 1 hour
244 prec_to_RRR ( syn->s3.RRR, s->val );
245 syn->mask |= SYNOP_SEC3;
246 /*}*/
247 }
248 }
249 else if ( syn->s5.RRR[0] == 0 )
250 {
251 syn->s5.tr[0] = '5'; // 1 hour
252 prec_to_RRR ( syn->s5.RRR, s->val );
253 syn->mask |= SYNOP_SEC5;
254 }
255 }
256 else if ( tpd == 7200 )
257 {
258 if ( syn->s1.RRR[0] == 0 )
259 {
260 if ( strcmp ( "6", syn->s0.A1 ) )
261 {
262 //Not for REG IV
263 syn->s1.tr[0] = '6'; // 2 hour
264 prec_to_RRR ( syn->s1.RRR, s->val );
265 syn->mask |= SYNOP_SEC1;
266 }
267 }
268 }
269 else if ( tpd == 10800 )
270 {
271 if ( ( hr % 3 ) == 0 )
272 {
273 if ( syn->s3.tr[0] == '5' )
274 {
275 syn->s5.tr[0] = '5';
276 strcpy ( syn->s5.RRR, syn->s3.RRR );
277 syn->mask |= SYNOP_SEC5;
278 }
279 syn->s3.tr[0] = '7'; // 3 hour
280 prec_to_RRR ( syn->s3.RRR, s->val );
281 syn->mask |= SYNOP_SEC3;
282 }
283 }
284 else if ( tpd == ( 6 * 3600 ) )
285 {
286 if ( strcmp ( "1", syn->s0.A1 ) == 0 )
287 {
288 if ( ( hr % 12 ) == 0 )
289 {
290 syn->s1.tr[0] = '1'; // 6 hour
291 prec_to_RRR ( syn->s1.RRR, s->val );
292 syn->mask |= SYNOP_SEC1;
293 }
294 }
295 else if ( strcmp ( "2", syn->s0.A1 ) == 0 )
296 {
297 if ( ( hr % 3 ) == 0 )
298 {
299 syn->s1.tr[0] = '1'; // 6 hour
300 prec_to_RRR ( syn->s1.RRR, s->val );
301 syn->mask |= SYNOP_SEC1;
302 }
303 }
304 else if ( strcmp ( "3", syn->s0.A1 ) == 0 )
305 {
306 if ( hr == 0 ||
307 hr == 6 ||
308 hr == 18 )
309 {
310 syn->s1.tr[0] = '1'; // 6 hour
311 prec_to_RRR ( syn->s1.RRR, s->val );
312 syn->mask |= SYNOP_SEC1;
313 }
314 }
315 else if ( strcmp ( "4", syn->s0.A1 ) == 0 )
316 {
317 if ( ( hr % 6 ) == 0 )
318 {
319 syn->s1.tr[0] = '1'; // 6 hour
320 prec_to_RRR ( syn->s1.RRR, s->val );
321 syn->mask |= SYNOP_SEC1;
322 }
323 }
324 else if ( strcmp ( "5", syn->s0.A1 ) == 0 )
325 {
326 if ( hr == 6 ||
327 hr == 12 ||
328 hr == 18 )
329 {
330 syn->s1.tr[0] = '1'; // 6 hour
331 prec_to_RRR ( syn->s1.RRR, s->val );
332 syn->mask |= SYNOP_SEC1;
333 }
334 }
335 else if ( strcmp ( "6", syn->s0.A1 ) == 0 )
336 {
337 if ( hr == 0 ||
338 hr == 18 )
339 {
340 syn->s1.tr[0] = '1'; // 6 hour
341 prec_to_RRR ( syn->s1.RRR, s->val );
342 syn->mask |= SYNOP_SEC1;
343 }
344 }
345 else if ( strcmp ( "7", syn->s0.A1 ) == 0 )
346 {
347 if ( hr == 6 )
348 {
349 syn->s1.tr[0] = '1'; // 6 hour
350 prec_to_RRR ( syn->s1.RRR, s->val );
351 syn->mask |= SYNOP_SEC1;
352 }
353 }
354
355 // last chance
356 if ( syn->s1.RRR[0] == 0 )
357 {
358 if ( ( hr % 6 ) == 0 )
359 {
360 syn->s1.tr[0] = '1'; // 6 hour
361 prec_to_RRR ( syn->s1.RRR, s->val );
362 syn->mask |= SYNOP_SEC1;
363 }
364 }
365 }
366 else if ( tpd == ( 9 * 3600 ) )
367 {
368 if ( syn->s3.RRR[0] == 0 )
369 {
370 syn->s3.tr[0] = '8'; // 9 hour
371 prec_to_RRR ( syn->s3.RRR, s->val );
372 syn->mask |= SYNOP_SEC3;
373 }
374 else if ( syn->s5.RRR[0] == 0 )
375 {
376 syn->s5.tr[0] = '8'; // 9 hour
377 prec_to_RRR ( syn->s5.RRR, s->val );
378 syn->mask |= SYNOP_SEC5;
379 }
380 }
381 else if ( tpd == ( 12 * 3600 ) )
382 {
383 if ( strcmp ( "1", syn->s0.A1 ) == 0 )
384 {
385 if ( hr == 18 )
386 {
387 syn->s1.tr[0] = '2'; // 12 hour
388 prec_to_RRR ( syn->s1.RRR, s->val );
389 syn->mask |= SYNOP_SEC1;
390 }
391 }
392 else if ( strcmp ( "2", syn->s0.A1 ) == 0 )
393 {
394 if ( ( hr % 3 ) == 0 )
395 {
396 syn->s1.tr[0] = '2'; // 12 hour
397 prec_to_RRR ( syn->s1.RRR, s->val );
398 syn->mask |= SYNOP_SEC1;
399 }
400 }
401 else if ( strcmp ( "6", syn->s0.A1 ) == 0 )
402 {
403 if ( ( hr % 12 ) == 6 )
404 {
405 syn->s1.tr[0] = '2'; // 12 hour
406 prec_to_RRR ( syn->s1.RRR, s->val ) ;
407 syn->mask |= SYNOP_SEC1;
408 }
409 else if ( strcmp( syn->s0.II, "08") == 0 && syn->s0.iii[0] == '5' ) // Portugal exception
410 {
411 syn->s1.tr[0] = '2'; // 12 hour
412 prec_to_RRR ( syn->s1.RRR, s->val );
413 syn->mask |= SYNOP_SEC1;
414 }
415 }
416 else if ( strcmp ( "7", syn->s0.A1 ) == 0 )
417 {
418 if ( hr == 12 )
419 {
420 syn->s1.tr[0] = '2'; // 12 hour
421 prec_to_RRR ( syn->s1.RRR, s->val );
422 syn->mask |= SYNOP_SEC1;
423 }
424 }
425
426 // last chance
427 if ( syn->s1.RRR[0] == 0 )
428 {
429 if ( ( hr % 6 ) == 0 )
430 {
431 syn->s1.tr[0] = '2'; // 12 hour
432 prec_to_RRR ( syn->s1.RRR, s->val );
433 syn->mask |= SYNOP_SEC1;
434 }
435 else if ( ( hr % 3 ) == 0 )
436 {
437 if ( syn->s3.RRR[0] == 0 )
438 {
439 syn->s3.tr[0] = '2'; // 12 hour
440 prec_to_RRR ( syn->s3.RRR, s->val );
441 syn->mask |= SYNOP_SEC3;
442 }
443 else if ( syn->s3.tr[0] == '1' ||
444 syn->s3.tr[0] == '5' )
445 {
446 strcpy ( syn->s5.tr, syn->s3.tr );
447 strcpy ( syn->s5.RRR, syn->s3.RRR );
448 syn->mask |= SYNOP_SEC5;
449 syn->s3.tr[0] = '2'; // 12 hour
450 prec_to_RRR ( syn->s3.RRR, s->val );
451 syn->mask |= SYNOP_SEC3;
452 }
453 }
454 }
455 }
456 else if ( tpd == ( 15 * 3600 ) )
457 {
458 if ( syn->s3.RRR[0] == 0 )
459 {
460 syn->s3.tr[0] = '9'; // 15 hour
461 prec_to_RRR ( syn->s3.RRR, s->val );
462 syn->mask |= SYNOP_SEC3;
463 }
464 else if ( syn->s5.RRR[0] == 0 )
465 {
466 syn->s5.tr[0] = '9'; // 15 hour
467 prec_to_RRR ( syn->s5.RRR, s->val );
468 syn->mask |= SYNOP_SEC5;
469 }
470 }
471 else if ( tpd == ( 18 * 3600 ) )
472 {
473 if ( strcmp ( "7", syn->s0.A1 ) == 0 )
474 {
475 if ( hr == 18 )
476 {
477 syn->s1.tr[0] = '3'; // 12 hour
478 prec_to_RRR ( syn->s1.RRR, s->val );
479 syn->mask |= SYNOP_SEC1;
480 }
481 }
482 }
483 else if ( tpd == ( 24 * 3600 ) )
484 {
485 if ( strcmp ( "1", syn->s0.A1 ) == 0 )
486 {
487 if ( hr == 6 )
488 {
489 syn->s1.tr[0] = '4'; // 24 hour
490 prec_to_RRR ( syn->s1.RRR, s->val );
491 syn->mask |= SYNOP_SEC1;
492 }
493 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
494 syn->mask |= SYNOP_SEC3;
495 }
496 else if ( strcmp ( "2", syn->s0.A1 ) == 0 )
497 {
498 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
499 syn->mask |= SYNOP_SEC3;
500 }
501 else if ( strcmp ( "3", syn->s0.A1 ) == 0 )
502 {
503 if ( hr == 12 )
504 {
505 syn->s1.tr[0] = '4'; // 24 hour
506 prec_to_RRR ( syn->s1.RRR, s->val );
507 syn->mask |= SYNOP_SEC1;
508 }
509 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
510 syn->mask |= SYNOP_SEC3;
511 }
512 else if ( strcmp ( "4", syn->s0.A1 ) == 0 )
513 {
514 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
515 syn->mask |= SYNOP_SEC3;
516 }
517 else if ( strcmp ( "5", syn->s0.A1 ) == 0 )
518 {
519 if ( hr == 0 )
520 {
521 syn->s1.tr[0] = '4'; // 24 hour
522 prec_to_RRR ( syn->s1.RRR, s->val );
523 syn->mask |= SYNOP_SEC1;
524 }
525 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
526 syn->mask |= SYNOP_SEC3;
527 }
528 else if ( strcmp ( "6", syn->s0.A1 ) == 0 )
529 {
530 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
531 {
532 if ( strcmp ( "06", syn->e.HH ) == 0 )
533 {
534 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
535 syn->mask |= SYNOP_SEC3;
536 }
537 }
538 else
539 {
540 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
541 syn->mask |= SYNOP_SEC3;
542 }
543 }
544 else if ( strcmp ( "7", syn->s0.A1 ) == 0 )
545 {
546 if ( hr == 0 )
547 {
548 syn->s1.tr[0] = '4'; // 24 hour
549 prec_to_RRR ( syn->s1.RRR, s->val );
550 syn->mask |= SYNOP_SEC1;
551 }
552 }
553 }
554 break;
555
556 case 13: // 0 13 013 . Total snow depth
557 if ( syn->s3.sss[0] == 0 )
558 {
559 total_snow_depth_to_sss ( syn->s3.sss, s->val );
560 syn->mask |= SYNOP_SEC3;
561 }
562 break;
563
564 case 19: // 0 13 019 . Total precipitaction past 1 hour
565 hr = hour_rounded ( syn );
566 if ( syn->s3.RRR[0] == 0 )
567 {
568 if ( strcmp ( "1", syn->s0.A1 ) == 0 ||
569 strcmp ( "2", syn->s0.A1 ) == 0 ||
570 strcmp ( "3", syn->s0.A1 ) == 0 ||
571 strcmp ( "4", syn->s0.A1 ) == 0 ||
572 strcmp ( "5", syn->s0.A1 ) == 0 ||
573 strcmp ( "6", syn->s0.A1 ) == 0 )
574 {
575 /*if ( hr % 3)
576 {*/
577 syn->s3.tr[0] = '5'; // 1 hour
578 prec_to_RRR ( syn->s3.RRR, s->val );
579 syn->mask |= SYNOP_SEC3;
580 /*}*/
581 }
582 }
583 else if ( syn->s5.RRR[0] == 0 )
584 {
585 syn->s5.tr[0] = '5'; // 1 hour
586 prec_to_RRR ( syn->s5.RRR, s->val );
587 syn->mask |= SYNOP_SEC5;
588 }
589 break;
590
591 case 20: // 0 13 020 . Total precipitation past 3 hours
592 hr = hour_rounded ( syn );
593 if ( ( hr % 3 ) == 0 )
594 {
595 if ( syn->s3.tr[0] == '5' )
596 {
597 syn->s5.tr[0] = '5';
598 strcpy ( syn->s5.RRR, syn->s3.RRR );
599 syn->mask |= SYNOP_SEC5;
600 }
601 syn->s3.tr[0] = '7'; // 3 hour
602 prec_to_RRR ( syn->s3.RRR, s->val );
603 syn->mask |= SYNOP_SEC3;
604 }
605 break;
606
607 case 21: // 0 13 021 . Total precipitation past 6 hours
608 hr = hour_rounded ( syn );
609 if ( strcmp ( "1", syn->s0.A1 ) == 0 )
610 {
611 if ( ( hr % 12 ) == 0 )
612 {
613 syn->s1.tr[0] = '1'; // 6 hour
614 prec_to_RRR ( syn->s1.RRR, s->val );
615 syn->mask |= SYNOP_SEC1;
616 }
617 }
618 else if ( strcmp ( "2", syn->s0.A1 ) == 0 )
619 {
620 if ( ( hr % 3 ) == 0 )
621 {
622 syn->s1.tr[0] = '1'; // 6 hour
623 prec_to_RRR ( syn->s1.RRR, s->val );
624 syn->mask |= SYNOP_SEC1;
625 }
626 }
627 else if ( strcmp ( "3", syn->s0.A1 ) == 0 )
628 {
629 if ( hr == 0 ||
630 hr == 6 ||
631 hr == 18 )
632 {
633 syn->s1.tr[0] = '1'; // 6 hour
634 prec_to_RRR ( syn->s1.RRR, s->val );
635 syn->mask |= SYNOP_SEC1;
636 }
637 }
638 else if ( strcmp ( "4", syn->s0.A1 ) == 0 )
639 {
640 if ( ( hr % 6 ) == 0 )
641 {
642 syn->s1.tr[0] = '1'; // 6 hour
643 prec_to_RRR ( syn->s1.RRR, s->val );
644 syn->mask |= SYNOP_SEC1;
645 }
646 }
647 else if ( strcmp ( "5", syn->s0.A1 ) == 0 )
648 {
649 if ( hr == 6 ||
650 hr == 12 ||
651 hr == 18 )
652 {
653 syn->s1.tr[0] = '1'; // 6 hour
654 prec_to_RRR ( syn->s1.RRR, s->val );
655 syn->mask |= SYNOP_SEC1;
656 }
657 }
658 else if ( strcmp ( "6", syn->s0.A1 ) == 0 )
659 {
660 if ( hr == 0 ||
661 hr == 18 )
662 {
663 syn->s1.tr[0] = '1'; // 6 hour
664 prec_to_RRR ( syn->s1.RRR, s->val );
665 syn->mask |= SYNOP_SEC1;
666 }
667 }
668 else if ( strcmp ( "7", syn->s0.A1 ) == 0 )
669 {
670 if ( hr == 6 )
671 {
672 syn->s1.tr[0] = '1'; // 6 hour
673 prec_to_RRR ( syn->s1.RRR, s->val );
674 syn->mask |= SYNOP_SEC1;
675 }
676 }
677
678 if ( syn->s1.RRR[0] == 0 )
679 {
680 if ( ( hr % 6 ) == 0 )
681 {
682 syn->s1.tr[0] = '1'; // 6 hour
683 prec_to_RRR ( syn->s1.RRR, s->val );
684 syn->mask |= SYNOP_SEC1;
685 }
686 }
687 break;
688
689 case 22: // 0 13 022 . Total precipitation past 12 hours
690 hr = hour_rounded ( syn );
691 if ( strcmp ( "1", syn->s0.A1 ) == 0 )
692 {
693 if ( hr == 18 )
694 {
695 syn->s1.tr[0] = '2'; // 12 hour
696 prec_to_RRR ( syn->s1.RRR, s->val );
697 syn->mask |= SYNOP_SEC1;
698 }
699 }
700 else if ( strcmp ( "2", syn->s0.A1 ) == 0 )
701 {
702 if ( ( hr % 3 ) == 0 )
703 {
704 syn->s1.tr[0] = '2'; // 12 hour
705 prec_to_RRR ( syn->s1.RRR, s->val );
706 syn->mask |= SYNOP_SEC1;
707 }
708 }
709 else if ( strcmp ( "6", syn->s0.A1 ) == 0 )
710 {
711 if ( ( hr % 12 ) == 6 )
712 {
713 syn->s1.tr[0] = '2'; // 12 hour
714 prec_to_RRR ( syn->s1.RRR, s->val );
715 syn->mask |= SYNOP_SEC1;
716 }
717 }
718 else if ( strcmp ( "7", syn->s0.A1 ) == 0 )
719 {
720 if ( hr == 12 )
721 {
722 syn->s1.tr[0] = '2'; // 12 hour
723 prec_to_RRR ( syn->s1.RRR, s->val );
724 syn->mask |= SYNOP_SEC1;
725 }
726 }
727
728 // Last chance
729 if ( syn->s1.RRR[0] == 0 )
730 {
731 if ( ( hr % 6 ) == 0 )
732 {
733 syn->s1.tr[0] = '2'; // 12 hour
734 prec_to_RRR ( syn->s1.RRR, s->val );
735 syn->mask |= SYNOP_SEC1;
736 }
737 else if ( ( hr % 3 ) == 0 )
738 {
739 if ( syn->s3.RRR[0] == 0 )
740 {
741 syn->s3.tr[0] = '2'; // 12 hour
742 prec_to_RRR ( syn->s3.RRR, s->val );
743 syn->mask |= SYNOP_SEC3;
744 }
745 else if ( syn->s3.tr[0] == '1' ||
746 syn->s3.tr[0] == '5' )
747 {
748 strcpy ( syn->s5.tr, syn->s3.tr );
749 strcpy ( syn->s5.RRR, syn->s3.RRR );
750 syn->mask |= SYNOP_SEC5;
751 syn->s3.tr[0] = '2'; // 12 hour
752 prec_to_RRR ( syn->s3.RRR, s->val );
753 syn->mask |= SYNOP_SEC3;
754 }
755 }
756 }
757
758 break;
759
760 case 23: // 0 13 023 . Total precipitaction past 24 hours
761 if ( s->val < 0.0 )
762 {
763 return 0;
764 }
765 hr = hour_rounded ( syn );
766 if ( strcmp ( "1", syn->s0.A1 ) == 0 )
767 {
768 if ( hr == 6 )
769 {
770 syn->s1.tr[0] = '4'; // 24 hour
771 prec_to_RRR ( syn->s1.RRR, s->val );
772 syn->mask |= SYNOP_SEC1;
773 }
774 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
775 syn->mask |= SYNOP_SEC3;
776 }
777 else if ( strcmp ( "2", syn->s0.A1 ) == 0 )
778 {
779 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
780 syn->mask |= SYNOP_SEC3;
781 }
782 else if ( strcmp ( "3", syn->s0.A1 ) == 0 )
783 {
784 if ( hr == 12 )
785 {
786 syn->s1.tr[0] = '4'; // 24 hour
787 prec_to_RRR ( syn->s1.RRR, s->val );
788 syn->mask |= SYNOP_SEC1;
789 }
790 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
791 syn->mask |= SYNOP_SEC3;
792 }
793 else if ( strcmp ( "4", syn->s0.A1 ) == 0 )
794 {
795 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
796 syn->mask |= SYNOP_SEC3;
797 }
798 else if ( strcmp ( "5", syn->s0.A1 ) == 0 )
799 {
800 if ( hr == 0 )
801 {
802 syn->s1.tr[0] = '4'; // 24 hour
803 prec_to_RRR ( syn->s1.RRR, s->val );
804 syn->mask |= SYNOP_SEC1;
805 }
806 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
807 syn->mask |= SYNOP_SEC3;
808 }
809 else if ( strcmp ( "6", syn->s0.A1 ) == 0 )
810 {
811 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
812 {
813 if ( strcmp ( "06", syn->e.HH ) == 0 )
814 {
815 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
816 syn->mask |= SYNOP_SEC3;
817 }
818 }
819 else
820 {
821 prec_to_RRRR24 ( syn->s3.RRRR24, s->val );
822 syn->mask |= SYNOP_SEC3;
823 }
824 }
825 else if ( strcmp ( "7", syn->s0.A1 ) == 0 )
826 {
827 if ( hr == 0 )
828 {
829 syn->s1.tr[0] = '4'; // 24 hour
830 prec_to_RRR ( syn->s1.RRR, s->val );
831 syn->mask |= SYNOP_SEC1;
832 }
833 }
834 break;
835
836 case 56: // 0 13 056 . Character and intensity of precipitation
837 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
838 {
839 sprintf ( aux, "%d", s->ival );
840 syn->s3.XoXoXoXo[2] = aux[0];
841 syn->mask |= SYNOP_SEC3;
842 }
843 break;
844
845 case 57: // 0 13 057 . Time of beginning or end of precipitation
846 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for region I
847 {
848 sprintf ( aux, "%d" , s->ival );
849 syn->s3.XoXoXoXo[3] = aux[0];
850 syn->mask |= SYNOP_SEC3;
851 }
852 break;
853
854 case 118: // 0 13 118 . Recent snow depth
855 if ( syn->s3.d9.n < SYNOP_NMISC )
856 {
857 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "931%s", recent_snow_to_ss ( aux, s->val ) );
858 ( syn->s3.d9.n ) ++;
859 }
860 break;
861 default:
862 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
863 bufr2tac_set_error ( s, 0, "syn_parse_x13()", "Descriptor not parsed" );
864 break;
865 }
866 return 0;
867}
int hour_rounded(struct synop_chunks *syn)
Get the rounded hour of a given date.
Definition: bufr2tac_x04.c:78
char * prec_to_RRRR24(char *target, double r)
converts a precipitation in Kg/m2 into a RRRR24 string
Definition: bufr2tac_x13.c:87
char * recent_snow_to_ss(char *target, double r)
converts recent snow in m to ss (code table 3870)
Definition: bufr2tac_x13.c:157
char * prec_to_RRR(char *target, double r)
converts a precipitation in Kg/m2 into a RRR string
Definition: bufr2tac_x13.c:32
char * total_snow_depth_to_sss(char *target, double r)
converts tatal snow depth in m to sss (code table 3889)
Definition: bufr2tac_x13.c:124
char RRR[4]
Definition: metsynop.h:284
char tr[2]
Definition: metsynop.h:285

References bufr2tac_subset_state::a, synop_sec0::A1, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), synop_sec3::d9, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_chunks::e, report_date_ext::HH, hour_rounded(), synop_sec0::II, synop_sec0::iii, bufr2tac_subset_state::ival, bufr_atom_data::mask, synop_chunks::mask, data9::misc, data9::n, prec_to_RRR(), prec_to_RRRR24(), recent_snow_to_ss(), synop_sec1::RRR, synop_sec3::RRR, synop_sec5::RRR, synop_sec3::RRRR24, synop_chunks::s0, synop_chunks::s1, synop_chunks::s3, synop_chunks::s5, misc3::SpSp, synop_sec3::sss, SYNOP_NMISC, SYNOP_SEC1, SYNOP_SEC3, SYNOP_SEC5, time_period_duration(), total_snow_depth_to_sss(), synop_sec1::tr, synop_sec3::tr, synop_sec5::tr, synop_sec1::UUU, bufr2tac_subset_state::val, synop_sec3::XoXoXoXo, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x14()

int syn_parse_x14 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 14.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 59 of file bufr2tac_x14.c.

60{
61 int tpd;
62
63 switch ( s->a->desc.y )
64 {
65 case 1: // 0 14 001 long-wave radiation 24 hours
66 case 11:
68 {
69 return 0;
70 }
71 strcpy ( syn->s3.j524[4], "4" );
72 sprintf ( syn->s3.FFFF24[4], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
73 syn->mask |= SYNOP_SEC3;
74 break;
75
76 case 2: // 0 14 002 Long-wave radiation
77 case 12:
79 {
80 return 0;
81 }
82 tpd = time_period_duration ( s );
83 if ( tpd == ( 24 * 3600 ) )
84 {
85 if ( check_j_cm2 ( s->val ) == 0 )
86 return 0;
87 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
88 {
89 if ( strcmp ( "06", syn->e.HH ) == 0 )
90 {
91 if ( s->ival >= 0 )
92 {
93 strcpy ( syn->s3.j524[4], "4" );
94 sprintf ( syn->s3.FFFF24[4], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
95 }
96 else
97 {
98 strcpy ( syn->s3.j524[5], "5" );
99 sprintf ( syn->s3.FFFF24[5], "%04d", ( int ) ( - ( s->val ) / 10000.0 + 0.5 ) );
100 }
101 syn->mask |= SYNOP_SEC3;
102 }
103 }
104 else
105 {
106 if ( s->ival >= 0 )
107 {
108 strcpy ( syn->s3.j524[4], "4" );
109 sprintf ( syn->s3.FFFF24[4], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
110 }
111 else
112 {
113 strcpy ( syn->s3.j524[5], "5" );
114 sprintf ( syn->s3.FFFF24[5], "%04d", ( int ) ( - ( s->val ) / 10000.0 + 0.5 ) );
115 }
116 syn->mask |= SYNOP_SEC3;
117 }
118 }
119 else if ( tpd == 3600 )
120 {
121 if ( check_kj_m2 ( s->val ) == 0 )
122 return 0;
123 if ( s->ival >= 0 )
124 {
125 strcpy ( syn->s3.j5[4], "4" );
126 sprintf ( syn->s3.FFFF[4], "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
127 }
128 else
129 {
130 strcpy ( syn->s3.j5[4], "5" );
131 sprintf ( syn->s3.FFFF[4], "%04d", ( int ) ( - ( s->val ) / 1000.0 + 0.5 ) );
132 }
133 }
134 syn->mask |= SYNOP_SEC3;
135 break;
136
137 case 3: // 0 14 003 short-wave radiation 24 hours
138 case 13:
139 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
140 {
141 return 0;
142 }
143 if ( check_j_cm2 ( s->val ) == 0 )
144 return 0;
145 strcpy ( syn->s3.j524[6], "6" );
146 sprintf ( syn->s3.FFFF24[6], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
147 syn->mask |= SYNOP_SEC3;
148 break;
149
150 case 4: // 0 14 002 short-wave radiation
151 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
152 {
153 return 0;
154 }
155 tpd = time_period_duration ( s );
156 if ( tpd == ( 24 * 3600 ) )
157 {
158 if ( check_j_cm2 ( s->val ) == 0 )
159 return 0;
160 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
161 {
162 if ( strcmp ( "06", syn->e.HH ) == 0 )
163 {
164 strcpy ( syn->s3.j524[6], "6" );
165 sprintf ( syn->s3.FFFF24[6], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
166 }
167 }
168 else
169 {
170 strcpy ( syn->s3.j524[6], "6" );
171 sprintf ( syn->s3.FFFF24[6], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
172 }
173 }
174 else if ( tpd == 3600 )
175 {
176 if ( check_kj_m2 ( s->val ) == 0 )
177 return 0;
178 strcpy ( syn->s3.j5[6], "6" );
179 sprintf ( syn->s3.FFFF[6], "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
180 }
181 syn->mask |= SYNOP_SEC3;
182 break;
183
184 case 14: // 0 14 014 Net short wave radiation integrated over period specified
185 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
186 {
187 return 0;
188 }
189 tpd = time_period_duration ( s );
190 if ( tpd == ( 24 * 3600 ) )
191 {
192 if ( check_j_cm2 ( s->val ) == 0 )
193 return 0;
194 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
195 {
196 if ( strcmp ( "06", syn->e.HH ) == 0 )
197 {
198 sprintf ( syn->s3.FFFF507, "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
199 syn->mask |= SYNOP_SEC3;
200 }
201 }
202 else
203 {
204 sprintf ( syn->s3.FFFF507, "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
205 syn->mask |= SYNOP_SEC3;
206 }
207 }
208 else if ( tpd == 3600 )
209 {
210 if ( check_kj_m2 ( s->val ) == 0 )
211 return 0;
212 sprintf ( syn->s3.FFFF407, "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
213 }
214 syn->mask |= SYNOP_SEC3;
215 break;
216
217
218 case 16: // 0 14 016 Short wave radiation integrated over period specified
219 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
220 {
221 return 0;
222 }
223 tpd = time_period_duration ( s );
224 if ( tpd == ( 24 * 3600 ) )
225 {
226 if ( check_j_cm2 ( s->val ) == 0 )
227 return 0;
228 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
229 {
230 if ( strcmp ( "06", syn->e.HH ) == 0 )
231 {
232 if ( s->ival >= 0 )
233 {
234 strcpy ( syn->s3.j524[0], "0" );
235 sprintf ( syn->s3.FFFF24[0], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
236 }
237 else
238 {
239 strcpy ( syn->s3.j524[1], "1" );
240 sprintf ( syn->s3.FFFF24[1], "%04d", ( int ) ( - ( s->val ) / 10000.0 + 0.5 ) );
241 }
242 syn->mask |= SYNOP_SEC3;
243 }
244 }
245 else
246 {
247 if ( s->ival >= 0 )
248 {
249 strcpy ( syn->s3.j524[0], "0" );
250 sprintf ( syn->s3.FFFF24[0], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
251 }
252 else
253 {
254 strcpy ( syn->s3.j524[1], "1" );
255 sprintf ( syn->s3.FFFF24[1], "%04d", ( int ) ( - ( s->val ) / 10000.0 + 0.5 ) );
256 }
257 syn->mask |= SYNOP_SEC3;
258 }
259 }
260 else if ( tpd == 3600 )
261 {
262 if ( check_kj_m2 ( s->val ) == 0 )
263 return 0;
264 if ( s->ival >= 0 )
265 {
266 strcpy ( syn->s3.j5[0], "0" );
267 sprintf ( syn->s3.FFFF[0], "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
268 }
269 else
270 {
271 strcpy ( syn->s3.j5[1], "1" );
272 sprintf ( syn->s3.FFFF[1], "%04d", ( int ) ( - ( s->val ) / 1000.0 + 0.5 ) );
273 }
274 }
275 syn->mask |= SYNOP_SEC3;
276 break;
277
278 case 28: // 0 14 028 Global solar radiation integrated over period specified
279 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
280 {
281 return 0;
282 }
283 tpd = time_period_duration ( s );
284 if ( tpd == ( 24 * 3600 ) )
285 {
286 if ( check_j_cm2 ( s->val ) == 0 )
287 return 0;
288 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
289 {
290 if ( strcmp ( "06", syn->e.HH ) == 0 )
291 {
292 strcpy ( syn->s3.j524[2], "2" );
293 sprintf ( syn->s3.FFFF24[2], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
294 syn->mask |= SYNOP_SEC3;
295 }
296 }
297 else
298 {
299 strcpy ( syn->s3.j524[2], "2" );
300 sprintf ( syn->s3.FFFF24[2], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
301 syn->mask |= SYNOP_SEC3;
302 }
303 }
304 else if ( tpd == 3600 )
305 {
306 if ( check_kj_m2 ( s->val ) == 0 )
307 return 0;
308 strcpy ( syn->s3.j5[2], "2" );
309 sprintf ( syn->s3.FFFF[2], "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
310 }
311 syn->mask |= SYNOP_SEC3;
312 break;
313
314 case 29: // 0 14 029 Diffuse solar radiation integrated over period specified
315 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
316 {
317 return 0;
318 }
319 tpd = time_period_duration ( s );
320 if ( tpd == ( 24 * 3600 ) )
321 {
322 if ( check_j_cm2 ( s->val ) == 0 )
323 return 0;
324 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
325 {
326 if ( strcmp ( "06", syn->e.HH ) == 0 )
327 {
328 strcpy ( syn->s3.j524[3], "3" );
329 sprintf ( syn->s3.FFFF24[3], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
330 syn->mask |= SYNOP_SEC3;
331 }
332 }
333 else
334 {
335 strcpy ( syn->s3.j524[3], "3" );
336 sprintf ( syn->s3.FFFF24[3], "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
337 syn->mask |= SYNOP_SEC3;
338 }
339 }
340 else if ( tpd == 3600 )
341 {
342 if ( check_kj_m2 ( s->val ) == 0 )
343 return 0;
344 strcpy ( syn->s3.j5[3], "3" );
345 sprintf ( syn->s3.FFFF[3], "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
346 }
347 syn->mask |= SYNOP_SEC3;
348 break;
349
350
351 case 30: // 0 14 030 Direct solar radiation integrated over period specified
352 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
353 {
354 return 0;
355 }
356 tpd = time_period_duration ( s );
357 if ( tpd == ( 24 * 3600 ) )
358 {
359 if ( check_j_cm2 ( s->val ) == 0 )
360 return 0;
361 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
362 {
363 if ( strcmp ( "06", syn->e.HH ) == 0 )
364 {
365 sprintf ( syn->s3.FFFF508, "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
366 syn->mask |= SYNOP_SEC3;
367 }
368 }
369 else
370 {
371 sprintf ( syn->s3.FFFF508, "%04d", ( int ) ( s->val / 10000.0 + 0.5 ) );
372 syn->mask |= SYNOP_SEC3;
373 }
374 }
375 else if ( tpd == 3600 )
376 {
377 if ( check_kj_m2 ( s->val ) == 0 )
378 return 0;
379 sprintf ( syn->s3.FFFF408, "%04d", ( int ) ( s->val / 1000.0 + 0.5 ) );
380 }
381 syn->mask |= SYNOP_SEC3;
382 break;
383
384 case 31: // 0 14 031 Total sunshine
385 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
386 {
387 return 0;
388 }
389 tpd = time_period_duration ( s );
390 if ( tpd == ( 24 * 3600 ) )
391 {
392 if ( check_j_cm2 ( s->val ) == 0 )
393 return 0;
394 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
395 {
396 if ( strcmp ( "06", syn->e.HH ) == 0 )
397 {
398 sprintf ( syn->s3.SSS, "%03d", (abs(s->ival) / 6) % 1000 );
399 syn->mask |= SYNOP_SEC3;
400 }
401 }
402 else
403 {
404 sprintf ( syn->s3.SSS, "%03d", (abs(s->ival) / 6) % 1000 );
405 syn->mask |= SYNOP_SEC3;
406 }
407 }
408 else if ( tpd == 3600 )
409 {
410 if ( check_kj_m2 ( s->val ) == 0 )
411 return 0;
412 sprintf ( syn->s3.SS, "%02d", abs(s->ival / 6) % 100 );
413 syn->mask |= SYNOP_SEC3;
414 }
415 break;
416
417 case 32: // 0 14 032 Total sunshine (hours)
418 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
419 {
420 return 0;
421 }
422 tpd = time_period_duration ( s );
423 if ( tpd == ( 24 * 3600 ) )
424 {
425 if ( check_j_cm2 ( s->val ) == 0 )
426 return 0;
427 if ( strcmp ( "07", syn->s0.II ) == 0 ) // France
428 {
429 if ( strcmp ( "06", syn->e.HH ) == 0 )
430 {
431 sprintf ( syn->s3.SSS, "%03d", s->ival * 10 );
432 syn->mask |= SYNOP_SEC3;
433 }
434 }
435 else
436 {
437 sprintf ( syn->s3.SSS, "%03d", s->ival * 10 );
438 syn->mask |= SYNOP_SEC3;
439 }
440 }
441 else if ( tpd == 3600 )
442 {
443 if ( check_kj_m2 ( s->val ) == 0 )
444 return 0;
445 sprintf ( syn->s3.SS, "%02d", s->ival * 10 );
446 syn->mask |= SYNOP_SEC3;
447 }
448 break;
449
450 default:
451 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
452 bufr2tac_set_error ( s, 0, "syn_parse_x14()", "Descriptor not parsed" );
453 break;
454 }
455
456 return 0;
457}
int check_kj_m2(double val)
Check if a radiation value can be wrote in Kj/m2 using up to 4 chars.
Definition: bufr2tac_x14.c:33
int check_j_cm2(double val)
Check if a radiation value can be wrote in J/cm2 using up to 4 chars.
Definition: bufr2tac_x14.c:45

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), check_j_cm2(), check_kj_m2(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_chunks::e, synop_sec3::FFFF, synop_sec3::FFFF24, synop_sec3::FFFF407, synop_sec3::FFFF408, synop_sec3::FFFF507, synop_sec3::FFFF508, report_date_ext::HH, synop_sec0::II, bufr2tac_subset_state::ival, synop_sec3::j5, synop_sec3::j524, bufr_atom_data::mask, synop_chunks::mask, synop_chunks::s0, synop_chunks::s3, synop_sec3::SS, synop_sec3::SSS, SYNOP_SEC3, time_period_duration(), bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x20()

int syn_parse_x20 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 20.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 298 of file bufr2tac_x20.c.

299{
300 char aux[16];
301
302 switch ( s->a->desc.y )
303 {
304 case 1: // 0 20 001 . Horizontal visibility
305 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
306 {
307 return 0;
308 }
309 vism_to_VV ( syn->s1.VV, s->val );
310 break;
311
312 case 3: // 0 20 003 . Present weather
313 // there are some cases
314 // Case 1)
315 // On current templates, sec1 WW is NOT preceeded by a time displacament descriptor
316 // In some national cases, a further complementary info about weather conditions is
317 // precedeed by two time displacament descriptors giving the time interval from where
318 // significant weather is described. In such cases we will use 902tt and 903tt, or
319 // 964.. if the period macthes with W1W2 period
320 // If WW = 20-29 and period matches last hour we then use 962.. group
321 // as the indication of period and 966WW as weather
322 if ( ( s->i - 1 ) == s->k_itval && ( s->i - 2 ) == s->k_jtval )
323 {
324 // check missing value
325 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
326 {
327 return 0;
328 }
329 // check no significan weather.
330 if ( s->ival == 100 || s->ival == 508 )
331 {
332 return 0;
333 }
334
335 // parse period
336 if ( s->itval == 0 && s->jtval == s->tw1w2 )
337 {
338 // Case of W1W2 interval
339 if ( syn->s3.d9.n == SYNOP_NMISC )
340 {
341 return 0;
342 }
343 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "964" );
344 s->SnSn = 964;
345 }
346 else if ( s->itval == 0 && s->jtval == -3600 && syn->s1.ww[0] == '2' )
347 {
348 // case of ww 20-29 and period equal to last hour. We will use 962...
349 if ( syn->s3.d9.n == SYNOP_NMISC )
350 {
351 return 0;
352 }
353 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "962" );
354 s->SnSn = 962;
355 }
356 else
357 {
358 if ( ( syn->s3.d9.n + 2 ) >= SYNOP_NMISC )
359 {
360 return 0;
361 }
362 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "902" );
363 secs_to_tt ( syn->s3.d9.misc[syn->s3.d9.n].spsp, s->jtval );
364 syn->s3.d9.n++;
365 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "903" );
366 secs_to_tt ( syn->s3.d9.misc[syn->s3.d9.n].spsp, s->itval );
367 syn->s3.d9.n++;
368 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "966" );
369 s->SnSn = 966;
370 }
371
372 // now set the value
373 if ( s->ival < 100 )
374 {
375 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp , "%02d", s->ival );
376 syn->mask |= SYNOP_SEC3;
377 }
378 else if ( s->ival < 200 )
379 {
380 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", s->ival % 100 );
381 syn->mask |= SYNOP_SEC3;
382 }
383 syn->s3.d9.n++;
384 }
385
386 // Case 2)
387 // Complementary present weather after 7wwW1W1 has been set.
388 // If last itval == 0 the we assume that the info should be set on 960.. groups
389 else if ( syn->s1.ww[0] && s->itval == 0 )
390 {
391 // check if overflowed 9 struct
392 if ( syn->s3.d9.n == SYNOP_NMISC )
393 {
394 return 0;
395 }
396 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "960" );
397 s->SnSn = 960;
398
399 if ( s->ival < 0 )
400 {
401 return 0;
402 }
403 if ( s->ival < 100 )
404 {
405 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp , "%02d", s->ival );
406 syn->mask |= SYNOP_SEC3;
407 }
408 else if ( s->ival < 200 )
409 {
410 sprintf ( syn->s3.d9.misc[syn->s3.d9.n].spsp, "%02d", s->ival % 100 );
411 syn->mask |= SYNOP_SEC3;
412 }
413 syn->s3.d9.n++;
414 }
415 else
416 {
417 // 7wwW1W2 group
418 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
419 {
421 return 0;
422 }
423 if ( s->ival < 100 )
424 {
425 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
426 {
427 strcpy ( syn->s1.ix, "1" );
428 }
429 else if ( s->type == 1 || s->type == 2 )
430 {
431 strcpy ( syn->s1.ix, "1" );
432 }
433 else if ( s->type == 0 )
434 {
435 strcpy ( syn->s1.ix, "4" );
436 }
437 sprintf ( syn->s1.ww, "%02d", s->ival );
438 syn->mask |= SYNOP_SEC1;
439 }
440 else if ( s->ival == 100 )
441 {
442 strcpy ( syn->s1.ix, "5" );
443 syn->mask |= SYNOP_SEC1;
445 }
446 else if ( s->ival < 200 )
447 {
448 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
449 {
450 strcpy ( syn->s1.ix, "7" );
451 }
452 else if ( s->type == 0 || s->type == 2 )
453 {
454 strcpy ( syn->s1.ix, "7" );
455 }
456 sprintf ( syn->s1.ww, "%02d", s->ival % 100 );
457 syn->mask |= SYNOP_SEC1;
458 }
459 else if ( s->ival == 508 )
460 {
461 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
462 {
463 strcpy ( syn->s1.ix, "5" );
464 }
465 else if ( s->type == 0 || s->type == 2 )
466 {
467 strcpy ( syn->s1.ix, "5" );
468 }
470 }
471 else if ( s->ival == 509 )
472 {
473 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
474 {
475 strcpy ( syn->s1.ix, "6" );
476 }
477 else if ( s->type == 0 || s->type == 2 )
478 {
479 strcpy ( syn->s1.ix, "6" );
480 }
482 }
483
484 //printf("%s%s* %s\n", syn->s0.II, syn->s0.iii, syn->s1.ww);
485 }
486 break;
487
488 case 4: // 0 20 004 . Past weather (1)
489 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
490 {
492 return 0;
493 }
494
495 // stores w1w2 period
496 s->tw1w2 = s->itval;
497 if ( s->ival < 10 )
498 {
499 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
500 {
501 strcpy ( syn->s1.ix,"1" );
502 }
503 else if ( syn->s1.ix[0] == '/' )
504 {
505 if ( s->type == 1 || s->type == 2 )
506 {
507 strcpy ( syn->s1.ix, "1" );
508 }
509 else if ( s->type == 0 )
510 {
511 strcpy ( syn->s1.ix, "4" );
512 }
513 }
514 sprintf ( syn->s1.W1, "%d", s->ival );
515 syn->mask |= SYNOP_SEC1;
516 }
517 else if ( s->ival == 10 )
518 {
519 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
520 {
521 if ( s->type == 1 || s->type == 2 )
522 {
523 strcpy ( syn->s1.ix, "2" );
524 }
525 else if ( s->type == 0 )
526 {
527 strcpy ( syn->s1.ix, "5" );
528 }
529 }
531 }
532 else
533 {
534 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
535 {
536 strcpy ( syn->s1.ix,"7" );
537 }
538 else if ( s->type == 0 || s->type == 2 )
539 {
540 strcpy ( syn->s1.ix, "7" );
541 }
542 sprintf ( syn->s1.W1, "%d", abs ( s->ival ) % 10 );
543 syn->mask |= SYNOP_SEC1;
544 }
545 break;
546
547 case 5: // 0 20 005 . Past weather (2)
548 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
549 {
551 return 0;
552 }
553 if ( s->ival < 10 )
554 {
555 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
556 {
557 strcpy ( syn->s1.ix,"1" );
558 }
559 else if ( syn->s1.ix[0] == '/' )
560 {
561 if ( s->type == 1 || s->type == 2 )
562 {
563 strcpy ( syn->s1.ix, "1" );
564 }
565 else if ( s->type == 0 )
566 {
567 strcpy ( syn->s1.ix, "4" );
568 }
569 }
570 sprintf ( syn->s1.W2, "%d", s->ival );
571 syn->mask |= SYNOP_SEC1;
572 }
573 else if ( s->ival == 10 )
574 {
575 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
576 {
577 if ( s->type == 1 || s->type == 2 )
578 {
579 strcpy ( syn->s1.ix, "2" );
580 }
581 else if ( s->type == 0 )
582 {
583 strcpy ( syn->s1.ix, "5" );
584 }
585 }
587 }
588 else
589 {
590 if ( syn->s1.ix[0] == '/' && ( ( s->mask & SUBSET_MASK_HAVE_TYPE_STATION ) == 0 ) )
591 {
592 strcpy ( syn->s1.ix, "7" );
593 }
594 else if ( s->type == 0 || s->type == 2 )
595 {
596 strcpy ( syn->s1.ix, "7" );
597 }
598 sprintf ( syn->s1.W2, "%d", abs ( s->ival ) % 10 );
599 syn->mask |= SYNOP_SEC1;
600 }
601 break;
602
603 case 10: // 0 20 010 . Cloud cover (total)
604 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
605 {
606 return 0;
607 }
608 percent_to_okta ( syn->s1.N, s->val );
609 break;
610
611 case 11: // 0 20 011 . Cloud amount
612 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
613 {
614 return 0;
615 }
616 if ( s->clayer == 0 || s->clayer == 5 || s->clayer == 7 || s->clayer == 8 || s->clayer == 62 )
617 {
618 if ( s->ival <= 8 )
619 {
620 sprintf ( syn->s1.Nh, "%1d", abs(s->ival) % 10 );
621 }
622 else if ( s->ival <= 10 )
623 {
624 sprintf ( syn->s1.Nh, "9" );
625 }
626 else if ( s->ival == 15 )
627 {
628 sprintf ( syn->s1.Nh, "/" );
629 }
630 syn->mask |= SYNOP_SEC1;
631 }
632 else if ( s->clayer < 0 )
633 {
634 if ( s->ival <= 8 )
635 {
636 sprintf ( syn->s4.N1, "%1d", abs(s->ival) % 10 );
637 }
638 else if ( s->ival <= 10 )
639 {
640 sprintf ( syn->s4.N1, "9" );
641 }
642 else if ( s->ival == 15 )
643 {
644 sprintf ( syn->s4.N1, "/" );
645 }
646 syn->mask |= SYNOP_SEC4;
647 }
648 else if ( s->clayer > 0 && s->clayer < 5 )
649 {
650 if ( s->ival <= 8 )
651 {
652 sprintf ( syn->s3.nub[s->clayer - 1].Ns, "%1d", s->ival );
653 }
654 else if ( s->ival <= 10 )
655 {
656 sprintf ( syn->s3.nub[s->clayer - 1].Ns, "9" );
657 }
658 else if ( s->ival == 15 )
659 {
660 sprintf ( syn->s3.nub[s->clayer - 1].Ns, "/" );
661 }
662 syn->mask |= SYNOP_SEC3;
663 }
664 break;
665
666 case 12: // 0 20 012 . Cloud type
667 if ( s->clayer == 0 || s->clayer == 5 || s->clayer == 7 || s->clayer == 8 || s->clayer == 62 )
668 {
669 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
670 {
671 return 0;
672 }
673 if ( s->ival < 10 )
674 {
675 sprintf ( syn->s3.C, "%d", abs(s->ival) % 10 );
676 syn->mask |= SYNOP_SEC3;
677 }
678 else if ( s->ival >= 10 && s->ival < 20 )
679 {
680 sprintf ( syn->s1.Ch, "%1d", s->ival % 10 );
681 syn->mask |= SYNOP_SEC1;
682 }
683 else if ( s->ival >= 20 && s->ival < 30 )
684 {
685 sprintf ( syn->s1.Cm, "%1d", s->ival % 10 );
686 syn->mask |= SYNOP_SEC1;
687 }
688 else if ( s->ival >= 30 && s->ival < 40 )
689 {
690 sprintf ( syn->s1.Cl, "%1d", s->ival % 10 );
691 syn->mask |= SYNOP_SEC1;
692 }
693 else if ( s->ival == 59 )
694 {
695 sprintf ( syn->s1.Nh, "/" );
696 syn->mask |= SYNOP_SEC1;
697 }
698 else if ( s->ival == 60 )
699 {
700 sprintf ( syn->s1.Ch, "/" );
701 syn->mask |= SYNOP_SEC1;
702 }
703 else if ( s->ival == 61 )
704 {
705 sprintf ( syn->s1.Cm, "/" );
706 syn->mask |= SYNOP_SEC1;
707 }
708 else if ( s->ival == 62 )
709 {
710 sprintf ( syn->s1.Cl, "/" );
711 syn->mask |= SYNOP_SEC1;
712 }
713 }
714 else if ( s->clayer < 0 )
715 {
716 // case of base of clouds below station level
717 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
718 {
719 return 0;
720 }
721 if ( s->ival == 59 )
722 {
723 sprintf ( syn->s4.C1, "/" );
724 syn->mask |= SYNOP_SEC4;
725 }
726 else if ( s->ival < 10 )
727 {
728 sprintf ( syn->s4.C1, "%1d", abs (s->ival) % 10 );
729 syn->mask |= SYNOP_SEC4;
730 }
731 }
732 else if ( s->clayer > 0 && s->clayer < 5 )
733 {
734 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
735 {
736 sprintf ( syn->s3.nub[s->clayer - 1].C, "/" );
737 return 0;
738 }
739 if ( s->ival == 59 || s->ival >= 10 )
740 {
741 sprintf ( syn->s3.nub[s->clayer - 1].C, "/" );
742 }
743 else
744 {
745 // C clouds for 8 groups SEC 3
746 sprintf ( syn->s3.nub[s->clayer - 1].C, "%1d", s->ival % 10 );
747 }
748 syn->mask |= SYNOP_SEC3;
749 }
750 break;
751
752 case 13: // 0 20 013 . Height of base of cloud
753 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
754 {
755 return 0;
756 }
757 if ( s->clayer == 0 || s->clayer == 7 || s->clayer == 5 || s->clayer == 62 ) // first layer or low layer is for sec1
758 {
759 m_to_h ( syn->s1.h, s->val );
760 }
761 else if ( s->clayer > 0 && s->clayer < 5 )
762 {
763 if ( syn->s3.nub[s->clayer - 1].Ns[0] )
764 {
765 m_to_hh ( syn->s3.nub[s->clayer - 1].hshs, s->val );
766 }
767 else
768 {
769 m_to_9h ( syn->s3.nub[s->clayer - 1].hshs, s->val );
770 }
771 }
772 break;
773
774 case 14: // 0 20 014 . Height of Top of cloud
775 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
776 {
777 return 0;
778 }
779 if ( s->clayer < 0 ) // base below station level
780 {
781 m_to_hh ( syn->s4.H1H1, s->val );
782 syn->mask |= SYNOP_SEC4;
783 }
784 break;
785
786 case 17:
787 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
788 {
789 return 0;
790 }
791 if ( s->clayer < 0 && s->ival < 10 ) // base below station level
792 {
793 sprintf ( syn->s4.Ct, "%d", abs(s->ival) % 10 );
794 syn->mask |= SYNOP_SEC4;
795 }
796 break;
797
798 case 21: // 0 20 021 . Type of precipitation
799 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
800 {
801 return 0;
802 }
803
804 if ( syn->s0.A1[0] == '6' ) // for Reg VI
805 {
806 // flag table width = 30 bits
807 if ( s->ival & ( 1 << ( 30 - 15 ) ) &&
808 ( s->ival & ( 1 << ( 30 - 16 ) ) ) == 0 &&
809 ( s->ival & ( 1 << ( 30 - 20 ) ) ) == 0
810 )
811 {
812 // Only Glaze
813 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "934" );
814 s->SnSn = 934;
815 // here we increase counter
816 syn->s3.d9.n++;
817 }
818 else if ( s->ival & ( 1 << ( 30 - 16 ) ) &&
819 ( s->ival & ( 1 << ( 30 - 15 ) ) ) == 0 &&
820 ( s->ival & ( 1 << ( 30 - 20 ) ) ) == 0
821 )
822 {
823 // Only Rime
824 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "935" );
825 s->SnSn = 935;
826 // here we increase counter
827 syn->s3.d9.n++;
828 }
829 else if ( s->ival & ( 1 << ( 30 - 20 ) ) &&
830 ( s->ival & ( 1 << ( 30 - 15 ) ) ) == 0 &&
831 ( s->ival & ( 1 << ( 30 - 16 ) ) ) == 0
832 )
833 {
834 // Only Wet snow
835 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "937" );
836 s->SnSn = 937;
837 // here we increase counter
838 syn->s3.d9.n++;
839 }
840 else if ( s->ival & ( 1 << ( 30 - 15 ) ) ||
841 s->ival & ( 1 << ( 30 - 16 ) ) ||
842 s->ival & ( 1 << ( 30 - 20 ) ) )
843 {
844 // Compound deposit
845 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "936" );
846 s->SnSn = 936;
847 // here we increase counter
848 syn->s3.d9.n++;
849 }
850 }
851 break;
852
853 case 23: // 0 20 023 . Other weather phenomena
854 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
855 {
856 return 0;
857 }
858
859 if ( syn->s0.A1[0] == '6' ) // for Reg VI
860 {
861 // flag table width = 18 bits
862 if ( s->ival & ( 1 << ( 18 - 1 ) ) )
863 {
864 // Dust/sand whirl
865 syn->s3.d9.misc[syn->s3.d9.n].spsp[0] = '5'; // moderate intensity
866 syn->s3.d9.misc[syn->s3.d9.n].spsp[1] = '/'; // at the moment
867 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "919" );
868 s->SnSn = 919;
869 // here we increase counter
870 syn->s3.d9.n++;
871 }
872 else if ( ( s->ival & ( 1 << ( 18 - 9 ) ) ) ||
873 ( s->ival & ( 1 << ( 18 - 10 ) ) )
874 )
875 {
876 // Funnel clouds
877 syn->s3.d9.misc[syn->s3.d9.n].spsp[0] = '3'; // assumed less than 3 Km from station
878 syn->s3.d9.misc[syn->s3.d9.n].spsp[1] = '/'; // at the moment
879 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "919" );
880 s->SnSn = 919;
881 // here we increase counter
882 syn->s3.d9.n++;
883 }
884 else if ( s->ival & ( 1 << ( 18 - 12 ) ) )
885 {
886 syn->s3.d9.misc[syn->s3.d9.n].spsp[0] = '0'; // assumed less than 3 Km from station
887 syn->s3.d9.misc[syn->s3.d9.n].spsp[1] = '/'; // at the moment
888 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "919" );
889 s->SnSn = 919;
890 // here we increase counter
891 syn->s3.d9.n++;
892 }
893 else if ( s->ival & ( 1 << ( 18 - 2 ) ) )
894 {
895 syn->s3.d9.misc[syn->s3.d9.n].spsp[0] = '2'; // FIXME What kind of squall ?
896 syn->s3.d9.misc[syn->s3.d9.n].spsp[1] = '/'; // at the moment
897 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "918" );
898 s->SnSn = 918;
899 // here we increase counter
900 syn->s3.d9.n++;
901 }
902 }
903 break;
904
905 case 24: // 0 20 024 . Intensity of phenomena
906 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
907 {
908 return 0;
909 }
910 if ( syn->s0.A1[0] == '6' ) // for Reg VI
911 {
912 if ( s->SnSn == 919 )
913 {
914 if ( syn->s3.d9.misc[syn->s3.d9.n - 1].spsp[0] == '5' )
915 {
916 if ( s->ival == 1 )
917 {
918 syn->s3.d9.misc[syn->s3.d9.n - 1].spsp[0] = '4';
919 }
920 else if ( s->ival == 3 || s->ival == 4 )
921 {
922 syn->s3.d9.misc[syn->s3.d9.n - 1].spsp[0] = '6';
923 }
924 }
925 }
926 }
927 break;
928
929 case 25: // 0 20 025 . Obscuration
930 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
931 {
932 return 0;
933 }
934
935 if ( syn->s0.A1[0] == '6' ) // for Reg VI
936 {
937 // flag table width = 21 bits
938 if ( s->ival & ( 1 << ( 21 - 1 ) ) )
939 {
940 // Dust/sand whirl
941 syn->s3.d9.misc[syn->s3.d9.n].spsp[0] = '1'; // We next willl modify
942 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "929" );
943 s->SnSn = 929;
944 // here we increase counter
945 syn->s3.d9.n++;
946 }
947
948 }
949 break;
950
951 case 26: // 9 29 026 . Character of obscuration
952 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
953 {
954 return 0;
955 }
956 if ( syn->s0.A1[0] == '6' ) // for Reg VI
957 {
958 if ( s->SnSn == 929 )
959 {
960 if ( s->ival == 6 )
961 {
962 syn->s3.d9.misc[syn->s3.d9.n - 1].spsp[0] = '6';
963 }
964 }
965 }
966 break;
967
968 case 27: // 0 20 027 . Phenomenon occurrence
969 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
970 {
971 if ( syn->s0.A1[0] == '6' ) // for Reg VI
972 {
973 // flag table width = 9 bits
974 if ( s->SnSn == 919 || s->SnSn == 918 )
975 {
976 syn->s3.d9.misc[syn->s3.d9.n - 1].SpSp[0] = 0;
977 }
978 }
979 return 0;
980 }
981 if ( syn->s0.A1[0] == '6' ) // for Reg VI
982 {
983 // flag table width = 9 bits
984 if ( s->SnSn == 919 || s->SnSn == 918 )
985 {
986 if ( ( s->ival & ( 1 << ( 9 - 3 ) ) ) == 0 )
987 {
988 syn->s3.d9.misc[syn->s3.d9.n - 1].SpSp[0] = 0; // No valid group
989 }
990 }
991 }
992 break;
993
994 case 40: // 9 29 040 . Evolution of drift of snow
995 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
996 {
997 return 0;
998 }
999 if ( syn->s0.A1[0] == '6' ) // for Reg VI
1000 {
1001 if ( s->SnSn == 929 )
1002 {
1003 sprintf ( aux, "%d", s->ival % 10 );
1004 syn->s3.d9.misc[syn->s3.d9.n - 1].spsp[1] = aux[0]; // S8'
1005 }
1006 }
1007 break;
1008
1009 case 54: // 0 20 054 . True direction from which clouds are moving
1010 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1011 {
1012 return 0;
1013 }
1014 if ( syn->s0.A1[0] == '6' ) // for Reg VI
1015 {
1016 grad_to_D ( aux, s->val );
1017 if ( s->SnSn == 919 || s->SnSn == 918 )
1018 {
1019 syn->s3.d9.misc[syn->s3.d9.n - 1].spsp[1] = aux[0];
1020 }
1021 else if ( s->clayer == 7 )
1022 {
1023 grad_to_D ( syn->s3.Dl, s->val );
1024 }
1025 else if ( s->clayer == 8 )
1026 {
1027 grad_to_D ( syn->s3.Dm, s->val );
1028 }
1029 else if ( s->clayer == 9 )
1030 {
1031 grad_to_D ( syn->s3.Dh, s->val );
1032 }
1033 syn->mask |= SYNOP_SEC3;
1034 }
1035 else if ( syn->s0.A1[0] == '4' ) // for Reg IV
1036 {
1037 grad_to_D ( aux, s->val );
1038 if ( s->clayer == 7 )
1039 {
1040 syn->s3.XoXoXoXo[1] = aux[0];
1041 }
1042 else if ( s->clayer == 8 )
1043 {
1044 syn->s3.XoXoXoXo[2] = aux[0];
1045 }
1046 else if ( s->clayer == 9 )
1047 {
1048 syn->s3.XoXoXoXo[3] = aux[0];
1049 }
1050 syn->mask |= SYNOP_SEC3;
1051 }
1052 else // other Regions
1053 {
1054 if ( s->clayer == 7 )
1055 {
1056 grad_to_D ( syn->s3.Dl, s->val );
1057 }
1058 else if ( s->clayer == 8 )
1059 {
1060 grad_to_D ( syn->s3.Dm, s->val );
1061 }
1062 else if ( s->clayer == 9 )
1063 {
1064 grad_to_D ( syn->s3.Dh, s->val );
1065 }
1066 syn->mask |= SYNOP_SEC3;
1067 }
1068 break;
1069
1070 case 55: // 0 20 055 . State of sky in tropics
1071 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1072 {
1073 return 0;
1074 }
1075 if ( strcmp ( syn->s0.A1, "4" ) == 0 )
1076 {
1077 // For REG IV
1078 if ( s->ival < 10 )
1079 {
1080 sprintf ( aux,"%d", s->ival );
1081 syn->s3.XoXoXoXo[0] = aux[0];
1082 }
1083 else
1084 {
1085 syn->s3.XoXoXoXo[0] = '/';
1086 }
1087 // then copy data direction of cloud drift from 3 02 047 if any
1088 if ( syn->s3.Dl[0] )
1089 {
1090 syn->s3.XoXoXoXo[1] = syn->s3.Dl[0];
1091 }
1092 if ( syn->s3.Dm[0] )
1093 {
1094 syn->s3.XoXoXoXo[1] = syn->s3.Dm[0];
1095 }
1096 if ( syn->s3.Dh[0] )
1097 {
1098 syn->s3.XoXoXoXo[1] = syn->s3.Dh[0];
1099 }
1100 syn->mask |= SYNOP_SEC3;
1101 }
1102 break;
1103
1104 case 62: // 0 20 062 . State of the ground (with or without snow)
1105 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1106 {
1107 return 0;
1108 }
1109 if ( strcmp ( syn->s0.A1, "2" ) == 0 )
1110 {
1111 // For REG II
1112 if ( s->ival < 10 )
1113 {
1114 sprintf ( aux,"%d", s->ival );
1115 sprintf ( syn->s3.E, "%d", s->ival );
1116 syn->s3.XoXoXoXo[0] = aux[0];
1117 }
1118 else if ( s->ival < 20 )
1119 {
1120 syn->s3.XoXoXoXo[0] = '/';
1121 sprintf ( syn->s3.E1,"%d", s->ival % 10 );
1122 }
1123 if ( syn->s3.XoXoXoXo[1] == 0 )
1124 {
1125 // In case of still no snTgTg
1126 syn->s3.XoXoXoXo[1] = '/';
1127 syn->s3.XoXoXoXo[2] = '/';
1128 syn->s3.XoXoXoXo[3] = '/';
1129 }
1130 }
1131 else
1132 {
1133 // The Other regs
1134 if ( s->ival < 10 )
1135 {
1136 sprintf ( syn->s3.E,"%d", abs(s->ival) % 10 );
1137 }
1138 else if ( s->ival < 20 )
1139 {
1140 sprintf ( syn->s3.E1,"%d", s->ival % 10 );
1141 }
1142 }
1143 syn->mask |= SYNOP_SEC3;
1144 break;
1145
1146 case 66: // 0 20 066 . Max diameter of hailstones
1147 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1148 {
1149 return 0;
1150 }
1151 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1152 {
1153 m_to_RR ( syn->s3.d9.misc[syn->s3.d9.n].spsp, s->val );
1154 strcpy ( syn->s3.d9.misc[syn->s3.d9.n].SpSp, "932" );
1155 s->SnSn = 932;
1156 // here we increase counter
1157 syn->s3.d9.n++;
1158 }
1159 break;
1160
1161 case 67: // 0 20 067 . Diameter of deposit
1162 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1163 {
1164 return 0;
1165 }
1166 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1167 {
1168 m_to_RR ( syn->s3.d9.misc[syn->s3.d9.n - 1].spsp, s->val );
1169 }
1170 break;
1171
1172 case 101: // 0 20 101. Locust (acridian) name
1173 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1174 {
1175 return 0;
1176 }
1177 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1178 {
1179 if ( s->ival < 10 )
1180 {
1181 sprintf ( aux, "%d", s->ival );
1182 syn->s3.R8[0][0] = aux[0]; // Ln
1183 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1184 }
1185 }
1186 break;
1187
1188 case 102: // 0 20 102. Locust (maturity) color
1189 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1190 {
1191 return 0;
1192 }
1193 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1194 {
1195 if ( s->ival < 10 )
1196 {
1197 sprintf ( aux, "%d", s->ival );
1198 syn->s3.R8[0][1] = aux[0]; // Lc
1199 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1200 }
1201 }
1202 break;
1203
1204 case 103: // 0 20 103. Stage of development of locusts
1205 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1206 {
1207 return 0;
1208 }
1209 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1210 {
1211 if ( s->ival < 10 )
1212 {
1213 sprintf ( aux, "%d", s->ival );
1214 syn->s3.R8[0][2] = aux[0]; // Ld
1215 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1216 }
1217 }
1218 break;
1219
1220 case 104: // 0 20 104. Organization state of swarm or band of locusts
1221 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1222 {
1223 return 0;
1224 }
1225 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1226 {
1227 if ( s->ival < 10 )
1228 {
1229 sprintf ( aux, "%d", s->ival );
1230 syn->s3.R8[0][3] = aux[0]; // Lg
1231 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1232 }
1233 }
1234 break;
1235
1236 case 105: // 0 20 105. Size of swarm or band of locusts and duration of
1237 // passage of swarm
1238 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1239 {
1240 return 0;
1241 }
1242 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1243 {
1244 if ( s->ival < 10 )
1245 {
1246 sprintf ( aux, "%d", s->ival );
1247 syn->s3.R8[1][0] = aux[0]; // Sl
1248 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1249 }
1250 }
1251 break;
1252
1253 case 106: // 0 20 106. Locust population density
1254 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1255 {
1256 return 0;
1257 }
1258 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1259 {
1260 if ( s->ival < 10 )
1261 {
1262 sprintf ( aux, "%d", s->ival );
1263 syn->s3.R8[1][1] = aux[0]; // dl
1264 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1265 }
1266 }
1267 break;
1268
1269 case 107: // 0 20 107. Direction of movements of locust swarm
1270 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1271 {
1272 return 0;
1273 }
1274 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1275 {
1276 if ( s->ival < 10 )
1277 {
1278 sprintf ( aux, "%d", s->ival );
1279 syn->s3.R8[1][1] = aux[0]; // Dl
1280 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1281 }
1282 }
1283 break;
1284
1285 case 108: // 0 20 108. Extent of vegetation
1286 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1287 {
1288 return 0;
1289 }
1290 if ( strcmp ( syn->s0.A1, "1" ) == 0 ) // Only for Region I
1291 {
1292 if ( s->ival < 8 )
1293 {
1294 sprintf ( aux, "%d", s->ival );
1295 syn->s3.R8[1][1] = aux[0]; // Dl
1296 syn->mask |= ( SYNOP_SEC3 | SYNOP_SEC3_8 );
1297 }
1298 }
1299 break;
1300
1301 default:
1302 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
1303 bufr2tac_set_error ( s, 0, "syn_parse_x20()", "Descriptor not parsed" );
1304 break;
1305 }
1306
1307 // check about h
1308 if ( syn->s1.h[0] == '/' && syn->s1.N[0] == '0' )
1309 {
1310 syn->s1.h[0] = '9';
1311 }
1312
1313 return 0;
1314}
char * grad_to_D(char *D, double grad)
Converts true direction in grads to D (code table 0700)
Definition: bufr2tac_x05.c:32
char * secs_to_tt(char *tt, int secs)
get tt code from seconds
Definition: bufr2tac_x11.c:34
char * m_to_9h(char *target, double h)
converts the altitude of cloud layer into 9h string code
Definition: bufr2tac_x20.c:135
char * percent_to_okta(char *target, double perc)
Converts percent cloud cover into okta.
Definition: bufr2tac_x20.c:32
char * vism_to_VV(char *target, double V)
Convert horizontal visibilty in meters to a VV string.
Definition: bufr2tac_x20.c:226
char * m_to_hh(char *target, double h)
converts the altitude of cloud layer into hh string code
Definition: bufr2tac_x20.c:188
char * m_to_RR(char *target, double m)
Convert distance (m) in RR code (3570)
Definition: bufr2tac_x20.c:261
char * m_to_h(char *target, double h)
converts the altitude of cloud layer into h string code
Definition: bufr2tac_x20.c:83
struct synop_sec4 s4
Definition: metsynop.h:301
char Ct[2]
Definition: metsynop.h:272
char H1H1[4]
Definition: metsynop.h:271
char C1[2]
Definition: metsynop.h:270
char N1[2]
Definition: metsynop.h:269

References bufr2tac_subset_state::a, synop_sec0::A1, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), nub3::C, synop_sec3::C, synop_sec4::C1, synop_sec1::Ch, synop_sec1::Cl, bufr2tac_subset_state::clayer, synop_sec1::Cm, synop_sec4::Ct, synop_sec3::d9, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec3::Dh, synop_sec3::Dl, synop_sec3::Dm, synop_sec3::E, synop_sec3::E1, grad_to_D(), synop_sec1::h, synop_sec4::H1H1, nub3::hshs, bufr2tac_subset_state::i, bufr2tac_subset_state::itval, bufr2tac_subset_state::ival, synop_sec1::ix, bufr2tac_subset_state::jtval, bufr2tac_subset_state::k_itval, bufr2tac_subset_state::k_jtval, m_to_9h(), m_to_h(), m_to_hh(), m_to_RR(), bufr_atom_data::mask, bufr2tac_subset_state::mask, synop_chunks::mask, data9::misc, synop_sec1::N, data9::n, synop_sec4::N1, synop_sec1::Nh, nub3::Ns, synop_sec3::nub, percent_to_okta(), synop_sec3::R8, synop_chunks::s0, synop_chunks::s1, synop_chunks::s3, synop_chunks::s4, secs_to_tt(), bufr2tac_subset_state::SnSn, misc3::SpSp, misc3::spsp, SUBSET_MASK_HAVE_NO_SIGNIFICANT_W1, SUBSET_MASK_HAVE_NO_SIGNIFICANT_W2, SUBSET_MASK_HAVE_NO_SIGNIFICANT_WW, SUBSET_MASK_HAVE_TYPE_STATION, SYNOP_NMISC, SYNOP_SEC1, SYNOP_SEC3, SYNOP_SEC3_8, SYNOP_SEC4, bufr2tac_subset_state::tw1w2, bufr2tac_subset_state::type, bufr2tac_subset_state::val, vism_to_VV(), synop_sec1::VV, synop_sec1::W1, synop_sec1::W2, synop_sec1::ww, synop_sec3::XoXoXoXo, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x22()

int syn_parse_x22 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 01.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 35 of file bufr2tac_x22.c.

36{
37 char aux[16];
38
40 return 0;
41
42 switch ( s->a->desc.y )
43 {
44 case 1: // 0 22 001 Direction of waves
45 case 3: // 0 22 003 Direction of swell waves
46 if ( syn->s2.dw1dw1[0] == 0 )
47 {
48 sprintf ( syn->s2.dw1dw1, "%02d", abs(( s->ival + 5 ) /10) % 100 );
49 }
50 else if ( syn->s2.dw2dw2[0] == 0 )
51 {
52 sprintf ( syn->s2.dw2dw2, "%02d", abs(( s->ival + 5 ) /10) % 100 );
53 }
54 syn->mask |= SYNOP_SEC2; // have sec2 data
55 break;
56
57 case 11: // 0 22 011 wind period in seconds
58 if ( syn->s2.PwPw[0] == 0 )
59 {
60 sprintf ( syn->s2.PwPw, "%02d", ( int ) ( s->val ) );
61 syn->mask |= SYNOP_SEC2; // have sec2 data
62 }
63 break;
64
65 case 12: // 0 22 012 wind wave period in seconds
66 if ( syn->s2.PwaPwa[0] == 0 )
67 {
68 sprintf ( syn->s2.PwaPwa, "%02d", ( int ) ( s->val ) );
69 syn->mask |= SYNOP_SEC2; // have sec2 data
70 }
71 break;
72
73 case 13: // 0 22 013 swell wave period in seconds
74 if ( syn->s2.Pw1Pw1[0] == 0 )
75 {
76 sprintf ( syn->s2.Pw1Pw1, "%02d", ( int ) ( s->val ) );
77 }
78 else if ( syn->s2.Pw2Pw2[0] == 0 )
79 {
80 sprintf ( syn->s2.Pw2Pw2, "%02d", ( int ) ( s->val ) );
81 }
82 syn->mask |= SYNOP_SEC2; // have sec2 data
83 break;
84
85 case 21: // 0 22 021 wind wave heigh in m
86 if ( syn->s2.HwHw[0] == 0 )
87 {
88 sprintf ( syn->s2.HwHw, "%02d", ( int ) ( s->val * 2.0 + 0.01 ) );
89 syn->mask |= SYNOP_SEC2; // have sec2 data
90 }
91 break;
92
93 case 22: // 0 22 022 wind wave heigh in meters
94 if ( syn->s2.HwaHwa[0] == 0 )
95 {
96 sprintf ( syn->s2.HwaHwa, "%02d", ( int ) ( s->val * 2.0 + 0.01 ) ); // 0.5 m units
97 syn->mask |= SYNOP_SEC2; // have sec2 data
98 }
99 if ( syn->s2.HwaHwaHwa[0] == 0 )
100 {
101 sprintf ( syn->s2.HwaHwaHwa, "%03d", ( int ) ( s->val * 10.0 + 0.5 ) ); // 0.1 m units
102 syn->mask |= SYNOP_SEC2; // have sec2 data
103 }
104 break;
105
106 case 23: // 0 22 023 swell wave heigh in meters
107 if ( syn->s2.Hw1Hw1[0] == 0 )
108 {
109 sprintf ( syn->s2.Hw1Hw1, "%02d", ( int ) ( s->val * 2.0 + 0.01 ) );
110 }
111 else if ( syn->s2.Hw2Hw2[0] == 0 )
112 {
113 sprintf ( syn->s2.Hw2Hw2, "%02d", ( int ) ( s->val * 2.0 + 0.01 ) );
114 }
115 syn->mask |= SYNOP_SEC2; // have sec2 data
116 break;
117
118 case 42:
119 case 43:
120 case 45:
121 case 49: // 0 22 049 Sea surface temperature
122 if ( syn->s2.TwTwTw[0] == 0 )
123 {
124 if ( kelvin_to_snTTT ( aux, s->val ) )
125 {
126 syn->s2.ss[0] = aux[0];
127 strcpy ( syn->s2.TwTwTw, aux + 1 );
128 syn->mask |= SYNOP_SEC2; // have sec2 data
129 }
130 }
131 break;
132 default:
133 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
134 bufr2tac_set_error ( s, 0, "syn_parse_x22()", "Descriptor not parsed" );
135 break;
136 }
137 return 0;
138}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, synop_sec2::dw1dw1, synop_sec2::dw2dw2, synop_sec2::Hw1Hw1, synop_sec2::Hw2Hw2, synop_sec2::HwaHwa, synop_sec2::HwaHwaHwa, synop_sec2::HwHw, bufr2tac_subset_state::ival, kelvin_to_snTTT(), bufr_atom_data::mask, synop_chunks::mask, synop_sec2::Pw1Pw1, synop_sec2::Pw2Pw2, synop_sec2::PwaPwa, synop_sec2::PwPw, synop_chunks::s2, synop_sec2::ss, SYNOP_SEC2, synop_sec2::TwTwTw, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ syn_parse_x31()

int syn_parse_x31 ( struct synop_chunks syn,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 31.

Parameters
synpointer to a struct synop_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 35 of file bufr2tac_x31.c.

36{
37
39 {
40 // 0 31 000 does not have DESCRIPTOR_VALUE_MISSING
41 if (s->a->desc.y != 0)
42 return 0;
43 s->rep = 1;
44 s->k_rep = s->i;
45 }
46
47 if ( syn == NULL )
48 {
49 return 1;
50 }
51
52 switch ( s->a->desc.y )
53 {
54 case 0: // 0 31 000 . Short delayed descriptor replication factor
55 s->rep = s->ival;
56 s->k_rep = s->i;
57 break;
58
59 case 1:
60 s->rep = s->ival;
61 s->k_rep = s->i;
62 break;
63
64 default:
65 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
66 bufr2tac_set_error ( s, 0, "syn_parse_x31()", "Descriptor not parsed" );
67 break;
68 }
69 return 0;
70}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::i, bufr2tac_subset_state::ival, bufr2tac_subset_state::k_rep, bufr_atom_data::mask, bufr2tac_subset_state::rep, and bufr_descriptor::y.

Referenced by parse_subset_as_synop().

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

◆ synop_YYYYMMDDHHmm_to_YYGG()

int synop_YYYYMMDDHHmm_to_YYGG ( struct synop_chunks syn)

Sets YYGG from YYYYMMDDHHmm extended group.

Parameters
synpointer to the target struct synop_chunks

Definition at line 31 of file bufr2tac_synop.c.

32{
33 char aux[20];
34 char tz[256], *c;
35 time_t t;
36 struct tm tim;
37
38 if ( strlen ( syn->e.YYYY ) &&
39 strlen ( syn->e.MM ) &&
40 strlen ( syn->e.DD ) &&
41 strlen ( syn->e.HH ) &&
42 strlen ( syn->e.mm ) )
43 {
44 sprintf ( aux,"%s%s%s%s%s", syn->e.YYYY, syn->e.MM, syn->e.DD, syn->e.HH, syn->e.mm );
45 }
46
47 if ( strlen ( aux ) != 12 )
48 {
49 return 1;
50 }
51
52 // Get current TZ
53 tz[0] = '\0';
54 c = getenv ( "TZ" );
55 if ( c != NULL && c[0] && strlen ( c ) < 256 )
56 {
57 strcpy ( tz, c );
58 }
59
60 // Set TZ to UTC
61 setenv ( "TZ", "UTC", 1 );
62 tzset();
63
64 memset ( &tim, 0, sizeof ( struct tm ) );
65 strptime ( aux, "%Y%m%d%H%M", &tim );
66
67 t = mktime ( &tim ) + 1799 ; // rounding trick
68 gmtime_r ( &t, &tim );
69 sprintf ( syn->s0.YY, "%02d", tim.tm_mday );
70 sprintf ( syn->s0.GG, "%02d", tim.tm_hour );
71
72 // Revert TZ changes
73 if ( tz[0] )
74 {
75 setenv ( "TZ", tz, 1 );
76 tzset();
77 }
78 else
79 {
80 unsetenv ( "TZ" );
81 }
82
83 return 0;
84}

References report_date_ext::DD, synop_chunks::e, synop_sec0::GG, report_date_ext::HH, report_date_ext::MM, report_date_ext::mm, synop_chunks::s0, synop_sec0::YY, and report_date_ext::YYYY.

Referenced by parse_subset_as_synop().

Here is the caller graph for this function:

◆ temp_parse_x01()

int temp_parse_x01 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 01.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 415 of file bufr2tac_x01.c.

416{
417 char aux[80];
418
419 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
420 return 0;
421
422 switch ( s->a->desc.y )
423 {
424 case 1: // 0 01 001 . WMO block number
425 sprintf ( t->a.s1.II, "%02d", s->ival );
426 sprintf ( t->b.s1.II, "%02d", s->ival );
427 sprintf ( t->c.s1.II, "%02d", s->ival );
428 sprintf ( t->d.s1.II, "%02d", s->ival );
429 break;
430
431 case 2: // 0 01 002 . WMO station number
432 sprintf ( t->a.s1.iii, "%03d", s->ival );
433 sprintf ( t->b.s1.iii, "%03d", s->ival );
434 sprintf ( t->c.s1.iii, "%03d", s->ival );
435 sprintf ( t->d.s1.iii, "%03d", s->ival );
436 break;
437
438 case 3: // 0 01 003 . WMO Region
439 sprintf ( t->a.s1.A1, "%d", s->ival );
440 sprintf ( t->b.s1.A1, "%d", s->ival );
441 sprintf ( t->c.s1.A1, "%d", s->ival );
442 sprintf ( t->d.s1.A1, "%d", s->ival );
443 if ( strcmp ( t->a.s1.A1, "1" ) == 0 )
444 {
445 strcpy ( t->a.s1.Reg, "I" );
446 strcpy ( t->b.s1.Reg, "I" );
447 strcpy ( t->c.s1.Reg, "I" );
448 strcpy ( t->d.s1.Reg, "I" );
449 }
450 else if ( strcmp ( t->a.s1.A1, "2" ) == 0 )
451 {
452 strcpy ( t->a.s1.Reg, "II" );
453 strcpy ( t->b.s1.Reg, "II" );
454 strcpy ( t->c.s1.Reg, "II" );
455 strcpy ( t->d.s1.Reg, "II" );
456 }
457 else if ( strcmp ( t->a.s1.A1, "3" ) == 0 )
458 {
459 strcpy ( t->a.s1.Reg, "III" );
460 strcpy ( t->b.s1.Reg, "III" );
461 strcpy ( t->c.s1.Reg, "III" );
462 strcpy ( t->d.s1.Reg, "III" );
463 }
464 else if ( strcmp ( t->a.s1.A1, "4" ) == 0 )
465 {
466 strcpy ( t->a.s1.Reg, "IV" );
467 strcpy ( t->b.s1.Reg, "IV" );
468 strcpy ( t->c.s1.Reg, "IV" );
469 strcpy ( t->d.s1.Reg, "IV" );
470 }
471 else if ( strcmp ( t->a.s1.A1, "5" ) == 0 )
472 {
473 strcpy ( t->a.s1.Reg, "V" );
474 strcpy ( t->b.s1.Reg, "V" );
475 strcpy ( t->c.s1.Reg, "V" );
476 strcpy ( t->d.s1.Reg, "V" );
477 }
478 else if ( strcmp ( t->a.s1.A1, "6" ) == 0 )
479 {
480 strcpy ( t->a.s1.Reg, "VI" );
481 strcpy ( t->b.s1.Reg, "VI" );
482 strcpy ( t->c.s1.Reg, "VI" );
483 strcpy ( t->d.s1.Reg, "VI" );
484 }
485 break;
486
487 case 4: // 0 01 004 . WMO Subarea
488 case 20: // 0 01 020 . WMO region subarea
489 sprintf ( t->a.s1.bw, "%d", s->ival );
490 sprintf ( t->b.s1.bw, "%d", s->ival );
491 sprintf ( t->c.s1.bw, "%d", s->ival );
492 sprintf ( t->d.s1.bw, "%d", s->ival );
493 break;
494
495 case 11: // 0 01 011. Ship or mobile land station index
496 if ( strlen ( s->a->cval ) < 16 )
497 {
498 strcpy ( aux, s->a->cval );
499 adjust_string ( aux );
500 if ( aux[0] == '\xff' )
501 break;
502
503 if ( strlen ( aux ) < 10 )
504 {
505 strcpy ( t->a.s1.D_D, aux );
506 strcpy ( t->b.s1.D_D, aux );
507 strcpy ( t->c.s1.D_D, aux );
508 strcpy ( t->d.s1.D_D, aux );
509 }
510 }
511 break;
512
513 case 15: // 0 01 015 . Station or site name
514 case 18: // 0 01 018 . Short station or site name
515 case 19: // 0 01 019 . Long station or site name
516 if ( strlen ( s->a->cval ) <= 80 )
517 {
518 strcpy ( aux, s->a->cval );
519 adjust_string ( aux );
520 strcpy ( s->name, aux );
522 }
523 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
524 {
525 bufr2tac_set_error ( s, 1, "temp_parse_x01()", "Station or site name length > 80. Cannot set s->name" );
526 }
527 break;
528
529 case 101: // 0 01 101 . State identifier
530 if ( strlen ( s->a->ctable ) <= 256 )
531 {
532 strcpy ( aux, s->a->ctable );
533 adjust_string ( aux );
534 strcpy ( s->country, aux );
536 }
537 else if ( BUFR2TAC_DEBUG_LEVEL > 0 )
538 {
539 bufr2tac_set_error ( s, 1, "temp_parse_x01()", "State identifier length > 256. Cannot set s->country" );
540 }
541 break;
542
543 case 125: // 0 01 125 . WIGOS identifier series
544 t->wid.series = ( uint8_t ) s->ival;
545 break;
546
547 case 126: // 0 01 126 . WIGOS issuer of identifier
548 t->wid.issuer = ( uint16_t ) s->ival;
549 break;
550
551 case 127: // 0 01 127 , WIGOS issue number
552 t->wid.issue = ( uint16_t ) s->ival;
553 break;
554
555 case 128: // 0 01 128 . WIGOS local identifier (character)
556 if ( strlen ( s->a->cval ) <= 16 )
557 {
558 strcpy ( t->wid.local_id, s->a->cval );
559 if ( check_wigos_local_id ( s->a->cval ) )
560 {
561 bufr2tac_set_error ( s, 1, "temp_parse_x01()","Bad WIGOS Local identifier" );
562 }
564 }
565 break;
566
567 default:
568 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
569 bufr2tac_set_error ( s, 0, "temp_parse_x01()", "Descriptor not parsed" );
570 break;
571 }
572 return 0;
573}
char Reg[4]
Definition: mettemp.h:319
char A1[2]
Definition: mettemp.h:312
char bw[2]
Definition: mettemp.h:313
char Reg[4]
Definition: mettemp.h:346
char A1[2]
Definition: mettemp.h:339
char bw[2]
Definition: mettemp.h:340

References bufr2tac_subset_state::a, temp_chunks::a, temp_acd_sec1::A1, temp_b_sec1::A1, adjust_string(), temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_acd_sec1::bw, temp_b_sec1::bw, temp_chunks::c, check_wigos_local_id(), bufr2tac_subset_state::country, bufr_atom_data::ctable, bufr_atom_data::cval, temp_chunks::d, temp_acd_sec1::D_D, temp_b_sec1::D_D, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_acd_sec1::II, temp_b_sec1::II, temp_acd_sec1::iii, temp_b_sec1::iii, wigos_id::issue, wigos_id::issuer, bufr2tac_subset_state::ival, wigos_id::local_id, bufr_atom_data::mask, bufr2tac_subset_state::mask, bufr2tac_subset_state::name, temp_acd_sec1::Reg, temp_b_sec1::Reg, temp_a::s1, temp_b::s1, temp_c::s1, temp_d::s1, wigos_id::series, SUBSET_MASK_HAVE_COUNTRY, SUBSET_MASK_HAVE_NAME, SUBSET_MASK_HAVE_WIGOS_ID, temp_chunks::wid, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x02()

int temp_parse_x02 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 02.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 187 of file bufr2tac_x02.c.

188{
189 if ( t == NULL )
190 return 1;
191
192 switch ( s->a->desc.y )
193 {
194 case 3: // 0 02 003 . Type of measuring equipment used
195 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
196 {
197 sprintf ( t->b.s1.a4,"/" );
198 return 0;
199 }
200 switch ( s->ival )
201 {
202 case 0:
203 case 1:
204 case 2:
205 case 3:
206 sprintf ( t->b.s1.a4,"%d", s->ival );
207 break;
208 case 4:
209 case 5:
210 case 6:
211 case 7:
212 sprintf ( t->b.s1.a4,"%d", s->ival + 1 );
213 break;
214 default:
215 strcpy ( t->b.s1.a4, "9" ); // reserved
216 break;
217 }
218 break;
219
220 case 11: // 0 02 011 . Radiosonde type
221 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
222 {
223 sprintf ( t->a.s7.rara, "//" );
224 sprintf ( t->b.s7.rara, "//" );
225 sprintf ( t->c.s7.rara, "//" );
226 sprintf ( t->d.s7.rara, "//" );
227 return 0;
228 }
229 if ( s->ival >= 0 )
230 {
231 sprintf ( t->a.s7.rara, "%02d", s->ival % 100 );
232 sprintf ( t->b.s7.rara, "%02d", s->ival % 100 );
233 sprintf ( t->c.s7.rara, "%02d", s->ival % 100 );
234 sprintf ( t->d.s7.rara, "%02d", s->ival % 100 );
235 }
236 break;
237
238 case 13: // 0 02 013 . Solar and infrared radiation correction
239 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
240 {
241 strcpy ( t->a.s7.sr, "/" );
242 strcpy ( t->b.s7.sr, "/" );
243 strcpy ( t->c.s7.sr, "/" );
244 strcpy ( t->d.s7.sr, "/" );
245 return 0;
246
247 }
248 if ( s->ival >= 0 && s->ival <= 7 )
249 {
250 sprintf ( t->a.s7.sr, "%d", s->ival );
251 sprintf ( t->b.s7.sr, "%d", s->ival );
252 sprintf ( t->c.s7.sr, "%d", s->ival );
253 sprintf ( t->d.s7.sr, "%d", s->ival );
254 }
255 else
256 {
257 // case of missing data
258 strcpy ( t->a.s7.sr, "/" );
259 strcpy ( t->b.s7.sr, "/" );
260 strcpy ( t->c.s7.sr, "/" );
261 strcpy ( t->d.s7.sr, "/" );
262 }
263 break;
264
265 case 14: // 0 02 014 . Tracking technique/status of system used
266 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
267 {
268 strcpy ( t->a.s7.sasa, "//" );
269 strcpy ( t->b.s7.sasa, "//" );
270 strcpy ( t->c.s7.sasa, "//" );
271 strcpy ( t->d.s7.sasa, "//" );
272 return 0;
273 }
274 if ( s->ival >= 0 && s->ival < 100 )
275 {
276 sprintf ( t->a.s7.sasa, "%02d", s->ival );
277 sprintf ( t->b.s7.sasa, "%02d", s->ival );
278 sprintf ( t->c.s7.sasa, "%02d", s->ival );
279 sprintf ( t->d.s7.sasa, "%02d", s->ival );
280 }
281 else
282 {
283 strcpy ( t->a.s7.sasa, "//" );
284 strcpy ( t->b.s7.sasa, "//" );
285 strcpy ( t->c.s7.sasa, "//" );
286 strcpy ( t->d.s7.sasa, "//" );
287 }
288 break;
289
290 default:
291 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
292 bufr2tac_set_error ( s, 0, "temp_parse_x02()", "Descriptor not parsed" );
293 break;
294 }
295 return 0;
296}

References bufr2tac_subset_state::a, temp_chunks::a, temp_b_sec1::a4, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::ival, bufr_atom_data::mask, temp_sec7::rara, temp_b::s1, temp_a::s7, temp_b::s7, temp_c::s7, temp_d::s7, temp_sec7::sasa, temp_sec7::sr, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x04()

int temp_parse_x04 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 04.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 575 of file bufr2tac_x04.c.

576{
577 switch ( s->a->desc.y )
578 {
579 case 1: // 0 04 001 . Year
580 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
581 {
582 return 0;
583 }
584 else if ( s->ival < 2000 || s->ival > 2050 )
585 {
586 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
587 bufr2tac_set_error ( s, 2, "temp_parse_x04()", "Bad year" );
588 return 1;
589 }
590 if ( t->a.e.YYYY[0] == 0 )
591 {
592 sprintf ( t->a.e.YYYY, "%04d", s->ival );
593 sprintf ( t->b.e.YYYY, "%04d", s->ival );
594 sprintf ( t->c.e.YYYY, "%04d", s->ival );
595 sprintf ( t->d.e.YYYY, "%04d", s->ival );
596 }
598 break;
599
600 case 2: // 0 04 002 . Month
601 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
602 {
603 return 0;
604 }
605 if ( t->a.e.MM[0] == 0 )
606 {
607 sprintf ( t->a.e.MM, "%02d", s->ival );
608 sprintf ( t->b.e.MM, "%02d", s->ival );
609 sprintf ( t->c.e.MM, "%02d", s->ival );
610 sprintf ( t->d.e.MM, "%02d", s->ival );
611 }
613 break;
614
615 case 3: // 0 04 003 . Day of month
616 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
617 {
618 return 0;
619 }
620 if ( t->a.e.DD[0] == 0 )
621 {
622 sprintf ( t->a.e.DD, "%02d", s->ival );
623 sprintf ( t->b.e.DD, "%02d", s->ival );
624 sprintf ( t->c.e.DD, "%02d", s->ival );
625 sprintf ( t->d.e.DD, "%02d", s->ival );
626 }
628 //sprintf(t->s0.YY, "%02d", (int) sq->sequence[is].val);
629 break;
630
631 case 4: // 0 04 004 . Hour
632 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
633 {
634 return 0;
635 }
636 if ( t->a.e.HH[0] == 0 )
637 {
638 sprintf ( t->a.e.HH, "%02d", s->ival );
639 sprintf ( t->b.e.HH, "%02d", s->ival );
640 sprintf ( t->c.e.HH, "%02d", s->ival );
641 sprintf ( t->d.e.HH, "%02d", s->ival );
642 sprintf ( t->a.s7.GG, "%02d", s->ival );
643 sprintf ( t->b.s7.GG, "%02d", s->ival );
644 sprintf ( t->c.s7.GG, "%02d", s->ival );
645 sprintf ( t->d.s7.GG, "%02d", s->ival );
646 }
648 //sprintf(t->s0.GG, "%02d", (int) sq->sequence[is].val);
649 break;
650
651 case 5: // 0 04 005 . Minute
652 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
653 {
654 return 0;
655 }
656 if ( t->a.e.mm[0] == 0 )
657 {
658 sprintf ( t->a.e.mm, "%02d", s->ival );
659 sprintf ( t->b.e.mm, "%02d", s->ival );
660 sprintf ( t->c.e.mm, "%02d", s->ival );
661 sprintf ( t->d.e.mm, "%02d", s->ival );
662 sprintf ( t->a.s7.gg, "%02d", s->ival );
663 sprintf ( t->b.s7.gg, "%02d", s->ival );
664 sprintf ( t->c.s7.gg, "%02d", s->ival );
665 sprintf ( t->d.s7.gg, "%02d", s->ival );
666 }
668 break;
669
670 case 6: // 0 04 006 . Second
671 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
672 {
673 return 0;
674 }
675 if ( t->a.e.ss[0] == 0 )
676 {
677 sprintf ( t->a.e.ss, "%02d", s->ival );
678 sprintf ( t->b.e.ss, "%02d", s->ival );
679 sprintf ( t->c.e.ss, "%02d", s->ival );
680 sprintf ( t->d.e.ss, "%02d", s->ival );
681 }
683 break;
684
685 case 86: // 0 04 086 . Long time period or displacement (since launch time)
686
687 // s->rep is used to check what type of point we are dealing from
688 // see repliator 0 31 001 and 0 31 002 to understand it better
689 // Because this is the first descriptor in a sequence for a point, we use this
690 // descriptor to set properly the current index
691 if ( s->rep > 0 )
692 {
693 // case of Temperature, humidty ... point
694 if ( ( int ) s->r->n < s->rep )
695 {
696 // Because of there are bufr reports with a lot of not significant points
697 // we only collect the first one and significant points, i.e. those that flags are non zero
698 // When flags are zero we just overwrite points
699 if ( s->r->n < ( RAW_TEMP_NMAX_POINTS ) &&
700 ( s->r->n == 0 || s->r->raw[s->r->n - 1].flags ) )
701 {
702 s->r->n += 1; // Here we update the index
703 }
704 }
705 s->r->raw[s->r->n - 1].dt = s->ival;
706 }
707 else
708 {
709 // case of wind shear point
710 if ( ( int ) s->w->n < s->itval )
711 {
712 s->w->n += 1;
713 }
714 s->w->raw[s->w->n - 1].dt = s->ival;
715 }
716 break;
717
718 default:
719 if ( BUFR2TAC_DEBUG_LEVEL > 1 && ( s->a->mask & DESCRIPTOR_VALUE_MISSING ) == 0 )
720 bufr2tac_set_error ( s, 0, "temp_parse_x04()", "Descriptor not parsed" );
721 break;
722 }
723 return 0;
724}
#define SUBSET_MASK_HAVE_SECOND
Bit mask to mark a struct bufr_subset_sequence_data having observation second.
Definition: bufr2tac.h:170
#define RAW_TEMP_NMAX_POINTS
maximum number of raw points points
Definition: mettemp.h:144
struct report_date_ext e
Definition: mettemp.h:469
struct report_date_ext e
Definition: mettemp.h:484
struct report_date_ext e
Definition: mettemp.h:499

References bufr2tac_subset_state::a, temp_chunks::a, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, report_date_ext::DD, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_raw_point_data::dt, temp_raw_wind_shear_point::dt, temp_a::e, temp_b::e, temp_c::e, temp_d::e, temp_raw_point_data::flags, temp_sec7::GG, temp_sec7::gg, report_date_ext::HH, bufr2tac_subset_state::itval, bufr2tac_subset_state::ival, bufr_atom_data::mask, bufr2tac_subset_state::mask, report_date_ext::MM, report_date_ext::mm, temp_raw_data::n, temp_raw_wind_shear_data::n, bufr2tac_subset_state::r, temp_raw_data::raw, temp_raw_wind_shear_data::raw, RAW_TEMP_NMAX_POINTS, bufr2tac_subset_state::rep, temp_a::s7, temp_b::s7, temp_c::s7, temp_d::s7, report_date_ext::ss, SUBSET_MASK_HAVE_DAY, SUBSET_MASK_HAVE_HOUR, SUBSET_MASK_HAVE_MINUTE, SUBSET_MASK_HAVE_MONTH, SUBSET_MASK_HAVE_SECOND, SUBSET_MASK_HAVE_YEAR, bufr2tac_subset_state::w, bufr_descriptor::y, and report_date_ext::YYYY.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x05()

int temp_parse_x05 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Definition at line 204 of file bufr2tac_x05.c.

205{
206 int ia;
207
208 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
209 return 0;
210
211 // this is to avoid warning
212 if ( t == NULL )
213 return 1;
214
215 switch ( s->a->desc.y )
216 {
217 case 1: // 0 05 001 . Latitude (High accuracy)
218 case 2: // 0 05 002 . Latitude (Coarse accuracy)
219 if ( s->val < 0.0 )
220 s->mask |= SUBSET_MASK_LATITUDE_SOUTH; // Sign for latitude
222 s->lat = s->val;
223 ia = ( int ) ( fabs ( s->val ) * 10.0 + 0.5 );
224 sprintf ( t->a.s1.LaLaLa, "%03d",ia );
225 sprintf ( t->b.s1.LaLaLa, "%03d",ia );
226 sprintf ( t->c.s1.LaLaLa, "%03d",ia );
227 sprintf ( t->d.s1.LaLaLa, "%03d",ia );
228 t->a.s1.Ula[0] = t->a.s1.LaLaLa[1];
229 t->b.s1.Ula[0] = t->b.s1.LaLaLa[1];
230 t->c.s1.Ula[0] = t->c.s1.LaLaLa[1];
231 t->d.s1.Ula[0] = t->d.s1.LaLaLa[1];
232
233 // check if set both LaLaLa and LoLoLoLo to set Qc
234 if ( ( t->a.s1.Qc[0] == 0 ) && t->a.s1.LaLaLa[0] && t->a.s1.LoLoLoLo[0] )
235 {
237 {
239 strcpy ( t->a.s1.Qc, "5" );
240 else
241 strcpy ( t->a.s1.Qc, "3" );
242 }
243 else
244 {
246 strcpy ( t->a.s1.Qc, "7" );
247 else
248 strcpy ( t->a.s1.Qc, "1" );
249 }
250 strcpy ( t->b.s1.Qc, t->a.s1.Qc );
251 strcpy ( t->c.s1.Qc, t->a.s1.Qc );
252 strcpy ( t->d.s1.Qc, t->a.s1.Qc );
253 }
254
255 // check if about MMM
256 if ( ( t->a.s1.MMM[0] == 0 ) && t->a.s1.LaLaLa[0] && t->a.s1.LoLoLoLo[0] )
257 {
258 latlon_to_MMM ( t->a.s1.MMM, s->lat, s->lon );
259 strcpy ( t->b.s1.MMM, t->a.s1.MMM );
260 strcpy ( t->c.s1.MMM, t->a.s1.MMM );
261 strcpy ( t->d.s1.MMM, t->a.s1.MMM );
262 }
263 break;
264
265 case 15: // 0 05 015. Latitude displacement since launch site (high accuracy)
266 if ( s->rep > 0 && s->r->n > 0 )
267 {
268 s->r->raw[s->r->n - 1].dlat = s->val;
269 }
270 else if ( s->w->n > 0 )
271 {
272 s->w->raw[s->w->n - 1].dlat = s->val;
273 }
274 break;
275
276 default:
277 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
278 bufr2tac_set_error ( s, 0, "temp_parse_x05()", "Descriptor not parsed" );
279 break;
280 }
281
282 return 0;
283}

References bufr2tac_subset_state::a, temp_chunks::a, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_raw_point_data::dlat, temp_raw_wind_shear_point::dlat, temp_acd_sec1::LaLaLa, temp_b_sec1::LaLaLa, bufr2tac_subset_state::lat, latlon_to_MMM(), temp_acd_sec1::LoLoLoLo, bufr2tac_subset_state::lon, bufr_atom_data::mask, bufr2tac_subset_state::mask, temp_acd_sec1::MMM, temp_b_sec1::MMM, temp_raw_data::n, temp_raw_wind_shear_data::n, temp_acd_sec1::Qc, temp_b_sec1::Qc, bufr2tac_subset_state::r, temp_raw_data::raw, temp_raw_wind_shear_data::raw, bufr2tac_subset_state::rep, temp_a::s1, temp_b::s1, temp_c::s1, temp_d::s1, SUBSET_MASK_HAVE_LATITUDE, SUBSET_MASK_LATITUDE_SOUTH, SUBSET_MASK_LONGITUDE_WEST, temp_acd_sec1::Ula, temp_b_sec1::Ula, bufr2tac_subset_state::val, bufr2tac_subset_state::w, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x06()

int temp_parse_x06 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Definition at line 200 of file bufr2tac_x06.c.

201{
202 int ia;
203
204 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
205 return 0;
206
207 switch ( s->a->desc.y )
208 {
209 case 1: // 0 06 001 . Longitude (High accuracy)
210 case 2: // 0 06 002 . Longitude (Coarse)
211 if ( s->val < 0.0 )
212 s->mask |= SUBSET_MASK_LONGITUDE_WEST; // Sign for longitude
214 ia = ( int ) ( fabs ( s->val ) * 10.0 + 0.5 );
215 sprintf ( t->a.s1.LoLoLoLo, "%04d",ia );
216 sprintf ( t->b.s1.LoLoLoLo, "%04d",ia );
217 sprintf ( t->c.s1.LoLoLoLo, "%04d",ia );
218 sprintf ( t->d.s1.LoLoLoLo, "%04d",ia );
219 t->a.s1.Ulo[0] = t->a.s1.LoLoLoLo[2];
220 t->b.s1.Ulo[0] = t->b.s1.LoLoLoLo[2];
221 t->c.s1.Ulo[0] = t->c.s1.LoLoLoLo[2];
222 t->d.s1.Ulo[0] = t->d.s1.LoLoLoLo[2];
223 s->lon = s->val;
224
225 // check if set both LaLaLa and LoLoLoLo to set Qc
226 if ( ( t->a.s1.Qc[0] == 0 ) && t->a.s1.LaLaLa[0] && t->a.s1.LoLoLoLo[0] )
227 {
229 {
231 strcpy ( t->a.s1.Qc, "5" );
232 else
233 strcpy ( t->a.s1.Qc, "3" );
234 }
235 else
236 {
238 strcpy ( t->a.s1.Qc, "7" );
239 else
240 strcpy ( t->a.s1.Qc, "1" );
241 }
242 strcpy ( t->b.s1.Qc, t->a.s1.Qc );
243 strcpy ( t->c.s1.Qc, t->a.s1.Qc );
244 strcpy ( t->d.s1.Qc, t->a.s1.Qc );
245 }
246
247 // check if about MMM
248 if ( ( t->a.s1.MMM[0] == 0 ) && t->a.s1.LaLaLa[0] && t->a.s1.LoLoLoLo[0] )
249 {
250 latlon_to_MMM ( t->a.s1.MMM, s->lat, s->lon );
251 strcpy ( t->b.s1.MMM, t->a.s1.MMM );
252 strcpy ( t->c.s1.MMM, t->a.s1.MMM );
253 strcpy ( t->d.s1.MMM, t->a.s1.MMM );
254 }
255 break;
256
257 case 15: // 0 06 015. Longitude displacement since launch site (high accuracy)
258 if ( s->rep > 0 && s->r->n > 0 )
259 {
260 s->r->raw[s->r->n - 1].dlon = s->val;
261 }
262 else if ( s->w->n > 0 )
263 {
264 s->w->raw[s->w->n - 1].dlon = s->val;
265 }
266 break;
267
268 default:
269 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
270 bufr2tac_set_error ( s, 0, "temp_parse_x06()", "Descriptor not parsed" );
271 break;
272 }
273
274 return 0;
275}

References bufr2tac_subset_state::a, temp_chunks::a, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_raw_point_data::dlon, temp_raw_wind_shear_point::dlon, temp_acd_sec1::LaLaLa, bufr2tac_subset_state::lat, latlon_to_MMM(), temp_acd_sec1::LoLoLoLo, temp_b_sec1::LoLoLoLo, bufr2tac_subset_state::lon, bufr_atom_data::mask, bufr2tac_subset_state::mask, temp_acd_sec1::MMM, temp_b_sec1::MMM, temp_raw_data::n, temp_raw_wind_shear_data::n, temp_acd_sec1::Qc, temp_b_sec1::Qc, bufr2tac_subset_state::r, temp_raw_data::raw, temp_raw_wind_shear_data::raw, bufr2tac_subset_state::rep, temp_a::s1, temp_b::s1, temp_c::s1, temp_d::s1, SUBSET_MASK_HAVE_LONGITUDE, SUBSET_MASK_LATITUDE_SOUTH, SUBSET_MASK_LONGITUDE_WEST, temp_acd_sec1::Ulo, temp_b_sec1::Ulo, bufr2tac_subset_state::val, bufr2tac_subset_state::w, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x07()

int temp_parse_x07 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Definition at line 258 of file bufr2tac_x07.c.

259{
260 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
261 {
262 return 0;
263 }
264
265// this is to avoid warning
266 if ( t == NULL )
267 {
268 return 1;
269 }
270
271 switch ( s->a->desc.y )
272 {
273 case 4: // 0 07 004 . Pressure
274 if ( s->rep > 0 && s->r->n > 0 )
275 {
276 s->r->raw[s->r->n - 1].p = s->val;
277 }
278 else if ( s->w->n > 0 )
279 {
280 s->w->raw[s->w->n - 1].p = s->val;
281 }
282 break;
283
284 case 30: // 0 07 030 . Height of station ground above msl
285 sprintf ( t->a.s1.h0h0h0h0, "%04.0lf" , s->val );
286 sprintf ( t->b.s1.h0h0h0h0, "%04.0lf" , s->val );
287 sprintf ( t->c.s1.h0h0h0h0, "%04.0lf" , s->val );
288 sprintf ( t->d.s1.h0h0h0h0, "%04.0lf" , s->val );
289 break;
290
291 case 31: // 0 07 031 . Height of barometer above msl
292 s->alt = s->val;
293 break;
294
295 default:
296 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
297 bufr2tac_set_error ( s, 0, "temp_parse_x07()", "Descriptor not parsed" );
298 break;
299 }
300
301 return 0;
302}

References bufr2tac_subset_state::a, temp_chunks::a, bufr2tac_subset_state::alt, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_acd_sec1::h0h0h0h0, temp_b_sec1::h0h0h0h0, bufr_atom_data::mask, temp_raw_data::n, temp_raw_wind_shear_data::n, temp_raw_point_data::p, temp_raw_wind_shear_point::p, bufr2tac_subset_state::r, temp_raw_data::raw, temp_raw_wind_shear_data::raw, bufr2tac_subset_state::rep, temp_a::s1, temp_b::s1, temp_c::s1, temp_d::s1, bufr2tac_subset_state::val, bufr2tac_subset_state::w, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x08()

int temp_parse_x08 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 08.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 421 of file bufr2tac_x08.c.

422{
423 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
424 {
425 return 0;
426 }
427
428 if ( t == NULL )
429 {
430 return 1;
431 }
432
433 switch ( s->a->desc.y )
434 {
435 case 2: // 0 08 002.
436 // this is to mark of the begining or end of cloud surface data
437 if ( s->isq == 0 )
438 {
439 s->isq = 1;
440 }
441 else
442 {
443 s->isq = 0;
444 }
445 break;
446
447 case 21: // 0 08 021. Time significance
448 if ( s->ival != 18 )
449 {
450 return 1; // it should be 18 (launch date/time)
451 }
452 break;
453
454 case 42: // 0 08 042. Extended vertical sounding significance
455 if ( s->rep > 0 && s->r->n > 0 )
456 {
457 s->r->raw[s->r->n - 1].flags = s->ival;
458 }
459 else if ( s->w->n > 0 )
460 {
461 // wind shear case
462 s->w->raw[s->w->n - 1].flags = s->ival;
463 }
464 break;
465
466 default:
467 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
468 bufr2tac_set_error ( s, 0, "temp_parse_x08()", "Descriptor not parsed" );
469 break;
470 }
471 return 0;
472}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_raw_point_data::flags, temp_raw_wind_shear_point::flags, bufr2tac_subset_state::isq, bufr2tac_subset_state::ival, bufr_atom_data::mask, temp_raw_data::n, temp_raw_wind_shear_data::n, bufr2tac_subset_state::r, temp_raw_data::raw, temp_raw_wind_shear_data::raw, bufr2tac_subset_state::rep, bufr2tac_subset_state::w, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x10()

int temp_parse_x10 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 10.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 297 of file bufr2tac_x10.c.

298{
299 if ( t == NULL || s == NULL )
300 {
301 return 1;
302 }
303
304 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
305 {
306 return 0;
307 }
308
309 switch ( s->a->desc.y )
310 {
311 case 9: // 0 10 009. geopotential
312 if ( s->rep > 0 && s->r->n > 0 )
313 {
314 s->r->raw[s->r->n - 1].h = s->val;
315 }
316 break;
317
318 default:
319 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
320 bufr2tac_set_error ( s, 0, "temp_parse_x10()", "Descriptor not parsed" );
321 break;
322 }
323 return 0;
324}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_raw_point_data::h, bufr_atom_data::mask, temp_raw_data::n, bufr2tac_subset_state::r, temp_raw_data::raw, bufr2tac_subset_state::rep, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x11()

int temp_parse_x11 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 11.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 500 of file bufr2tac_x11.c.

501{
502
503 if ( t == NULL )
504 {
505 return 1;
506 }
507
508 switch ( s->a->desc.y )
509 {
510 case 1: // 0 11 001. Wind direction
511 if ( s->rep > 0 && s->r->n > 0 )
512 {
513 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
514 {
515 s->r->raw[s->r->n - 1].dd = MISSING_REAL;
516 }
517 else
518 {
519 s->r->raw[s->r->n - 1].dd = s->val;
520 }
521 }
522 break;
523
524 case 2: // 0 11 002. Wind speed
525 if ( s->rep > 0 && s->r->n > 0 )
526 {
527 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
528 {
529 s->r->raw[s->r->n - 1].ff = MISSING_REAL;
530 }
531 else
532 {
533 s->r->raw[s->r->n - 1].ff = s->val;
534 }
535 }
536 break;
537
538 case 61: // 0 11 061. Absolute wind shear in 1 km layer below
539 if ( s->w->n > 0 )
540 {
541 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
542 {
543 s->w->raw[s->w->n - 1].ws_blw = MISSING_REAL;
544 }
545 else
546 {
547 s->w->raw[s->w->n - 1].ws_blw = s->val;
548 }
549 }
550 break;
551
552 case 62: // 0 11 062. Absolute wind shear in 1 km layer above
553 if ( s->w->n > 0 )
554 {
555 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
556 {
557 s->w->raw[s->w->n - 1].ws_abv = MISSING_REAL;
558 }
559 else
560 {
561 s->w->raw[s->w->n - 1].ws_abv = s->val;
562 }
563 }
564 break;
565
566 default:
567 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
568 bufr2tac_set_error ( s, 0, "temp_parse_x11()", "Descriptor not parsed" );
569 break;
570 }
571 return 0;
572}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_raw_point_data::dd, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_raw_point_data::ff, bufr_atom_data::mask, MISSING_REAL, temp_raw_data::n, temp_raw_wind_shear_data::n, bufr2tac_subset_state::r, temp_raw_data::raw, temp_raw_wind_shear_data::raw, bufr2tac_subset_state::rep, bufr2tac_subset_state::val, bufr2tac_subset_state::w, temp_raw_wind_shear_point::ws_abv, temp_raw_wind_shear_point::ws_blw, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x12()

int temp_parse_x12 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 12.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 751 of file bufr2tac_x12.c.

752{
753 if ( t == NULL )
754 {
755 return 1;
756 }
757
758 switch ( s->a->desc.y )
759 {
760 case 101: // 0 12 101. Temperature/dry-bulb temperature (scale 2)
761 if ( s->rep > 0 && s->r->n > 0 )
762 {
763 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
764 {
765 s->r->raw[s->r->n - 1].T = MISSING_REAL;
766 }
767 else
768 {
769 s->r->raw[s->r->n - 1].T = s->val;
770 }
771 }
772 break;
773
774 case 103: // 0 12 103. Dew-point temperature (scale 2)
775 if ( s->rep > 0 && s->r->n > 0 )
776 {
777 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
778 {
779 s->r->raw[s->r->n - 1].Td = MISSING_REAL;
780 }
781 else
782 {
783 s->r->raw[s->r->n - 1].Td = s->val;
784 }
785 }
786 break;
787
788 default:
789 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
790 bufr2tac_set_error ( s, 0, "temp_parse_x12()", "Descriptor not parsed" );
791 break;
792 }
793
794 return 0;
795}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr_atom_data::mask, MISSING_REAL, temp_raw_data::n, bufr2tac_subset_state::r, temp_raw_data::raw, bufr2tac_subset_state::rep, temp_raw_point_data::T, temp_raw_point_data::Td, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x20()

int temp_parse_x20 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 20.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 1354 of file bufr2tac_x20.c.

1355{
1356
1357 switch ( s->a->desc.y )
1358 {
1359 case 11: // 0 20 011 . Cloud amount
1360 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1361 {
1362 return 0;
1363 }
1364 if ( s->ival <= 8 )
1365 {
1366 sprintf ( t->b.s8.Nh, "%1d", abs(s->ival) % 10 );
1367 }
1368 else if ( s->ival <= 10 )
1369 {
1370 sprintf ( t->b.s8.Nh, "9" );
1371 }
1372 else if ( s->ival == 15 )
1373 {
1374 sprintf ( t->b.s8.Nh, "/" );
1375 }
1376 t->b.mask |= TEMP_SEC_8;
1377 break;
1378
1379 case 12: // 0 20 012 . Cloud type
1380 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1381 {
1382 return 0;
1383 }
1384 if ( s->ival >= 10 && s->ival < 20 )
1385 {
1386 sprintf ( t->b.s8.Ch, "%1d", s->ival % 10 );
1387 }
1388 else if ( s->ival >= 20 && s->ival < 30 )
1389 {
1390 sprintf ( t->b.s8.Cm, "%1d", s->ival % 10 );
1391 }
1392 else if ( s->ival >= 30 && s->ival < 40 )
1393 {
1394 sprintf ( t->b.s8.Cl, "%1d", s->ival % 10 );
1395 }
1396 else if ( s->ival == 59 )
1397 {
1398 sprintf ( t->b.s8.Nh, "/" );
1399 }
1400 else if ( s->ival == 60 )
1401 {
1402 sprintf ( t->b.s8.Ch, "/" );
1403 }
1404 else if ( s->ival == 61 )
1405 {
1406 sprintf ( t->b.s8.Cm, "/" );
1407 }
1408 else if ( s->ival == 62 )
1409 {
1410 sprintf ( t->b.s8.Cl, "/" );
1411 }
1412 t->b.mask |= TEMP_SEC_8;
1413 break;
1414
1415 case 13: // 0 20 013 . Height of base of cloud
1416 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
1417 {
1418 return 0;
1419 }
1420 m_to_h ( t->b.s8.h, s->val );
1421 break;
1422
1423 default:
1424 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
1425 bufr2tac_set_error ( s, 0, "temp_parse_x20()", "Descriptor not parsed" );
1426 break;
1427 }
1428 return 0;
1429}
#define TEMP_SEC_8
mask bit meaning sec 8 of a part of TEMP report parsed with success
Definition: mettemp.h:101

References bufr2tac_subset_state::a, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_b_sec8::Ch, temp_b_sec8::Cl, temp_b_sec8::Cm, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_b_sec8::h, bufr2tac_subset_state::ival, m_to_h(), bufr_atom_data::mask, temp_b::mask, temp_b_sec8::Nh, temp_b::s8, TEMP_SEC_8, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x22()

int temp_parse_x22 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 22.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 289 of file bufr2tac_x22.c.

290{
291 char aux[16];
292
293 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
294 return 0;
295
296 switch ( s->a->desc.y )
297 {
298 case 43:
299 if ( kelvin_to_snTTT ( aux, s->val ) )
300 {
301 t->a.s7.sn[0] = aux[0];
302 t->b.s7.sn[0] = aux[0];
303 t->c.s7.sn[0] = aux[0];
304 t->d.s7.sn[0] = aux[0];
305 strcpy ( t->a.s7.TwTwTw, aux + 1 );
306 strcpy ( t->b.s7.TwTwTw, aux + 1 );
307 strcpy ( t->c.s7.TwTwTw, aux + 1 );
308 strcpy ( t->d.s7.TwTwTw, aux + 1 );
309 t->a.mask |= TEMP_SEC_7; // have sec7 data
310 }
311 break;
312
313 default:
314 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
315 bufr2tac_set_error ( s, 0, "temp_parse_x22()", "Descriptor not parsed" );
316 break;
317 }
318
319 return 0;
320}
#define TEMP_SEC_7
mask bit meaning sec 7 of a part of TEMP report parsed with success
Definition: mettemp.h:95

References bufr2tac_subset_state::a, temp_chunks::a, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, kelvin_to_snTTT(), bufr_atom_data::mask, temp_a::mask, temp_a::s7, temp_b::s7, temp_c::s7, temp_d::s7, temp_sec7::sn, TEMP_SEC_7, temp_sec7::TwTwTw, bufr2tac_subset_state::val, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x31()

int temp_parse_x31 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 31.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 120 of file bufr2tac_x31.c.

121{
122 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
123 {
124 return 0;
125 }
126
127 if ( t == NULL )
128 {
129 return 1;
130 }
131
132 switch ( s->a->desc.y )
133 {
134 case 0: // 0 31 000 . Short delayed descriptor replication factor
135 // It is no meaning here
136 break;
137 case 1: // 0 31 001 . Replicator
138 // It is supposed that it is the extended replicator used when describing
139 // wind shear points in raiosonde
140 // It is the amount of points of wind shear data at pressure level
141 if ( s->ival < TEMP_NMAX_POINTS )
142 {
143 s->itval = s->ival;
144 s->rep = 0; // used to mark it is a share point in sequent descriptors
145 }
146 else
147 {
148 return 1; // too much points
149 }
150 s->k_itval = s->i;
151 s->w->n = 0;
152 break;
153
154 case 2: // 0 31 002 . Extended replicator
155 // It is supposed that it is the extended replicator used when describing
156 // Temperature, dew-point and wind data at a pressure level with radiosonde position
157 // So the integer value of repliactor IS the amount of points
158 s->rep = s->ival; // replications and points we need. Also Used to mark this type of point
159 s->itval = 0;
160 s->k_rep = s->i;
161 s->r->n = 0;
162 break;
163 default:
164 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
165 bufr2tac_set_error ( s, 0, "temp_parse_x31()", "Descriptor not parsed" );
166 break;
167 }
168 return 0;
169}

References bufr2tac_subset_state::a, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::i, bufr2tac_subset_state::itval, bufr2tac_subset_state::ival, bufr2tac_subset_state::k_itval, bufr2tac_subset_state::k_rep, bufr_atom_data::mask, temp_raw_data::n, temp_raw_wind_shear_data::n, bufr2tac_subset_state::r, bufr2tac_subset_state::rep, TEMP_NMAX_POINTS, bufr2tac_subset_state::w, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ temp_parse_x33()

int temp_parse_x33 ( struct temp_chunks t,
struct bufr2tac_subset_state s 
)

Parse a expanded descriptor with X = 33.

Parameters
tpointer to a struct temp_chunks where to set the results
spointer to a struct bufr2tac_subset_state where is stored needed information in sequential analysis

It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway

Definition at line 100 of file bufr2tac_x33.c.

101{
102
103 switch ( s->a->desc.y )
104 {
105 case 24: // 0 33 024. Station elevation quality mark (for mobile stations)
106 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
107 {
108 strcpy ( t->a.s1.im, "/" );
109 strcpy ( t->b.s1.im, "/" );
110 strcpy ( t->c.s1.im, "/" );
111 strcpy ( t->d.s1.im, "/" );
112 return 0;
113 }
114
115 if ( s->ival >= 0 && s->ival < 9 )
116 {
117 sprintf ( t->a.s1.im, "%d", s->ival );
118 sprintf ( t->a.s1.im, "%d", s->ival );
119 sprintf ( t->a.s1.im, "%d", s->ival );
120 sprintf ( t->a.s1.im, "%d", s->ival );
121 }
122 else
123 {
124 strcpy ( t->a.s1.im, "/" );
125 strcpy ( t->b.s1.im, "/" );
126 strcpy ( t->c.s1.im, "/" );
127 strcpy ( t->d.s1.im, "/" );
128 }
129 break;
130 default:
131 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
132 bufr2tac_set_error ( s, 0, "temp_parse_x33()", "Descriptor not parsed" );
133 break;
134 }
135 return 0;
136}

References bufr2tac_subset_state::a, temp_chunks::a, temp_chunks::b, BUFR2TAC_DEBUG_LEVEL, bufr2tac_set_error(), temp_chunks::c, temp_chunks::d, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, temp_acd_sec1::im, temp_b_sec1::im, bufr2tac_subset_state::ival, bufr_atom_data::mask, temp_a::s1, temp_b::s1, temp_c::s1, temp_d::s1, and bufr_descriptor::y.

Referenced by parse_subset_as_temp().

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

◆ three_bytes_to_uint()

three_bytes_to_uint ( const unsigned char *  source)

returns the integer value from an array of three bytes, most significant first

Definition at line 30 of file bufr2tac_utils.c.

31{
32 return ( source[2] + source[1] * 256 + source[0] * 65536 );
33}

Referenced by read_bufr().

Here is the caller graph for this function:

◆ time_period_duration()

int time_period_duration ( struct bufr2tac_subset_state s)

Get time period duration in seconds.

Parameters
spinter to struct bufr2tac_subset_state

Returns -1 if no duration is computed. Otherwise returns time duration in seconds

Definition at line 33 of file bufr2tac_x04.c.

34{
35 if ( s->k_itval == ( s->k_jtval + 1 ) )
36 {
37 // two consecutive time period displacements
38 if ( ( s->itmask & DESCRIPTOR_VALUE_MISSING ) == 0 &&
39 ( s->jtmask & DESCRIPTOR_VALUE_MISSING ) == 0 )
40 {
41 return ( abs ( s->itval - s->jtval ) );
42 }
43 else if ( ( s->itmask & DESCRIPTOR_VALUE_MISSING ) &&
45 {
46 return 0;
47 }
48 else if ( ( s->itmask & DESCRIPTOR_VALUE_MISSING ) == 0 &&
50 {
51 return ( abs ( s->itval ) );
52 }
53 else if ( ( s->jtmask & DESCRIPTOR_VALUE_MISSING ) == 0 &&
55 {
56 return -1;
57 }
58 }
59
60 // just a single time period displacement
61 if ( ( s->itmask & DESCRIPTOR_VALUE_MISSING ) == 0 )
62 {
63 return ( abs ( s->itval ) );
64 }
65 else
66 {
67 return 0;
68 }
69}

References DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::itmask, bufr2tac_subset_state::itval, bufr2tac_subset_state::jtmask, bufr2tac_subset_state::jtval, bufr2tac_subset_state::k_itval, and bufr2tac_subset_state::k_jtval.

Referenced by syn_parse_x12(), syn_parse_x13(), and syn_parse_x14().

Here is the caller graph for this function:

◆ total_snow_depth_to_sss()

char * total_snow_depth_to_sss ( char *  target,
double  r 
)

converts tatal snow depth in m to sss (code table 3889)

Parameters
rrecent snow depth in meters
targetthe resulting string

Definition at line 124 of file bufr2tac_x13.c.

125{
126 int i;
127 if ( r >= 0.0 )
128 i = ( int ) ( r * 100.0 + 0.5 ); // convert to cm
129 else
130 i = ( int ) ( r * 100.0 - 0.5 ); // convert to cm
131
132 if ( i > 0 && i <= 996 )
133 {
134 sprintf ( target, "%03d", i );
135 }
136 else if ( i == -1 )
137 {
138 sprintf ( target, "997" );
139 }
140 else if ( i == -2 )
141 {
142 sprintf ( target, "998" );
143 }
144 else
145 {
146 sprintf ( target, "999" );
147 }
148 return target;
149}

Referenced by syn_parse_x13().

Here is the caller graph for this function:

◆ vism_to_VV()

char * vism_to_VV ( char *  target,
double  V 
)

Convert horizontal visibilty in meters to a VV string.

Parameters
Vthe visibility (m)
targetthe resulting VV string

Definition at line 226 of file bufr2tac_x20.c.

227{
228 if ( V < 100.0 )
229 {
230 strcpy ( target, "00" );
231 }
232 else if ( V <= 5000.0 )
233 {
234 sprintf ( target, "%02d", ( int ) ( V + 0.1 ) / 100 );
235 }
236 else if ( V < 6000.0 )
237 {
238 sprintf ( target, "50" ); // this is to avoid 51-55 range
239 }
240 else if ( V <= 30000.0 )
241 {
242 sprintf ( target, "%02d", ( int ) ( V + 0.1 ) / 1000 + 50 );
243 }
244 else if ( V <= 70000.0 )
245 {
246 sprintf ( target, "%02d", ( int ) ( V - 30000.0 ) / 5000 + 80 );
247 }
248 else
249 {
250 strcpy ( target, "89" );
251 }
252 return target;
253}

Referenced by syn_parse_x20().

Here is the caller graph for this function:

◆ wind_to_dndnfnfnfn()

char * wind_to_dndnfnfnfn ( char *  target,
double  dd,
double  ff 
)

Definition at line 93 of file bufr2tac_x11.c.

94{
95 int ix;
96
97 if ( dd == MISSING_REAL || ff == MISSING_REAL )
98 {
99 strcpy ( target, "/////" );
100 return target;
101 }
102
103 ix = ( int ) ( ( dd + 2.5 ) / 5 ) * 5 * 100 + ( int ) ( ff + 0.5 );
104 sprintf ( target, "%05d", ix );
105 return target;
106}

References MISSING_REAL.

Referenced by parse_temp_raw_data().

Here is the caller graph for this function:

◆ YYYYMMDDHHmm_to_met_datetime()

int YYYYMMDDHHmm_to_met_datetime ( struct met_datetime t,
const char *  source 
)

Parse the string YYYYMMDDHHmm[ss] and set a struct met_datetime.

Parameters
sourcestring with date in YYYYMMDDHHmm[ss] format
tpointer to a struct met_datetime where to set the results

Definition at line 156 of file bufr2tac_utils.c.

157{
158 if ( strlen ( source ) != 12 && strlen ( source ) != 14 )
159 return 1;
160 memset ( &t->tim, 0, sizeof ( struct tm ) );
161 if ( strlen ( source ) == 12 )
162 {
163 strptime ( source, "%Y%m%d%H%M", &t->tim );
164 }
165 else
166 {
167 strptime ( source, "%Y%m%d%H%M%S", &t->tim );
168 }
169 strcpy ( t->datime, source );
170 t->t = mktime ( &t->tim );
171 return 0;
172}

References met_datetime::datime, met_datetime::t, and met_datetime::tim.

Referenced by parse_subset_as_buoy(), parse_subset_as_climat(), parse_subset_as_synop(), and parse_subset_as_temp().

Here is the caller graph for this function:

Variable Documentation

◆ BUFR2TAC_DEBUG_LEVEL

int BUFR2TAC_DEBUG_LEVEL
extern