static void write_constr_pdb(const char *fn, const char *title, gmx_mtop_t *mtop, int start, int homenr, t_commrec *cr, rvec x[], matrix box) { char fname[STRLEN], format[STRLEN]; FILE *out; int dd_ac0 = 0, dd_ac1 = 0, i, ii, resnr; gmx_domdec_t *dd; char *anm, *resnm; dd = NULL; if (DOMAINDECOMP(cr)) { dd = cr->dd; dd_get_constraint_range(dd, &dd_ac0, &dd_ac1); start = 0; homenr = dd_ac1; } if (PAR(cr)) { sprintf(fname, "%s_n%d.pdb", fn, cr->sim_nodeid); } else { sprintf(fname, "%s.pdb", fn); } sprintf(format, "%s\n", get_pdbformat()); out = gmx_fio_fopen(fname, "w"); fprintf(out, "TITLE %s\n", title); gmx_write_pdb_box(out, -1, box); for (i = start; i < start+homenr; i++) { if (dd != NULL) { if (i >= dd->nat_home && i < dd_ac0) { continue; } ii = dd->gatindex[i]; } else { ii = i; } gmx_mtop_atominfo_global(mtop, ii, &anm, &resnr, &resnm); fprintf(out, format, "ATOM", (ii+1)%100000, anm, resnm, ' ', resnr%10000, ' ', 10*x[i][XX], 10*x[i][YY], 10*x[i][ZZ]); } fprintf(out, "TER\n"); gmx_fio_fclose(out); }
int init_mmcg( int nfile, // number of files const t_filenm fnm[], // file names t_inputrec* ir, // input record and box stuff gmx_mtop_t *top_global, // global topology int *allcgnr, // charge groups number int *allcgid[], // charge groups ids int *allsolnr, // solvent groups number int *allsolid[], // solvent groups ids t_commrec *cr // communicators ) { char *mmcgf, *topf, line[STRLEN+1], strtmp[STRLEN+1], *pos; FILE *mmcgfp, *topfp; int k0,k=0,i,resnr; int icg,cg0,cg1; int allatresnr, *allatresid; t_block all_cgs; all_cgs = gmx_mtop_global_cgs(top_global); // index of cgs for whole system mmcgf = ftp2fn(efGMX,nfile,fnm); if((mmcgfp = fopen(mmcgf,"r"))==NULL) { // opening-of mmcg-data failed fprintf(stderr, "ERROR : Impossible to open the mmcg-data file\n"); return 1; } while (!feof(mmcgfp)) { // counting lines in mmcg-data file if (fgets (line,STRLEN+1,mmcgfp)) allatresnr++; } // reading mmcg data snew (allatresid,allatresnr); rewind (mmcgfp); for (i=0,k=0; i<allatresnr;i++) { fgets(line,STRLEN+1,mmcgfp); if(line[0] == '#') { if(strstr(line,"nstwtlist")) { // number of step for list regeneration pos = strchr(line,'='); pos++; ir->mmcg.nstwtlist = atoi(pos); } else if (strstr(line,"shell1wt")) { // inner limit of water droplet pos = strchr(line,'='); pos++; ir->mmcg.shell1wt = atoi(pos); } else if (strstr(line,"shell2wt")) { // outer limit of water droplet pos = strchr(line,'='); pos++; ir->mmcg.shell2wt = atoi(pos); } continue; } // reading all-atoms resids allatresid[k] = atoi(line); if(allatresid[k] != 0) k++; } // end for, mmcg file scanning allatresnr = k; if (cr->nnodes!=1) gmx_barrier(cr); fclose(mmcgfp); // printing all-atoms resids in the log file fprintf(log,"MM/CG : gmx_resids: %d\n", allatresnr); for(i=0; i<allatresnr;i++) fprintf (log, " %d\n", allatresid[i]); fprintf(log,"\n"); // internal enumeration for (i=0; i<allatresnr;i++) (allatresid[i])--; // allocating charge groups and solvent snew(*allcgid, ncg_mtop(top_global)); int maxsol; // It seems that GROMACS did not store the correct number of solvent // molecules in top_global... At this point the value of nmol is more than 10 million! // => srenew() at the end of the routine when allsolnr will be computed int moltype_id=0; while (strcmp(top_global->moltype->name[moltype_id],"SOL")) { moltype_id++; } maxsol = top_global->molblock[moltype_id].nmol; MPI_Bcast(&maxsol,1,MPI_INT,0,cr->mpi_comm_mysim); snew(*allsolid, maxsol); // charge groups to monitor, first and last indices cg0 = 0; cg1 = ncg_mtop(top_global); char **atomname_=NULL,**resname_=NULL; // we need these to get the information of atoms // cf. mtop_utils.h for(icg=cg0; icg<cg1; icg++) { // get residue number and name of the cg's first atom k0 = all_cgs.index[icg]; gmx_mtop_atominfo_global(top_global,k0,&atomname_,&resnr,&resname_); if (!strcmp(resname_,"SOL")) { // Water (*allsolid)[*allsolnr] = icg; (*allsolnr)++; // counting waters } for (i=0; i<allatresnr; i++) { if (resnr == allatresid[i]) { // touché ! (*allcgid)[*allcgnr] = icg; (*allcgnr)++; // counting cg } } } if(cr->nnodes!=1) gmx_barrier(cr); return 0; }