ECC-320: Preparation. Rename dumper classes

This commit is contained in:
Shahram Najm 2016-09-12 15:27:34 +01:00
parent 0052b7b682
commit 05e352c534
10 changed files with 179 additions and 116 deletions

View File

@ -274,10 +274,10 @@ list( APPEND grib_api_srcs
grib_dumper_class_debug.c
grib_dumper_class_default.c
grib_dumper_class_keys.c
grib_dumper_class_C.c
grib_dumper_class_filter.c
grib_dumper_class_fortran.c
grib_dumper_class_python.c
grib_dumper_class_bufr_encode_C.c
grib_dumper_class_bufr_encode_filter.c
grib_dumper_class_bufr_encode_fortran.c
grib_dumper_class_bufr_encode_python.c
grib_dumper_class_json.c
grib_dumper_class_xml.c
grib_dumper_class_c_code.c

View File

@ -33,7 +33,7 @@ libeccodes_la_prototypes= \
action_class_trigger.c \
action_class_when.c \
action_class_concept.c \
action_class_hash_array.c \
action_class_hash_array.c \
action_class_set.c \
action_class_set_darray.c \
action_class_set_iarray.c \
@ -289,10 +289,10 @@ libeccodes_la_prototypes= \
grib_dumper_class_debug.c \
grib_dumper_class_default.c \
grib_dumper_class_keys.c \
grib_dumper_class_C.c \
grib_dumper_class_filter.c \
grib_dumper_class_fortran.c \
grib_dumper_class_python.c \
grib_dumper_class_bufr_encode_C.c \
grib_dumper_class_bufr_encode_filter.c \
grib_dumper_class_bufr_encode_fortran.c \
grib_dumper_class_bufr_encode_python.c \
grib_dumper_class_json.c \
grib_dumper_class_xml.c \
grib_dumper_class_c_code.c \

View File

@ -1,15 +1,15 @@
/* This file is automatically generated by ./make_class.pl, do not edit */
extern grib_dumper_class* grib_dumper_class_C;
extern grib_dumper_class* grib_dumper_class_bufr_encode_C;
extern grib_dumper_class* grib_dumper_class_c_code;
extern grib_dumper_class* grib_dumper_class_compare;
extern grib_dumper_class* grib_dumper_class_debug;
extern grib_dumper_class* grib_dumper_class_default;
extern grib_dumper_class* grib_dumper_class_file;
extern grib_dumper_class* grib_dumper_class_filter;
extern grib_dumper_class* grib_dumper_class_fortran;
extern grib_dumper_class* grib_dumper_class_bufr_encode_filter;
extern grib_dumper_class* grib_dumper_class_bufr_encode_fortran;
extern grib_dumper_class* grib_dumper_class_json;
extern grib_dumper_class* grib_dumper_class_keys;
extern grib_dumper_class* grib_dumper_class_python;
extern grib_dumper_class* grib_dumper_class_bufr_encode_python;
extern grib_dumper_class* grib_dumper_class_serialize;
extern grib_dumper_class* grib_dumper_class_string;
extern grib_dumper_class* grib_dumper_class_wmo;

View File

@ -57,7 +57,7 @@ static void dump_section (grib_dumper* d, grib_accessor* a,grib_block_of_acce
static void header (grib_dumper*,grib_handle*);
static void footer (grib_dumper*,grib_handle*);
typedef struct grib_dumper_C {
typedef struct grib_dumper_bufr_encode_C {
grib_dumper dumper;
/* Members defined in C */
long section_offset;
@ -66,13 +66,13 @@ typedef struct grib_dumper_C {
long isLeaf;
long isAttribute;
grib_string_list* keys;
} grib_dumper_C;
} grib_dumper_bufr_encode_C;
static grib_dumper_class _grib_dumper_class_C = {
static grib_dumper_class _grib_dumper_class_bufr_encode_C = {
0, /* super */
"C", /* name */
sizeof(grib_dumper_C), /* size */
"bufr_encode_C", /* name */
sizeof(grib_dumper_bufr_encode_C), /* size */
0, /* inited */
&init_class, /* init_class */
&init, /* init */
@ -90,7 +90,7 @@ static grib_dumper_class _grib_dumper_class_C = {
&footer, /* footer */
};
grib_dumper_class* grib_dumper_class_C = &_grib_dumper_class_C;
grib_dumper_class* grib_dumper_class_bufr_encode_C = &_grib_dumper_class_bufr_encode_C;
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
@ -115,7 +115,7 @@ static void init_class (grib_dumper_class* c){}
static int init(grib_dumper* d)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
grib_context* c=d->handle->context;
self->section_offset=0;
self->empty=1;
@ -129,7 +129,7 @@ static int init(grib_dumper* d)
static int destroy(grib_dumper* d)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
grib_string_list* next=self->keys;
grib_string_list* cur=self->keys;
grib_context* c=d->handle->context;
@ -151,7 +151,7 @@ static char* dval_to_string(grib_context* c, double v)
static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -238,7 +238,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -316,7 +316,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -414,7 +414,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -487,7 +487,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
double value; size_t size = 1;
int r;
char* sval;
@ -529,7 +529,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
@ -596,7 +596,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
char *value=NULL;
char *p = NULL;
size_t size = 0;
@ -692,7 +692,7 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
if (!grib_inline_strcmp(a->name,"BUFR") ||
!grib_inline_strcmp(a->name,"GRIB") ||
!grib_inline_strcmp(a->name,"META")
@ -722,7 +722,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
{
int i=0;
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
unsigned long flags;
while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
self->isAttribute=1;
@ -754,7 +754,7 @@ static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
static void header(grib_dumper* d, grib_handle* h)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
char sampleName[200]={0};
long localSectionPresent,edition,bufrHeaderCentre,isSatellite;
@ -801,7 +801,7 @@ static void header(grib_dumper* d, grib_handle* h)
static void footer(grib_dumper* d, grib_handle* h)
{
grib_dumper_C *self = (grib_dumper_C*)d;
grib_dumper_bufr_encode_C *self = (grib_dumper_bufr_encode_C*)d;
fprintf(self->dumper.out,"\n codes_set_long(h, \"pack\", 1);\n");
if (d->count==1)
fprintf(self->dumper.out," fout = fopen(\"outfile.bufr\", \"w\");\n");

View File

@ -55,7 +55,7 @@ static void dump_values (grib_dumper* d, grib_accessor* a);
static void dump_label (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_section (grib_dumper* d, grib_accessor* a,grib_block_of_accessors* block);
typedef struct grib_dumper_filter {
typedef struct grib_dumper_bufr_encode_filter {
grib_dumper dumper;
/* Members defined in filter */
long section_offset;
@ -65,13 +65,13 @@ typedef struct grib_dumper_filter {
long isLeaf;
long isAttribute;
grib_string_list* keys;
} grib_dumper_filter;
} grib_dumper_bufr_encode_filter;
static grib_dumper_class _grib_dumper_class_filter = {
static grib_dumper_class _grib_dumper_class_bufr_encode_filter = {
0, /* super */
"filter", /* name */
sizeof(grib_dumper_filter), /* size */
"bufr_encode_filter", /* name */
sizeof(grib_dumper_bufr_encode_filter), /* size */
0, /* inited */
&init_class, /* init_class */
&init, /* init */
@ -89,7 +89,7 @@ static grib_dumper_class _grib_dumper_class_filter = {
0, /* footer */
};
grib_dumper_class* grib_dumper_class_filter = &_grib_dumper_class_filter;
grib_dumper_class* grib_dumper_class_bufr_encode_filter = &_grib_dumper_class_bufr_encode_filter;
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix);
@ -114,7 +114,7 @@ static void init_class (grib_dumper_class* c){}
static int init(grib_dumper* d)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
grib_context* c=d->handle->context;
self->section_offset=0;
self->empty=1;
@ -127,7 +127,7 @@ static int init(grib_dumper* d)
static int destroy(grib_dumper* d)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
grib_string_list* next=self->keys;
grib_string_list* cur=self->keys;
grib_context* c=d->handle->context;
@ -142,7 +142,7 @@ static int destroy(grib_dumper* d)
static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -222,7 +222,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* prefix)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -284,7 +284,7 @@ static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* p
static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -379,7 +379,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -445,7 +445,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
double value; size_t size = 1;
int r;
grib_handle* h=grib_handle_of_accessor(a);
@ -486,7 +486,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
@ -559,7 +559,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
char *value=NULL;
char *p = NULL;
size_t size = 0;
@ -653,7 +653,7 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
if (!grib_inline_strcmp(a->name,"BUFR") ||
!grib_inline_strcmp(a->name,"GRIB") ||
!grib_inline_strcmp(a->name,"META")
@ -685,7 +685,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
{
int i=0;
grib_dumper_filter *self = (grib_dumper_filter*)d;
grib_dumper_bufr_encode_filter *self = (grib_dumper_bufr_encode_filter*)d;
unsigned long flags;
while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
self->isAttribute=1;

View File

@ -57,7 +57,7 @@ static void dump_section (grib_dumper* d, grib_accessor* a,grib_block_of_acce
static void header (grib_dumper*,grib_handle*);
static void footer (grib_dumper*,grib_handle*);
typedef struct grib_dumper_fortran {
typedef struct grib_dumper_bufr_encode_fortran {
grib_dumper dumper;
/* Members defined in fortran */
long section_offset;
@ -66,13 +66,13 @@ typedef struct grib_dumper_fortran {
long isLeaf;
long isAttribute;
grib_string_list* keys;
} grib_dumper_fortran;
} grib_dumper_bufr_encode_fortran;
static grib_dumper_class _grib_dumper_class_fortran = {
static grib_dumper_class _grib_dumper_class_bufr_encode_fortran = {
0, /* super */
"fortran", /* name */
sizeof(grib_dumper_fortran), /* size */
"bufr_encode_fortran", /* name */
sizeof(grib_dumper_bufr_encode_fortran), /* size */
0, /* inited */
&init_class, /* init_class */
&init, /* init */
@ -90,7 +90,7 @@ static grib_dumper_class _grib_dumper_class_fortran = {
&footer, /* footer */
};
grib_dumper_class* grib_dumper_class_fortran = &_grib_dumper_class_fortran;
grib_dumper_class* grib_dumper_class_bufr_encode_fortran = &_grib_dumper_class_bufr_encode_fortran;
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix);
@ -115,7 +115,7 @@ static void init_class (grib_dumper_class* c){}
static int init(grib_dumper* d)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
grib_context* c=d->handle->context;
self->section_offset=0;
self->empty=1;
@ -129,7 +129,7 @@ static int init(grib_dumper* d)
static int destroy(grib_dumper* d)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
grib_string_list* next=self->keys;
grib_string_list* cur=self->keys;
grib_context* c=d->handle->context;
@ -157,7 +157,7 @@ static char* dval_to_string(grib_context* c, double v)
static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -246,7 +246,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -325,7 +325,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -422,7 +422,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -494,7 +494,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
double value; size_t size = 1;
int r;
char* sval;
@ -536,7 +536,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
@ -605,7 +605,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
char *value=NULL;
char *p = NULL;
size_t size = 0;
@ -702,7 +702,7 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
if (!grib_inline_strcmp(a->name,"BUFR") ||
!grib_inline_strcmp(a->name,"GRIB") ||
!grib_inline_strcmp(a->name,"META")
@ -732,7 +732,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
{
int i=0;
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
unsigned long flags;
while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
self->isAttribute=1;
@ -764,7 +764,7 @@ static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
static void header(grib_dumper* d, grib_handle* h)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
char sampleName[200]={0};
long localSectionPresent,edition,bufrHeaderCentre,isSatellite;
@ -807,7 +807,7 @@ static void header(grib_dumper* d, grib_handle* h)
static void footer(grib_dumper* d, grib_handle* h)
{
grib_dumper_fortran *self = (grib_dumper_fortran*)d;
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
fprintf(self->dumper.out," call codes_set(ibufr,'pack',1)\n");
if (d->count==1)
fprintf(self->dumper.out," call codes_open_file(outfile,'outfile.bufr','w')\n");

View File

@ -57,7 +57,7 @@ static void dump_section (grib_dumper* d, grib_accessor* a,grib_block_of_acce
static void header (grib_dumper*,grib_handle*);
static void footer (grib_dumper*,grib_handle*);
typedef struct grib_dumper_python {
typedef struct grib_dumper_bufr_encode_python {
grib_dumper dumper;
/* Members defined in python */
long section_offset;
@ -66,13 +66,13 @@ typedef struct grib_dumper_python {
long isLeaf;
long isAttribute;
grib_string_list* keys;
} grib_dumper_python;
} grib_dumper_bufr_encode_python;
static grib_dumper_class _grib_dumper_class_python = {
static grib_dumper_class _grib_dumper_class_bufr_encode_python = {
0, /* super */
"python", /* name */
sizeof(grib_dumper_python), /* size */
"bufr_encode_python", /* name */
sizeof(grib_dumper_bufr_encode_python), /* size */
0, /* inited */
&init_class, /* init_class */
&init, /* init */
@ -90,7 +90,7 @@ static grib_dumper_class _grib_dumper_class_python = {
&footer, /* footer */
};
grib_dumper_class* grib_dumper_class_python = &_grib_dumper_class_python;
grib_dumper_class* grib_dumper_class_bufr_encode_python = &_grib_dumper_class_bufr_encode_python;
/* END_CLASS_IMP */
static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix);
@ -115,7 +115,7 @@ static void init_class (grib_dumper_class* c){}
static int init(grib_dumper* d)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
grib_context* c=d->handle->context;
self->section_offset=0;
self->empty=1;
@ -129,7 +129,7 @@ static int init(grib_dumper* d)
static int destroy(grib_dumper* d)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
grib_string_list* next=self->keys;
grib_string_list* cur=self->keys;
grib_context* c=d->handle->context;
@ -151,7 +151,7 @@ static char* dval_to_string(const grib_context* c,double v)
static void dump_values(grib_dumper* d,grib_accessor* a)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -236,7 +236,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* prefix)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
double value; size_t size = 0;
double *values=NULL;
int err = 0;
@ -312,7 +312,7 @@ static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* p
static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -407,7 +407,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* prefix)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
long value; size_t size = 0;
long *values=NULL;
int err = 0;
@ -477,7 +477,7 @@ static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
double value; size_t size = 1;
int r;
char* sval;
@ -519,7 +519,7 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
@ -585,7 +585,7 @@ static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* commen
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
char *value=NULL;
char *p = NULL;
size_t size = 0;
@ -680,7 +680,7 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
if (!grib_inline_strcmp(a->name,"BUFR") ||
!grib_inline_strcmp(a->name,"GRIB") ||
!grib_inline_strcmp(a->name,"META")
@ -710,7 +710,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
{
int i=0;
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
unsigned long flags;
while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
self->isAttribute=1;
@ -742,7 +742,7 @@ static void dump_attributes(grib_dumper* d,grib_accessor* a, const char* prefix)
static void header(grib_dumper* d, grib_handle* h)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
char sampleName[200]={0};
long localSectionPresent,edition,bufrHeaderCentre,isSatellite;
@ -776,7 +776,7 @@ static void header(grib_dumper* d, grib_handle* h)
static void footer(grib_dumper* d, grib_handle* h)
{
grib_dumper_python *self = (grib_dumper_python*)d;
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
fprintf(self->dumper.out," codes_set(ibufr, 'pack', 1)\n");
if (d->count==1)
fprintf(self->dumper.out," outfile = open('outfile.bufr', 'w')\n");

View File

@ -1,13 +1,13 @@
/* This file is automatically generated by ./make_class.pl, do not edit */
{ "C", &grib_dumper_class_C, },
{ "bufr_encode_C", &grib_dumper_class_bufr_encode_C, },
{ "c_code", &grib_dumper_class_c_code, },
{ "debug", &grib_dumper_class_debug, },
{ "default", &grib_dumper_class_default, },
{ "filter", &grib_dumper_class_filter, },
{ "fortran", &grib_dumper_class_fortran, },
{ "bufr_encode_filter", &grib_dumper_class_bufr_encode_filter, },
{ "bufr_encode_fortran", &grib_dumper_class_bufr_encode_fortran, },
{ "json", &grib_dumper_class_json, },
{ "keys", &grib_dumper_class_keys, },
{ "python", &grib_dumper_class_python, },
{ "bufr_encode_python", &grib_dumper_class_bufr_encode_python, },
{ "serialize", &grib_dumper_class_serialize, },
{ "wmo", &grib_dumper_class_wmo, },
{ "xml", &grib_dumper_class_xml, },

View File

@ -167,6 +167,41 @@ int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* fil
return 0;
}
static char* get_dumper_name(grib_runtime_options* options)
{
if (grib_options_on("E:")) {
/* Dumper for ENCODING */
if (strcmp(options->dump_mode,"filter")==0) {
return "bufr_encode_filter";
}
if (strcmp(options->dump_mode,"fortran")==0) {
return "bufr_encode_fortran";
}
if (strcmp(options->dump_mode,"C")==0) {
return "bufr_encode_C";
}
if (strcmp(options->dump_mode,"python")==0) {
return "bufr_encode_python";
}
}
else if (grib_options_on("D:")) {
/* Dumper for DECODING */
if (strcmp(options->dump_mode,"filter")==0) {
return "bufr_decode_filter";
}
if (strcmp(options->dump_mode,"fortran")==0) {
return "bufr_decode_fortran";
}
if (strcmp(options->dump_mode,"C")==0) {
return "bufr_decode_C";
}
if (strcmp(options->dump_mode,"python")==0) {
return "bufr_decode_python";
}
}
return options->dump_mode;
}
int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
{
long length=0;
@ -269,6 +304,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
}
grib_dump_content(h,stdout,options->dump_mode,options->dump_flags,0);
} else {
const char* dumper_name = get_dumper_name(options);
err=grib_set_long(h,"unpack",1);
if (err) {
if (options->fail) {
@ -280,7 +316,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
return err;
}
}
dumper=grib_dump_content_with_dumper(h,dumper,stdout,options->dump_mode,options->dump_flags,0);
dumper=grib_dump_content_with_dumper(h,dumper,stdout,dumper_name,options->dump_flags,0);
if (!dumper) exit(1);
}
@ -301,30 +337,57 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h)
int grib_tool_finalise_action(grib_runtime_options* options)
{
if (json) fprintf(stdout,"\n]}\n");
if (!strcmp(options->dump_mode,"filter")) {
fprintf(stdout,"set pack=1;\nwrite;\n");
}
if (!strcmp(options->dump_mode,"fortran")) {
fprintf(stdout,"end program bufr_create_message\n");
}
if (!strcmp(options->dump_mode,"C")) {
fprintf(stdout," return 0;\n");
fprintf(stdout,"}\n");
}
if (!strcmp(options->dump_mode,"python")) {
fprintf(stdout,"\n\n");
fprintf(stdout,"def main():\n");
fprintf(stdout," try:\n");
fprintf(stdout," bufr_create_message()\n");
fprintf(stdout," except CodesInternalError as err:\n");
fprintf(stdout," traceback.print_exc(file=sys.stderr)\n");
fprintf(stdout," return 1\n");
fprintf(stdout,"\n\n");
fprintf(stdout,"if __name__ == \"__main__\":\n");
fprintf(stdout," sys.exit(main())\n");
if (grib_options_on("E:")) {
/* Code for ENCODING */
if (!strcmp(options->dump_mode,"filter")) {
fprintf(stdout,"set pack=1;\nwrite;\n");
}
if (!strcmp(options->dump_mode,"fortran")) {
fprintf(stdout,"end program bufr_create_message\n");
}
if (!strcmp(options->dump_mode,"C")) {
fprintf(stdout," return 0;\n");
fprintf(stdout,"}\n");
}
if (!strcmp(options->dump_mode,"python")) {
fprintf(stdout,"\n\n");
fprintf(stdout,"def main():\n");
fprintf(stdout," try:\n");
fprintf(stdout," bufr_create_message()\n");
fprintf(stdout," except CodesInternalError as err:\n");
fprintf(stdout," traceback.print_exc(file=sys.stderr)\n");
fprintf(stdout," return 1\n");
fprintf(stdout,"\n\n");
fprintf(stdout,"if __name__ == \"__main__\":\n");
fprintf(stdout," sys.exit(main())\n");
}
}
else if (grib_options_on("D:")) {
/* Code for DECODING */
if (!strcmp(options->dump_mode,"filter")) {
}
if (!strcmp(options->dump_mode,"fortran")) {
}
if (!strcmp(options->dump_mode,"C")) {
fprintf(stdout," return 0;\n");
fprintf(stdout,"}\n");
}
if (!strcmp(options->dump_mode,"python")) {
fprintf(stdout,"\n\n");
fprintf(stdout,"def main():\n");
fprintf(stdout," try:\n");
fprintf(stdout," bufr_decode_message()\n");
fprintf(stdout," except CodesInternalError as err:\n");
fprintf(stdout," traceback.print_exc(file=sys.stderr)\n");
fprintf(stdout," return 1\n");
fprintf(stdout,"\n\n");
fprintf(stdout,"if __name__ == \"__main__\":\n");
fprintf(stdout," sys.exit(main())\n");
}
}
return 0;
}

View File

@ -1397,11 +1397,11 @@
>
</File>
<File
RelativePath="..\..\..\src\grib_dumper_class_filter.c"
RelativePath="..\..\..\src\grib_dumper_class_bufr_encode_filter.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_dumper_class_fortran.c"
RelativePath="..\..\..\src\grib_dumper_class_bufr_encode_fortran.c"
>
</File>
<File
@ -1413,7 +1413,7 @@
>
</File>
<File
RelativePath="..\..\..\src\grib_dumper_class_python.c"
RelativePath="..\..\..\src\grib_dumper_class_bufr_encode_python.c"
>
</File>
<File