From 6225f0b3ed624026fa118c100266d9c2a173078a Mon Sep 17 00:00:00 2001 From: Andrea Valassi Date: Sun, 19 Jun 2022 15:40:23 +0200 Subject: [PATCH] [fvsc] add dummyColor.sh to replace colors by dummy color 0 in events.lhe #402 --- epochX/cudacpp/tmad/dummyColor.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 epochX/cudacpp/tmad/dummyColor.sh diff --git a/epochX/cudacpp/tmad/dummyColor.sh b/epochX/cudacpp/tmad/dummyColor.sh new file mode 100755 index 0000000000..8970217e91 --- /dev/null +++ b/epochX/cudacpp/tmad/dummyColor.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Temmporary workaround for #402 +# Replace event-by-event color information in by a dummy color 0 in +if [ "$1" == "$2" ] || [ "$2" == "" ] || [ "$3" != "" ]; then + echo "Usage: $0 " + exit 1 +fi +infile=$1 +outfile=$2 + +if [ ! -f ${infile} ]; then + echo "ERROR! File not found: ${infile}" + exit 1 +fi + +cat ${infile} | awk \ + 'BEGIN{line=1000; npar=0} + {if ($1==""){line=0; print $0} + else {line=line+1; + if (line==1){npar=$1; print $0} + else if (line<=1+npar){split("AAA"$0,a,FS,seps); # see https://stackoverflow.com/a/40456663 (add AAA to keep leading whitespaces) + a[6]=sprintf("%"length($5)"d",0); # 1st color is field 5 (but a[6] because of AAA) + a[7]=sprintf("%"length($6)"d",0); # 2nd color is field 6 (but a[7] because of AAA) + printf("%s",seps[1]); # print only leading whitespaces (not AAA) + for(i=2;i<=NF+1;i++) printf("%s%s",a[i],seps[i]); # NF+1 because of AAA + print ""} # print newline + else print $0}}' > ${outfile}