mirror of https://github.com/ecmwf/eccodes.git
ECC-851: Refactoring: duplicated tigge 'scan' function
This commit is contained in:
parent
bdbb473418
commit
338010d94c
|
@ -1,28 +1,35 @@
|
||||||
# tigge
|
# tigge
|
||||||
|
|
||||||
|
# library
|
||||||
|
ecbuild_add_library(TARGET tigge_tools
|
||||||
|
TYPE STATIC
|
||||||
|
NOINSTALL
|
||||||
|
SOURCES tigge_tools.c tigge_tools.h)
|
||||||
|
|
||||||
|
# executables
|
||||||
ecbuild_add_executable(TARGET tigge_check
|
ecbuild_add_executable(TARGET tigge_check
|
||||||
SOURCES tigge_check.c
|
SOURCES tigge_check.c
|
||||||
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
||||||
LIBS eccodes
|
LIBS eccodes tigge_tools
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
ecbuild_add_executable(TARGET tigge_name
|
ecbuild_add_executable(TARGET tigge_name
|
||||||
SOURCES tigge_name.c
|
SOURCES tigge_name.c
|
||||||
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
||||||
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
|
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
|
||||||
LIBS eccodes
|
LIBS eccodes tigge_tools
|
||||||
)
|
)
|
||||||
|
|
||||||
ecbuild_add_executable(TARGET tigge_accumulations
|
ecbuild_add_executable(TARGET tigge_accumulations
|
||||||
SOURCES tigge_accumulations.c
|
SOURCES tigge_accumulations.c
|
||||||
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
||||||
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
|
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
|
||||||
LIBS eccodes
|
LIBS eccodes tigge_tools
|
||||||
)
|
)
|
||||||
|
|
||||||
ecbuild_add_executable(TARGET tigge_split
|
ecbuild_add_executable(TARGET tigge_split
|
||||||
SOURCES tigge_split.c
|
SOURCES tigge_split.c
|
||||||
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
INCLUDES ${ECCODES_EXTRA_INCLUDE_DIRS}
|
||||||
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
|
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
|
||||||
LIBS eccodes
|
LIBS eccodes tigge_tools
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "tigge_tools.h"
|
||||||
|
|
||||||
#define CHECK(a) check(#a,a)
|
#define CHECK(a) check(#a,a)
|
||||||
#define WARN(a) warn(#a,a)
|
#define WARN(a) warn(#a,a)
|
||||||
|
@ -1308,7 +1309,7 @@ static void verify(grib_handle* h)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validate(const char* path)
|
void validate(const char* path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path,"r");
|
FILE *f = fopen(path,"r");
|
||||||
grib_handle *h = 0;
|
grib_handle *h = 0;
|
||||||
|
@ -1357,26 +1358,6 @@ static void validate(const char* path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scan(const char* name)
|
|
||||||
{
|
|
||||||
DIR *dir;
|
|
||||||
if((dir = opendir(name)) != NULL)
|
|
||||||
{
|
|
||||||
struct dirent* e;
|
|
||||||
char tmp[1024];
|
|
||||||
while( (e = readdir(dir)) != NULL)
|
|
||||||
{
|
|
||||||
if(e->d_name[0] == '.') continue;
|
|
||||||
sprintf(tmp,"%s/%s",name,e->d_name);
|
|
||||||
scan(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
validate(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void usage()
|
static void usage()
|
||||||
{
|
{
|
||||||
printf("tigge_check [options] grib_file grib_file ...\n");
|
printf("tigge_check [options] grib_file grib_file ...\n");
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include "tigge_tools.h"
|
||||||
|
|
||||||
/* #define CHECK(a) check(#a,a) */
|
/* #define CHECK(a) check(#a,a) */
|
||||||
#define NUMBER(a) (sizeof(a)/sizeof(a[0]))
|
#define NUMBER(a) (sizeof(a)/sizeof(a[0]))
|
||||||
|
@ -152,7 +153,7 @@ static void verify(grib_handle *h,const char* full,const char* base)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validate(const char* path)
|
void validate(const char* path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path,"r");
|
FILE *f = fopen(path,"r");
|
||||||
grib_handle *h = 0;
|
grib_handle *h = 0;
|
||||||
|
@ -204,26 +205,6 @@ static void usage()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scan(const char* name)
|
|
||||||
{
|
|
||||||
DIR *dir;
|
|
||||||
if((dir = opendir(name)) != NULL)
|
|
||||||
{
|
|
||||||
struct dirent* e;
|
|
||||||
char tmp[1024];
|
|
||||||
while( (e = readdir(dir)) != NULL)
|
|
||||||
{
|
|
||||||
if(e->d_name[0] == '.') continue;
|
|
||||||
sprintf(tmp,"%s/%s",name,e->d_name);
|
|
||||||
scan(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
validate(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
Loading…
Reference in New Issue