/usr/share/xcrysden/Tcl/cxxAdvGeom.tcl is in xcrysden-data 1.5.60-1.
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 | #############################################################################
# Author: #
# ------ #
# Anton Kokalj Email: Tone.Kokalj@ijs.si #
# Department of Physical and Organic Chemistry Phone: x 386 1 477 3523 #
# Jozef Stefan Institute Fax: x 386 1 477 3811 #
# Jamova 39, SI-1000 Ljubljana #
# SLOVENIA #
# #
# Source: $XCRYSDEN_TOPDIR/Tcl/cxxAdvGeom.tcl
# ------ #
# Copyright (c) 1996-2003 by Anton Kokalj #
#############################################################################
proc cxxAdvGeom.manualOption {{retry 0}} {
global system AdvGeom
set file $system(SCRDIR)/CRYSTAL.option
set helpText {#
# Please add an "advanced geometrical" option manually. Refer
# to CRYSTAL Manual if you want to get a help on
# "advanced geometrical option"
#
# Start at the begining of next line:
}
if { $retry == 0 } {
WriteFile $file $helpText w
} else {
set old [ReadFile -nonewline $file]
set text [format "%s%s\n" $helpText $old]
WriteFile $file $text w
}
update
xcEditFile $file -foreground
#
# drop the comments from file
#
set content {}
foreach line [split [ReadFile -nonewline $file] \n] {
if { [string match *\#* $line] == 0 } {
if { $line != {} } {
append option [format "%s\n" $line]
}
}
}
xcDebug -stderr "manualOption:"
xcDebug -stderr "-------------"
xcDebug -stderr $option
#
# register the option
#
set n [xcAdvGeomState new]
set AdvGeom($n,option) $option
#
# check if option is OK
#
set cxxInput [MakeInput]
set inp xc_inp.$system(PID)
set out xc_out.$system(PID)
WriteFile $inp $cxxInput w
set status [cxxAdvGeom.testINPUT $inp $out]
if { $status == "noretry" } {
xcAdvGeomState delete
return 0
} elseif { $status == "retry" } {
xcAdvGeomState delete
set status [cxxAdvGeom.manualOption retry]
return $status
} else {
#
# option is OK -> update the display
#
GenCommUndoRedo "Add an Option Manually"
CalStru
xcUpdateState
return 1
}
}
proc cxxAdvGeom.viewScript {} {
xcDisplayVarText [MakeInput] {CRYSTAL Input Script}
}
proc cxxAdvGeom.manualEdit {{retry 0}} {
global system cxx AdvGeom
if { $retry == 0 } {
set input [MakeInput]
} else {
set input $cxx(tmpInputContent)
}
#
# edit a file
#
cd $system(SCRDIR)
set inp xc_inp.$system(PID)
set out xc_out.$system(PID)
WriteFile $inp $input w
update
xcEditFile $inp -foreground
# handle correctly the EXTPRT/COORPRT/STOP keywords
set cxx(tmpInputContent) [cxxHandleEXTPRT [ReadFile -nonewline $inp]]
WriteFile $inp $cxx(tmpInputContent) w
#
# test a new file
#
set status [cxxAdvGeom.testINPUT $inp $out]
if { $status == "noretry" } {
return 0
} elseif { $status == "retry" } {
set status [cxxAdvGeom.manualEdit retry]
return $status
} else {
#
# option is OK -> proceed
#
# register the option
set n [xcAdvGeomState new]
set AdvGeom($n,edit) $cxx(tmpInputContent)
GenCommUndoRedo "Edit Manually"
CalStru
xcUpdateState
return 1
}
}
proc cxxAdvGeom.testINPUT {inp out} {
global system
set catchCode [catch {exec $system(c95_integrals) < $inp > $out} errMsg]
if { $errMsg == {} } {
set errMsg "CRYSTAL module: $system(c95_integrals) exited with and
exit status 0, but the \"ERROR ****\" string
exists in the output"
}
if { $errMsg == "FORTRAN STOP" && $catchCode } {
# printing the "FORTRAN STOP" to stderr caused the error.
set catchCode 0
}
set content [ReadFile $out]
if { [string match "*ERROR \*\*\*\**" $content] || $catchCode > 0 } {
# option is BAD - and error occured!!!
set id [tk_dialog [WidgetName] ERROR \
"An ERROR occur while executing CRYSTAL module: $system(c95_integrals)" error 0 OK ErrorInfo {View Crystal Ouput}]
if { $id == 1 } {
set t [xcDisplayVarText $errMsg {Error Info}]
tkwait window $t
} elseif { $id == 2 } {
set cxxOutput [ReadFile $out]
set t [xcDisplayVarText $cxxOutput {Crystal Ouput}]
tkwait window $t
}
# ask user "Do you want top retry?
set id [tk_dialog [WidgetName] QUESTION \
"Do You want to retry ?" question 1 No Yes]
if { $id == 1 } {
return retry
} else {
return noretry
}
} else {
return 1
}
}
proc cxxHandleEXTPRT {geoInput} {
# maybe EXTPRT/COORPRT/STOP are already specified, but there may
# be some additional geometry manipulation after EXTPRT keyword,
# so the only safe thing is to throw that out and specifying it
# again
xcDebug -debug "bug-fixing: geoInput: $geoInput"
set swap $geoInput
regsub -all EXTPRT|COORPRT|STOP $swap {} geoInput
append geoInput "\nEXTPRT\nCOORPRT\nSTOP\n"
# skip empty lines
set geoInput [xcSkipEmptyLines $geoInput]
xcDebug -debug "bug-fixing: geoInput_new: $geoInput"
return $geoInput
}
|