static void par_fn(char *base, int ftp, const t_commrec *cr, gmx_bool bAppendSimId, gmx_bool bAppendNodeId, char buf[], int bufsize) { if ((size_t)bufsize < (strlen(base)+10)) { gmx_mem("Character buffer too small!"); } /* Copy to buf, and strip extension */ strcpy(buf, base); buf[strlen(base) - strlen(ftp2ext(fn2ftp(base))) - 1] = '\0'; if (bAppendSimId) { sprintf(buf+strlen(buf), "%d", cr->ms->sim); } if (bAppendNodeId) { strcat(buf, "_rank"); sprintf(buf+strlen(buf), "%d", cr->nodeid); } strcat(buf, "."); /* Add extension again */ strcat(buf, (ftp == efTPX) ? "tpr" : (ftp == efEDR) ? "edr" : ftp2ext(ftp)); if (debug) { fprintf(debug, "rank %d par_fn '%s'\n", cr->nodeid, buf); if (fn2ftp(buf) == efLOG) { fprintf(debug, "log\n"); } } }
static void par_fn(char *base,int ftp,const t_commrec *cr, bool bUnderScore, char buf[],int bufsize) { int n; if(bufsize<(strlen(base)+4)) gmx_mem("Character buffer too small!"); /* Copy to buf, and strip extension */ strcpy(buf,base); buf[strlen(base) - strlen(ftp2ext(fn2ftp(base))) - 1] = '\0'; /* Add node info */ if (bUnderScore) strcat(buf,"_"); if (MULTISIM(cr) && !bUnderScore) { sprintf(buf+strlen(buf),"%d",cr->ms->sim); } else if (PAR(cr)) { sprintf(buf+strlen(buf),"%d",cr->nodeid); } strcat(buf,"."); /* Add extension again */ strcat(buf,(ftp == efTPX) ? "tpr" : (ftp == efEDR) ? "edr" : ftp2ext(ftp)); }
static void read_stx_conf(const char *infile, t_topology *top, rvec x[], rvec *v, int *ePBC, matrix box) { FILE *in; t_trxframe fr; int ftp; char g96_line[STRLEN+1]; if (top->atoms.nr == 0) { fprintf(stderr, "Warning: Number of atoms in %s is 0\n", infile); } else if (top->atoms.atom == NULL) { gmx_mem("Uninitialized array atom"); } if (ePBC) { *ePBC = -1; } ftp = fn2ftp(infile); switch (ftp) { case efGRO: gmx_gro_read_conf(infile, top, x, v, box); break; case efG96: fr.title = NULL; fr.natoms = top->atoms.nr; fr.atoms = &top->atoms; fr.x = x; fr.v = v; fr.f = NULL; in = gmx_fio_fopen(infile, "r"); read_g96_conf(in, infile, &fr, &top->symtab, g96_line); gmx_fio_fclose(in); copy_mat(fr.box, box); top->name = put_symtab(&top->symtab, fr.title); sfree(const_cast<char *>(fr.title)); break; case efPDB: case efBRK: case efENT: gmx_pdb_read_conf(infile, top, x, ePBC, box); break; case efESP: gmx_espresso_read_conf(infile, top, x, v, box); break; default: gmx_incons("Not supported in read_stx_conf"); } }
void read_stx_conf(const char *infile, char *title, t_atoms *atoms, rvec x[], rvec *v, int *ePBC, matrix box) { FILE *in; char buf[256]; gmx_mtop_t *mtop; t_topology top; t_trxframe fr; int i, ftp, natoms; real d; char g96_line[STRLEN+1]; if (atoms->nr == 0) { fprintf(stderr, "Warning: Number of atoms in %s is 0\n", infile); } else if (atoms->atom == NULL) { gmx_mem("Uninitialized array atom"); } if (ePBC) { *ePBC = -1; } ftp = fn2ftp(infile); switch (ftp) { case efGRO: read_whole_conf(infile, title, atoms, x, v, box); break; case efG96: fr.title = NULL; fr.natoms = atoms->nr; fr.atoms = atoms; fr.x = x; fr.v = v; fr.f = NULL; in = gmx_fio_fopen(infile, "r"); read_g96_conf(in, infile, &fr, g96_line); gmx_fio_fclose(in); copy_mat(fr.box, box); strncpy(title, fr.title, STRLEN); break; case efPDB: case efBRK: case efENT: read_pdb_conf(infile, title, atoms, x, ePBC, box, TRUE, NULL); break; case efESP: read_espresso_conf(infile, atoms, x, v, box); break; case efTPR: case efTPB: case efTPA: snew(mtop, 1); i = read_tpx(infile, NULL, box, &natoms, x, v, NULL, mtop); if (ePBC) { *ePBC = i; } strcpy(title, *(mtop->name)); /* Free possibly allocated memory */ done_atom(atoms); *atoms = gmx_mtop_global_atoms(mtop); top = gmx_mtop_t_to_t_topology(mtop); tpx_make_chain_identifiers(atoms, &top.mols); sfree(mtop); /* The strings in the symtab are still in use in the returned t_atoms * structure, so we should not free them. But there is no place to put the * symbols; the only choice is to leak the memory... * So we clear the symbol table before freeing the topology structure. */ free_symtab(&top.symtab); done_top(&top); break; default: gmx_incons("Not supported in read_stx_conf"); } }
void read_stx_conf(char *infile, char *title,t_atoms *atoms, rvec x[],rvec *v,int *ePBC,matrix box) { FILE *in; char buf[256]; gmx_mtop_t *mtop; t_topology top; t_trxframe fr; int i,ftp,natoms,i1; real d,r1,r2; if (atoms->nr == 0) fprintf(stderr,"Warning: Number of atoms in %s is 0\n",infile); else if (atoms->atom == NULL) gmx_mem("Uninitialized array atom"); if (ePBC) *ePBC = -1; ftp=fn2ftp(infile); switch (ftp) { case efGRO: read_whole_conf(infile, title, atoms, x, v, box); break; case efG96: fr.title = title; fr.natoms = atoms->nr; fr.atoms = atoms; fr.x = x; fr.v = v; fr.f = NULL; in = gmx_fio_fopen(infile,"r"); read_g96_conf(in, infile, &fr); gmx_fio_fclose(in); copy_mat(fr.box,box); break; case efPDB: case efBRK: case efENT: read_pdb_conf(infile, title, atoms, x, ePBC, box, TRUE, NULL); break; case efESP: read_espresso_conf(infile,atoms,x,v,box); break; case efTPR: case efTPB: case efTPA: snew(mtop,1); i = read_tpx(infile,&i1,&r1,&r2,NULL,box,&natoms,x,v,NULL,mtop); if (ePBC) *ePBC = i; strcpy(title,*(mtop->name)); /* Free possibly allocated memory */ done_atom(atoms); *atoms = gmx_mtop_global_atoms(mtop); top = gmx_mtop_t_to_t_topology(mtop); tpx_make_chain_identifiers(atoms,&top.mols); sfree(mtop); done_top(&top); break; default: gmx_incons("Not supported in read_stx_conf"); } }