mirror of https://github.com/ecmwf/eccodes.git
ECC-327: bufr_dump -EC (all tests pass)
This commit is contained in:
parent
bd68931b64
commit
072462a3a7
|
@ -389,6 +389,12 @@ int codes_set_long_array(grib_handle* h, const char* key, const long* vals, size
|
||||||
{
|
{
|
||||||
return grib_set_long_array(h,key,vals,length);
|
return grib_set_long_array(h,key,vals,length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int codes_set_string_array(grib_handle *h, const char *key, const char **vals, size_t length)
|
||||||
|
{
|
||||||
|
return grib_set_string_array(h, key, vals, length);
|
||||||
|
}
|
||||||
|
|
||||||
int codes_set_values(grib_handle* h,grib_values* grib_values , size_t arg_count)
|
int codes_set_values(grib_handle* h,grib_values* grib_values , size_t arg_count)
|
||||||
{
|
{
|
||||||
return grib_set_values(h,grib_values,arg_count);
|
return grib_set_values(h,grib_values,arg_count);
|
||||||
|
|
|
@ -910,6 +910,18 @@ int codes_set_force_double_array(codes_handle* h, const char* key, const double*
|
||||||
* @return 0 if OK, integer value on error
|
* @return 0 if OK, integer value on error
|
||||||
*/
|
*/
|
||||||
int codes_set_long_array(codes_handle* h, const char* key, const long* vals, size_t length);
|
int codes_set_long_array(codes_handle* h, const char* key, const long* vals, size_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a string array from a key. If several keys of the same name are present, the last one is set
|
||||||
|
* @see codes_get_long_array
|
||||||
|
*
|
||||||
|
* @param h : the handle to set the data to
|
||||||
|
* @param key : the key to be searched
|
||||||
|
* @param vals : the address of a string array where the data will be read
|
||||||
|
* @param length : a size_t that contains the length of the array on input
|
||||||
|
* @return 0 if OK, integer value on error
|
||||||
|
*/
|
||||||
|
int codes_set_string_array(codes_handle *h, const char *key, const char **vals, size_t length);
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -924,6 +924,18 @@ int grib_set_force_double_array(grib_handle* h, const char* key, const double* v
|
||||||
* @return 0 if OK, integer value on error
|
* @return 0 if OK, integer value on error
|
||||||
*/
|
*/
|
||||||
int grib_set_long_array (grib_handle* h, const char* key , const long* vals , size_t length);
|
int grib_set_long_array (grib_handle* h, const char* key , const long* vals , size_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a string array from a key. If several keys of the same name are present, the last one is set
|
||||||
|
* @see grib_get_string_array
|
||||||
|
*
|
||||||
|
* @param h : the handle to set the data to
|
||||||
|
* @param key : the key to be searched
|
||||||
|
* @param vals : the address of a string array where the data will be read
|
||||||
|
* @param length : a size_t that contains the length of the array on input
|
||||||
|
* @return 0 if OK, integer value on error
|
||||||
|
*/
|
||||||
|
int grib_set_string_array(grib_handle* h, const char *key, const char **vals, size_t length);
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -547,13 +547,11 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(self->dumper.out," if(allocated(svalues)) deallocate(svalues)\n");
|
fprintf(self->dumper.out," free(svalues);\n");
|
||||||
fprintf(self->dumper.out," allocate(svalues(%lu))\n", (unsigned long)size);
|
fprintf(self->dumper.out," svalues = (char**)malloc(%lu * sizeof(char*));\n", (unsigned long)size);
|
||||||
|
fprintf(self->dumper.out," size = %lu;\n", size);
|
||||||
fprintf(self->dumper.out," svalues=(/");
|
|
||||||
|
|
||||||
self->empty=0;
|
self->empty=0;
|
||||||
|
|
||||||
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
|
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
|
||||||
if (!values) {
|
if (!values) {
|
||||||
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
|
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
|
||||||
|
@ -561,17 +559,16 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
|
||||||
}
|
}
|
||||||
|
|
||||||
err = grib_unpack_string_array(a,values,&size);
|
err = grib_unpack_string_array(a,values,&size);
|
||||||
|
|
||||||
for (i=0;i<size-1;i++) {
|
for (i=0;i<size-1;i++) {
|
||||||
fprintf(self->dumper.out," \"%s\", &\n",values[i]);
|
fprintf(self->dumper.out," svalues[%lu]=\"%s\"; \n", i, values[i]);
|
||||||
}
|
}
|
||||||
fprintf(self->dumper.out," \"%s\" /)\n",values[i]);
|
fprintf(self->dumper.out," svalues[%lu]=\"%s\";\n", i, values[i]);
|
||||||
|
|
||||||
if (self->isLeaf==0) {
|
if (self->isLeaf==0) {
|
||||||
if ((r=compute_key_rank(h,self->keys,a->name))!=0)
|
if ((r=compute_key_rank(h,self->keys,a->name))!=0)
|
||||||
fprintf(self->dumper.out," call codes_set_string_array(ibufr,'#%d#%s',svalues)\n",r,a->name);
|
fprintf(self->dumper.out," codes_set_string_array(h, \"#%d#%s\", (const char **)svalues, size);\n",r,a->name);
|
||||||
else
|
else
|
||||||
fprintf(self->dumper.out," call codes_set_string_array(ibufr,'%s',svalues)\n",a->name);
|
fprintf(self->dumper.out," codes_set_string_array(h, \"%s\", (const char **)svalues, size);\n",a->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->isLeaf==0) {
|
if (self->isLeaf==0) {
|
||||||
|
@ -629,12 +626,11 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
|
||||||
if (self->isLeaf==0) {
|
if (self->isLeaf==0) {
|
||||||
depth+=2;
|
depth+=2;
|
||||||
if (r!=0)
|
if (r!=0)
|
||||||
fprintf(self->dumper.out," call codes_set(ibufr,'#%d#%s',",r,a->name);
|
fprintf(self->dumper.out," codes_set_string(h, \"#%d#%s\", ", r, a->name);
|
||||||
else
|
else
|
||||||
fprintf(self->dumper.out," call codes_set(ibufr,'%s',",a->name);
|
fprintf(self->dumper.out," codes_set_string(h, \"%s\", ", a->name);
|
||||||
}
|
}
|
||||||
fprintf(self->dumper.out,"\'%s\')\n",value);
|
fprintf(self->dumper.out,"\"%s\", &size);\n",value);
|
||||||
|
|
||||||
|
|
||||||
if (self->isLeaf==0) {
|
if (self->isLeaf==0) {
|
||||||
char* prefix;
|
char* prefix;
|
||||||
|
|
|
@ -21,25 +21,7 @@ tempBufr=outfile.bufr
|
||||||
tempDir=${label}.dir
|
tempDir=${label}.dir
|
||||||
mkdir -p $tempDir
|
mkdir -p $tempDir
|
||||||
|
|
||||||
#bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
||||||
bufr_files="
|
|
||||||
207003.bufr ascs_139.bufr b006_96.bufr goga_89.bufr new.bufr soil_7.bufr
|
|
||||||
aaen_55.bufr aseh_139.bufr btem_109.bufr hirb_55.bufr nomi_206.bufr ssbt_127.bufr
|
|
||||||
aben_55.bufr asel_139.bufr cmwi_87.bufr hirs_55.bufr ocea_131.bufr stuk_7.bufr
|
|
||||||
ahws_139.bufr ashs_139.bufr cmwn_87.bufr ias1_240.bufr ocea_21.bufr syno_1.bufr
|
|
||||||
airs_57.bufr atap_55.bufr cori_156.bufr iasi_241.bufr pilo_91.bufr syno_2.bufr
|
|
||||||
alws_139.bufr ateu_155.bufr crit_202.bufr itwt_233.bufr profiler_european.bufr syno_3.bufr
|
|
||||||
amsa_55.bufr atms_201.bufr csrh_189.bufr jaso_214.bufr rada_250.bufr syno_4.bufr
|
|
||||||
amsb_55.bufr atov_55.bufr emsg_189.bufr maer_207.bufr rado_250.bufr syno_multi.bufr
|
|
||||||
amse_55.bufr avhm_87.bufr emsg_87.bufr mhen_55.bufr s4kn_165.bufr temp-land-with-substituted-values.bufr
|
|
||||||
amsu_55.bufr avhn_87.bufr euwv_87.bufr mhsa_55.bufr sb19_206.bufr temp_101.bufr
|
|
||||||
amv2_87.bufr avhr_58.bufr fy3a_154.bufr mhsb_55.bufr sbu8_206.bufr tmr7_129.bufr
|
|
||||||
amv3_87.bufr b002_95.bufr fy3b_154.bufr mhse_55.bufr smin_49.bufr uegabe.bufr
|
|
||||||
asbh_139.bufr b002_96.bufr g2to_206.bufr mloz_206.bufr smis_49.bufr
|
|
||||||
asbl_139.bufr b003_56.bufr go15_87.bufr modi_87.bufr smiu_49.bufr
|
|
||||||
asca_139.bufr b005_87.bufr goee_87.bufr modw_87.bufr smos_203.bufr
|
|
||||||
asch_139.bufr b005_89.bufr goes_87.bufr monw_87.bufr sn4k_165.bufr
|
|
||||||
"
|
|
||||||
|
|
||||||
# pkgconfig should be one level above the test dir
|
# pkgconfig should be one level above the test dir
|
||||||
PKGCONFIG_FILE=../eccodes.pc
|
PKGCONFIG_FILE=../eccodes.pc
|
||||||
|
|
Loading…
Reference in New Issue