mirror of https://github.com/ecmwf/eccodes.git
C examples: binary open
This commit is contained in:
parent
25595620b8
commit
a77570cd19
|
@ -28,7 +28,7 @@ int main(int argc, char* argv[])
|
|||
west=-10;
|
||||
east=30;
|
||||
|
||||
f=fopen(infile,"r");
|
||||
f=fopen(infile,"rb");
|
||||
if (!f) {
|
||||
perror(infile);
|
||||
exit(1);
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc,char* argv[])
|
|||
int cnt=0;
|
||||
const char* infile = "../../data/bufr/syno_multi.bufr";
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -40,8 +40,8 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
in = fopen(argv[1],"r");
|
||||
out = fopen(argv[2],"w");
|
||||
in = fopen(argv[1],"rb");
|
||||
out = fopen(argv[2],"wb");
|
||||
|
||||
/* open input and output */
|
||||
if (!in || !out) {
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
outfile=argv[2];
|
||||
|
||||
f = fopen(argv[1],"r");
|
||||
f = fopen(argv[1],"rb");
|
||||
if(!f) {
|
||||
perror(argv[1]);
|
||||
exit(1);
|
||||
|
|
|
@ -40,7 +40,7 @@ int main(int argc,char* argv[])
|
|||
filename=argv[1];
|
||||
|
||||
/* open bufr file */
|
||||
in=fopen(filename,"r");
|
||||
in=fopen(filename,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", filename);
|
||||
return 1;
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc,char* argv[])
|
|||
int cnt=0;
|
||||
const char* infile = "../../data/bufr/syno_multi.bufr";
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -27,7 +27,7 @@ int main(int argc,char* argv[])
|
|||
char** strArray = NULL; /* array of strings */
|
||||
const char* infile = "../../data/bufr/pgps_110.bufr";
|
||||
|
||||
FILE* in = fopen(infile,"r");
|
||||
FILE* in = fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc,char* argv[])
|
|||
|
||||
filename=argv[1];
|
||||
|
||||
in=fopen(filename,"r");
|
||||
in=fopen(filename,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", filename);
|
||||
return 1;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
* C Implementation: bufr_missing
|
||||
*
|
||||
* Description: how to handle missing values in BUFR messages.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "eccodes.h"
|
||||
|
@ -30,7 +29,7 @@ int main(int argc,char* argv[])
|
|||
int cnt=0;
|
||||
const char* infile = "../../data/bufr/syno_1.bufr";
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in)
|
||||
{
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
|
|
|
@ -66,7 +66,7 @@ int main(int argc, char** argv)
|
|||
FILE* fin = 0;
|
||||
codes_handle* h1 = 0;
|
||||
codes_handle* h2 = 0;
|
||||
fin = fopen("../../data/bufr/syno_multi.bufr", "r");
|
||||
fin = fopen("../../data/bufr/syno_multi.bufr", "rb");
|
||||
assert(fin);
|
||||
|
||||
err = pthread_create(&thread1, NULL, process_bufr, (void *)fin);
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc,char* argv[])
|
|||
|
||||
filename=argv[1];
|
||||
|
||||
in=fopen(filename,"r");
|
||||
in=fopen(filename,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", filename);
|
||||
return 1;
|
||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc,char* argv[])
|
|||
const char* infile = "../../data/bufr/asca_139.bufr";
|
||||
char key_name[128];
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc,char* argv[])
|
|||
int cnt=0;
|
||||
const char* infile = "../../data/bufr/syno_multi.bufr";
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc,char* argv[])
|
|||
const char* infile = "../../data/bufr/temp_101.bufr";
|
||||
char key_name[128];
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -43,8 +43,8 @@ int main(int argc,char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
in = fopen(infile,"r");
|
||||
out = fopen(argv[1],"w");
|
||||
in = fopen(infile,"rb");
|
||||
out = fopen(argv[1],"wb");
|
||||
|
||||
if (!in || !out) {
|
||||
perror("ERROR: unable to open files");
|
||||
|
|
|
@ -35,7 +35,7 @@ int main(int argc,char* argv[])
|
|||
int cnt=0;
|
||||
const char* infile = "../../data/bufr/synop_multi_subset.bufr";
|
||||
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc,char* argv[])
|
|||
return 1;
|
||||
}
|
||||
infile = argv[1];
|
||||
in=fopen(infile,"r");
|
||||
in=fopen(infile,"rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", infile);
|
||||
return 1;
|
||||
|
|
|
@ -37,8 +37,8 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
in = fopen(argv[1],"r");
|
||||
out = fopen(argv[2],"w");
|
||||
in = fopen(argv[1],"rb");
|
||||
out = fopen(argv[2],"wb");
|
||||
|
||||
if (!in || !out) {
|
||||
perror("ERROR: unable to open files");
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
in = fopen(argv[1],"r");
|
||||
in = fopen(argv[1],"rb");
|
||||
|
||||
if (!in) {
|
||||
perror("ERROR: unable to input file");
|
||||
|
|
|
@ -30,7 +30,7 @@ int main (int argc, char **argv)
|
|||
const double missing = 9999.0;
|
||||
double *lats, *lons, *values; /* arrays */
|
||||
|
||||
in = fopen (filename, "r");
|
||||
in = fopen(filename, "rb");
|
||||
if (!in) {
|
||||
printf ("ERROR: unable to open input file %s\n", filename);
|
||||
return 1;
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
|||
const char* filename = "../../data/regular_latlon_surface.grib1";
|
||||
codes_handle *h = NULL;
|
||||
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open file %s\n",filename);
|
||||
return 1;
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
|||
|
||||
filename=argv[1];
|
||||
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open file %s\n", filename);
|
||||
return 1;
|
||||
|
|
|
@ -42,7 +42,7 @@ int main(int argc, char** argv)
|
|||
|
||||
if (argc != 2) usage(argv[0]);
|
||||
filename=argv[1];
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
fprintf(stderr, "ERROR: unable to open file %s\n",filename);
|
||||
return 1;
|
||||
|
|
|
@ -59,7 +59,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (argc != 2) usage(argv[0]);
|
||||
|
||||
f = fopen(argv[1],"r");
|
||||
f = fopen(argv[1],"rb");
|
||||
if(!f) {
|
||||
perror(argv[1]);
|
||||
exit(1);
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char** argv)
|
|||
const char* filename = "../../data/satellite.grib";
|
||||
codes_handle *h = NULL;
|
||||
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open input file %s\n",filename);
|
||||
return 1;
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char** argv)
|
|||
/* turn off support for multi fields messages */
|
||||
/* codes_multi_support_off(0); */
|
||||
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open file %s\n",filename);
|
||||
return 1;
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char** argv)
|
|||
ofilename=argv[2];
|
||||
|
||||
/* open input file */
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
fprintf(stderr, "ERROR: unable to open input file %s\n",filename);
|
||||
return 1;
|
||||
|
|
|
@ -45,13 +45,13 @@ int main(int argc, char** argv)
|
|||
long bitsPerValue1=0, bitsPerValue2=0;
|
||||
int i=0;
|
||||
|
||||
in = fopen(infile,"r");
|
||||
in = fopen(infile,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open input file %s\n",infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out = fopen(outfile,"w");
|
||||
out = fopen(outfile,"wb");
|
||||
if(!out) {
|
||||
printf("ERROR: unable to open output file %s\n",outfile);
|
||||
fclose(in);
|
||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
|||
if (argc<2) usage(argv[0]);
|
||||
filename=argv[1];
|
||||
|
||||
in = fopen(filename,"r");
|
||||
in = fopen(filename,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open file %s\n",filename);
|
||||
return 1;
|
||||
|
|
|
@ -37,13 +37,13 @@ int main(int argc, char** argv)
|
|||
double missing=9999;
|
||||
int i=0;
|
||||
|
||||
in = fopen(infile, "r");
|
||||
in = fopen(infile, "rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open input file %s\n",infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out = fopen(outfile, "w");
|
||||
out = fopen(outfile, "wb");
|
||||
if(!out) {
|
||||
printf("ERROR: unable to open output file %s\n",outfile);
|
||||
fclose(in);
|
||||
|
|
|
@ -36,13 +36,13 @@ int main(int argc, char** argv)
|
|||
const void* buffer = NULL;
|
||||
size_t str_len = 0; /* See the call to codes_set_string later */
|
||||
|
||||
in = fopen(infile,"r");
|
||||
in = fopen(infile,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open file %s\n",infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out = fopen(outfile,"w");
|
||||
out = fopen(outfile,"wb");
|
||||
if(!out) {
|
||||
printf("ERROR: unable to open file %s\n",outfile);
|
||||
fclose(in);
|
||||
|
|
|
@ -43,13 +43,13 @@ int main(int argc, char** argv)
|
|||
infile = argv[1];
|
||||
outfile= argv[2];
|
||||
|
||||
in = fopen(infile, "r");
|
||||
in = fopen(infile, "rb");
|
||||
if(!in) {
|
||||
fprintf(stderr, "ERROR: unable to open input file %s\n",infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out = fopen(outfile, "w");
|
||||
out = fopen(outfile, "wb");
|
||||
if(!out) {
|
||||
fprintf(stderr, "ERROR: unable to open output file %s\n",outfile);
|
||||
fclose(in);
|
||||
|
|
|
@ -32,7 +32,7 @@ static void read_data(int num_msgs)
|
|||
long stepRange = 0;
|
||||
codes_handle *h = NULL;
|
||||
|
||||
fp = fopen(file_path, "r");
|
||||
fp = fopen(file_path, "rb");
|
||||
if(!fp) {
|
||||
fprintf(stderr, "ERROR: unable to open grib file %s\n", file_path);
|
||||
exit(1);
|
||||
|
|
|
@ -369,7 +369,7 @@ int main(int argc, char** argv)
|
|||
CODES_CHECK(codes_set_long(h,"setBitsPerValue",0),0);
|
||||
/* Save the message */
|
||||
|
||||
f = fopen(argv[1],"w");
|
||||
f = fopen(argv[1],"wb");
|
||||
if(!f) {
|
||||
perror(argv[1]);
|
||||
exit(1);
|
||||
|
|
|
@ -84,7 +84,7 @@ int main(int argc, char** argv)
|
|||
fclose(fin);
|
||||
|
||||
fname=argv[2];
|
||||
fin=fopen(fname,"r");
|
||||
fin=fopen(fname,"rb");
|
||||
if(!fin) { perror(fname); exit(1); }
|
||||
h=codes_handle_new_from_file(0,fin,PRODUCT_GRIB, &ret);
|
||||
if (!h || ret!=CODES_SUCCESS) {printf(" unable to create handle\n");exit(1);}
|
||||
|
|
|
@ -33,7 +33,7 @@ int main ( int argc, char* argv[])
|
|||
what_str=argv[3];
|
||||
out_name=argv[4];
|
||||
|
||||
in=fopen(in_name1,"r");
|
||||
in=fopen(in_name1,"rb");
|
||||
if (!in) {
|
||||
perror(in_name1);
|
||||
exit(1);
|
||||
|
@ -43,7 +43,7 @@ int main ( int argc, char* argv[])
|
|||
CODES_CHECK(err,0);
|
||||
fclose(in);
|
||||
|
||||
in=fopen(in_name2,"r");
|
||||
in=fopen(in_name2,"rb");
|
||||
if (!in) {
|
||||
perror(in_name2);
|
||||
exit(1);
|
||||
|
|
|
@ -34,13 +34,13 @@ int main(int argc, char** argv)
|
|||
size_t str_len=3;
|
||||
long Ni = 0;
|
||||
|
||||
in = fopen(infile,"r");
|
||||
in = fopen(infile,"rb");
|
||||
if(!in) {
|
||||
printf("ERROR: unable to open input file %s\n",infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out = fopen(outfile,"w");
|
||||
out = fopen(outfile,"wb");
|
||||
if(!out) {
|
||||
printf("ERROR: unable to open output file %s\n",outfile);
|
||||
fclose(in);
|
||||
|
|
|
@ -21,7 +21,7 @@ int main(int argc, char* argv[])
|
|||
int i;
|
||||
char* name = NULL;
|
||||
|
||||
f=fopen(infile,"r");
|
||||
f=fopen(infile,"rb");
|
||||
if (!f) {
|
||||
perror(infile);
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue