Skip to content

Commit

Permalink
Examples: Use binary write mode for fopen
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Mar 7, 2024
1 parent 92cbaa0 commit 95aa40f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/C/grib_multi_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char** argv)
}

/* open output file */
of = fopen(ofilename, "w");
of = fopen(ofilename, "wb");
if (!of) {
fprintf(stderr, "ERROR: unable to open output file %s\n", ofilename);
exit(1);
Expand Down
22 changes: 11 additions & 11 deletions examples/C/grib_multi_write.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@

. ./include.ctest.sh

#if [ ! -f "${data_dir}/sample.grib2" ]
#then
# echo SKIP: $0
# exit
#fi
label="grib_multi_write_c"
tempGrib=temp.$label.grib
tempText=temp.$label.txt

${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

step=`${tools_dir}/grib_get -M -p step ${data_dir}/multi_sample.grib2`
reference=${data_dir}/multi_step.txt
diff $reference $tempText

# -M = Turn multi-field support off
step=`${tools_dir}/grib_get -M -p step $tempGrib`
[ $step -eq 12 ]

rm -f ${data_dir}/multi_sample.grib2 ${data_dir}/multi_step.test
# Clean up
rm -f $tempGrib $tempText

0 comments on commit 95aa40f

Please sign in to comment.