This file is indexed.

/usr/share/cgnstools/convert.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# convert.tcl - CGNS conversion routines

array set Tools {
  cnvfile ""
  location v
  variable p
  varcnv ""
  varcnv,flag 0
  rmini ""
  rmaxi ""
  rminj ""
  rmaxj ""
  rmink ""
  rmaxk ""
  gamma 1.4
  dataclass d
  datacnv ""
  datacnv,flag 0
  datacnv,errs 0
}

array set ConvFiles {
  p primitive.cnv
  c conserved.cnv
  d dimensional.cnv
  n nondimensional.cnv
  u undimensional.cnv
}

array set ConvLabels {
  p Primitive
  c Conserved
  d Dimensional
  n NormalizedByDimensional
  u NormalizedByUnknownDimensional
}

proc convert_location {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 "Solution Location"
  wm transient $w .
  wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0}

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

  radiobutton $f.v -text "Vertex" \
    -variable Tools(location) -value v \
    -command "catch {pack forget $w.rind}"
  radiobutton $f.c -text "Cell Center" \
    -variable Tools(location) -value c \
    -command "catch {pack $w.rind -side top -pady 2 -fill x}"
  pack $f.v $f.c -side left -expand 1

  tools_cgnsinput $w 2
  tools_cgnsoutput $w solname
  tools_averaging $w

  FrameCreate $w.rind -text "Rind Cells" -font $Font(bold)
  if {$Tools(location) == "c"} {
    pack $w.rind -side top -pady 2 -fill x
  }
  set rind [FrameGet $w.rind]

  foreach i {i j k} {
    set f [frame $rind.$i]
    pack $f -side left -expand 1
    checkbutton $f.min -text "min $i" \
      -variable Tools(rmin$i) -onvalue $i -offvalue ""
    checkbutton $f.max -text "max $i" \
      -variable Tools(rmax$i) -onvalue [string toupper $i] -offvalue ""
    pack $f.min $f.max -side top -anchor w
  }

  if {![tools_interact $w]} return

  set opts -$Tools(location)$Tools(weight)
  if {$Tools(location) == "c"} {
    foreach i {i j k} {
      foreach j {rmin rmax} {
        if {$Tools($j$i) != ""} {
          append opts $Tools($j$i)
        }
      }
    }
  }
  lappend cmd $opts
  foreach i {basenum zonenum solnum} {
    if {$Tools($i) != ""} {
      lappend cmd "-[string index $i 0]$Tools($i)"
    }
  }
  if {$Tools(solname) != ""} {
    lappend cmd "-S$Tools(solname)"
  }
  lappend cmd $Tools(cgnsinput)
  if {$Tools(cgnsoutput) != ""} {
    lappend cmd $Tools(cgnsoutput)
  }

  if {$Tools(location) == "c"} {
    tools_run "Vertex to CellCenter" $cmd $Tools(cgnsoutput)
  } else {
    tools_run "CellCenter to Vertex" $cmd $Tools(cgnsoutput)
  }
}

proc convert_variables {w name exe} {
  global ProgData Tools Font ConvLabels

  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 "Solution Variables"
  wm transient $w .
  wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0}

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

  set f [frame $var.f1]
  pack $f -side top -fill x
  radiobutton $f.p -text $ConvLabels(p) -variable Tools(variable) \
    -value p -command {convert_file p varcnv}
  radiobutton $f.c -text $ConvLabels(c) -variable Tools(variable) \
    -value c -command {convert_file c varcnv}
  frame $f.g
  label $f.g.lab -text gamma
  entry $f.g.ent -textvariable Tools(gamma) -width 10
  pack $f.g.lab $f.g.ent -side left
  pack $f.p $f.c $f.g -side left -expand 1

  frame $var.sep -bd 1 -height 2 -relief sunken
  pack $var.sep -side top -fill x -pady 3

  if {$Tools(varcnv) == ""} {
    convert_file $Tools(variable) varcnv
  }

  set f [frame $var.f2]
  pack $f -side top -fill x
  checkbutton $f.use -text "Use Conversion File" \
    -variable Tools(varcnv,flag) -onvalue 1 -offvalue 0
  button $f.edit -text "Edit Conversion File" \
    -command "convert_edit varcnv $w"
  pack $f.use $f.edit -side left -expand 1

  set f [frame $var.f3]
  pack $f -side top -fill x
  label $f.lab -text Filename -width 13 -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(varcnv) -width 20
  pack $f.ent -side left -fill x -expand 1
  button $f.but -text Browse -command "convert_browse varcnv $f.but"
  pack $f.but -side right

  tools_cgnsinput $w 2
  tools_cgnsoutput $w solname

  if {![tools_interact $w check_variables]} return

  if {$Tools(varcnv,flag)} {
    lappend cmd -f$Tools(cnvfile)
  } else {
    lappend cmd -$Tools(variable)
  }
  foreach i {basenum zonenum solnum} {
    if {$Tools($i) != ""} {
      lappend cmd "-[string index $i 0]$Tools($i)"
    }
  }
  if {$Tools(solname) != ""} {
    lappend cmd "-S$Tools(solname)"
  }
  lappend cmd $Tools(cgnsinput)
  if {$Tools(cgnsoutput) != ""} {
    lappend cmd $Tools(cgnsoutput)
  }

  set n $Tools(variable)
  tools_run "$ConvLabels($n) Variables" $cmd $Tools(cgnsoutput)
}

proc convert_file {n ftype} {
  global Tools ConvFiles tcl_platform
  set name $ConvFiles($n)
  set cnvpath [get_file $name]
  if {$cnvpath == ""} {
    set Tools($ftype) $name
  } else {
    if {$tcl_platform(platform) == "windows"} {
      set Tools($ftype) [join [split $cnvpath /] \\]
    } else {
      set Tools($ftype) $cnvpath
    }
  }
}

proc convert_edit {name {parent .}} {
  global Tools _EditFile
  if {$Tools($name) == ""} return
  edit_file .editcnv $Tools($name) $parent
  tkwait window .editcnv
  set Tools($name) $_EditFile(.editcnv,name)
}

proc convert_browse {name w} {
  global Tools tcl_platform
  set fname [FileOpen "Conversion File" $Tools($name) $w \
    {{{Conversion Scripts} {.cnv .clc .txt}} {{All Files} {*}}}]
  if {$fname != ""} {
    if {$tcl_platform(platform) == "windows"} {
      set Tools($name) [join [split $fname /] \\]
    } else {
      set Tools($name) $fname
    }
  }
}

proc check_variables {w} {
  global Tools tcl_platform
  if {$Tools(varcnv,flag)} {
    if {$Tools(varcnv) == ""} {
      errormsg "variable conversion file not specified" $w
      return 0
    }
    set cnvpath [get_file $Tools(varcnv)]
    if {$cnvpath == ""} {
      errormsg "can't find conversion file $Tools(varcnv)" $w
      return 0
    }
    if {$tcl_platform(platform) == "windows"} {
      set Tools(cnvfile) [join [split $cnvpath /] \\]
    } else {
      set Tools(cnvfile) $cnvpath
    }
  }
  if {$Tools(gamma) != ""} {
    if {[catch {expr $Tools(gamma) <= 1.0} nogood] || $nogood} {
      errormsg "invalid value for gamma" $w
      return 0
    }
  }
  return [tools_check_input $w]
}

proc convert_dimensional {w name exe} {
  global ProgData Tools Font ConvLabels

  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 "Dimensionalization"
  wm transient $w .
  wm protocol $w WM_DELETE_WINDOW {set Tools(done) 0}

  FrameCreate $w.var -text "Data Class" -font $Font(bold)
  pack $w.var -side top -pady 2 -fill x
  set var [FrameGet $w.var]

  set f [frame $var.f1]
  pack $f -side top -fill x
  foreach i {d n u} {
    radiobutton $f.$i -text $ConvLabels($i) -variable Tools(dataclass) \
      -value $i -command "convert_file $i datacnv"
    pack $f.$i -side left -expand 1
  }

  frame $var.sep -bd 1 -height 2 -relief sunken
  pack $var.sep -side top -fill x -pady 3

  if {$Tools(datacnv) == ""} {
    convert_file $Tools(dataclass) datacnv
  }

  set f [frame $var.f2]
  pack $f -side top -fill x
  checkbutton $f.use -text "Use Conversion File" \
    -variable Tools(datacnv,flag) -onvalue 1 -offvalue 0
  checkbutton $f.errs -text "Show Parsing Errors" \
    -variable Tools(datacnv,errs) -onvalue 1 -offvalue 0
  button $f.edit -text "Edit Conversion File" \
    -command "convert_edit datacnv $w"
  pack $f.use $f.errs $f.edit -side left -expand 1

  set f [frame $var.f3]
  pack $f -side top -fill x
  label $f.lab -text "Filename" -width 13 -anchor w
  pack $f.lab -side left
  entry $f.ent -textvariable Tools(datacnv) -width 20
  pack $f.ent -side left -fill x -expand 1
  button $f.but -text Browse -command "convert_browse datacnv $f.but"
  pack $f.but -side right

  tools_cgnsinput $w 2
  tools_cgnsoutput $w

  if {![tools_interact $w check_dimensional]} return

  lappend cmd -$Tools(dataclass)
  if {$Tools(datacnv,errs)} {
    lappend cmd -v
  }
  if {$Tools(datacnv,flag)} {
    lappend cmd -f$Tools(cnvfile)
  }
  foreach i {basenum zonenum solnum} {
    if {$Tools($i) != ""} {
      lappend cmd "-[string index $i 0]$Tools($i)"
    }
  }
  lappend cmd $Tools(cgnsinput)
  if {$Tools(cgnsoutput) != ""} {
    lappend cmd $Tools(cgnsoutput)
  }

  set n $Tools(dataclass)
  tools_run $ConvLabels($n) $cmd $Tools(cgnsoutput)
}

proc check_dimensional {w} {
  global Tools tcl_platform
  if {$Tools(datacnv,flag)} {
    if {$Tools(datacnv) == ""} {
      errormsg "data class conversion file not specified" $w
      return 0
    }
    set cnvpath [get_file $Tools(datacnv)]
    if {$cnvpath == ""} {
      errormsg "can't find conversion file $Tools(datacnv)" $w
      return 0
    }
    if {$tcl_platform(platform) == "windows"} {
      set Tools(cnvfile) [join [split $cnvpath /] \\]
    } else {
      set Tools(cnvfile) $cnvpath
    }
  }
  return [tools_check_input $w]
}