This file is indexed.

/usr/bin/gfsjoin is in gerris 20110329-dfsg.2-1build2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# script to join gerris output files in parallel simulations


help ()
{
    echo ""
    echo "Usage: gfsjoin Simfile Directory Rootname NP Tailname > Joined"
    echo ""
    echo "Simfile:        Name of the simulation file"
    echo "Directory:      Directory where results are located"
    echo "Rootname:       File root name"
    echo "NP:             Number of processors"
    echo "Tailname:       File tail name"
    echo ""
    exit
}

#verbose=1

message ()
{
    if test $verbose; then
	echo $1 > /dev/stdout
    fi
}

errmessage ()
{
        echo $1 > /dev/stderr
}


#------------------------------------------------------------------------------

#checking input
if [ $# -ne 5 ]; then
   if [ $1 == '-h' ]; then
       help
   else
        errmessage "Input error, this command requires 5 arguments"
        errmessage "Type gfsjoin -h for more info"
   fi
exit
fi

# removing all blanks and tabs immediately before the end of line.
# Comments are also removed to avoid errors
tmp=`mktemp -d`
sed -e 's/#.*//' -e 's/[ ^I]*$//' -e '/^$/ d' $1 | sed '/^#/ d'  > $tmp/sim.tmp

c1=$3
c2=$5
c3="$tmp/sim.tmp"
numproc=$4
dir=$2

# checking operations
y=`expr ${#c2} - 2`
tailst=`expr substr $c2 $y 3`

if [ $tailst == 'gfs' ]; then
   compress=0
else
        if [ $tailst == '.gz' ]; then
          compress=1
          c2=`expr substr $c2 1 $[$y-1]`
        else
          errmessage "Your simulation file has not a valid extension ("$tailst")"
          errmessage "The correct file extensions are either .gfs or .gz"
          exit
        fi
fi

p1=$(awk '/GfsSimulation/ {print $1}' $c3)
p2=$(awk '/GfsSimulation/ {print $2}' $c3)

i=1
if [ $compress -eq 1 ]; then
while [ $i -le $numproc ]; do
    gunzip -q ${dir}'/'$c1$[$i-1]$c2
    i=$[$i+1]
done
fi

message 'Creating output................'

# Variables to handle the files names
i=0
while [ $i -lt $numproc ]; do
    mainfile[$i]=${dir}'/'$c1$i$c2
    message "${mainfile[$i]}"
    i=$[$i+1]
done

# Copying the first two lines of the simulation file
head -2 ${mainfile[0]} > $tmp/tmp.tmp
# Inserting the correct number of boxes and connections
sed -e '/GfsSimulation/ s/[0-9]*/'$p1'/1' -e '/GfsSimulation/s/[0-9]*/'$p2'/2' $tmp/tmp.tmp

# Copying solid file (if any)
sed -n '/SurfaceFile/ p' $c3

# The first two lines are removed because they have useless information.
# As I have already inserted the solid, this information is also removed from the files
i=0
while [ $i -lt $numproc ]; do
    nend=$(echo -n $(sed -n '/GtsSurface/,/Gfs/ p' ${mainfile[$i]} | tail -1 | awk '{print $1}' ))
    nend=$(echo -n $(awk '$1 ~ /'$nend'/ {print NR}' ${mainfile[$i]} | head -1 ))
    nend=$[$nend+0]
    if [ $nend -ne 0 ]; then
	sed -e '1,2 d' -e '/GtsSurface/,'$[$nend-1]' d' ${mainfile[$i]} > $tmp/tmpfile$i
    else
	more +3 ${mainfile[$i]} > $tmp/tmpfile$i
    fi
    i=$[$i+1]
done

#Taking the initial common arguments
sed -n '1,/GfsBox/p' $tmp/tmpfile0 | sed '$ d' 

# Creating temporal file with all the boxes (sed is used to remove the 
# local connectivities in case they will be equal)
# boxes in proc 0
(sed -n '/GfsBox/,$p' $tmp/tmpfile0 | awk '
BEGIN{}
{
condition1 = ( $3 == "right" || $3 == "left" || $3 == "top" || $3 == "bottom" || $3 == "front" || $3 == "back" )
if(!(NF == 3 && condition1)) {print $0}
}
END{}') > $tmp/tmp.tmp

# the rest of boxes
i=1
while [ $i -lt $numproc ]; do
    (sed -n '/GfsBox/,$p' $tmp/tmpfile$i | awk '
BEGIN{}
{
condition1= ( $3 == "right" || $3 == "left" || $3 == "top" || $3 == "bottom" || $3 == "front" || $3 == "back" )
if(!(NF == 3 && condition1)) {print $0}
}
END{}') >> $tmp/tmp.tmp
    i=$[$i+1]
done

message
message "IMPORTANT: This script assumes that the \"id\" is in correlative order in your simulation file (not the pid)"
message

awk '$1 ~ /GfsBox/ && /id =/ {print $0}' $tmp/tmp.tmp | \
    awk 'BEGIN{}
     { i = 0
       do {
           i++
       } while ( $i !~ /^id/ )
        print $(i+2)
}
END{}' > $tmp/tmp.tmp2

# The last box in the temporal file is:
lastid=$(tail -1 $tmp/tmp.tmp2)
# And the total number of boxes:
numboxes=$(wc -l $tmp/tmp.tmp2 | awk '{print $1}')

message "Putting boxes in order in the final file"
# Boxes are pasted in the final file in order (it is assumed to be sequential)
i=1
while [ $i -le $numboxes ]; do
    if [ $i -ne $lastid ]; then
	message -n "$i ,"
        n0=$(awk '{if($1 == '$i') {print NR}}' $tmp/tmp.tmp2)
        n1=$(awk 'FNR == '$[$n0+1]' {print $1}' $tmp/tmp.tmp2)
        # Taking the lines of this range (the last line is removed
	# because it corresponds to the next box)
        (awk '/id = '$i' pid/,/id = '$n1' pid/ {print $0}' $tmp/tmp.tmp | head -n -1)
        i=$[$i+1]
    else
	message -n "$i ,"
        nf=$(awk '$1 ~ /GfsBox/ && $5 == '$i' && $3 ~ /id/ {print NR}' $tmp/tmp.tmp)
        more +$nf $tmp/tmp.tmp
        i=$[$i+1]
    fi
done

# Copying the global conectivities
tail -n $p2 $c3

message
message
if [ $compress -eq 1 ]; then
	message 'compressing files again'
	gzip -f -q ${dir}'/'${c1}*'.gfs'
fi

rm -rf $tmp