Ejemplo n.º 1
0
int main(int argc, char *argv[]) {
int i,j;
int suc;
int pid;
char *amberhome;
if (strcmp(COLORTEXT, "YES") == 0 || strcmp(COLORTEXT, "yes") == 0) {
	if (argc == 2
		&& (strcmp(argv[1], "-h") == 0
			|| strcmp(argv[1], "-H") == 0)) {
		printf("Usage: poltop -i  topology file name\n"
		       "              -o  output file name\n"
		       "              -r  replace the existing polarizability in the topology? \n"
		       "                  1: yes (the default) \n"
		       "                  0: no  (use with care !)\n"
		       "              -m  polarizability models, suppressed by argument '-p'\n"
		       "                  A1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  B0: Applequist,        no 1-2 and 1-3, %50 of 1-4, also known as CA\n"
		       "                  B1: Thole linear,      no 1-2 and 1-3, %50 of 1-4, also known as CL\n"
		       "                  B2: Thole exponential, no 1-2 and 1-3, %50 of 1-4, also known as CE\n"
		       "                  B3: Thole tinker-like, no 1-2 and 1-3, %50 of 1-4, also known as CT\n"
		       "                  C0: Thole Applequist,  no 1-2 and 1-3, %83 of 1-4, also known as BA\n"
		       "                  C1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, also known as BL\n"
		       "                  C2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, also known as BE\n"
		       "                  C3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, also known as BT\n"
		       "                  D0: Thole Applequist,  no 1-2 and 1-3, %100 of 1-4, also known as AA\n"
		       "                  D1: Thole linear,      no 1-2 and 1-3, %100 of 1-4, also known as AL\n"
		       "                  D2: Thole exponential, no 1-2 and 1-3, %100 of 1-4, also known as AE\n"
		       "                  D3: Thole tinker-like, no 1-2 and 1-3, %100 of 1-4, also known as AT\n"
		       "              -t  atom type file, optional, the default is $AMBERHOME/dat/antechamber/ATCOR2.DAT\n"
		       "              -p  parameter file, optional\n");
		exit(1);
	}
	if (argc != 7 && argc !=9 && argc != 11 && argc != 13 && argc != 15) {
		printf("Usage: poltop -i  topology file name\n"
		       "              -o  output file name\n"
		       "              -r  replace the existing polarizability in the topology? \n"
		       "                  1: yes (the default) \n"
		       "                  0: no  (use with care !)\n"
		       "              -m  polarizability models, suppressed by argument '-p'\n"
		       "                  A1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  B0: Applequist,        no 1-2 and 1-3, %50 of 1-4, also known as CA\n"
		       "                  B1: Thole linear,      no 1-2 and 1-3, %50 of 1-4, also known as CL\n"
		       "                  B2: Thole exponential, no 1-2 and 1-3, %50 of 1-4, also known as CE\n"
		       "                  B3: Thole tinker-like, no 1-2 and 1-3, %50 of 1-4, also known as CT\n"
		       "                  C0: Thole Applequist,  no 1-2 and 1-3, %83 of 1-4, also known as BA\n"
		       "                  C1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, also known as BL\n"
		       "                  C2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, also known as BE\n"
		       "                  C3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, also known as BT\n"
		       "                  D0: Thole Applequist,  no 1-2 and 1-3, %100 of 1-4, also known as AA\n"
		       "                  D1: Thole linear,      no 1-2 and 1-3, %100 of 1-4, also known as AL\n"
		       "                  D2: Thole exponential, no 1-2 and 1-3, %100 of 1-4, also known as AE\n"
		       "                  D3: Thole tinker-like, no 1-2 and 1-3, %100 of 1-4, also known as AT\n"
		       "              -t  atom type file, optional, the default is $AMBERHOME/dat/antechamber/ATCOR2.DAT\n"
		       "              -p  parameter file, optional\n");
		exit(1);
	}
} else {
	if (argc == 2)
	if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-H") == 0) {
		printf("Usage: poltop -i  topology file name\n"
		       "              -o  output file name\n"
		       "              -r  replace the existing polarizability in the topology? \n"
		       "                  1: yes (the default) \n"
		       "                  0: no  (use with care !)\n"
		       "              -m  polarizability models, suppressed by argument '-p'\n"
		       "                  A1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  B0: Applequist,        no 1-2 and 1-3, %50 of 1-4, also known as CA\n"
		       "                  B1: Thole linear,      no 1-2 and 1-3, %50 of 1-4, also known as CL\n"
		       "                  B2: Thole exponential, no 1-2 and 1-3, %50 of 1-4, also known as CE\n"
		       "                  B3: Thole tinker-like, no 1-2 and 1-3, %50 of 1-4, also known as CT\n"
		       "                  C0: Thole Applequist,  no 1-2 and 1-3, %83 of 1-4, also known as BA\n"
		       "                  C1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, also known as BL\n"
		       "                  C2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, also known as BE\n"
		       "                  C3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, also known as BT\n"
		       "                  D0: Thole Applequist,  no 1-2 and 1-3, %100 of 1-4, also known as AA\n"
		       "                  D1: Thole linear,      no 1-2 and 1-3, %100 of 1-4, also known as AL\n"
		       "                  D2: Thole exponential, no 1-2 and 1-3, %100 of 1-4, also known as AE\n"
		       "                  D3: Thole tinker-like, no 1-2 and 1-3, %100 of 1-4, also known as AT\n"
		       "              -t  atom type file, optional, the default is $AMBERHOME/dat/antechamber/ATCOR2.DAT\n"
		       "              -p  parameter file, optional\n");
		exit(1);
	}
	if (argc != 7 && argc !=9 && argc != 11 && argc != 13) {
		printf("Usage: poltop -i  topology file name\n"
		       "              -o  output file name\n"
		       "              -r  replace the existing polarizability in the topology? \n"
		       "                  1: yes (the default) \n"
		       "                  0: no  (use with care !)\n"
		       "              -m  polarizability models, suppressed by argument '-p'\n"
		       "                  A1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  A3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, variable screening lengths \n"
		       "                  B0: Applequist,        no 1-2 and 1-3, %50 of 1-4, also known as CA\n"
		       "                  B1: Thole linear,      no 1-2 and 1-3, %50 of 1-4, also known as CL\n"
		       "                  B2: Thole exponential, no 1-2 and 1-3, %50 of 1-4, also known as CE\n"
		       "                  B3: Thole tinker-like, no 1-2 and 1-3, %50 of 1-4, also known as CT\n"
		       "                  C0: Thole Applequist,  no 1-2 and 1-3, %83 of 1-4, also known as BA\n"
		       "                  C1: Thole linear,      no 1-2 and 1-3, %83 of 1-4, also known as BL\n"
		       "                  C2: Thole exponential, no 1-2 and 1-3, %83 of 1-4, also known as BE\n"
		       "                  C3: Thole tinker-like, no 1-2 and 1-3, %83 of 1-4, also known as BT\n"
		       "                  D0: Thole Applequist,  no 1-2 and 1-3, %100 of 1-4, also known as AA\n"
		       "                  D1: Thole linear,      no 1-2 and 1-3, %100 of 1-4, also known as AL\n"
		       "                  D2: Thole exponential, no 1-2 and 1-3, %100 of 1-4, also known as AE\n"
		       "                  D3: Thole tinker-like, no 1-2 and 1-3, %100 of 1-4, also known as AT\n"
		       "              -t  atom type file, optional, the default is $AMBERHOME/dat/antechamber/ATCOR2.DAT\n"
		       "              -p  parameter file, optional\n");
		exit(1);
	}
}

ireplace = 1;
ireadat = 0;
ireadparm = 0;
strcpy(model, "A0");

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], "-p") == 0) {
		strcpy(pfilename, argv[i + 1]);
		ireadparm = 1;
	}
	if (strcmp(argv[i], "-t") == 0) {
		strcpy(tfilename, argv[i + 1]);
		ireadat = 1;
	}
	if (strcmp(argv[i], "-r") == 0) 
		ireplace = atoi(argv[i + 1]);
	if (strcmp(argv[i], "-m") == 0) 
		strcpy(model, argv[i + 1]);
}
if((fpin=fopen(ifilename,"r"))==NULL) {
    	fprintf(stdout, "\n Cannot open topology file: %s, exit", ifilename);
	exit(1);
}
if((fpout=fopen(ofilename,"w"))==NULL) {
	fprintf(stdout, "\n Cannot open file to write: %s, exit", ofilename);
	exit(1);
}
rtopparm();
atom = (ATOM *) malloc(sizeof(ATOM) * (atomnum + 10));
if (atom == NULL) {
        fprintf(stdout, "memory allocation error for *atom\n");
        exit(1);
}

if(ireadparm == 0) {
    amberhome = (char *) getenv("AMBERHOME");
    if( amberhome == NULL ){
       fprintf( stdout, "AMBERHOME is not set!\n" );
       exit(1);
    }
    strcpy(pfilename, amberhome);
    strcat(pfilename, "/dat/antechamber/POL.PARM"); 
    rparm();
}
else if(ireadparm == 1) rparm2();

if(ireadat == 0) {
    amberhome = (char *) getenv("AMBERHOME");
    if( amberhome == NULL ){
       fprintf( stdout, "AMBERHOME is not set!\n" );
       exit(1);
    }
    strcpy(tfilename, amberhome);
    strcat(tfilename, "/dat/antechamber/ATCOR2.DAT"); 
}
rcorr();
rewind(fpin);
rtopatom();

// find the parameters
for(i=0;i<atomnum;i++) {
	suc = 0;
	for(j=0;j<typenum;j++) {
		if(strcmp(atom[i].type, type[j].name) == 0) {
			pid = type[j].pid;
			if(ireplace == 1) atom[i].pol = parm[pid].pol;	
			atom[i].damp_factor = parm[pid].damp_factor;	
			suc = 1;
			break;
		}
	}
	if(suc == 0) {
		fprintf(stdout, "The atom type (%s) does not show up in the atom type file %s !\n", atom[i].type, tfilename);
		exit(0);
	}
	if(debug == 1) {
		printf("ATOM %d %5s %5s %9.5lf %9.5lf\n", i+1, atom[i].name, atom[i].type, atom[i].pol, atom[i].damp_factor);
	}
}

if(atom[0].damp_factor < -999990) idamp_factor = 0;

rewind(fpin);
wtop();
fclose(fpin);
fclose(fpout);
return(0);
}
Ejemplo n.º 2
0
int 
main(int argc, char *argv[])
{
  int prompt;
  complex **qin;
  Real *q;
  double starttime, endtime;
  
  int jflav, k;
  int key[4] = {1,1,1,1};  /* 4D Fourier transform */
  

  initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);

  g_sync();

  starttime=dclock();

  /* set up */
  prompt = setup();

  /* Set up for Fourier transform in all directions */
  if(prompt != 2)setup_restrict_fourier(key, NULL);

  /* loop over input sets */

  while( readin(prompt) == 0){
    
    if(prompt == 2)continue;   /* For testing */
  
    /* Create qin array */
    qin = (complex **)malloc(sizeof(complex *)*param.nrand);
    if(qin == NULL){
      node0_printf("main: No room for qin\n");
      terminate(1);
    }
    for(k = 0; k < param.nrand; k++){
      qin[k] = create_c_array_field(NMU);
      if(qin[k] == NULL){
	node0_printf("main: No room for qin[%d]\n",k);
	terminate(1);
      }
    }

    for(jflav = 0; jflav < param.nflav; jflav++){

      /* Allocate space and read all the data for flavor "jflav" */
      /* Accumulate the result in qin, weighted by the charge  */

      accumulate_current_density(param.fname[jflav], qin, param.charges[jflav], 
				 &param.mass[jflav], param.nrand);
    }
    
    /* Calculate the density-density correlator q */
    q = rcorr(qin, param.nrand);

    /* Destroy qin array */
    for(k = 0; k < param.nrand; k++)
      destroy_c_array_field(qin[k], NMU);
    free(qin);

    /* Symmetrize over hypercubic group transformations */
    symmetrize(q);

    /* Write the results to the specified file */
    print_result(q, param.nrand);

    destroy_r_field(q);
  
  } /* readin(prompt) */

  node0_printf("RUNNING COMPLETED\n");
  endtime=dclock();
    
  node0_printf("Time = %e seconds\n",(double)(endtime-starttime));

  normal_exit(0);
  return 0;
}