Example #1
0
def main():

    # setup the command line parser options 
    parser = OptionParser() 
    parser.add_option("-T", "--temperature", dest="T", type="float",
                      help="simulation temperature in Kelvin") 
    parser.add_option("-b", "--beta", dest="b", type="float",
                      help="number of particles") 
    parser.add_option("-d", "--delta", dest="d", type="float",
                      help="strength of SzSz interaction") 
    parser.add_option("-r", "--replica", dest = "r",type="int",
                      help="number of replica copies") 
    parser.add_option("-x", "--Lx", dest="x", type="int",
                      help="lattice width") 
    parser.add_option("-y", "--Ly", dest="y", type="int",
                      help="lattice height") 
    parser.add_option('-f', dest="folder", 
            help="path to the folder containing state files to be resubmitted. Default = ./OUTPUT")
    parser.add_option("--run",type=str,
            help="optional id that will be added to the submit script's name")
    parser.add_option("-e", "--exclude", action="append", dest="exID", type="int",\
            help="a list of PIMC ID numbers to exclude")
    parser.add_option("-c", "--cluster", dest="cluster", choices=['westgrid','sharcnet','scinet','clumeq','bluemoon'],\
            help="target cluster: [westgrid,sharcnet,scinet,clumeq,bluemoon]") 

    parser.set_defaults(load=False)
    parser.set_defaults(folder='OUTPUT')
    parser.set_defaults(run='')

    # parse the command line options and get the reduce flag
    (options, args) = parser.parse_args() 

    # remember the current path but switch temporary to the files location folder
    CurrentFolder  = os.getcwd() 
    options.folder = options.folder.rstrip('/')
    os.chdir(options.folder)

    if (not options.cluster):
        parser.error("need to specify a cluster")


    # Get the data string and create the pimc helper object
    ssexy = ssexyhelp.SSEXYHelp(options)
    ssexy.getSimulationParameters()
    if  (not ssexy.id): 
        print "No filenames detected satisfying those criteria"
        sys.exit()
    
    
    estFileNames  = ssexy.getFileList('estimator',idList=ssexy.id) 

    # If we have excluded any ID's we remove them from the list
    if options.exID:
        for id in options.exID:
            for n,fname in enumerate(logFileNames):
                if int(id) == ssexy.getID(fname):
                    logFileNames.pop(n)

    #Load sumbission command lines from the log files 
    SubmitData = []
    i = 0
    N = 0
    nN= 0

    #print As
    for estFile in estFileNames:   
        stateFile =  'state'+estFile[9:]
        fsize = len(open(estFile,'r').readlines())
        #if os.path.getsize(stateFile) != 0: 
        if fsize > 100:
            PIMCommand = getPIMCommand(estFile)
            PIMCommand += '-m %d ' %(1500)
            PIMCommand += '-s %s/%s' %(options.folder,stateFile)
            SubmitData.append(PIMCommand)

    #switch back to folder we used to be 
    os.chdir(CurrentFolder)
     
    # Now create the submission files
    if options.cluster == 'westgrid':
        clusters.westgrid(SubmitData,options.run)

    if options.cluster == 'sharcnet':
        clusters.sharcnet(SubmitData,options.run)

    if options.cluster == 'scinet':
        clusters.scinet(SubmitData,options.run)

    if options.cluster == 'clumeq':
        clusters.clumeq(SubmitData,options.run)

    if options.cluster == 'bluemoon':
        clusters.bluemoon(SubmitData,options.run)
Example #2
0
def main(): 

    # setup the command line parser options 
    parser = ArgumentParser(description="Build submission scripts for various clusters") 
    parser.add_argument("file", help='configuration file')
    parser.add_argument('-b','--batch', type=int, help='Turn on batch mode. Sets the number of RG seeds.')
    parser.add_argument('-s','--shift', type=int, default = 0, help='Seed shift for the batch job')
    parser.add_argument("cluster", metavar="cluster", choices=['clumeq','westgrid','sharcnet','scinet','bluemoon'],\
            help="target cluster: [westgrid,sharcnet,scinet,clumeq,bluemoon]") 
    parser.add_argument("-r",type=str, dest='run', default="",help="optional JobId number that will be added to the scripts name")
    # parse the command line options
    args = parser.parse_args() 
    inFileName = args.file

    if (not args.cluster):
        parser.error("need to specify a cluster")

    # We open up the input file, and read in all lines.
    inFile = open(inFileName,'r')
    inLines = inFile.readlines();

    # The first line of the file contains all static pimc options
    staticPIMCOps = inLines[0].rstrip('\n')

    # The next lines contains the short-name of the pimc option
    # and a list of values.  
    optionValue = {}
    numOptions = {}
    for line in inLines[1:]:
        option = line.split()
        flag = option.pop(0)
        # Now we determine if we have a range or if we have actually included the values
        if option[0].find(':') != -1:

            # determine if we have floats or ints
            if option[0].find('.') != -1:
                type_converter = lambda x: float(x)
            else:
                type_converter = lambda x: int(x)

            dataRange = option[0].split(':')
            print dataRange
            # Parse the range string
            dataMin = type_converter(dataRange[0])
            dataMax = type_converter(dataRange[1])
            dataStep = type_converter(dataRange[2])

            # construct the option list
            vals = [dataMin]
            while vals[-1] < dataMax:
                vals.append(vals[-1]+dataStep)

            # assign the option list
            if flag in optionValue.keys():
	       optionValue[flag] += vals
	       numOptions[flag]  +=len(vals)
            else:
		optionValue[flag] = vals
                numOptions[flag]  = len(vals)
       	else:
            # store the typed out values
            if flag in optionValue.keys():
	       optionValue[flag] +=option
	       numOptions[flag]  +=len(option)
       	    else:
            	optionValue[flag] = option
            	numOptions[flag]  = len(option)

    # We make sure all option strings have the same length 
    if numOptions:
        num = numOptions[flag]
        for (flag,n) in numOptions.iteritems():
           print (flag,n)        
	   if n != num:
                print flag, ' ', n
		print 'Not all parameters have the same number of values!', num
                sys.exit()
                
    commandLines = []
    print optionValue
    index = 0
    for i in range(0,num):
        commandLine = './ssexy.e '
        for flag,val in optionValue.iteritems():
            commandLine += '-%s %s ' % (flag,val[i])
        commandLine += staticPIMCOps
        commandLines.append(commandLine)

    ncommandLines = []
    if  args.batch!=None:
        for j in range(args.shift,args.shift+args.batch):
            for commandLine in commandLines:
                ncommandLines.append(commandLine + ' -p %d ' %j)
        commandLines=ncommandLines
    
    if args.cluster == 'westgrid':
        clusters.westgrid(commandLines,args.run)

    if args.cluster == 'sharcnet':
        clusters.sharcnet(commandLines,args.run)

    if args.cluster == 'scinet':
        clusters.scinet(commandLines,args.run)

    if args.cluster == 'clumeq':
        clusters.clumeq(commandLines,args.run)

    if args.cluster == 'bluemoon':
        clusters.bluemoon(commandLines,args.run)