bin/checkvasp in vasputils-0.0.11 vs bin/checkvasp in vasputils-0.0.12
- old
+ new
@@ -1,80 +1,111 @@
#! /usr/bin/env ruby
# coding: utf-8
-# Show state of vasp geometry optimization calculations.
+puts "'checkvasp' is obsoleted. Use showvaspdir and showvaspgeomopt."
+exit
-#require "vasputils/calcseries.rb"
-require "rubygems"
-gem "vasputils"
-require "vasputils.rb"
-
-#require "vasputils/vaspgeomopt.rb"
-#require "vasputils/vaspdir.rb"
-require "pp"
+## Show state of vasp geometry optimization calculations.
+#
+##require "vasputils/calcseries.rb"
+#require "rubygems"
+#gem "vasputils"
+#require "vasputils.rb"
+#
+#require "pp"
#require "optparse"
-
-LONGEST_STATE = :terminated.size
-KLASSES = [VaspUtils::VaspDir, VaspUtils::VaspGeometryOptimizer]
-
-dirs = ARGV
-dirs = Dir.glob("*").sort if ARGV.empty?
-
-def guess(dir)
- KLASSES.each do |klass|
- begin
- vd = klass.new(dir)
- return klass
- rescue klass::InitializeError
- end
- end
- raise "Cannot identify class for directory #{dir}."
-end
-
-dirs.each do |dir|
- next unless File.directory? dir
-
- begin
- klass = guess(dir)
- klass_name = klass.to_s
- rescue
- klass_name = "UnknownDir"
- end
-
- printf "%-11s ", klass_name
-
- case klass_name
- when "VaspUtils::VaspDir"
- calc = klass.new(dir)
- printf "%-10s ", calc.state
- #pp calc.outcar
- printf "%5s ", ""
- begin
- outcar = calc.outcar
- printf "%8.3f %3d (%3d) ",
- outcar[:totens][-1], outcar[:ionic_steps], outcar[:electronic_steps]
- rescue
- printf "%8s %3s (%3s) ", " "*8, " "*3, " "*3
- end
-
- when "VaspUtils::VaspGeometryOptimizer"
- calc = klass.new(dir)
- printf "%-10s ", calc.state
-
- ld = calc.latest_dir
- printf "%5s ", ld.dir.sub(/.*try/, "try")
- begin
- outcar = ld.outcar
- printf "%8.3f %3d (%3d) ",
- outcar[:totens][-1], outcar[:ionic_steps], outcar[:electronic_steps]
- rescue
- printf "%8s %3s (%3s) ", " "*8, " "*3, " "*3
- end
-
- when "UnknownDir"
- printf "-" * 35
- printf " "
-
- end
- puts dir
-
-end
+#
+### option analysis
+#OPTIONS = {}
+#op = OptionParser.new
+#OPTIONS[:show_state] = []
+#op.on("-f", "--finished" , "Show finished. -a is ignored."){OPTIONS[:show_state] << :finished}
+#op.on("-y", "--yet" , "Show yet." ){OPTIONS[:show_state] << :yet}
+#op.on("-t", "--terminated", "Show terminated." ){OPTIONS[:show_state] << :terminated}
+#op.on("-s", "--started" , "Show sarted." ){OPTIONS[:show_state] << :started}
+#op.on("-l", "--files-with-matches", "Show filename only." ){OPTIONS[:filename ] = true}
+#op.parse!(ARGV)
+#
+### if all select are not set, all are set.
+#if OPTIONS[:show_state].size == 0
+# OPTIONS[:all] = true
+#end
+##pp OPTIONS; exit
+#
+#LONGEST_STATE = :terminated.size
+#KLASSES = [VaspUtils::VaspDir, VaspUtils::VaspGeometryOptimizer]
+#
+#dirs = ARGV
+#dirs = Dir.glob("*").sort if ARGV.empty?
+#
+#def guess(dir)
+# KLASSES.each do |klass|
+# begin
+# vd = klass.new(dir)
+# return klass
+# rescue klass::InitializeError
+# end
+# end
+# raise "Cannot identify class for directory #{dir}."
+#end
+#
+#def show(klass_name, state, try, toten, i_step, e_step, dir)
+# if (OPTIONS[:all]) || (OPTIONS[:show_state].include? state)
+# unless OPTIONS[:filename]
+# printf "%-11s ", klass_name
+# printf "%-10s ", state
+# printf "%5s ", try
+# printf "%17s %3s (%3s) ", toten, i_step, e_step
+# end
+# print dir
+# puts
+# end
+#end
+#
+#dirs.each do |dir|
+# next unless File.directory? dir
+#
+# begin
+# klass = guess(dir)
+# klass_name = klass.to_s
+# rescue
+# klass_name = "UnknownDir"
+# end
+#
+# case klass_name
+# when "VaspUtils::VaspDir"
+# klass_name = "VaspDir"
+# calc = klass.new(dir)
+# state = calc.state
+# try = ""
+# begin
+# outcar = calc.outcar
+# toten = sprintf("%17.6f", outcar[:totens][-1].to_f)
+# i_step = outcar[:ionic_steps]
+# e_step = outcar[:electronic_steps]
+# rescue
+# toten = i_step = e_step = ""
+# end
+#
+# when "VaspUtils::VaspGeometryOptimizer"
+# klass_name = "VaspGeomOpt"
+# calc = klass.new(dir)
+# state = calc.state
+#
+# ld = calc.latest_dir
+# try = sprintf "%5s", ld.dir.sub(/.*try/, "try")
+# begin
+# outcar = ld.outcar
+# toten = sprintf("%15.6f ", outcar[:totens][-1].to_f)
+# i_step = outcar[:ionic_steps]
+# e_step = outcar[:electronic_steps]
+# rescue
+# toten = i_step = e_step = ""
+# end
+#
+# when "UnknownDir"
+# klass_name = "UnknownDir"
+# state = try = toten = i_step = e_step = ""
+# end
+# show(klass_name, state, try, toten, i_step, e_step, dir)
+#
+#end