Exemplo n.º 1
0
int gmx_mk_angndx(int argc, char *argv[])
{
    static const char *desc[] = {
        "[THISMODULE] makes an index file for calculation of",
        "angle distributions etc. It uses a run input file ([REF].tpx[ref]) for the",
        "definitions of the angles, dihedrals etc."
    };
    static const char *opt[] = { NULL, "angle", "dihedral", "improper", "ryckaert-bellemans", NULL };
    static gmx_bool    bH    = TRUE;
    static real        hq    = -1;
    t_pargs            pa[]  = {
        { "-type", FALSE, etENUM, {opt},
          "Type of angle" },
        { "-hyd", FALSE, etBOOL, {&bH},
          "Include angles with atoms with mass < 1.5" },
        { "-hq", FALSE, etREAL, {&hq},
          "Ignore angles with atoms with mass < 1.5 and magnitude of their charge less than this value" }
    };

    output_env_t       oenv;
    FILE              *out;
    t_topology        *top;
    int                i, j, ntype;
    int                nft = 0, *ft, mult = 0;
    int              **index;
    int               *ft_ind;
    int               *nr;
    char             **grpnames;
    t_filenm           fnm[] = {
        { efTPR, NULL, NULL, ffREAD  },
        { efNDX, NULL, "angle", ffWRITE }
    };
#define NFILE asize(fnm)

    if (!parse_common_args(&argc, argv, 0, NFILE, fnm, asize(pa), pa,
                           asize(desc), desc, 0, NULL, &oenv))
    {
        return 0;
    }

    GMX_RELEASE_ASSERT(opt[0] != 0, "Options inconsistency; opt[0] is NULL");

    ft = select_ftype(opt[0], &nft, &mult);

    top = read_top(ftp2fn(efTPR, NFILE, fnm), NULL);

    ntype = calc_ntype(nft, ft, &(top->idef));
    snew(grpnames, ntype);
    snew(ft_ind, top->idef.ntypes);
    fill_ft_ind(nft, ft, &top->idef, ft_ind, grpnames);

    snew(nr, ntype);
    snew(index, ntype);
    fill_ang(nft, ft, mult, nr, index, ft_ind, top, !bH, hq);

    out = ftp2FILE(efNDX, NFILE, fnm, "w");
    for (i = 0; (i < ntype); i++)
    {
        if (nr[i] > 0)
        {
            fprintf(out, "[ %s ]\n", grpnames[i]);
            for (j = 0; (j < nr[i]*mult); j++)
            {
                fprintf(out, " %5d", index[i][j]+1);
                if ((j % 12) == 11)
                {
                    fprintf(out, "\n");
                }
            }
            fprintf(out, "\n");
        }
    }
    gmx_ffclose(out);

    return 0;
}
Exemplo n.º 2
0
int main(int argc,char *argv[])
{
  static char *desc[] = {
    "mk_angndx makes an index file for calculation of",
    "angle distributions etc. It uses a run input file ([TT].tpx[tt]) for the",
    "definitions of the angles, dihedrals etc."
  };
  static char *opt[] = { NULL, "angle", "dihedral", "improper", "ryckaert-bellemans", NULL };
  static bool bH=TRUE;
  t_pargs pa[] = {
    { "-type", FALSE, etENUM, {opt},
      "Type of angle" },
    { "-hyd", FALSE, etBOOL, {&bH},
      "Include angles with atoms with mass < 1.5" }
  };
  
  FILE       *out;
  t_topology *top;
  int        i,j,ntype;
  int        nft=0,*ft,mult=0;
  int        **index;
  int        *ft_ind;
  int        *nr;
  char       **grpnames;
  t_filenm fnm[] = {
    { efTPX, NULL, NULL, ffREAD  },
    { efNDX, NULL, "angle", ffWRITE }
  };
#define NFILE asize(fnm)

  CopyRight(stderr,argv[0]);
  parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa,
		    asize(desc),desc,0,NULL);


  ft = select_ftype(opt[0],&nft,&mult);

  top = read_top(ftp2fn(efTPX,NFILE,fnm),NULL);

  ntype = calc_ntype(nft,ft,&(top->idef));
  snew(grpnames,ntype);
  snew(ft_ind,top->idef.ntypes);
  fill_ft_ind(nft,ft,&top->idef,ft_ind,grpnames);
  
  snew(nr,ntype);
  snew(index,ntype);
  fill_ang(nft,ft,mult,nr,index,ft_ind,top,!bH);
  
  out=ftp2FILE(efNDX,NFILE,fnm,"w");
  for(i=0; (i<ntype); i++) {
    if (nr[i] > 0) {
      fprintf(out,"[ %s ]\n",grpnames[i]);
      for(j=0; (j<nr[i]*mult); j++) {
	fprintf(out," %5d",index[i][j]+1);
	if ((j % 12) == 11)
	  fprintf(out,"\n");
      }
      fprintf(out,"\n");
    }
  }
  fclose(out);
  
  thanx(stderr);
  
  return 0;
}