mirror of https://github.com/ecmwf/eccodes.git
Examples: Use binary write mode for fopen
This commit is contained in:
parent
92cbaa050d
commit
95aa40fc23
|
@ -72,7 +72,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open output file */
|
/* open output file */
|
||||||
of = fopen(ofilename, "w");
|
of = fopen(ofilename, "wb");
|
||||||
if (!of) {
|
if (!of) {
|
||||||
fprintf(stderr, "ERROR: unable to open output file %s\n", ofilename);
|
fprintf(stderr, "ERROR: unable to open output file %s\n", ofilename);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -9,20 +9,20 @@
|
||||||
|
|
||||||
. ./include.ctest.sh
|
. ./include.ctest.sh
|
||||||
|
|
||||||
#if [ ! -f "${data_dir}/sample.grib2" ]
|
label="grib_multi_write_c"
|
||||||
#then
|
tempGrib=temp.$label.grib
|
||||||
# echo SKIP: $0
|
tempText=temp.$label.txt
|
||||||
# exit
|
|
||||||
#fi
|
|
||||||
|
|
||||||
${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 ${data_dir}/multi_sample.grib2 > /dev/null
|
${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 $tempGrib > /dev/null
|
||||||
|
|
||||||
${tools_dir}/grib_get -p step ${data_dir}/multi_sample.grib2 > ${data_dir}/multi_step.test
|
${tools_dir}/grib_get -p step $tempGrib > $tempText
|
||||||
|
|
||||||
diff ${data_dir}/multi_step.test ${data_dir}/multi_step.txt
|
reference=${data_dir}/multi_step.txt
|
||||||
|
diff $reference $tempText
|
||||||
step=`${tools_dir}/grib_get -M -p step ${data_dir}/multi_sample.grib2`
|
|
||||||
|
|
||||||
|
# -M = Turn multi-field support off
|
||||||
|
step=`${tools_dir}/grib_get -M -p step $tempGrib`
|
||||||
[ $step -eq 12 ]
|
[ $step -eq 12 ]
|
||||||
|
|
||||||
rm -f ${data_dir}/multi_sample.grib2 ${data_dir}/multi_step.test
|
# Clean up
|
||||||
|
rm -f $tempGrib $tempText
|
||||||
|
|
Loading…
Reference in New Issue