Tools: Rename of common variables

This commit is contained in:
Shahram Najm 2020-07-17 15:37:57 +01:00
parent 2c0f6bc9da
commit 1f1a2cbe5b
44 changed files with 200 additions and 200 deletions

View File

@ -236,14 +236,14 @@ static int counter = 0;
static int start = -1; static int start = -1;
static int end = -1; static int end = -1;
const char* grib_tool_description = const char* tool_description =
"Compare BUFR messages contained in two files." "Compare BUFR messages contained in two files."
"\n\tIf some differences are found it fails returning an error code." "\n\tIf some differences are found it fails returning an error code."
"\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R."
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* grib_tool_name = "bufr_compare"; const char* tool_name = "bufr_compare";
const char* grib_tool_usage = "[options] bufr_file1 bufr_file2"; const char* tool_usage = "[options] bufr_file1 bufr_file2";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -326,7 +326,7 @@ int grib_tool_init(grib_runtime_options* options)
} }
/* Check 1st file is not a directory */ /* Check 1st file is not a directory */
exit_if_input_is_directory(grib_tool_name, options->infile_extra->name); exit_if_input_is_directory(tool_name, options->infile_extra->name);
if (grib_options_on("r")) { if (grib_options_on("r")) {
char* filename[1]; char* filename[1];
@ -388,7 +388,7 @@ int grib_tool_init(grib_runtime_options* options)
if (grib_options_on("R:")) { if (grib_options_on("R:")) {
char* sarg = grib_options_get_option("R:"); char* sarg = grib_options_get_option("R:");
options->tolerance_count = MAX_KEYS; options->tolerance_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count));
if (ret == GRIB_INVALID_ARGUMENT) { if (ret == GRIB_INVALID_ARGUMENT) {
usage(); usage();
exit(1); exit(1);
@ -426,7 +426,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }

View File

@ -15,12 +15,12 @@
#include "grib_tools.h" #include "grib_tools.h"
const char* grib_tool_description = const char* tool_description =
"Copies the content of BUFR files printing" "Copies the content of BUFR files printing"
" values of some keys." " values of some keys."
"\n\tIf the name of the output_bufr_file contains a key enclosed in square brackets, its value will be used."; "\n\tIf the name of the output_bufr_file contains a key enclosed in square brackets, its value will be used.";
const char* grib_tool_name = "bufr_copy"; const char* tool_name = "bufr_copy";
const char* grib_tool_usage = "[options] bufr_file bufr_file ... output_bufr_file"; const char* tool_usage = "[options] bufr_file bufr_file ... output_bufr_file";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */
@ -90,7 +90,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }

View File

@ -62,9 +62,9 @@ grib_option grib_options[] = {
/* {"x",0,0,0,1,0} */ /* {"x",0,0,0,1,0} */
}; };
const char* grib_tool_description = "Dump the content of a BUFR file in different formats."; const char* tool_description = "Dump the content of a BUFR file in different formats.";
const char* grib_tool_name = "bufr_dump"; const char* tool_name = "bufr_dump";
const char* grib_tool_usage = "[options] bufr_file bufr_file ..."; const char* tool_usage = "[options] bufr_file bufr_file ...";
static int json = 0; static int json = 0;
static int dump_descriptors = 0; static int dump_descriptors = 0;
static char* json_option = 0; static char* json_option = 0;
@ -108,7 +108,7 @@ int grib_tool_init(grib_runtime_options* options)
options->strict = 1; /* Must set here as bufr_dump has its own -S option */ options->strict = 1; /* Must set here as bufr_dump has its own -S option */
if (opt > 1) { if (opt > 1) {
printf("%s: simultaneous j/C/O options not allowed\n", grib_tool_name); printf("%s: simultaneous j/C/O options not allowed\n", tool_name);
exit(1); exit(1);
} }
@ -116,7 +116,7 @@ int grib_tool_init(grib_runtime_options* options)
options->dump_mode = "json"; options->dump_mode = "json";
json_option = grib_options_get_option("j:"); json_option = grib_options_get_option("j:");
if (strlen(json_option) > 1 || (json_option[0] != 's' && json_option[0] != 'f' && json_option[0] != 'a')) { if (strlen(json_option) > 1 || (json_option[0] != 's' && json_option[0] != 'f' && json_option[0] != 'a')) {
printf("%s: Invalid JSON option %s\n", grib_tool_name, json_option); printf("%s: Invalid JSON option %s\n", tool_name, json_option);
exit(1); exit(1);
} }
json = 1; json = 1;
@ -188,7 +188,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi
return 0; return 0;
Assert(file); Assert(file);
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
/* /*
* Dumping of index files * Dumping of index files
@ -201,7 +201,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi
err = grib_index_dump_file(stdout, filename); err = grib_index_dump_file(stdout, filename);
if (err) { if (err) {
grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n", grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n",
grib_tool_name, tool_name,
filename, filename,
grib_get_error_message(err)); grib_get_error_message(err));
exit(1); exit(1);

View File

@ -30,12 +30,12 @@ grib_option grib_options[] = {
{ "7", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 },
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Apply the rules defined in rules_file to each BUFR " "Apply the rules defined in rules_file to each BUFR "
"message\n\tin the BUFR files provided as arguments.\n\t" "message\n\tin the BUFR files provided as arguments.\n\t"
"If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input.";
const char* grib_tool_name = "bufr_filter"; const char* tool_name = "bufr_filter";
const char* grib_tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"bufr_file bufr_file ..."; "bufr_file bufr_file ...";
@ -75,7 +75,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }
@ -112,7 +112,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
int err = 0; int err = 0;
grib_file_close_all(&err); grib_file_close_all(&err);
if (err != GRIB_SUCCESS) { if (err != GRIB_SUCCESS) {
perror(grib_tool_name); perror(tool_name);
exit(err); exit(err);
} }

View File

@ -35,12 +35,12 @@ grib_option grib_options[] = {
{ "v", 0, 0, 1, 0, 0 } { "v", 0, 0, 1, 0, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Get values of some header keys from a BUFR file." "Get values of some header keys from a BUFR file."
"\n\tIt is similar to bufr_ls, but fails returning an error code " "\n\tIt is similar to bufr_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* grib_tool_name = "bufr_get"; const char* tool_name = "bufr_get";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -71,7 +71,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }

View File

@ -15,11 +15,11 @@
#include "grib_tools.h" #include "grib_tools.h"
const char* grib_tool_description = const char* tool_description =
"Build an index file for a set of input BUFR files.\n" "Build an index file for a set of input BUFR files.\n"
"\tWarning: THIS TOOL IS NOT YET IMPLEMENTED"; "\tWarning: THIS TOOL IS NOT YET IMPLEMENTED";
const char* grib_tool_name = "bufr_index_build"; const char* tool_name = "bufr_index_build";
const char* grib_tool_usage = "[options] file file ... "; const char* tool_usage = "[options] file file ... ";
grib_index* idx = NULL; grib_index* idx = NULL;
char* keys; char* keys;
char* default_keys = "mars"; char* default_keys = "mars";
@ -86,7 +86,7 @@ int grib_tool_init(grib_runtime_options* options)
int grib_tool_new_filename_action(grib_runtime_options* options, const char* file) int grib_tool_new_filename_action(grib_runtime_options* options, const char* file)
{ {
int ret = 0; int ret = 0;
printf("--- %s: processing %s\n", grib_tool_name, file); printf("--- %s: processing %s\n", tool_name, file);
ret = grib_index_add_file(idx, file); ret = grib_index_add_file(idx, file);
if (ret) { if (ret) {
printf("error: %s\n", grib_get_error_message(ret)); printf("error: %s\n", grib_get_error_message(ret));
@ -124,7 +124,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
grib_index_compress(idx); grib_index_compress(idx);
} }
printf("--- %s: keys included in the index file %s:\n", printf("--- %s: keys included in the index file %s:\n",
grib_tool_name, options->outfile->name); tool_name, options->outfile->name);
printf("--- "); printf("--- ");
first = 1; first = 1;
the_keys = idx->keys; the_keys = idx->keys;

View File

@ -37,12 +37,12 @@ grib_option grib_options[] = {
{ "v", 0, 0, 1, 0, 0 } { "v", 0, 0, 1, 0, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"List content of BUFR files printing values of " "List content of BUFR files printing values of "
"some header keys.\n\tOnly scalar keys can be printed." "some header keys.\n\tOnly scalar keys can be printed."
"\n\tIt does not fail when a key is not found."; "\n\tIt does not fail when a key is not found.";
const char* grib_tool_name = "bufr_ls"; const char* tool_name = "bufr_ls";
const char* grib_tool_usage = "[options] bufr_file bufr_file ..."; const char* tool_usage = "[options] bufr_file bufr_file ...";
static int first_handle = 1; static int first_handle = 1;
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -84,7 +84,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }

View File

@ -42,12 +42,12 @@ grib_option grib_options[] = {
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Sets key/value pairs in the input BUFR file and writes" "Sets key/value pairs in the input BUFR file and writes"
"\n\teach message to the output_file." "\n\teach message to the output_file."
"\n\tIt fails when an error occurs (e.g. key not found)."; "\n\tIt fails when an error occurs (e.g. key not found).";
const char* grib_tool_name = "bufr_set"; const char* tool_name = "bufr_set";
const char* grib_tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -166,7 +166,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
int err = 0; int err = 0;
grib_file_close_all(&err); grib_file_close_all(&err);
if (err != GRIB_SUCCESS) { if (err != GRIB_SUCCESS) {
perror(grib_tool_name); perror(tool_name);
exit(err); exit(err);
} }

View File

@ -11,7 +11,7 @@
#include "grib_api_internal.h" #include "grib_api_internal.h"
static int fail_on_error = 1; static int fail_on_error = 1;
static const char* tool_name = NULL; static const char* toolname = NULL;
static void usage(const char* prog) static void usage(const char* prog)
{ {
@ -81,15 +81,15 @@ int main(int argc, char* argv[])
unsigned long count_total = 0, count_curr = 0; unsigned long count_total = 0, count_curr = 0;
int message_type = 0; /* GRIB, BUFR etc */ int message_type = 0; /* GRIB, BUFR etc */
tool_name = argv[0]; toolname = argv[0];
if (argc < 2) if (argc < 2)
usage(tool_name); usage(toolname);
if (strstr(tool_name, "grib_count")) if (strstr(toolname, "grib_count"))
message_type = CODES_GRIB; message_type = CODES_GRIB;
if (strstr(tool_name, "bufr_count")) if (strstr(toolname, "bufr_count"))
message_type = CODES_BUFR; message_type = CODES_BUFR;
if (strstr(tool_name, "gts_count")) if (strstr(toolname, "gts_count"))
message_type = CODES_GTS; message_type = CODES_GTS;
count_total = 0; count_total = 0;
@ -104,7 +104,7 @@ int main(int argc, char* argv[])
} }
filename = argv[i]; filename = argv[i];
if (path_is_directory(filename)) { if (path_is_directory(filename)) {
fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename); fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", toolname, filename);
continue; continue;
} }

View File

@ -32,14 +32,14 @@ grib_option grib_options[]={
{"v",0,0,0,1,0} {"v",0,0,0,1,0}
}; };
char* grib_tool_description= char* tool_description=
"It converts grib messages applying the rules from a conversion_rules file." "It converts grib messages applying the rules from a conversion_rules file."
"\n\tThe rules are of the type \"keyname = value;\" and if blocks are allowed as" "\n\tThe rules are of the type \"keyname = value;\" and if blocks are allowed as"
"\n\tif ( keyname1 == value1 || keyname2 != value2 && keyname3 == value3 ) {" "\n\tif ( keyname1 == value1 || keyname2 != value2 && keyname3 == value3 ) {"
"\n\t keyname4 = value4;" "\n\t keyname4 = value4;"
"\n\t}"; "\n\t}";
char* grib_tool_name="grib_convert"; char* tool_name="grib_convert";
char* grib_tool_usage="[options] conversion_rules " char* tool_usage="[options] conversion_rules "
"grib_file grib_file ... output_grib_file"; "grib_file grib_file ... output_grib_file";
int grib_options_count=sizeof(grib_options)/sizeof(grib_option); int grib_options_count=sizeof(grib_options)/sizeof(grib_option);

View File

@ -29,9 +29,9 @@ grib_option grib_options[]={
{"q",0,0,1,0,0} {"q",0,0,1,0,0}
}; };
char* grib_tool_description="Dump the content of a grib file in debug mode."; char* tool_description="Dump the content of a grib file in debug mode.";
char* grib_tool_name="grib_debug"; char* tool_name="grib_debug";
char* grib_tool_usage="[options] grib_file grib_file ..."; char* tool_usage="[options] grib_file grib_file ...";
int grib_options_count=sizeof(grib_options)/sizeof(grib_option); int grib_options_count=sizeof(grib_options)/sizeof(grib_option);

View File

@ -29,10 +29,10 @@ grib_option grib_options[]={
{"a",0,0,0,1,0} {"a",0,0,0,1,0}
}; };
char* grib_tool_description="Lists the keys available for a type of grib (-T option) or \n" char* tool_description="Lists the keys available for a type of grib (-T option) or \n"
"\tin a grib message from a file (-F option)."; "\tin a grib message from a file (-F option).";
char* grib_tool_name="grib_keys"; char* tool_name="grib_keys";
char* grib_tool_usage="[options]"; char* tool_usage="[options]";
char name[1024]; char name[1024];
int grib_options_count=sizeof(grib_options)/sizeof(grib_option); int grib_options_count=sizeof(grib_options)/sizeof(grib_option);

View File

@ -34,9 +34,9 @@ grib_option grib_options[]={
{"v",0,0,1,0,0} {"v",0,0,1,0,0}
}; };
char* grib_tool_description="Lat lon values list for given points list. "; char* tool_description="Lat lon values list for given points list. ";
char* grib_tool_name="grib_points"; char* tool_name="grib_points";
char* grib_tool_usage="file_list_of_points grib_file grib_file ..."; char* tool_usage="file_list_of_points grib_file grib_file ...";
int grib_options_count=sizeof(grib_options)/sizeof(grib_option); int grib_options_count=sizeof(grib_options)/sizeof(grib_option);
double lat=0; double lat=0;
@ -79,7 +79,7 @@ int grib_tool_init(grib_runtime_options* options) {
} else if (*end1 == '1') { } else if (*end1 == '1') {
options->latlon_mode=1; options->latlon_mode=1;
} else { } else {
printf("ERROR %s: wrong mode given in option -l\n",grib_tool_name); printf("ERROR %s: wrong mode given in option -l\n",tool_name);
exit(1); exit(1);
} }
} }

View File

@ -165,14 +165,14 @@ static int global_counter = 0;
static int theStart = -1; static int theStart = -1;
static int theEnd = -1; static int theEnd = -1;
const char* grib_tool_description = const char* tool_description =
"Compare GRIB messages contained in two files." "Compare GRIB messages contained in two files."
"\n\tIf some differences are found it fails returning an error code." "\n\tIf some differences are found it fails returning an error code."
"\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R."
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* grib_tool_name = "grib_compare"; const char* tool_name = "grib_compare";
const char* grib_tool_usage = "[options] grib_file1 grib_file2"; const char* tool_usage = "[options] grib_file1 grib_file2";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -319,7 +319,7 @@ int grib_tool_init(grib_runtime_options* options)
if (grib_options_on("R:")) { if (grib_options_on("R:")) {
char* sarg = grib_options_get_option("R:"); char* sarg = grib_options_get_option("R:");
options->tolerance_count = MAX_KEYS; options->tolerance_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count));
if (ret == GRIB_INVALID_ARGUMENT) { if (ret == GRIB_INVALID_ARGUMENT) {
usage(); usage();
exit(1); exit(1);

View File

@ -15,12 +15,12 @@
#include "grib_tools.h" #include "grib_tools.h"
const char* grib_tool_description = const char* tool_description =
"Copies the content of GRIB files printing" "Copies the content of GRIB files printing"
" values of some keys." " values of some keys."
"\n\tIf the name of the output_grib_file contains a key enclosed in square brackets, its value will be used."; "\n\tIf the name of the output_grib_file contains a key enclosed in square brackets, its value will be used.";
const char* grib_tool_name = "grib_copy"; const char* tool_name = "grib_copy";
const char* grib_tool_usage = "[options] grib_file grib_file ... output_grib_file"; const char* tool_usage = "[options] grib_file grib_file ... output_grib_file";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */
@ -94,7 +94,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }
@ -145,7 +145,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
int err = 0; int err = 0;
grib_file_close_all(&err); grib_file_close_all(&err);
if (err != GRIB_SUCCESS) { if (err != GRIB_SUCCESS) {
perror(grib_tool_name); perror(tool_name);
exit(err); exit(err);
} }
/* if (options->outfile->file) /* if (options->outfile->file)

View File

@ -39,9 +39,9 @@ grib_option grib_options[] = {
{ "x", 0, 0, 0, 1, 0 } { "x", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = "Dump the content of a GRIB file in different formats."; const char* tool_description = "Dump the content of a GRIB file in different formats.";
const char* grib_tool_name = "grib_dump"; const char* tool_name = "grib_dump";
const char* grib_tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
static int json = 0; static int json = 0;
static int first_handle = 1; static int first_handle = 1;
static int dump_keys = 0; static int dump_keys = 0;
@ -69,7 +69,7 @@ int grib_tool_init(grib_runtime_options* options)
options->dump_mode = "default"; options->dump_mode = "default";
if (opt > 1) { if (opt > 1) {
printf("%s: simultaneous j/O/D options not allowed\n", grib_tool_name); printf("%s: simultaneous j/O/D options not allowed\n", tool_name);
exit(1); exit(1);
} }
@ -130,7 +130,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi
return 0; return 0;
Assert(file); Assert(file);
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
sprintf(tmp, "FILE: %s ", options->current_infile->name); sprintf(tmp, "FILE: %s ", options->current_infile->name);
if (!grib_options_on("C")) if (!grib_options_on("C"))
@ -147,7 +147,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi
err = grib_index_dump_file(stdout, filename); err = grib_index_dump_file(stdout, filename);
if (err) { if (err) {
grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n", grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n",
grib_tool_name, tool_name,
filename, filename,
grib_get_error_message(err)); grib_get_error_message(err));
exit(1); exit(1);

View File

@ -26,12 +26,12 @@ grib_option grib_options[] = {
{ "7", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 },
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Apply the rules defined in rules_file to each GRIB " "Apply the rules defined in rules_file to each GRIB "
"message\n\tin the GRIB files provided as arguments.\n\t" "message\n\tin the GRIB files provided as arguments.\n\t"
"If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input.";
const char* grib_tool_name = "grib_filter"; const char* tool_name = "grib_filter";
const char* grib_tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"grib_file grib_file ..."; "grib_file grib_file ...";
@ -68,7 +68,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }
@ -105,7 +105,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
int err = 0; int err = 0;
grib_file_close_all(&err); grib_file_close_all(&err);
if (err != GRIB_SUCCESS) { if (err != GRIB_SUCCESS) {
perror(grib_tool_name); perror(tool_name);
exit(err); exit(err);
} }

View File

@ -35,12 +35,12 @@ grib_option grib_options[] = {
{ "i:", 0, 0, 0, 1, 0 } { "i:", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Get values of some keys from a GRIB file." "Get values of some keys from a GRIB file."
"\n\tIt is similar to grib_ls, but fails returning an error code " "\n\tIt is similar to grib_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* grib_tool_name = "grib_get"; const char* tool_name = "grib_get";
const char* grib_tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
static double lat = 0; static double lat = 0;
@ -75,7 +75,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) { if (options->latlon) {
lat = strtod(options->latlon, &theEnd); lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') { if (*theEnd != ',') {
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",grib_tool_name); fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",tool_name);
exit(1); exit(1);
} }
lon = strtod(++theEnd, &end1); lon = strtod(++theEnd, &end1);
@ -95,7 +95,7 @@ int grib_tool_init(grib_runtime_options* options)
options->latlon_mode = 1; options->latlon_mode = 1;
} }
else { else {
fprintf(stderr, "Error %s: wrong mode given in option -l\n", grib_tool_name); fprintf(stderr, "Error %s: wrong mode given in option -l\n", tool_name);
exit(1); exit(1);
} }
} }
@ -162,7 +162,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
if (nearest) if (nearest)
grib_nearest_delete(nearest); grib_nearest_delete(nearest);
nearest = NULL; nearest = NULL;

View File

@ -39,11 +39,11 @@ grib_option grib_options[] = {
{ "V", 0, 0, 0, 1, 0 } { "V", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Print a latitude, longitude, data values list.\n" "Print a latitude, longitude, data values list.\n"
"\tNote: Rotated grids are first unrotated"; "\tNote: Rotated grids are first unrotated";
const char* grib_tool_name = "grib_get_data"; const char* tool_name = "grib_get_data";
const char* grib_tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
extern FILE* dump_file; extern FILE* dump_file;
@ -71,7 +71,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }

View File

@ -19,9 +19,9 @@ grib_option grib_options[] = {
}; };
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
const char* grib_tool_description = "Histogram of GRIB files"; const char* tool_description = "Histogram of GRIB files";
const char* grib_tool_name = "grib_histogram"; const char* tool_name = "grib_histogram";
const char* grib_tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
@ -45,7 +45,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
return 0; return 0;
} }

View File

@ -15,9 +15,9 @@
#include "grib_tools.h" #include "grib_tools.h"
const char* grib_tool_description = "Build an index file for a set of input GRIB files."; const char* tool_description = "Build an index file for a set of input GRIB files.";
const char* grib_tool_name = "grib_index_build"; const char* tool_name = "grib_index_build";
const char* grib_tool_usage = "[options] grib_file grib_file ... "; const char* tool_usage = "[options] grib_file grib_file ... ";
static grib_index* idx = NULL; static grib_index* idx = NULL;
static char* keys; static char* keys;
static char* default_keys = "mars"; static char* default_keys = "mars";
@ -83,7 +83,7 @@ int grib_tool_init(grib_runtime_options* options)
int grib_tool_new_filename_action(grib_runtime_options* options, const char* file) int grib_tool_new_filename_action(grib_runtime_options* options, const char* file)
{ {
int ret = 0; int ret = 0;
printf("--- %s: processing %s\n", grib_tool_name, file); printf("--- %s: processing %s\n", tool_name, file);
ret = grib_index_add_file(idx, file); ret = grib_index_add_file(idx, file);
if (ret) { if (ret) {
printf("error: %s\n", grib_get_error_message(ret)); printf("error: %s\n", grib_get_error_message(ret));
@ -121,7 +121,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
grib_index_compress(idx); grib_index_compress(idx);
} }
printf("--- %s: keys included in the index file %s:\n", printf("--- %s: keys included in the index file %s:\n",
grib_tool_name, options->outfile->name); tool_name, options->outfile->name);
printf("--- "); printf("--- ");
first = 1; first = 1;
the_keys = idx->keys; the_keys = idx->keys;

View File

@ -42,11 +42,11 @@ grib_option grib_options[] = {
{ "x", 0, 0, 0, 1, 0 } { "x", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"List content of GRIB files printing values of " "List content of GRIB files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* grib_tool_name = "grib_ls"; const char* tool_name = "grib_ls";
const char* grib_tool_usage = "[options] grib_file grib_file ..."; const char* tool_usage = "[options] grib_file grib_file ...";
static char* new_handle = ""; static char* new_handle = "";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -100,7 +100,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) { if (options->latlon) {
lat = strtod(options->latlon, &theEnd); lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') { if (*theEnd != ',') {
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",grib_tool_name); fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",tool_name);
exit(1); exit(1);
} }
lon = strtod(++theEnd, &end1); lon = strtod(++theEnd, &end1);
@ -120,7 +120,7 @@ int grib_tool_init(grib_runtime_options* options)
options->latlon_mode = 1; options->latlon_mode = 1;
} }
else { else {
fprintf(stderr, "Error %s: wrong mode given in option -l\n", grib_tool_name); fprintf(stderr, "Error %s: wrong mode given in option -l\n", tool_name);
exit(1); exit(1);
} }
} }
@ -208,7 +208,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file)
{ {
exit_if_input_is_directory(grib_tool_name, file->name); exit_if_input_is_directory(tool_name, file->name);
if (nearest) if (nearest)
grib_nearest_delete(nearest); grib_nearest_delete(nearest);
nearest = NULL; nearest = NULL;

View File

@ -34,9 +34,9 @@ int key_values_size = MAX_KEY_VALUES;
* tool to identify the fields to be merged */ * tool to identify the fields to be merged */
static const char* md5Key = "md5Product"; static const char* md5Key = "md5Product";
const char* grib_tool_description = "Merge two fields with identical parameters and different geographical area"; const char* tool_description = "Merge two fields with identical parameters and different geographical area";
const char* grib_tool_name = "grib_merge"; const char* tool_name = "grib_merge";
const char* grib_tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */

View File

@ -118,9 +118,9 @@ static int grib_options_help_count = sizeof(grib_options_help_list) / sizeof(gri
void usage(void) void usage(void)
{ {
int i = 0; int i = 0;
printf("\nNAME \t%s\n\n", grib_tool_name); printf("\nNAME \t%s\n\n", tool_name);
printf("DESCRIPTION\n\t%s\n\n", grib_tool_description); printf("DESCRIPTION\n\t%s\n\n", tool_description);
printf("USAGE \n\t%s %s\n\n", grib_tool_name, grib_tool_usage); printf("USAGE \n\t%s %s\n\n", tool_name, tool_usage);
printf("OPTIONS\n"); printf("OPTIONS\n");
for (i = 0; i < grib_options_count; i++) { for (i = 0; i < grib_options_count; i++) {
if (grib_options[i].command_line) if (grib_options[i].command_line)
@ -333,7 +333,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
} }
options->requested_print_keys_count = MAX_KEYS; options->requested_print_keys_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, karg, 0, GRIB_TYPE_UNDEFINED, ret = parse_keyval_string(tool_name, karg, 0, GRIB_TYPE_UNDEFINED,
options->requested_print_keys, &(options->requested_print_keys_count)); options->requested_print_keys, &(options->requested_print_keys_count));
if (ret == GRIB_INVALID_ARGUMENT) if (ret == GRIB_INVALID_ARGUMENT)
usage(); usage();
@ -360,7 +360,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
if (grib_options_on("s:")) { if (grib_options_on("s:")) {
sarg = grib_options_get_option("s:"); sarg = grib_options_get_option("s:");
options->set_values_count = MAX_KEYS; options->set_values_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, sarg, 1, GRIB_TYPE_UNDEFINED, options->set_values, &(options->set_values_count)); ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_UNDEFINED, options->set_values, &(options->set_values_count));
if (ret == GRIB_INVALID_ARGUMENT) if (ret == GRIB_INVALID_ARGUMENT)
usage(); usage();
} }
@ -368,7 +368,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
if (grib_options_on("b:")) { if (grib_options_on("b:")) {
barg = grib_options_get_option("b:"); barg = grib_options_get_option("b:");
options->set_values_count = MAX_KEYS; options->set_values_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, barg, 0, GRIB_TYPE_STRING, options->set_values, &(options->set_values_count)); ret = parse_keyval_string(tool_name, barg, 0, GRIB_TYPE_STRING, options->set_values, &(options->set_values_count));
if (ret == GRIB_INVALID_ARGUMENT) if (ret == GRIB_INVALID_ARGUMENT)
usage(); usage();
} }
@ -376,7 +376,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
if (grib_options_on("c:")) { if (grib_options_on("c:")) {
sarg = grib_options_get_option("c:"); sarg = grib_options_get_option("c:");
options->compare_count = MAX_KEYS; options->compare_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, sarg, 0, GRIB_TYPE_UNDEFINED, options->compare, ret = parse_keyval_string(tool_name, sarg, 0, GRIB_TYPE_UNDEFINED, options->compare,
&(options->compare_count)); &(options->compare_count));
if (ret == GRIB_INVALID_ARGUMENT) if (ret == GRIB_INVALID_ARGUMENT)
usage(); usage();
@ -392,7 +392,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
warg = grib_options_get_option("w:"); warg = grib_options_get_option("w:");
options->constraints_count = MAX_KEYS; options->constraints_count = MAX_KEYS;
ret = parse_keyval_string(grib_tool_name, warg, 1, GRIB_TYPE_UNDEFINED, ret = parse_keyval_string(tool_name, warg, 1, GRIB_TYPE_UNDEFINED,
options->constraints, &(options->constraints_count)); options->constraints, &(options->constraints_count));
if (ret == GRIB_INVALID_ARGUMENT) if (ret == GRIB_INVALID_ARGUMENT)
usage(); usage();
@ -458,9 +458,9 @@ char* grib_options_get_args(char* id)
void usage_doxygen(void) void usage_doxygen(void)
{ {
int i = 0; int i = 0;
printf("/*! \\page %s %s\n", grib_tool_name, grib_tool_name); printf("/*! \\page %s %s\n", tool_name, tool_name);
printf("\\section DESCRIPTION \n %s\n\n", grib_tool_description); printf("\\section DESCRIPTION \n %s\n\n", tool_description);
printf("\\section USAGE \n %s \n %s\n\n", grib_tool_name, grib_tool_usage); printf("\\section USAGE \n %s \n %s\n\n", tool_name, tool_usage);
printf("\\section OPTIONS \n"); printf("\\section OPTIONS \n");
for (i = 0; i < grib_options_count; i++) { for (i = 0; i < grib_options_count; i++) {
if (grib_options[i].command_line) { if (grib_options[i].command_line) {
@ -477,9 +477,9 @@ void usage_doxygen(void)
#if 0 #if 0
void usage_doxygen(void) { void usage_doxygen(void) {
int i=0; int i=0;
printf("/*! \\page %s %s\n",grib_tool_name,grib_tool_name); printf("/*! \\page %s %s\n",tool_name,tool_name);
printf("\\section DESCRIPTION \n%s\n\n",grib_tool_description); printf("\\section DESCRIPTION \n%s\n\n",tool_description);
printf("\\section USAGE \n%s \n%s\n\n",grib_tool_name,grib_tool_usage); printf("\\section USAGE \n%s \n%s\n\n",tool_name,tool_usage);
printf("\\section OPTIONS\n"); printf("\\section OPTIONS\n");
printf("<table frame=void border=0>\n"); printf("<table frame=void border=0>\n");
for (i=0;i<grib_options_count;i++) { for (i=0;i<grib_options_count;i++) {

View File

@ -46,12 +46,12 @@ grib_option grib_options[] = {
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Sets key/value pairs in the input GRIB file and writes" "Sets key/value pairs in the input GRIB file and writes"
"\n\teach message to the output_grib_file." "\n\teach message to the output_grib_file."
"\n\tIt fails when an error occurs (e.g. key not found)."; "\n\tIt fails when an error occurs (e.g. key not found).";
const char* grib_tool_name = "grib_set"; const char* tool_name = "grib_set";
const char* grib_tool_usage = "[options] grib_file grib_file ... output_grib_file"; const char* tool_usage = "[options] grib_file grib_file ... output_grib_file";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -169,7 +169,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
int err = 0; int err = 0;
grib_file_close_all(&err); grib_file_close_all(&err);
if (err != GRIB_SUCCESS) { if (err != GRIB_SUCCESS) {
perror(grib_tool_name); perror(tool_name);
exit(err); exit(err);
} }

View File

@ -28,12 +28,12 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
const char* grib_tool_description = const char* tool_description =
"Convert a GRIB file to netCDF format." "Convert a GRIB file to netCDF format."
"\n\tNote: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid" "\n\tNote: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid"
"\n\t(the key \"typeOfGrid\" should be \"regular_ll\" or \"regular_gg\")"; "\n\t(the key \"typeOfGrid\" should be \"regular_ll\" or \"regular_gg\")";
const char* grib_tool_name = "grib_to_netcdf"; const char* tool_name = "grib_to_netcdf";
const char* grib_tool_usage = "[options] grib_file grib_file ... "; const char* tool_usage = "[options] grib_file grib_file ... ";
static char argvString[2048] = {0,}; static char argvString[2048] = {0,};
/*=====================================================================*/ /*=====================================================================*/
@ -2143,9 +2143,9 @@ static nc_type translate_nctype(const char* name)
static void check_err(const char* function, const int stat, const int line) static void check_err(const char* function, const int stat, const int line)
{ {
if (stat != NC_NOERR) { if (stat != NC_NOERR) {
/* (void) fprintf(stderr, "line %d of %s: %s\n", line, grib_tool_name, nc_strerror(stat)); */ /* (void) fprintf(stderr, "line %d of %s: %s\n", line, tool_name, nc_strerror(stat)); */
(void)fprintf(stderr, "\n%s ERROR: line %d, %s: %s\n", (void)fprintf(stderr, "\n%s ERROR: line %d, %s: %s\n",
grib_tool_name, line, function, nc_strerror(stat)); tool_name, line, function, nc_strerror(stat));
if (stat == NC_EVARSIZE) { if (stat == NC_EVARSIZE) {
(void)fprintf(stderr, (void)fprintf(stderr,
"\nCannot create netCDF classic format, dataset is too large!\n" "\nCannot create netCDF classic format, dataset is too large!\n"
@ -3062,7 +3062,7 @@ static int define_netcdf_dimensions(hypercube* h, fieldset* fs, int ncid, datase
dims[i] = n - i - 1; dims[i] = n - i - 1;
for (i = 0; i < subsetcnt; ++i) { for (i = 0; i < subsetcnt; ++i) {
printf("%s: Defining variable '%s'.\n", grib_tool_name, subsets[i].att.name); printf("%s: Defining variable '%s'.\n", tool_name, subsets[i].att.name);
stat = nc_def_var(ncid, subsets[i].att.name, subsets[i].att.nctype, n, dims, &var_id); stat = nc_def_var(ncid, subsets[i].att.name, subsets[i].att.nctype, n, dims, &var_id);
check_err("nc_def_var", stat, __LINE__); check_err("nc_def_var", stat, __LINE__);
@ -3351,7 +3351,7 @@ static void print_ignored_keys(FILE* f, request* data)
int i = 0; int i = 0;
while ((ignore = get_value(data, "ignore", i)) != NULL) { while ((ignore = get_value(data, "ignore", i)) != NULL) {
if (i == 0) { if (i == 0) {
fprintf(f, "%s: Ignoring key(s): %s", grib_tool_name, ignore); fprintf(f, "%s: Ignoring key(s): %s", tool_name, ignore);
} }
else { else {
fprintf(f, ", %s", ignore); fprintf(f, ", %s", ignore);
@ -3861,25 +3861,25 @@ static int get_creation_mode(int option_kind)
int creation_mode = NC_CLOBBER; int creation_mode = NC_CLOBBER;
switch (option_kind) { switch (option_kind) {
case NC_FORMAT_CLASSIC: case NC_FORMAT_CLASSIC:
printf("%s: Creating classic file format.\n", grib_tool_name); printf("%s: Creating classic file format.\n", tool_name);
break; break;
case NC_FORMAT_64BIT: case NC_FORMAT_64BIT:
creation_mode |= NC_64BIT_OFFSET; creation_mode |= NC_64BIT_OFFSET;
printf("%s: Creating large (64 bit) file format.\n", grib_tool_name); printf("%s: Creating large (64 bit) file format.\n", tool_name);
break; break;
#ifdef NC_NETCDF4 #ifdef NC_NETCDF4
case NC_FORMAT_NETCDF4: case NC_FORMAT_NETCDF4:
creation_mode |= NC_NETCDF4; creation_mode |= NC_NETCDF4;
printf("%s: Creating netCDF-4/HDF5 format.\n", grib_tool_name); printf("%s: Creating netCDF-4/HDF5 format.\n", tool_name);
break; break;
case NC_FORMAT_NETCDF4_CLASSIC: case NC_FORMAT_NETCDF4_CLASSIC:
creation_mode |= NC_NETCDF4 | NC_CLASSIC_MODEL; creation_mode |= NC_NETCDF4 | NC_CLASSIC_MODEL;
printf("%s: Creating netCDF-4 classic model file format.\n", grib_tool_name); printf("%s: Creating netCDF-4 classic model file format.\n", tool_name);
break; break;
#else #else
case NC_FORMAT_NETCDF4: case NC_FORMAT_NETCDF4:
case NC_FORMAT_NETCDF4_CLASSIC: case NC_FORMAT_NETCDF4_CLASSIC:
grib_context_log(ctx, GRIB_LOG_ERROR, "%s not built with netcdf4, cannot create netCDF-4 files.", grib_tool_name); grib_context_log(ctx, GRIB_LOG_ERROR, "%s not built with netcdf4, cannot create netCDF-4 files.", tool_name);
exit(1); exit(1);
break; break;
#endif #endif
@ -3993,7 +3993,7 @@ int grib_tool_init(grib_runtime_options* options)
data_r = empty_request(0); data_r = empty_request(0);
user_r = empty_request(0); user_r = empty_request(0);
printf("%s: Version ", grib_tool_name); printf("%s: Version ", tool_name);
grib_print_api_version(stdout); grib_print_api_version(stdout);
printf("\n"); printf("\n");
@ -4128,7 +4128,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
grib_handle* h = NULL; grib_handle* h = NULL;
grib_file* file = NULL; grib_file* file = NULL;
printf("%s: Processing input file '%s'.\n", grib_tool_name, filename); printf("%s: Processing input file '%s'.\n", tool_name, filename);
file = grib_file_open(filename, "r", &e); file = grib_file_open(filename, "r", &e);
if (!file || !file->handle) if (!file || !file->handle)
@ -4280,7 +4280,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return -1; return -1;
} }
printf("%s: Found %d GRIB field%s in %d file%s.\n", grib_tool_name, fs->count, fs->count > 1 ? "s" : "", files, files > 1 ? "s" : ""); printf("%s: Found %d GRIB field%s in %d file%s.\n", tool_name, fs->count, fs->count > 1 ? "s" : "", files, files > 1 ? "s" : "");
if (ctx->debug) { if (ctx->debug) {
grib_context_log(ctx, GRIB_LOG_INFO, "Request representing %d fields ", fs->count); grib_context_log(ctx, GRIB_LOG_INFO, "Request representing %d fields ", fs->count);
@ -4304,8 +4304,8 @@ int grib_tool_finalise_action(grib_runtime_options* options)
/* Create netcdf file */ /* Create netcdf file */
printf("%s: Creating netCDF file '%s'\n", grib_tool_name, options->outfile->name); printf("%s: Creating netCDF file '%s'\n", tool_name, options->outfile->name);
printf("%s: NetCDF library version: %s\n", grib_tool_name, nc_inq_libvers()); printf("%s: NetCDF library version: %s\n", tool_name, nc_inq_libvers());
creation_mode = get_creation_mode(option_kind); creation_mode = get_creation_mode(option_kind);
stat = nc_create(options->outfile->name, creation_mode, &ncid); stat = nc_create(options->outfile->name, creation_mode, &ncid);
@ -4354,7 +4354,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
free_subsets(subsets, count); free_subsets(subsets, count);
free_nc_options(); free_nc_options();
printf("%s: Done.\n", grib_tool_name); printf("%s: Done.\n", tool_name);
return 0; return 0;
} }

View File

@ -1352,10 +1352,10 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h)
} }
#endif #endif
} }
int exit_if_input_is_directory(const char* tool_name, const char* filename) int exit_if_input_is_directory(const char* toolname, const char* filename)
{ {
if (path_is_directory(filename)) { if (path_is_directory(filename)) {
fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename); fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", toolname, filename);
exit(1); exit(1);
} }
return 0; return 0;

View File

@ -174,9 +174,9 @@ typedef struct grib_runtime_options
extern grib_option grib_options[]; extern grib_option grib_options[];
extern int grib_options_count; extern int grib_options_count;
extern const char* grib_tool_name; extern const char* tool_name;
extern const char* grib_tool_description; extern const char* tool_description;
extern const char* grib_tool_usage; extern const char* tool_usage;
extern FILE* dump_file; extern FILE* dump_file;
@ -206,6 +206,6 @@ int grib_process_runtime_options(grib_context* c, int argc, char** argv, grib_ru
void grib_tools_write_message(grib_runtime_options* options, grib_handle* h); void grib_tools_write_message(grib_runtime_options* options, grib_handle* h);
int grib_tool_new_filename_action(grib_runtime_options* options, const char* file); int grib_tool_new_filename_action(grib_runtime_options* options, const char* file);
int grib_no_handle_action(grib_runtime_options* options, int err); int grib_no_handle_action(grib_runtime_options* options, int err);
int exit_if_input_is_directory(const char* tool_name, const char* filename); int exit_if_input_is_directory(const char* toolname, const char* filename);
#endif #endif

View File

@ -131,13 +131,13 @@ int counter = 0;
int start = -1; int start = -1;
int end = -1; int end = -1;
const char* grib_tool_description = const char* tool_description =
"Compare GTS messages contained in two files." "Compare GTS messages contained in two files."
"\n\tIf some differences are found it fails returning an error code." "\n\tIf some differences are found it fails returning an error code."
"\n\tDefault behaviour: bit-by-bit compare, same order in files."; "\n\tDefault behaviour: bit-by-bit compare, same order in files.";
const char* grib_tool_name = "gts_compare"; const char* tool_name = "gts_compare";
const char* grib_tool_usage = const char* tool_usage =
"[options] " "[options] "
"file file"; "file file";

View File

@ -10,11 +10,11 @@
#include "grib_tools.h" #include "grib_tools.h"
const char* grib_tool_description = const char* tool_description =
"Copies the content of GTS files printing" "Copies the content of GTS files printing"
" values of some keys."; " values of some keys.";
const char* grib_tool_name = "gts_copy"; const char* tool_name = "gts_copy";
const char* grib_tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */

View File

@ -33,9 +33,9 @@ grib_option grib_options[] = {
{ "x", 0, 0, 0, 1, 0 } { "x", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = "Dump the content of a GTS file in different formats."; const char* tool_description = "Dump the content of a GTS file in different formats.";
const char* grib_tool_name = "gts_dump"; const char* tool_name = "gts_dump";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -62,7 +62,7 @@ int grib_tool_init(grib_runtime_options* options)
if (opt > 1) { if (opt > 1) {
printf("%s: simultaneous O/D options not allowed\n", grib_tool_name); printf("%s: simultaneous O/D options not allowed\n", tool_name);
exit(1); exit(1);
} }

View File

@ -26,12 +26,12 @@ grib_option grib_options[] = {
{ "7", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 },
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Apply the rules defined in rules_file to each GTS " "Apply the rules defined in rules_file to each GTS "
"message\n\tin the GTS files provided as arguments.\n\t" "message\n\tin the GTS files provided as arguments.\n\t"
"If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input.";
const char* grib_tool_name = "gts_filter"; const char* tool_name = "gts_filter";
const char* grib_tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"file file ..."; "file file ...";
int fail = 0; int fail = 0;

View File

@ -28,12 +28,12 @@ grib_option grib_options[] = {
{ "v", 0, 0, 1, 0, 0 } { "v", 0, 0, 1, 0, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Get values of some keys from a GTS file." "Get values of some keys from a GTS file."
"\n\tIt is similar to gts_ls, but fails returning an error code " "\n\tIt is similar to gts_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* grib_tool_name = "gts_get"; const char* tool_name = "gts_get";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
int mode = 0; int mode = 0;

View File

@ -32,11 +32,11 @@ grib_option grib_options[] = {
{ "v", 0, 0, 1, 0, 0 } { "v", 0, 0, 1, 0, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"List content of GTS files printing values of " "List content of GTS files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* grib_tool_name = "gts_ls"; const char* tool_name = "gts_ls";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
int mode = 0; int mode = 0;

View File

@ -194,14 +194,14 @@ int global_counter = 0;
int start = -1; int start = -1;
int end = -1; int end = -1;
const char* grib_tool_description = const char* tool_description =
"Compare METAR messages contained in two files." "Compare METAR messages contained in two files."
"\n\tIf some differences are found it fails returning an error code." "\n\tIf some differences are found it fails returning an error code."
"\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R."
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* grib_tool_name = "metar_compare"; const char* tool_name = "metar_compare";
const char* grib_tool_usage = const char* tool_usage =
"[options] " "[options] "
"file file"; "file file";

View File

@ -10,11 +10,11 @@
#include "grib_tools.h" #include "grib_tools.h"
const char* grib_tool_description = const char* tool_description =
"Copies the content of METAR files printing" "Copies the content of METAR files printing"
" values of some keys."; " values of some keys.";
const char* grib_tool_name = "metar_copy"; const char* tool_name = "metar_copy";
const char* grib_tool_usage = "[options] file file ... output_file"; const char* tool_usage = "[options] file file ... output_file";
grib_option grib_options[] = { grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value */ /* {id, args, help}, on, command_line, value */

View File

@ -36,9 +36,9 @@ grib_option grib_options[] = {
{ "x", 0, 0, 0, 1, 0 } { "x", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = "Dump the content of a METAR file in different formats."; const char* tool_description = "Dump the content of a METAR file in different formats.";
const char* grib_tool_name = "metar_dump"; const char* tool_name = "metar_dump";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -59,7 +59,7 @@ int grib_tool_init(grib_runtime_options* options)
options->dump_mode = "default"; options->dump_mode = "default";
if (opt > 1) { if (opt > 1) {
printf("%s: simultaneous O/D options not allowed\n", grib_tool_name); printf("%s: simultaneous O/D options not allowed\n", tool_name);
exit(1); exit(1);
} }

View File

@ -24,11 +24,11 @@ grib_option grib_options[] = {
{ "7", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 },
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Apply the rules defined in rules_file to each METAR " "Apply the rules defined in rules_file to each METAR "
"message\n\tin the files provided as arguments."; "message\n\tin the files provided as arguments.";
const char* grib_tool_name = "metar_filter"; const char* tool_name = "metar_filter";
const char* grib_tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"file file ..."; "file file ...";
int fail = 0; int fail = 0;

View File

@ -29,12 +29,12 @@ grib_option grib_options[] = {
{ "v", 0, 0, 1, 0, 0 } { "v", 0, 0, 1, 0, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Get values of some keys from a METAR file." "Get values of some keys from a METAR file."
"\n\tIt is similar to metar_ls, but fails returning an error code " "\n\tIt is similar to metar_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* grib_tool_name = "metar_get"; const char* tool_name = "metar_get";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
double lat = 0; double lat = 0;

View File

@ -44,11 +44,11 @@ grib_option grib_options[] = {
/*{"x",0,0,0,1,0}*/ /*{"x",0,0,0,1,0}*/
}; };
const char* grib_tool_description = const char* tool_description =
"List content of METAR files printing values of " "List content of METAR files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* grib_tool_name = "metar_ls"; const char* tool_name = "metar_ls";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
double lat = 0; double lat = 0;

View File

@ -29,9 +29,9 @@ grib_option grib_options[] = {
{ "x", 0, 0, 0, 1, 0 } { "x", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = "Dump the content of a TAF file in different formats."; const char* tool_description = "Dump the content of a TAF file in different formats.";
const char* grib_tool_name = "taf_dump"; const char* tool_name = "taf_dump";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -53,7 +53,7 @@ int grib_tool_init(grib_runtime_options* options)
if (opt > 1) { if (opt > 1) {
printf("%s: simultaneous C/O/D options not allowed\n", grib_tool_name); printf("%s: simultaneous C/O/D options not allowed\n", tool_name);
exit(1); exit(1);
} }

View File

@ -26,11 +26,11 @@ grib_option grib_options[] = {
{ "7", 0, 0, 0, 1, 0 }, { "7", 0, 0, 0, 1, 0 },
{ "v", 0, 0, 0, 1, 0 } { "v", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Apply the rules defined in rules_file to each TAF " "Apply the rules defined in rules_file to each TAF "
"message\n\tin the files provided as arguments."; "message\n\tin the files provided as arguments.";
const char* grib_tool_name = "taf_filter"; const char* tool_name = "taf_filter";
const char* grib_tool_usage = const char* tool_usage =
"[options] rules_file " "[options] rules_file "
"file file ..."; "file file ...";
int fail = 0; int fail = 0;

View File

@ -33,12 +33,12 @@ grib_option grib_options[] = {
{ "i:", 0, 0, 0, 1, 0 } { "i:", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"Get values of some keys from a TAF file." "Get values of some keys from a TAF file."
"\n\tIt is similar to taf_ls, but fails returning an error code " "\n\tIt is similar to taf_ls, but fails returning an error code "
"\n\twhen an error occurs (e.g. key not found)."; "\n\twhen an error occurs (e.g. key not found).";
const char* grib_tool_name = "taf_get"; const char* tool_name = "taf_get";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
int mode = 0; int mode = 0;

View File

@ -37,11 +37,11 @@ grib_option grib_options[] = {
{ "x", 0, 0, 0, 1, 0 } { "x", 0, 0, 0, 1, 0 }
}; };
const char* grib_tool_description = const char* tool_description =
"List content of TAF files printing values of " "List content of TAF files printing values of "
"some keys.\n\tIt does not fail when a key is not found."; "some keys.\n\tIt does not fail when a key is not found.";
const char* grib_tool_name = "taf_ls"; const char* tool_name = "taf_ls";
const char* grib_tool_usage = "[options] file file ..."; const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
double lat = 0; double lat = 0;