2015-01-16 16:35:11 +00:00
|
|
|
/*
|
2018-01-02 11:31:02 +00:00
|
|
|
* Copyright 2005-2018 ECMWF.
|
2015-01-16 16:35:11 +00:00
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
|
|
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
|
|
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "grib_tools.h"
|
|
|
|
|
2018-11-15 13:25:06 +00:00
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
|
|
|
|
2017-09-01 16:52:05 +00:00
|
|
|
static void usage_and_exit(const char* progname) {
|
|
|
|
printf("\nUsage: %s [-v] [-d] [-s]\n",progname);
|
|
|
|
exit(1);
|
|
|
|
}
|
2015-01-16 16:35:11 +00:00
|
|
|
|
2015-01-22 17:00:59 +00:00
|
|
|
#define INFO_PRINT_ALL 0
|
|
|
|
#define INFO_PRINT_VERSION (1<<0)
|
|
|
|
#define INFO_PRINT_DEFINITION_PATH (1<<1)
|
2015-01-16 16:35:11 +00:00
|
|
|
#define INFO_PRINT_SAMPLES_PATH (1<<2)
|
|
|
|
|
|
|
|
int main( int argc,char* argv[])
|
|
|
|
{
|
|
|
|
char* path=NULL;
|
|
|
|
int nfiles=0;
|
|
|
|
unsigned long print_flags=0;
|
2015-02-25 17:42:04 +00:00
|
|
|
int major=ECCODES_MAJOR_VERSION;
|
|
|
|
int minor=ECCODES_MINOR_VERSION;
|
|
|
|
int revision=ECCODES_REVISION_VERSION;
|
2015-01-16 16:35:11 +00:00
|
|
|
|
|
|
|
while (1) {
|
2016-03-07 10:01:46 +00:00
|
|
|
int c = getopt (argc, argv, "vds");
|
2015-01-16 16:35:11 +00:00
|
|
|
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 'v':
|
|
|
|
print_flags|=INFO_PRINT_VERSION;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
print_flags|=INFO_PRINT_DEFINITION_PATH;
|
|
|
|
break;
|
2015-01-22 17:00:59 +00:00
|
|
|
case 's':
|
2015-01-16 16:35:11 +00:00
|
|
|
print_flags|=INFO_PRINT_SAMPLES_PATH;
|
|
|
|
break;
|
|
|
|
default:
|
2017-09-01 16:52:05 +00:00
|
|
|
usage_and_exit(argv[0]);
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nfiles=argc-optind;
|
2017-09-01 16:52:05 +00:00
|
|
|
if (nfiles != 0) usage_and_exit(argv[0]);
|
2015-01-16 16:35:11 +00:00
|
|
|
|
|
|
|
if (print_flags == INFO_PRINT_ALL) {
|
2018-04-20 15:48:06 +00:00
|
|
|
grib_context* context = grib_context_get_default();
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("\n");
|
2016-11-11 16:41:38 +00:00
|
|
|
printf("%s Version %d.%d.%d",
|
|
|
|
grib_get_package_name(), major,minor,revision);
|
2015-03-10 18:20:46 +00:00
|
|
|
/* if (ECCODES_MAJOR_VERSION < 1) printf(" PRE-RELEASE"); */
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
2018-04-20 15:48:06 +00:00
|
|
|
if(context->debug) {
|
|
|
|
grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1=%s", grib_get_git_sha1());
|
|
|
|
}
|
2015-01-29 15:49:23 +00:00
|
|
|
#if GRIB_PTHREADS
|
2018-04-20 15:48:06 +00:00
|
|
|
grib_context_log(context, GRIB_LOG_DEBUG, "POSIX threads enabled\n");
|
|
|
|
#elif GRIB_OMP_THREADS
|
|
|
|
grib_context_log(context, GRIB_LOG_DEBUG, "OMP threads enabled\n");
|
2016-06-21 13:36:35 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MEMFS
|
2018-04-20 15:48:06 +00:00
|
|
|
grib_context_log(context, GRIB_LOG_DEBUG, "MEMFS enabled");
|
2015-01-29 15:49:23 +00:00
|
|
|
#endif
|
2016-03-07 10:01:46 +00:00
|
|
|
if ((path=getenv("ECCODES_DEFINITION_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("Definition files path from environment variable");
|
2015-01-23 22:47:51 +00:00
|
|
|
printf(" ECCODES_DEFINITION_PATH=%s\n",path);
|
2016-03-07 10:01:46 +00:00
|
|
|
} else if ((path=getenv("GRIB_DEFINITION_PATH")) != NULL) {
|
|
|
|
printf("Definition files path from environment variable");
|
|
|
|
printf(" GRIB_DEFINITION_PATH=%s\n",path);
|
|
|
|
printf("(This is for backward compatibility. "
|
|
|
|
"It is recommended you use ECCODES_DEFINITION_PATH instead!)\n");
|
2015-01-16 16:35:11 +00:00
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("Default definition files path is used: %s\n",ECCODES_DEFINITION_PATH);
|
2018-12-28 12:00:18 +00:00
|
|
|
printf("Definition files path can be changed by setting ECCODES_DEFINITION_PATH environment variable\n");
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
2016-03-07 10:01:46 +00:00
|
|
|
if ((path=getenv("ECCODES_SAMPLES_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("SAMPLES path from environment variable");
|
2015-01-23 22:47:51 +00:00
|
|
|
printf(" ECCODES_SAMPLES_PATH=%s\n",path);
|
2016-03-07 10:01:46 +00:00
|
|
|
} else if ((path=getenv("GRIB_SAMPLES_PATH")) != NULL) {
|
|
|
|
printf("SAMPLES path from environment variable");
|
|
|
|
printf(" GRIB_SAMPLES_PATH=%s\n",path);
|
|
|
|
printf("(This is for backward compatibility. "
|
|
|
|
"It is recommended you use ECCODES_SAMPLES_PATH instead!)\n");
|
2015-01-16 16:35:11 +00:00
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("Default SAMPLES path is used: %s\n",ECCODES_SAMPLES_PATH);
|
2018-12-28 12:00:18 +00:00
|
|
|
printf("SAMPLES path can be changed by setting ECCODES_SAMPLES_PATH environment variable\n");
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_flags & INFO_PRINT_VERSION)
|
|
|
|
printf("%d.%d.%d ",major,minor,revision);
|
|
|
|
|
|
|
|
if (print_flags & INFO_PRINT_DEFINITION_PATH) {
|
2016-01-11 16:36:46 +00:00
|
|
|
if ((path=codes_getenv("ECCODES_DEFINITION_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("%s",path);
|
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("%s",ECCODES_DEFINITION_PATH);
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_flags & INFO_PRINT_SAMPLES_PATH) {
|
2016-01-11 16:36:46 +00:00
|
|
|
if ((path=codes_getenv("ECCODES_SAMPLES_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("%s",path);
|
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("%s",ECCODES_SAMPLES_PATH);
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|