return natoms;
}
-int read_g96_conf(FILE *fp,const char *infile,t_trxframe *fr)
+int read_g96_conf(FILE *fp,const char *infile,t_trxframe *fr, char *line)
{
t_symtab *symtab=NULL;
- char line[STRLEN+1];
gmx_bool bAtStart,bTime,bAtoms,bPos,bVel,bBox,bEnd,bFinished;
int natoms,nbp;
double db1,db2,db3,db4,db5,db6,db7,db8,db9;
gmx_fio_fclose (in);
}
-static gmx_bool get_w_conf(FILE *in,const char *infile,char *title,
- t_atoms *atoms, int *ndec, rvec x[],rvec *v, matrix box)
+static gmx_bool get_w_conf(FILE *in, const char *infile, char *title,
+ t_symtab *symtab, t_atoms *atoms, int *ndec,
+ rvec x[], rvec *v, matrix box)
{
- t_symtab *symtab=NULL;
char name[6];
char line[STRLEN+1],*ptr;
char buf[256];
oldres = NOTSET; /* Unlikely number for the first residue! */
ddist = 0;
- if (!symtab) {
- snew(symtab,1);
- open_symtab(symtab);
- }
-
/* Read the title and number of atoms */
get_coordnum_fp(in,title,&natoms);
box[ZZ][XX] = y2;
box[ZZ][YY] = z2;
}
- close_symtab(symtab);
return bVel;
}
{
FILE *in;
int ndec;
-
+ t_symtab symtab;
+
/* open file */
in=gmx_fio_fopen(infile,"r");
- get_w_conf(in, infile, title, atoms, &ndec, x, v, box);
-
+ open_symtab(&symtab);
+ get_w_conf(in, infile, title, &symtab, atoms, &ndec, x, v, box);
+ /* We can't free the symbols, as they are still used in atoms, so
+ * the only choice is to leak them. */
+ free_symtab(&symtab);
+
gmx_fio_fclose(in);
}
gmx_bool gro_next_x_or_v(FILE *status,t_trxframe *fr)
{
t_atoms atoms;
+ t_symtab symtab;
char title[STRLEN],*p;
double tt;
int ndec=0,i;
if (gmx_eof(status))
return FALSE;
+ open_symtab(&symtab);
atoms.nr=fr->natoms;
snew(atoms.atom,fr->natoms);
atoms.nres=fr->natoms;
snew(atoms.resinfo,fr->natoms);
snew(atoms.atomname,fr->natoms);
- fr->bV = get_w_conf(status,title,title,&atoms,&ndec,fr->x,fr->v,fr->box);
+ fr->bV = get_w_conf(status,title,title,&symtab,&atoms,&ndec,fr->x,fr->v,fr->box);
fr->bPrec = TRUE;
fr->prec = 1;
/* prec = 10^ndec: */
sfree(atoms.atom);
sfree(atoms.resinfo);
sfree(atoms.atomname);
+ done_symtab(&symtab);
if ((p=strstr(title,"t=")) != NULL) {
p+=2;
FILE *in;
int ftp,tpxver,tpxgen;
t_trxframe fr;
+ char g96_line[STRLEN+1];
ftp=fn2ftp(infile);
range_check(ftp,0,efNR);
fr.x = NULL;
fr.v = NULL;
fr.f = NULL;
- *natoms=read_g96_conf(in,infile,&fr);
+ *natoms=read_g96_conf(in,infile,&fr,g96_line);
gmx_fio_fclose(in);
break;
case efXYZ:
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);
fr.v = v;
fr.f = NULL;
in = gmx_fio_fopen(infile,"r");
- read_g96_conf(in, infile, &fr);
+ read_g96_conf(in, infile, &fr, g96_line);
gmx_fio_fclose(in);
copy_mat(fr.box,box);
break;
* 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. */
- open_symtab(&top.symtab);
+ free_symtab(&top.symtab);
done_top(&top);
break;