int kfsinit(Fs *fs) { if(readinfo(fs) < 0 || readroot(fs, &fs->root.kfs) < 0) return -1; fs->root.fs = fs; fs->read = kfsread; fs->walk = kfswalk; return 0; }
static void fsread(Req *r) { vlong n, m, got; Aux *a = r->fid->aux; char *buf = r->ofcall.data; vlong len = r->ifcall.count; vlong off = r->ifcall.offset; if(ptype(r->fid->qid.path) == Pinfo){ r->ofcall.count = readinfo(pindex(r->fid->qid.path), buf, len, off); respond(r, nil); return; } if(r->fid->qid.type & QTDIR){ dirread9p(r, dirgen, a); respond(r, nil); return; } got = 0; n = Sess->mtu -OVERHEAD; do{ if(len - got < n) n = len - got; m = CIFSread(Sess, a->sp, a->fh, off + got, buf + got, n, len); if(m != -1) got += m; } while(got < len && m >= n); r->ofcall.count = got; if(m == -1) responderrstr(r); else respond(r, nil); }
int main(int argc, char *argv[]) { int i; int status = 0; char command[MAXCHAR]; size_t copied_size; amberhome = (char *) getenv("AMBERHOME"); if( amberhome == NULL ){ fprintf( stdout, "AMBERHOME is not set!\n" ); exit(1); } if (strcmp(COLORTEXT, "YES") == 0 || strcmp(COLORTEXT, "yes") == 0) { if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-H") == 0)) { printf("[31mUsage: respgen -i[0m input file name(ac)\n" "[31m -o[0m output file name\n" "[31m -l[0m maximum path length (default is -1, only recommand to use\n" " when the program takes long time to finish or causes core dump.)\n" " If applied, a value of 8 to 10 should good)\n" "[31m -f[0m output file format (resp1 or resp2) \n" "[32m resp0[0m - evaluation the current charges \n" "[32m resp1[0m - first stage resp fitting \n" "[32m resp2[0m - second stage resp fitting\n" "[32m iresp0[0m - evaluation the current charges for polarizable model\n" "[32m iresp1[0m- first stage of i_resp fitting \n" "[32m iresp2[0m- second stage of i_resp fitting\n" "[32m resp3[0m - one-stage resp fitting\n" "[32m resp4[0m - calculating ESP from point charges\n" "[32m resp5[0m - no-equalization\n" "[31m -e[0m equalizing atomic charge, default is 1\n" "[32m 0[0m not use \n" "[32m 1[0m by atomic paths\n" "[32m 2[0m by atomic paths and structural information, i.e. E/Z confirgurations\n" "[31m -a[0m additional input data (predefined charges, atom groups etc).)\n" "[31m -n[0m number of conformations (default is 1)\n" "[31m -w[0m weight of charge constraint, in default, 0.0005 for resp1 and 0.001 fore resp2\n"); exit(1); } if (argc != 7 && argc != 9 && argc != 11 && argc != 13 && argc != 15 && argc != 17) { printf("[31mUsage: respgen -i[0m input file name(ac)\n" "[31m -o[0m output file name\n" "[31m -l[0m maximum path length (default is -1, only recommand to use\n" " when the program takes long time to finish or causes core dump.)\n" " If applied, a value of 8 to 10 should good)\n" "[31m -f[0m output file format (resp1 or resp2) \n" "[32m resp0[0m - evaluation the current charges \n" "[32m resp1[0m - first stage resp fitting \n" "[32m resp2[0m - second stage resp fitting\n" "[32m iresp0[0m - evaluation the current charges for polarizable model\n" "[32m iresp1[0m- first stage of i_resp fitting \n" "[32m iresp2[0m- second stage of i_resp fitting\n" "[32m resp3[0m - one-stage resp fitting\n" "[32m resp4[0m - calculating ESP from point charges\n" "[32m resp5[0m - no-equalization\n" "[31m -e[0m equalizing atomic charge, default is 1\n" "[32m 0[0m not use \n" "[32m 1[0m by atomic paths\n" "[32m 2[0m by atomic paths and structural information, i.e. E/Z confirgurations\n" "[31m -a[0m additional input data (predefined charges, atom groups etc).)\n" "[31m -n[0m number of conformations (default is 1)\n" "[31m -w[0m weight of charge constraint, in default, 0.0005 for resp1 and 0.001 fore resp2\n"); exit(1); } } else { if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-H") == 0)) { printf("Usage respgen -i input file name(ac)\n"); printf(" -o output file name\n"); printf(" -l maximum path length (default is -1, only recommand to use\n"); printf(" when the program takes long time to finish or causes core dump.)\n"); printf(" If applied, a value of 8 to 10 should good)\n"); printf(" -f output file format (resp1 or resp2)\n"); printf(" resp0 - evaluation the current charges \n"); printf(" resp1 - first stage resp fitting\n"); printf(" resp2 - second stage resp fitting \n"); printf(" iresp0 - evaluation the current charges for polarizable model \n"); printf(" iresp1- first stage of i_resp fitting\n"); printf(" iresp2- second stage of i_resp fitting \n"); printf(" resp3 - one-stage resp fitting\n"); printf(" resp4 - calculating ESP from point charges \n"); printf(" resp5 - no-equalization \n"); printf(" -e equalizing atomic charge, default is 1\n"); printf(" 0 not use \n"); printf(" 1 by atomic paths\n"); printf(" 2 by atomic paths and structural information, i.e. E/Z confirgurations\n"); printf(" -a additional input data (predefined charges, atom groups etc).)\n"); printf(" -n number of conformations (default is 1)\n"); printf(" -w weight of charge constraint, in default, 0.0005 for resp1 and 0.001 fore resp2\n"); exit(1); } if (argc != 7 && argc != 9 && argc != 11 && argc != 13 && argc != 15 && argc != 17) { printf("Usage respgen -i input file name(ac)\n"); printf(" -o output file name\n"); printf(" -l maximum path length (default is -1, only recommand to use\n"); printf(" when the program takes long time to finish or causes core dump.)\n"); printf(" If applied, a value of 8 to 10 should good)\n"); printf(" -f output file format (resp1 or resp2)\n"); printf(" resp0 - evaluation the current charges \n"); printf(" resp1 - first stage resp fitting\n"); printf(" resp2 - second stage resp fitting \n"); printf(" iresp0 - evaluation the current charges for polarizable model \n"); printf(" iresp1- first stage of i_resp fitting\n"); printf(" iresp2- second stage of i_resp fitting \n"); printf(" resp3 - one-stage resp fitting\n"); printf(" resp4 - calculating ESP from point charges \n"); printf(" resp5 - no-equalization \n"); printf(" -e equalizing atomic charge, default is 1\n"); printf(" 0 not use \n"); printf(" 1 by atomic paths\n"); printf(" 2 by atomic paths and structural information, i.e. E/Z confirgurations\n"); printf(" -a additional input data (predefined charges, atom groups etc).)\n"); printf(" -w weight of charge constraint, in default, 0.0005 for resp1 and 0.001 fore resp2\n"); exit(1); } } method = -1; max_path_length = -1; for (i = 1; i < argc; i += 2) { if (strcmp(argv[i], "-i") == 0) strcpy(ifilename, argv[i + 1]); if (strcmp(argv[i], "-o") == 0) strcpy(ofilename, argv[i + 1]); if (strcmp(argv[i], "-a") == 0) { strcpy(afilename, argv[i + 1]); iaddinfo = 1; } if (strcmp(argv[i], "-n") == 0) nconf = atoi(argv[i+1]); if (strcmp(argv[i], "-l") == 0) max_path_length = atoi(argv[i+1]); if (strcmp(argv[i], "-f") == 0) { if (strcmp("resp", argv[i + 1]) == 0) method = -1; if (strcmp("resp0", argv[i + 1]) == 0) method = 0; if (strcmp("resp1", argv[i + 1]) == 0) { method = 1; weight = 0.0005; } if (strcmp("resp2", argv[i + 1]) == 0) { method = 2; weight = 0.001; } if (strcmp("resp3", argv[i + 1]) == 0) method = 3; if (strcmp("iresp1", argv[i + 1]) == 0) { method = 4; weight = 0.0005; } if (strcmp("iresp2", argv[i + 1]) == 0) { method = 5; weight = 0.001; } if (strcmp("resp4", argv[i + 1]) == 0) { method = 6; weight = 0.000; } if (strcmp("iresp0", argv[i + 1]) == 0) method = 7; if (strcmp("resp5", argv[i + 1]) == 0) { method = 8; weight = 0.0005; } } if (strcmp(argv[i], "-w") == 0) weight = atof(argv[i+1]); if (strcmp(argv[i], "-e") == 0) iequ = atoi(argv[i+1]); } if(nconf < 1) { printf("\nNumber of conformations must be equal to or larger than 1"); exit(1); } if(iequ != 0 && iequ != 1 && iequ !=2) iequ = 1; default_cinfo(&cinfo); default_minfo(&minfo); atom = (ATOM *) malloc(sizeof(ATOM) * cinfo.maxatom); if (atom == NULL) { fprintf(stdout, "memory allocation error for *atom\n"); exit(1); } bond = (BOND *) malloc(sizeof(BOND) * cinfo.maxbond); if (bond == NULL) { fprintf(stdout, "memory allocation error for *bond\n"); exit(1); } for (i = 0; i < cinfo.maxbond; ++i) { bond[i].jflag = -1; /* bond type has not been assigned */ } overflow_flag = rac(ifilename, &atomnum, atom, &bondnum, bond, &cinfo, &minfo); if (overflow_flag) { cinfo.maxatom = atomnum + 10; cinfo.maxbond = bondnum + 10; free(atom); free(bond); atom = (ATOM *) malloc(sizeof(ATOM) * cinfo.maxatom); if (atom == NULL) { fprintf(stdout, "memory allocation error for *atom\n"); exit(1); } bond = (BOND *) malloc(sizeof(BOND) * cinfo.maxbond); if (bond == NULL) { fprintf(stdout, "memory allocation error for *bond\n"); exit(1); } int i; for (i = 0; i < cinfo.maxbond; ++i) { bond[i].jflag = -1; /* bond type has not been assigned */ } overflow_flag = rac(ifilename, &atomnum, atom, &bondnum, bond, &cinfo, &minfo); } atomicnum(atomnum, atom); adjustatomname(atomnum, atom, 1); if(minfo.dcharge >= -9990) charge = minfo.dcharge; equ_atom_id = (int *) malloc(sizeof(int) * atomnum); if (equ_atom_id == NULL) { fprintf(stdout, "memory allocation error for *equ_atom_id\n"); exit(1); } for (i = 0; i < atomnum; i++) equ_atom_id[i] = -1; if(method == 3) { atqwt = (double *) malloc(sizeof(double) * atomnum); if (atqwt == NULL) { fprintf(stdout, "memory allocation error for *atqwt\n"); exit(1); } refcharge = (double *) malloc(sizeof(double) * atomnum); if (refcharge == NULL) { fprintf(stdout, "memory allocation error for *refcharge\n"); exit(1); } for(i=0;i<atomnum;i++) { atqwt[i] = 0; refcharge[i] = 0; } // now read in atomic weights and reference charge parameters pfilename[0] = '\0'; strcpy(pfilename, amberhome); strcat(pfilename, "/dat/antechamber/RESPPARM.DAT"); readparm(pfilename); wac("ANTECHAMBER_RESP.AC", atomnum, atom, bondnum, bond, cinfo, minfo); copied_size = build_exe_path(command, "atomtype -i ANTECHAMBER_RESP.AC -o ANTECHAMBER_RESP_AT.AC -d ", sizeof command, 1 ); dfilename[0] = '\0'; strcpy(dfilename, amberhome); strcat(dfilename, "/dat/antechamber/ATOMTYPE_RESP.DEF"); strncat(command, dfilename, MAXCHAR - copied_size ); if (cinfo.intstatus == 2) fprintf(stdout, "Running: %s\n", command); status = system(command); if(status != 0) { fprintf(stdout, "Error: cannot run \"%s\" in respgen.c properly, exit\n", command); exit(1); } assignparm("ANTECHAMBER_RESP_AT.AC"); } if(iequ == 1) identify_equatom(atomnum, atom, equ_atom_id, max_path_length, bondnum, bond, 0); if(iequ == 2) identify_equatom(atomnum, atom, equ_atom_id, max_path_length, bondnum, bond, 1); icharge = (int *) malloc(sizeof(int) * atomnum); if (icharge == NULL) { fprintf(stdout, "memory allocation error for *icharge in respin()\n"); exit(1); } pcharge = (double *) malloc(sizeof(double) * atomnum); if (pcharge == NULL) { fprintf(stdout, "memory allocation error for *pcharge in respin()\n"); exit(1); } for(i=0;i<atomnum;i++) { pcharge[i] = 0.0; icharge[i] = 0; } if(iaddinfo == 1) { if ((fpaddinfo = fopen(afilename, "r")) == NULL) { fprintf(stdout, "Cannot open the additional file %s to read in main(), exit\n", afilename); exit(1); } if ((fpcharge = fopen("QIN", "w")) == NULL) { fprintf(stdout, "Cannot open file QIN, exit\n"); exit(1); } readinfo(); } respin(method); if(iaddinfo == 1) { fclose(fpcharge); fclose(fpaddinfo); } printf("\n"); /* free(atom); free(selectindex); free(selectelement); free(equ_atom_id); free(pathnum); free(pathatomnum); for (i =0 ;i <atomnum; i++) free(pathscore[i]); */ return (0); }