# ------------------------------------- # main program # command-line args # if len(sys.argv) != 4: print("Syntax: python nwchem_wrap.py file/zmq ao/pw input_template") sys.exit(1) comm_mode = sys.argv[1] basis_type = sys.argv[2] input_template = sys.argv[3] if comm_mode == "file": cs = CSlib(1, comm_mode, "tmp.couple", None) elif comm_mode == "zmq": cs = CSlib(1, comm_mode, "*:5555", None) else: print("Syntax: python nwchem_wrap.py file/zmq") sys.exit(1) natoms = 0 box = [] if basis_type == "ao": natoms = nwchem_setup_ao(input_template) elif basis_type == "pw": natoms, box = nwchem_setup_pw(input_template) # initial message for AIMD protocol msgID, nfield, fieldID, fieldtype, fieldlen = cs.recv()
print "Syntax: python server.py mode N dtype" print " mode = file or zmq" print " N = length of data vectors" print " dtype = 1/2/3 = list, Numpy, ctypes" sys.exit(1) mode = sys.argv[1] nlen = int(sys.argv[2]) dtype = int(sys.argv[3]) if nlen < 1: error("Nlen < 1") if dtype < 1 or dtype > 3: error("Dtype < 1 or dtype > 3") # setup messaging if mode == "file": cs = CSlib(1,mode,"tmp.couple",None) elif mode == "zmq": cs = CSlib(1,mode,"*:5555",None) else: error("Invalid mode") # setup data according to dtype nper = 3 if dtype == 1: sint = nlen*[0] sint64 = nlen*[0] sfloat = nlen*[0.0] sdouble = nlen*[0.0] sarray = [[0]*nper for i in range(nlen)] elif dtype == 2:
print " type = 1/2/3 = list, Numpy, ctypes" sys.exit(1) mode = sys.argv[1] nlen = int(sys.argv[2]) dtype = int(sys.argv[3]) if nlen < 1: error("Nlen < 1") if dtype < 1 or dtype > 3: error("Type < 1 or type > 3") # setup messaging mpifree = 0 if mode == "file": cs = CSlib(1, mode, "tmp.couple", world) elif mode == "zmq": cs = CSlib(1, mode, "*:5555", world) elif mode == "mpi/one": mpifree = 1 onlyserver = world.Split(1, me) me = onlyserver.rank nprocs = onlyserver.size both = world world = onlyserver cs = CSlib(1, mode, both, world) elif mode == "mpi/two": cs = CSlib(1, mode, "tmp.couple", world) else: error("Invalid mode")
print " Niter = # of iterations" print " dtype = 1/2/3 = list, Numpy, ctypes" sys.exit(1) mode = sys.argv[1] nlen = int(sys.argv[2]) niter = int(sys.argv[3]) dtype = int(sys.argv[4]) if nlen < 1: error("Nlen < 1") if niter < 1: error("Niter < 1") if dtype < 1 or dtype > 3: error("Dtype < 1 or dtype > 3") # setup messaging if mode == "file": cs = CSlib(0, mode, "tmp.couple", None) elif mode == "zmq": cs = CSlib(0, mode, "localhost:5555", None) else: error("Invalid mode") # setup data according to dtype nper = 3 if dtype == 1: sint = nlen * [0] sint64 = nlen * [0] sfloat = nlen * [0] sdouble = nlen * [0] sarray = [[0] * nper for i in range(nlen)] elif dtype == 2: