#! /usr/bin/env ruby # coding: utf-8 # # USAGE: # qsubvasp [-n num] -c CLUSTER_NAME calc_dir # # [-n INDICATOR] # Integer can be uused as INDICATOR. # If INDICATOR cannot be evaluated as positive integer, # try to find tue hostname of localhost and # key of # the INDICATOR in ~/.machineinfo # Default value is 1. # # calc_dir is a vasp directory as usual, # when with -g option, VaspGeomOpt directory. #require "optparse" require "pp" require "yaml" require "optparse" require "rubygems" gem "comana" require "comana/queuesubmitter.rb" require "comana/machineinfo.rb" require "vasputils/vaspdir.rb" require "vasputils/vaspgeomopt.rb" opts = {} op = OptionParser.new op.on("-c cluster", "--cluster" , "Cluster name."){|v| opts["cluster"] = v } op.on("-n number", "--number", "Indicate node number, or key in ~/.machineinfo."){|v| opts["number"] = v } op.on("-g", "--geom-opt", "Geometry optimization."){ opts["geomopt"] = true} op.parse!(ARGV) def condition_check(opts) # Condition Check mi = MachineInfo.load_file("#{ENV["HOME"]}/.machineinfo") conds = {} # cluster name = opts["cluster"] #pp mi.get_info(name) if name conds["cluster"] = name else puts "-c CLUSTER_NAME is necessary." exit end # target and command unless ARGV.size == 1 puts "Indicate only one directory for vasp. Argument: #{ARGV}" exit end if opts["geomopt"] begin conds["target"] = VaspGeomOpt.new(File.expand_path(ARGV[0])) conds["command"] = "runvasp -g" rescue VaspGeomOpt::NoVaspDirError puts "Seem not to be a directory for VaspGeomOpt #{ARGV}" exit end else begin conds["target"] = VaspDir.new(File.expand_path(ARGV[0])) conds["command"] = "runvasp" rescue VaspDir::InitializeError puts "Seem not to be a directory for VaspDir #{ARGV}" exit end end # number str = opts["number"] num = str.to_i if num > 0 conds["number"] = num else if mi.get_info(name).has_key?(str) conds["number"] = mi.get_info(name)[str] else puts "-n argument must be a positive integer or key in ~/machineinfo." exit end end conds end opts = condition_check(opts) qs = QueueSubmitter.new(opts) #pp qs; exit begin qs.start puts "Submitted. Exit." exit rescue QueueSubmitter::AlreadyStartedError puts "Already started. Exit." exit rescue QueueSubmitter::PrepareNextError puts "Must not happen." exit end