1 | if {[llength $argv] != 1} { |
---|
2 | wm withdraw . |
---|
3 | tk_dialog .err {Wrong Args} \ |
---|
4 | "$argv0: argument should be a .EXP file name" \ |
---|
5 | error 0 Continue |
---|
6 | exit |
---|
7 | } |
---|
8 | |
---|
9 | set filename [lindex $argv 0] |
---|
10 | |
---|
11 | set expgui(font) 14 |
---|
12 | set expgui(debug) 0 |
---|
13 | |
---|
14 | pack [label .l -text "Reading $filename\nPlease wait"] |
---|
15 | update |
---|
16 | wm protocol . WM_DELETE_WINDOW {puts ""; exit} |
---|
17 | #============================================================================= |
---|
18 | #---------------------------------------------------------------- |
---|
19 | # where are we? |
---|
20 | set expgui(script) [info script] |
---|
21 | # translate links -- go six levels deep |
---|
22 | foreach i {1 2 3 4 5 6} { |
---|
23 | if {[file type $expgui(script)] == "link"} { |
---|
24 | set link [file readlink $expgui(script)] |
---|
25 | if { [file pathtype $link] == "absolute" } { |
---|
26 | set expgui(script) $link |
---|
27 | } { |
---|
28 | set expgui(script) [file dirname $expgui(script)]/$link |
---|
29 | } |
---|
30 | } else { |
---|
31 | break |
---|
32 | } |
---|
33 | } |
---|
34 | # fixup relative paths |
---|
35 | if {[file pathtype $expgui(script)] == "relative"} { |
---|
36 | set expgui(script) [file join [pwd] $expgui(script)] |
---|
37 | } |
---|
38 | set expgui(scriptdir) [file dirname $expgui(script) ] |
---|
39 | #---------------------------------------------------------------- |
---|
40 | source [file join $expgui(scriptdir) opts.tcl] |
---|
41 | # fetch EXP file processing routines |
---|
42 | source [file join $expgui(scriptdir) readexp.tcl] |
---|
43 | # commands for running GSAS programs |
---|
44 | #source [file join $expgui(scriptdir) gsascmds.tcl] |
---|
45 | # override options with locally defined values |
---|
46 | set filelist [file join $expgui(scriptdir) localconfig] |
---|
47 | if {$tcl_platform(platform) == "windows"} { |
---|
48 | lappend filelist "c:/gsas.config" |
---|
49 | } else { |
---|
50 | lappend filelist [file join ~ .gsas_config] |
---|
51 | } |
---|
52 | catch { |
---|
53 | foreach file $filelist { |
---|
54 | if [file exists $file] {source $file} |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | SetTkDefaultOptions $expgui(font) |
---|
59 | |
---|
60 | if {![file exists $filename]} { |
---|
61 | # read error |
---|
62 | wm withdraw . |
---|
63 | tk_dialog .err {Bad file} \ |
---|
64 | "$argv0: error\nfile $filename not found" \ |
---|
65 | error 0 Continue |
---|
66 | exit |
---|
67 | } |
---|
68 | set fmt [expload $filename] |
---|
69 | if {$fmt < 0} { |
---|
70 | # read error |
---|
71 | wm withdraw . |
---|
72 | tk_dialog .err {Bad file} \ |
---|
73 | "$argv0: error reading $filename\nThis is not a valid GSAS .EXP file" \ |
---|
74 | error 0 Continue |
---|
75 | exit |
---|
76 | } |
---|
77 | mapexp |
---|
78 | if {[llength $expmap(phaselist)] == 0} { |
---|
79 | # read error |
---|
80 | wm withdraw . |
---|
81 | tk_dialog .err {Bad file} \ |
---|
82 | "$argv0: error reading $filename\nNo phases found" \ |
---|
83 | error 0 Continue |
---|
84 | exit |
---|
85 | } |
---|
86 | if {[llength $expmap(phaselist)] > 1} { |
---|
87 | # count non-mm phases |
---|
88 | set i 0 |
---|
89 | foreach p $expmap(phaselist) type $expmap(phasetype) { |
---|
90 | if {$type != 4} {incr i; set phase $p} |
---|
91 | } |
---|
92 | if {$i > 1} { |
---|
93 | # need to select a phase |
---|
94 | .l config -text "Select a phase" |
---|
95 | foreach p $expmap(phaselist) type $expmap(phasetype) { |
---|
96 | set n [phaseinfo $p name] |
---|
97 | pack [radiobutton .p$p -text "Phase $p: $n" -variable phase \ |
---|
98 | -value $p] -anchor w |
---|
99 | if {$type == 4} { |
---|
100 | .p$p config -state disabled |
---|
101 | } |
---|
102 | } |
---|
103 | wm withdraw . |
---|
104 | update idletasks |
---|
105 | set x [expr {[winfo screenwidth .]/2 - [winfo reqwidth .]/2}] |
---|
106 | set y [expr {[winfo screenheight .]/2 - [winfo reqheight .]/2}] |
---|
107 | wm geom . +$x+$y |
---|
108 | wm deiconify . |
---|
109 | grab . |
---|
110 | focus . |
---|
111 | tkwait variable phase |
---|
112 | } |
---|
113 | } else { |
---|
114 | set phase $expmap(phaselist) |
---|
115 | if {$expmap(phasetype) == 4} { |
---|
116 | tk_dialog .err {Only mm phase} \ |
---|
117 | "$argv0: unable to read from $filename\nOnly a macromolecular phase is present." \ |
---|
118 | error 0 Continue |
---|
119 | exit |
---|
120 | } |
---|
121 | } |
---|
122 | foreach v {a b c alpha beta gamma} { |
---|
123 | lappend l [phaseinfo $phase $v] |
---|
124 | } |
---|
125 | set l1 {} |
---|
126 | foreach a $expmap(atomlist_$phase) { |
---|
127 | set l2 {} |
---|
128 | foreach p {label x y z type frac} { |
---|
129 | lappend l2 [atominfo $phase $a $p] |
---|
130 | } |
---|
131 | if {[atominfo $phase $a temptype] == "I"} { |
---|
132 | lappend l2 [atominfo $phase $a Uiso] |
---|
133 | } else { |
---|
134 | set ueq {} |
---|
135 | catch { |
---|
136 | set ueq [expr { |
---|
137 | ([atominfo $phase $a U11] + |
---|
138 | [atominfo $phase $a U22] + |
---|
139 | [atominfo $phase $a U33]) /3. |
---|
140 | }] |
---|
141 | } |
---|
142 | lappend l2 $ueq |
---|
143 | # } |
---|
144 | lappend l1 $l2 |
---|
145 | } |
---|
146 | puts [list [phaseinfo $phase spacegroup] $l $l1] |
---|
147 | exit |
---|