File indexing completed on 2024-04-06 11:56:23
0001
0002
0003 infile=$1
0004 iovfile=$2
0005 nbreaks=-1
0006 if [[ $3 != "" ]];then
0007 let nbreaks=$3
0008 fi
0009
0010 iovlist=()
0011 while IFS='' read -r line || [[ -n "$line" ]]; do
0012 iovlist+=($line)
0013 done < $iovfile
0014
0015 let niovs=${
0016 let lastiov=$niovs-1
0017 for (( i=0; i<${niovs}; i++ ));
0018 do
0019 let ni=$i+1
0020
0021 core=${infile%%.dat*}
0022 newfile=$core".dat_"${iovlist[i]}
0023 rm -f $newfile
0024
0025 str=""
0026 let nadded=1
0027
0028 for f in $(cat $infile)
0029 do
0030
0031 if [[ $f != "#"* ]];then
0032 nobegin=${f
0033 noend=${nobegin%%/00000*}
0034 let run=${noend/\//}
0035 addfile=${f%*,}
0036 if [ $i -eq $lastiov ];then
0037 if [ $run -ge ${iovlist[i]} ]; then
0038
0039 appendstr=""
0040 if [ $nadded -eq $nbreaks ];then
0041 appendstr="\n"
0042 let nadded=0
0043 else
0044 appendstr=","
0045 fi
0046 addfile=$addfile$appendstr
0047
0048 str=$str$addfile
0049 let nadded=nadded+1
0050 fi
0051 elif [ $run -ge ${iovlist[i]} ] && [ $run -lt ${iovlist[$ni]} ]; then
0052
0053 appendstr=""
0054 if [ $nadded -eq $nbreaks ];then
0055 appendstr="\n"
0056 let nadded=0
0057 else
0058 appendstr=","
0059 fi
0060 addfile=$addfile$appendstr
0061
0062 str=$str$addfile
0063 let nadded=nadded+1
0064 fi
0065 fi
0066
0067 done
0068
0069 str2=${str%,}
0070 if [[ $str2 != "" ]];then
0071 echo -e $str2 >> $newfile
0072 else
0073 $newfile" is empty. Please skip!"
0074 fi
0075
0076 done