cat ${nwo_file} \ | gawk \ -v dir="${dir}" \ -i ./error_funcs.gawk \ ' BEGIN { inf = "+inf" + 0; dir += 0; vstep = -1; nh = 0; ndat=0; pwd = 0.15; eps = 0.005; printf "dir = %d\n", dir > "/dev/stderr"; } /^ *[-+0-9.]/ { if (NF != 4) { data_error("bad NF") } ndat++; plo = $1 + dir*eps; vmd = $2 + dir*eps; phi = $3 + dir*eps; ct = $4 + dir*eps; pmd = vmd + dir*(eps + pwd/2); plo = pmd - pwd/2; phi = pmd + pwd/2; if (ct > 0) { print ""; print plo, 0; print plo, ct; print phi, ct; print phi, 0; nh++; } next; } // { data_error("bad format"); } END { printf "%5d histogram entries\n", ndat > "/dev/stderr"; printf "%5d non-zero histogram bars\n", nh > "/dev/stderr"; if (nh == 0) { bug("no bins"); } print ""; } ' \ > ${dat_file}