bufr2synop 0.24.0
Macros | Functions
bufrnoaa_io.c File Reference

File with I/O code for bufrnoaa binary. More...

#include "config.h"
#include "bufrnoaa.h"
Include dependency graph for bufrnoaa_io.c:

Go to the source code of this file.

Macros

#define CONFIG_H
 

Functions

void print_usage (void)
 
char * bufrnoaa_get_version (char *version, char *build, char *builder, int *version_major, int *version_minor, int *version_patch)
 Get strings with version information and build date and time. More...
 
void print_version ()
 
int read_args (int _argc, char *_argv[])
 read the arguments from stdio More...
 

Detailed Description

File with I/O code for bufrnoaa binary.

Definition in file bufrnoaa_io.c.

Macro Definition Documentation

◆ CONFIG_H

#define CONFIG_H

Definition at line 26 of file bufrnoaa_io.c.

Function Documentation

◆ bufrnoaa_get_version()

char * bufrnoaa_get_version ( char *  version,
char *  build,
char *  builder,
int *  version_major,
int *  version_minor,
int *  version_patch 
)

Get strings with version information and build date and time.

Parameters
versionpointer to string with version as result if not NULL
buildpointer to string with compiler and compilation date and time if not NULL
builderpointer to string with builder utility. 'cmake' or 'autotools' if not NULL
version_majorpointer to string with version_major component if not NULL
version_minorpointer to string with version_minor component if not NULL
version_patchpointer to string with version_patch component if not NULL

Retuns string pointer version.

Definition at line 72 of file bufrnoaa_io.c.

73{
74 int major = 0, minor = 0, patch = 0;
75 char *c;
76
77 if (version == NULL)
78 return NULL;
79 sprintf(version, "%s", VERSION);
80 // default values
81 sscanf(version, "%d.%d.%d", &major, &minor, &patch);
82 if (build)
83 {
84 c = build;
85#if defined(__INTEL_COMPILER)
86 c += sprintf(build, "using INTEL C compiler icc %d.%d ", __INTEL_COMPILER, __INTEL_COMPILER_UPDATE);
87#elif defined(__clang_version__)
88 c += sprintf(build, "using clang C compiler ", __clang_version__);
89#elif defined(__GNUC__)
90 c += sprintf(build, "using GNU C compiler gcc %d.%d.%d ", __GNUC__ , __GNUC_MINOR__ , __GNUC_PATCHLEVEL__);
91#elif defined(_MSC_VER)
92 c += sprintf(build, "using MICROSOFT C compiler %d ", _MSC_VER);
93#else
94 c += sprintf(build, "using an unknown C compiler ");
95#endif
96 sprintf(c,"at %s %s",__DATE__,__TIME__);
97 }
98
99 if (builder)
100#ifdef BUILD_USING_CMAKE
101 strcpy(builder, "cmake");
102#else
103 strcpy(builder, "autotools");
104#endif
105 if (version_major)
106 *version_major = major;
107 if (version_minor)
108 *version_minor = minor;
109 if (version_patch)
110 *version_patch = patch;
111 return version;
112}
#define VERSION
Definition: config.h:8

References VERSION.

Referenced by print_version().

Here is the caller graph for this function:

◆ print_usage()

void print_usage ( void  )

Definition at line 31 of file bufrnoaa_io.c.

32{
34 printf ( "Usage: \n" );
35 printf ( "\n%s -i input_file [-h][-v][-f][-l][-F prefix][-T T2_selection][-O selo][-S sels][-U selu]\n" , OWN);
36 printf ( " -h Print this help\n" );
37 printf ( " -v Print information about build and version\n" );
38 printf ( " -i Input file. Complete input path file for NOAA *.bin bufr archive file\n" );
39 printf ( " -2 Input file is formatted in alternative form: Headers has '#' instead of '*' marks and no sep after '7777'\n");
40 printf ( " -l list the names of reports in input file\n" );
41 printf ( " -f Extract selected reports and write them in files, one per bufr message, as \n" );
42 printf ( " example '20110601213442_ISIE06_SBBR_012100_RRB.bufr'. First field in name is input file timestamp \n" );
43 printf ( " Other fields are from header\n" );
44 printf ( " -F prefix. Builds an archive file with the same format as NOAA one but just with selected messages\n" );
45 printf ( " witgh option -T. Resulting name is 'prefix_input_filename'\n" );
46 printf ( " If no -F option no archive bin file is created.\n" );
47 printf ( " If no message is selected, the a void file is created.\n" );
48 printf ( " File timestamp is the same than input file\n" );
49 printf ( " -T T2_selection. A string with selection. A character per type (T2 code)\n" );
50 printf ( " 'S' = Surface . 'O'= Oceanographic. 'U'= upper air\n" );
51 printf ( " If no -T argument then nothing is selected\n" );
52 printf ( " -S sels. String with selection for A1 when T2='S'\n" );
53 printf ( " By default all A1 are selected\n" );
54 printf ( " -O selo. String with selection for A1 when T2='O'\n" );
55 printf ( " By default all A1 are selected\n" );
56 printf ( " -U sels. String with selection for A1 when T2='U'\n" );
57 printf ( " By default all A1 are selected\n" );
58}
char OWN[]
Definition: bufrnoaa.c:205
void print_version()
Definition: bufrnoaa_io.c:114

References OWN, and print_version().

Referenced by read_args().

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

◆ print_version()

void print_version ( void  )

Definition at line 114 of file bufrnoaa_io.c.

115{
116 char version[16], build[64], builder[32];
117
118 bufrnoaa_get_version(version, build, builder, NULL, NULL, NULL);
119 printf ("%s: Version '%s' built %s and %s.\n" , OWN, VERSION, build, builder);
120}
char * bufrnoaa_get_version(char *version, char *build, char *builder, int *version_major, int *version_minor, int *version_patch)
Get strings with version information and build date and time.
Definition: bufrnoaa_io.c:72

References bufrnoaa_get_version(), OWN, and VERSION.

Referenced by print_usage(), and read_args().

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

◆ read_args()

int read_args ( int  _argc,
char *  _argv[] 
)

read the arguments from stdio

Parameters
_argcnumber of arguments passed
_argvarray of arguments

Returns 1 if succcess, -1 othewise

Definition at line 130 of file bufrnoaa_io.c.

131{
132 int iopt;
133
134 ENTRADA[0] = '\0';
135 SEL[0] = '\0';
136 SELS[0] = '\0';
137 SELO[0] = '\0';
138 SELU[0] = '\0';
139 PREFIX[0] = '\0';
140 SELECT = 0;
141 INDIVIDUAL = 0;
142 COLECT = 0;
143 LISTF = 0;
144 VERBOSE = 1;
145 HEADER_MARK = '*';
146 strcpy(FINAL_SEP, SEP);
147
148 /*
149 Read input options
150 */
151 while ( ( iopt = getopt ( _argc, _argv, "hv2i:flF:O:qS:T:U:" ) ) !=-1 )
152 switch ( iopt )
153 {
154 case 'i':
155 if ( strlen ( optarg ) < 256 )
156 strcpy ( ENTRADA, optarg );
157 break;
158 case '2':
159 HEADER_MARK = '#';
160 FINAL_SEP[0] = 0;
161 break;
162 case 'f':
163 INDIVIDUAL = 1;
164 break;
165 case 'q':
166 VERBOSE = 0;
167 break;
168 case 'l':
169 LISTF = 1;
170 break;
171 case 'F':
172 if ( strlen ( optarg ) && strlen ( optarg ) < 64 )
173 {
174 strcpy ( PREFIX, optarg );
175 COLECT = 1;
176 }
177 break;
178 case 'T':
179 if ( strlen ( optarg ) < 64 )
180 {
181 strcpy ( SEL, optarg );
182 SELECT = 1;
183 }
184 break;
185 case 'S':
186 if ( strlen ( optarg ) < 64 )
187 {
188 strcpy ( SELS, optarg );
189 }
190 break;
191 case 'O':
192 if ( strlen ( optarg ) < 64 )
193 {
194 strcpy ( SELO, optarg );
195 }
196 break;
197 case 'U':
198 if ( strlen ( optarg ) < 64 )
199 {
200 strcpy ( SELU, optarg );
201 }
202 break;
203 case 'v':
205 exit ( EXIT_SUCCESS );
206 break;
207 case 'h':
208 default:
209 print_usage();
210 exit ( EXIT_SUCCESS );
211 }
212
213 if ( ENTRADA[0] == '\0' )
214 {
215 printf ( "%s: It is needed an input file. Use -i option\n", OWN );
216 return -1;
217 }
218 return 1;
219}
char ENTRADA[256]
Definition: bufrdeco_json.c:27
char SEP[]
Definition: bufrnoaa.c:206
int SELECT
Definition: bufrnoaa.c:192
char HEADER_MARK
Definition: bufrnoaa.c:202
char SELU[64]
Definition: bufrnoaa.c:199
char FINAL_SEP[4]
Definition: bufrnoaa.c:207
int INDIVIDUAL
Definition: bufrnoaa.c:192
char PREFIX[64]
Definition: bufrnoaa.c:201
char SELS[64]
Definition: bufrnoaa.c:198
int LISTF
Definition: bufrnoaa.c:193
int VERBOSE
Definition: bufrnoaa.c:192
char SELO[64]
Definition: bufrnoaa.c:200
int COLECT
Definition: bufrnoaa.c:192
void print_usage(void)
Definition: bufrnoaa_io.c:31

References COLECT, ENTRADA, FINAL_SEP, HEADER_MARK, INDIVIDUAL, LISTF, OWN, PREFIX, print_usage(), print_version(), SELECT, SELO, SELS, SELU, SEP, and VERBOSE.

Here is the call graph for this function: