#!/usr/bin/env python # async_qb_buggy# # # Created by athota1 on 18/08/10. # Copyright (c) 2010 __MyCompanyName__. All rights reserved. # import saga import os import subprocess import logging import sys import time #Configure here: HOST = "qb1.loni.org" REMOTE1 = "gatekeeper.ranger.tacc.teragrid.org" REMOTE2 = "qb1.loni.org" REMOTE3 = "painter1.loni.org" #dirs for replicas WORK_DIR = "/work/athota1/new_bigjob/decentralized/" WORK_DIR1= "/work/01297/athota1/new_bigjob/decentralized/" RPB = 4 #NUMBER_REPLICAS/BIGJOB def copy_with_saga(i): # print "####################start time(npt.conf copy)" + time.asctime(time.localtime(time.time())) + "##################" start = time.time() if i=RPB and i<(2*RPB)): source_url = saga.url('file://' + WORK_DIR + 'NPT.conf') dest_url = saga.url('gridftp://' +"gridftp.ranger.tacc.teragrid.org:2811" + WORK_DIR1+'agent/'+str(i)+'/') sagafile = saga.filesystem.file(source_url) try: sagafile.copy(dest_url) except saga.exception, e: print "\n(ERROR) remote ###NPT.CONF####file copy from %s to %s failed"%(HOST, REMOTE1) elif (i>=(2*RPB) and i<(3*RPB)): source_url = saga.url('file://' + WORK_DIR + 'NPT.conf') dest_url = saga.url('gridftp://' + REMOTE2 + WORK_DIR+'agent/'+str(i)+'/') sagafile = saga.filesystem.file(source_url) try: sagafile.copy(dest_url) except saga.exception, e: print "\n(ERROR) remote ###NPT.CONF####file copy from %s to %s failed"%(HOST, REMOTE1) else: source_url = saga.url('file://' + WORK_DIR + 'NPT.conf') dest_url = saga.url('gridftp://' + REMOTE3 + WORK_DIR+'agent/'+str(i)+'/') sagafile = saga.filesystem.file(source_url) try: sagafile.copy(dest_url) except saga.exception, e: print "\n(ERROR) remote ###NPT.CONF####file copy from %s to %s failed"%(HOST, REMOTE1) # print str(i) # print "####################end time(npt.conf copy)" + time.asctime(time.localtime(time.time())) + "##################" #print "time to copy: " + str(time.time() - start) return None def NAMD_config(some_temp): #print "#################### namd config prep start time" + time.asctime(time.localtime(time.time())) + "##################" # config prep when re-launching replicas start = time.time() ifile = open("NPT.conf") # should be changed if a different name is going to be used lines = ifile.readlines() for line in lines: if line.find("desired_temp") >= 0 and line.find("set") >= 0: lines[lines.index(line)] = "set desired_temp %s \n"%(some_temp) ifile.close() ofile = open("NPT.conf", "w") for line in lines: ofile.write(line) ofile.close() # print "####################end time config prep" + time.asctime(time.localtime(time.time())) + "##################" #print "time to prep: "+ str(time.time() - start) def read_temp(replica_id): enfile = open("stdout-" + str(replica_id)) lines = enfile.readlines() for line in lines: items = line.split() if len(items) > 0: if items[0] in ("ENERGY:"): en = items[12] # print "(DEBUG) energy : " + str(en)logging.debug return en if __name__ == "__main__": replica_id = sys.argv[2] LOG_FILENAME = 'logging.out' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('parsing') logging.debug("REPLICA # " + str(replica_id)) nodelist = sys.argv[4] logging.debug("the nodes assigned =" + str(nodelist)) tot_reps = sys.argv[3] logging.debug("total number of replicas " + str(tot_reps)) # command = "mpirun" + " -np " + "16" + " -machinefile " + nodelist + " " +WORK_DIR+ "agent/" +str(replica_id) + "/namd2" + " "+ WORK_DIR+ "agent/"+str(replica_id)+"/NPT.conf" if int(replica_id)