int main(int argc,char *argv[]) { char *cp, *ep; char host[49]; char tmpb[CMD_BUF_SIZE]; int tmo; #if NEWS printf("amptest: See <news> command\n"); printf("amptest: Type h for help\n"); #endif pname = argv[0]; printf("%s: Compiled %s %s\n",pname,__DATE__,__TIME__); printf("%s: %s\n",pname, git_version); tmo = 0; while (AmpIsBlocked()) { usleep(100000); if (tmo++ > 50) { printf("Amplifier is blocked by another program\n"); if (YesNo("Force","Reservation")) AmpUnBlock(); else exit(1); } } AmpBlock(); printf("Amplifier reservation taken, all other programs blocked\n"); amp = AmpOpen(); if (amp == 0) { printf("\nWARNING: Could not open driver"); printf("\n\n"); } else { printf("Driver opened OK\n\n"); } bzero((void *) host,49); gethostname(host,48); while (True) { if (amp) sprintf(prompt,"%s:Amp[%02d]",host,cmdindx+1); else sprintf(prompt,"%s:NoDriver:Amp[%02d]",host,cmdindx+1); cmdbuf = &(history[cmdindx][0]); if (strlen(cmdbuf)) printf("{%s} ",cmdbuf); printf("%s",prompt); bzero((void *) tmpb,CMD_BUF_SIZE); if (gets(tmpb)==NULL) exit(1); cp = &(tmpb[0]); if (*cp == '!') { cmdindx = strtoul(++cp,&ep,0) -1; cp = ep; if (cmdindx >= HISTORIES) cmdindx = 0; cmdbuf = &(history[cmdindx][0]); continue; } else if (*cp == '.') { printf("Execute:%s\n",cmdbuf); fflush(stdout); } else if ((*cp == '\n') || (*cp == '\0')) { cmdindx++; if (cmdindx >= HISTORIES) { printf("\n"); cmdindx = 0; } cmdbuf = &(history[cmdindx][0]); continue; } else if (*cp == '?') { printf("History:\n"); printf("\t!<1..24> Goto command\n"); printf("\tCR Goto next command\n"); printf("\t. Execute current command\n"); printf("\this Show command history\n"); continue; } else { cmdindx++; if (cmdindx >= HISTORIES) { printf("\n"); cmdindx = 0; } strcpy(cmdbuf,tmpb); } bzero((void *) val_bufs,sizeof(val_bufs)); GetAtoms(cmdbuf); DoCmd(0); } }
int main(int argc,char *argv[]) { char *cp; char host[49]; char tmpb[CMD_BUF_SIZE]; int c; #if NEWS printf("xmemtest: See <news> command\n"); printf("xmemtest: Type h for help\n"); #endif pname = argv[0]; printf("%s: Compiled %s %s\n",pname,__DATE__,__TIME__); for (;;) { c = getopt(argc, argv, "c:h"); if (c < 0) break; switch (c) { case 'c': if (set_conf_path(optarg)) printf("\nWarning: path invalid or too long\n"); break; case 'h': usage_complete(); exit(0); } } xmem = XmemOpen(); if (xmem == 0) { printf("\nWARNING: Could not open driver"); printf("\n\n"); } else { printf("Driver opened OK: Using XMEM module: 1\n\n"); } ReadSegTable(0); ReadNodeTableFile(0); printf("\n"); bzero((void *) host,49); gethostname(host,48); while (True) { if (xmem) sprintf(prompt,"%s:Xmem[%02d]",host,cmdindx+1); else sprintf(prompt,"%s:NoDriver:Xmem[%02d]",host,cmdindx+1); cmdbuf = &(history[cmdindx][0]); if (strlen(cmdbuf)) printf("{%s} ",cmdbuf); printf("%s",prompt); bzero((void *) tmpb,CMD_BUF_SIZE); if (gets(tmpb)==NULL) exit(1); cp = &(tmpb[0]); if (*cp == '!') { cmdindx = strtoul(++cp,&cp,0) -1; if (cmdindx >= HISTORIES) cmdindx = 0; cmdbuf = &(history[cmdindx][0]); continue; } else if (*cp == '.') { printf("Execute:%s\n",cmdbuf); fflush(stdout); } else if ((*cp == '\n') || (*cp == '\0')) { cmdindx++; if (cmdindx >= HISTORIES) { printf("\n"); cmdindx = 0; } cmdbuf = &(history[cmdindx][0]); continue; } else if (*cp == '?') { printf("History:\n"); printf("\t!<1..24> Goto command\n"); printf("\tCR Goto next command\n"); printf("\t. Execute current command\n"); printf("\this Show command history\n"); continue; } else { cmdindx++; if (cmdindx >= HISTORIES) { printf("\n"); cmdindx = 0; } strcpy(cmdbuf,tmpb); } bzero((void *) val_bufs,sizeof(val_bufs)); GetAtoms(cmdbuf); DoCmd(0); } }
int main(int argc,char *argv[]) { char *cp, *ep; char host[49]; char tmpb[CMD_BUF_SIZE]; printf("vmeiotest: See <news> command\n"); printf("vmeiotest: Type h for help\n"); pname = argv[0]; printf("%s: Compiled %s %s\n",pname,__DATE__,__TIME__); bzero((void *) host,49); gethostname(host,48); if (argc > 1) strcat(dev_name,argv[1]); else strcat(dev_name,"vmeio"); if ((vmeio[lun] = __vsl_open_name(lun,dev_name)) == NULL) { printf("Warning: Can't open support library\n"); perror(DRV_NAME); exit(1); } memlen = 1024; mem = malloc(memlen); get_window_parameters(lun); read_regs(dev_name); while (True) { cmdbuf = &(history[cmdindx][0]); if (strlen(cmdbuf)) printf("{%s} ",cmdbuf); fflush(stdout); if (vmeio) sprintf(prompt,"%s:%s[%02d]",host,dev_name,cmdindx+1); else sprintf(prompt,"%s:NoDriver:Vmeio[%02d]",host,cmdindx+1); printf("%s",prompt); bzero((void *) tmpb,CMD_BUF_SIZE); if (fgets(tmpb,CMD_BUF_SIZE,stdin)==NULL) exit(1); cp = tmpb; if (*cp == '!') { cmdindx = strtoul(++cp,&ep,0) -1; cp = ep; if (cmdindx >= HISTORIES) cmdindx = 0; cmdbuf = &(history[cmdindx][0]); continue; } else if (*cp == '.') { printf("Execute:%s\n",cmdbuf); fflush(stdout); } else if ((*cp == '\n') || (*cp == '\0')) { cmdindx++; if (cmdindx >= HISTORIES) { printf("\n"); cmdindx = 0; } cmdbuf = &(history[cmdindx][0]); continue; } else if (*cp == '?') { printf("History:\n"); printf("\t!<1..24> Goto command\n"); printf("\tCR Goto next command\n"); printf("\t. Execute current command\n"); printf("\this Show command history\n"); continue; } else { cmdindx++; if (cmdindx >= HISTORIES) { printf("\n"); cmdindx = 0; } strcpy(cmdbuf,tmpb); } bzero((void *) val_bufs,sizeof(val_bufs)); GetAtoms(cmdbuf); DoCmd(0); } }
int main(int argc,char *argv[]) { int rp, pr, dev; char *cp; char host[49]; char tmpb[CMD_BUF_SIZE]; pname = argv[0]; printf("%s: Compiled %s %s\n",pname,__DATE__,__TIME__); if (argc > 1) dev = strtoul(argv[1],&cp,0); do_open(dev); show_dev(1); bzero((void *) host,49); gethostname(host,48); while (True) { sprintf(prompt,"%s:Icv196.%d[%02d]",host,get_lun(),cmdindx+1); printf("%s",prompt); cmdbuf = &(history[cmdindx][0]); bzero((void *) tmpb,CMD_BUF_SIZE); if (fgets(tmpb,CMD_BUF_SIZE,stdin) == NULL) break; cp = &(tmpb[0]); pr = 0; /* Dont print a history */ rp = 0; /* Dont repeat a command */ while ((*cp == '-') || (*cp == '+') || (*cp == '.') || (*cp == '!')) { pr = 1; /* Print command on */ if (*cp == '!') { cp++; cmdindx = strtoul(cp,&cp,0) -1; if (cmdindx >= HISTORIES) cmdindx = 0; if (cmdindx < 0) cmdindx = HISTORIES -1; rp = 1; break; } if (*cp == '-') { if (--cmdindx < 0) cmdindx = HISTORIES -1; cmdbuf = &(history[cmdindx][0]); } if (*cp == '+') { if (++cmdindx >= HISTORIES) cmdindx = 0; cmdbuf = &(history[cmdindx][0]); } if (*cp == '.') { rp = 1; break; } cp++; } if (pr) { printf("{%s}\t ",cmdbuf); fflush(stdout); if (!rp) continue; } if (!rp) strcpy(cmdbuf,tmpb); bzero((void *) val_bufs,sizeof(val_bufs)); GetAtoms(cmdbuf); DoCmd(0); if ((!rp) && (++cmdindx >= HISTORIES)) cmdindx = 0; } exit(0); }
{ SetName("Hask"); } void MoleculesHaskell:: Init(const bool) throw (...) { struct ParallelScript::NamedFunctions_s funcs[] = { {"generateMolecules@16", (void **)&GenerateMolecules}, {0, 0} }; ScriptInit(L"MoleculesHaskell.dll", funcs); GenerateMolecules((float *)GetAtoms().GetData(), (int)GetCount(), GetHeight(), GetWidth()); CUmodule module = 0; TryCUDA(cuModuleLoad(&module, "MoleculesHaskell.ptx")); m_kernel = 0; TryCUDA(cuModuleGetFunction(&m_kernel, module, "DoAtoms")); } void MoleculesHaskell:: Execute() throw (...) { //printf("0"); size_t height = GetHeight(), width = GetWidth(),
int main() { // get list of dat/*.dat, and sort them char files[5000][11]; int nfile = FilesList(files, "dat"); qsort(&files[0], nfile, sizeof(files[0]), CompStrInt); if(nfile < 1) return -1; // exit if no files // read following system information from cube.in // number of atoms -> nat // number of atomic types -> ntyp // number of each atom in system -> num[] // proton number of each atom in the same order with num[] -> z[] // 3x3 matrix of the cell dimensions -> celldm[3][3] int nat = 0, ntyp = 0, num[30], z[30]; double celldm[3][3]; ReadInput(&nat, &ntyp, num, z, celldm); // we will need // the inverse of celldm matrix -> inv[3][3] // and lengths of cell vectors -> norm[3] double inv[3][3]; double norm[3] = { VecLen(celldm[0]), VecLen(celldm[1]), VecLen(celldm[2]) }; Inv3D(celldm, inv); // a string for // the name of the dat file to read -> fname[20] // the name of the cube file to write -> cname[20] // a FILE for the file i/o char fname[20], cname[20]; FILE *f; // read the grid information from the files[0] int ngrid[3]; sprintf(fname, "dat/%s", files[0]); f = fopen(fname, "r"); ReadDatHeader(f, ngrid); fclose(f); // let's calculate ngrid[0] * ngrid[1] once and for all. int dim = ngrid[0] * ngrid[1]; // calculate the voxel sizes double vsize[3][3]; memcpy(vsize, celldm, sizeof(celldm)); for(int i = 0; i < 3; ++i) { VecScale(vsize[i], 1.0/ngrid[i]); } int dummy[3]; #pragma omp parallel for private(f, fname, cname) shared(dummy) for(int file = 0; file < nfile; ++file) { // set cube file name sprintf(cname, "cube/%d.cube", atoi(files[file])); // if the file exists, skip if (access(cname, F_OK) == -1) { // create a Cube to read dat file into Cube *c = CubeInit(nat, ngrid); CubeSetVoxels(c, vsize); // Read the next dat file (header info is read to skip this part) sprintf(fname, "dat/%s", files[file]); f = fopen(fname, "r"); ReadDatHeader(f, dummy); ReadDatData(f, ngrid, dim, c); fclose(f); // get ionic positions for the corresponding frame from cp.pos GetAtoms(atoi(files[file]), c, nat, z, num); int pos = 0; char com[255] = ""; double rho; for (int i = 0; i < c->nat; i++) { if(Surround(i, c, 0.4, 1) > THR && c->atoms[i].Z == 22) { rho = Surround(i, c, 2.1, 0) ; printf("%d %lf %lf\n", atoi(files[file]), c->atoms[i].coor[2], rho); pos += sprintf(com + pos, "%d ", i); } fflush(stdout); } CubeBeautify(c, THR); CubeTrim(&c, THR); sprintf(c->comment[0], "%-10.6f %-10.6f %-10.6f %-10.6f %-10.6f %-10.6f", norm[0]*B2A, norm[1]*B2A, norm[2]*B2A, DEG*acos(VecDot(celldm[0], celldm[2])/(norm[2]*norm[0])), DEG*acos(VecDot(celldm[1], celldm[2])/(norm[1]*norm[2])), DEG*acos(VecDot(celldm[0], celldm[1])/(norm[0]*norm[1]))); strcpy(c->comment[1], com); printf("%s %s", files[file], com); CubeWrite(c, cname); CubeDelete(c); } } return 0; }
#include <Accelerator.h> // cons MoleculesOptimised:: MoleculesOptimised() : Molecules(), ParallelReference() { SetName("Opt "); } void MoleculesOptimised:: Init(const bool) throw (...) { m_atoms = &GetAtoms(); } void MoleculesOptimised:: Execute() throw (...) /*{ // This version is optimised accoring to: // http://y-less.com/wordpress/?p=117 size_t height = GetHeight(), width = GetWidth(), count = GetCount(); // Target array for the effects. float * d = GetStore(),