This file is indexed.

/usr/share/cgnstools/util.tcl is in cgns-convert 3.3.0-5.

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

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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# util.tcl - CGNS utility routines

array set Tools {
  subseti i
  subsetj j
  subsetk k
  cgnssol ""
  solbase ""
  solbase,flag 1
  bboxpad ""
  bboxpad,flag 1
  maxdepth ""
  maxdepth,flag 1
  maxelem ""
  maxelem,flag 1
  extrapolate 0
}

proc interpolate_cgns {w name exe} {
  global ProgData Tools Font

  if {$ProgData(file,name) == ""} return
  set cmd [get_executable $exe 1]
  if {$cmd == ""} return

  set Tools(cgnsinput) $ProgData(file,name)
  if {$Tools(cgnsoutput) == ""} {
    set Tools(cgnsoutput) $ProgData(file,name)
  }

  toplevel $w
  wm title $w "Interpolate Solution"
  wm transient $w .
  wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0}

  set labw 13

  FrameCreate $w.cgnssol -text "CGNS Solution" -font $Font(bold)
  pack $w.cgnssol -side top -pady 2 -fill x
  set wf [FrameGet $w.cgnssol]

  set f [frame $wf.file]
  pack $f -side top -fill x
  label $f.lab -text Filename -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(cgnssol) -width 30
  pack $f.ent -side left -fill x -expand 1
  button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnssol"
  pack $f.but -side right -fill y

  set f [frame $wf.basenum]
  pack $f -side top -fill x
  label $f.lab -text "Base Index" -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(solbase) -width 10
  pack $f.ent -side left
  checkbutton $f.but -text default \
    -variable Tools(solbase,flag) -onvalue 1 -offvalue 0 \
    -command "tools_state solbase $f.ent"
  pack $f.but -side left

  tools_state solbase $f.ent

  FrameCreate $w.cgnsinput -text "CGNS Grid" -font $Font(bold)
  pack $w.cgnsinput -side top -pady 2 -fill x
  set wf [FrameGet $w.cgnsinput]

  set f [frame $wf.file]
  pack $f -side top -fill x
  label $f.lab -text Filename -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(cgnsinput) -width 30
  pack $f.ent -side left -fill x -expand 1
  button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnsinput"
  pack $f.but -side right -fill y

  set f [frame $wf.basenum]
  pack $f -side top -fill x
  label $f.lab -text "Base Index" -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(basenum) -width 10
  pack $f.ent -side left
  checkbutton $f.but -text default \
    -variable Tools(basenum,flag) -onvalue 1 -offvalue 0 \
    -command "tools_state basenum $f.ent"
  pack $f.but -side left

  tools_state basenum $f.ent

  FrameCreate $w.cgnsoutput -text "CGNS Output" -font $Font(bold)
  pack $w.cgnsoutput -side top -pady 2 -fill x
  set wf [FrameGet $w.cgnsoutput]

  set f [frame $wf.file]
  pack $f -side top -fill x
  label $f.lab -text Filename -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(cgnsoutput) -width 30
  pack $f.ent -side left -fill x -expand 1
  button $f.but -text Browse -pady 0 -command "tools_browse $f.but cgnsoutput"
  pack $f.but -side right -fill y

  set f [frame $wf.basename]
  pack $f -side top -fill x
  label $f.lab -text "Base Name" -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(basename) -width 30
  pack $f.ent -side left -fill x -expand 1
  checkbutton $f.but -text default \
    -variable Tools(basename,flag) -onvalue 1 -offvalue 0 \
    -command "tools_state basename $f.ent {}"
  pack $f.but -side left

  tools_state basename $f.ent ""

  set f [frame $wf.solname]
  pack $f -side top -fill x
  label $f.lab -text "Solution Name" -width $labw -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(solname) -width 30
  pack $f.ent -side left -fill x -expand 1
  checkbutton $f.but -text default \
    -variable Tools(solname,flag) -onvalue 1 -offvalue 0 \
    -command "tools_state solname $f.ent {}"
  pack $f.but -side left

  tools_state solname $f.ent ""

  tools_averaging $w

  FrameCreate $w.treeopts -text "Octtree Options" -font $Font(bold)
  pack $w.treeopts -side top -pady 2 -fill x
  set treeopts [FrameGet $w.treeopts]

  foreach opt {\
    {bboxpad "Bounding Box Padding" 0.01} \
    {maxdepth "Max Octtree Depth" 16} \
    {maxelem "Max Octtree Elements" 256}} {
    set tag [lindex $opt 0]
    set f [frame $treeopts.$tag]
    pack $f -side top -anchor w
    label $f.lab -text [lindex $opt 1] -width 20 -anchor w
    entry $f.ent -textvariable Tools($tag) -width 15
    checkbutton $f.but -text default \
      -variable Tools($tag,flag) -onvalue 1 -offvalue 0 \
      -command "tools_state $tag $f.ent [lindex $opt 2]"
    pack $f.lab $f.ent $f.but -side left
    tools_state $tag $f.ent [lindex $opt 2]
  }

  checkbutton $treeopts.extrap -text "Allow Extrapolation" \
    -variable Tools(extrapolate) -onvalue 1 -offvalue 0
  pack $treeopts.extrap -side top -anchor w

  if {![tools_interact $w check_interpolation]} return

  foreach i {{c solbase} {b basenum} {B basename} {S solname} \
    {p bboxpad} {d maxdepth} {e maxelem}} {
    set opt $Tools([lindex $i 1])
    if {$opt != ""} {
      lappend cmd "-[lindex $i 0]$opt"
    }
  }
  if {$Tools(weight) != ""} {
    lappend cmd -w
  }
  if {$Tools(extrapolate)} {
    lappend cmd -a
  }
  lappend cmd $Tools(cgnssol) $Tools(cgnsinput)
  if {$Tools(cgnsoutput) != ""} {
    lappend cmd $Tools(cgnsoutput)
  }

  tools_run "Solution Interpolation" $cmd $Tools(cgnsoutput)
}

proc check_interpolation {w} {
  global Tools
  if {$Tools(cgnssol) == "" || ![file exists $Tools(cgnssol)]} {
    errormsg "CGNS solution file not specified or does not exist" $w
    return 0
  }
  if {$Tools(cgnsinput) == "" || ![file exists $Tools(cgnsinput)]} {
    errormsg "CGNS grid file not specified or does not exist" $w
    return 0
  }
  if {$Tools(bboxpad) != "" && [catch {expr double($Tools(bboxpad))}]} {
    errormsg "invalid value for bounding box padding" $w
    return 0
  }
  if {$Tools(maxdepth) != "" && [catch {expr int($Tools(maxdepth))}]} {
    errormsg "invalid value for max octtree depth" $w
    return 0
  }
  if {$Tools(maxelem) != "" && [catch {expr int($Tools(maxelem))}]} {
    errormsg "invalid value for max octtree elements" $w
    return 0
  }
  return 1
}

proc extract_subset {w name exe} {
  global ProgData Tools Font

  if {$ProgData(file,name) == ""} return
  set cmd [get_executable $exe 1]
  if {$cmd == ""} return

  set Tools(cgnsinput) $ProgData(file,name)
  if {$Tools(cgnsoutput) == ""} {
    set Tools(cgnsoutput) $ProgData(file,name)
  }

  toplevel $w
  wm title $w "Extract Subset"
  wm transient $w .
  wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0}

  FrameCreate $w.loc -text Directions -font $Font(bold)
  pack $w.loc -side top -pady 2 -fill x
  set f [FrameGet $w.loc]

  foreach n {i j k} {
    checkbutton $f.$n -text "[string toupper $n]-subset" \
    -variable Tools(subset$n) -onvalue $n -offvalue ""
    pack $f.$n -side left -expand 1
  }

  tools_cgnsinput $w 1
  tools_cgnsoutput $w basename
  tools_averaging $w

  if {![tools_interact $w check_subset]} return

  set opts $Tools(weight)
  foreach i {i j k} {
    if {$Tools(subset$i) != ""} {
      append opts $Tools(subset$i)
    }
  }
  lappend cmd -$opts
  foreach i {basenum zonenum} {
    if {$Tools($i) != ""} {
      lappend cmd "-[string index $i 0]$Tools($i)"
    }
  }
  if {$Tools(basename) != ""} {
    lappend cmd "-B$Tools(basename)"
  }
  lappend cmd $Tools(cgnsinput)
  if {$Tools(cgnsoutput) != ""} {
    lappend cmd $Tools(cgnsoutput)
  }

  tools_run "Subset Extraction" $cmd $Tools(cgnsoutput)
}

proc check_subset {w} {
  global Tools
  foreach i {i j k} {
    if {$Tools(subset$i) != ""} {
      return [tools_check_input $w]
    }
  }
  errormsg "no subset directions selected" $w
  return 0
}