Project

General

Profile

con-tpr-partial-fix.patch

patch - Alexey Shvetsov, 06/20/2015 09:42 AM

View differences:

src/gromacs/tools/convert_tpr.c
261 261
    t_topology   top;
262 262
    gmx_bool    *bKeep;
263 263
    atom_id     *invindex;
264
    gmx_mtop_atomlookup_t alook;
264 265
    int          i;
266
    int  molb=-1, molnr=-1, atnr=-1;
267
    int  molnri=-1, atnri=-1;
268
    int  molbc, molnrc, atnrc;
269
    int  *mbnmol, *mbnatmol;
265 270

  
266 271
    top      = gmx_mtop_t_to_t_topology(mtop);
272
    alook = gmx_mtop_atomlookup_init(mtop);
267 273
    bKeep    = bKeepIt(gnx, top.atoms.nr, index);
268 274
    invindex = invind(gnx, top.atoms.nr, index);
269 275

  
......
283 289
    }
284 290

  
285 291
    top.atoms.nr = gnx;
286

  
287
    mtop->nmoltype = 1;
288
    snew(mtop->moltype, mtop->nmoltype);
289
    mtop->moltype[0].name  = mtop->name;
290
    mtop->moltype[0].atoms = top.atoms;
291
    for (i = 0; i < F_NRE; i++)
292
    fprintf(stderr, "check: mtop->nmolblock = %d\n", mtop->nmolblock);
293
    snew(mbnmol, mtop->nmolblock);
294
    snew(mbnatmol, mtop->nmolblock);
295
    for(i=0;i<gnx;i++)
296
    {
297
        molbc = molb;
298
        molnrc = molnr;
299
        atnrc = atnr;
300
        gmx_mtop_atomnr_to_molblock_ind(alook, index[i], &molb, &molnr, &atnr);
301
        if (molb > molbc)
302
        {
303
            // block changed
304
            molnrc = -1;
305
            molnri = -1;
306
            if (molnr > molnrc)
307
            {
308
                // mol changed
309
                atnrc = -1;
310
                atnri = -1;
311
                molnri++;
312
                molnrc = molnr;
313
                mbnmol[molb] = molnri + 1;
314
                if (atnr > atnrc)
315
                {
316
                    // number of atoms changed
317
                    atnri++;
318
                    atnrc = atnr;
319
                    mbnatmol[molb] = atnri + 1;
320
                }
321
            } else {
322
                // same mol
323
                if (atnr > atnrc)
324
                {
325
                    atnri++;
326
                    atnrc = atnr;
327
                    mbnatmol[molb] = atnri + 1;
328
                }
329
            }
330
        } else {
331
            // same block
332
            if (molnr > molnrc)
333
            {
334
                // mol changed
335
                atnrc = -1;
336
                atnri = -1;
337
                molnri++;
338
                molnrc = molnr;
339
                mbnmol[molb] = molnri + 1;
340
                if (atnr > atnrc)
341
                {
342
                    // number of atoms changed
343
                    atnri++;
344
                    atnrc = atnr;
345
                    mbnatmol[molb] = atnri + 1;
346
                }
347
            } else {
348
                // same mol
349
                if (atnr > atnrc)
350
                {
351
                    atnri++;
352
                    atnrc = atnr;
353
                    mbnatmol[molb] = atnri + 1;
354
                }
355
            }
356
        }
357
    }
358
    // correct number of mols in molblocks in new top
359
    for(i=0; i<mtop->nmolblock;i++)
292 360
    {
293
        mtop->moltype[0].ilist[i] = top.idef.il[i];
361
        fprintf(stderr, "nmol in block %d is %d with %d atoms\n", i, mbnmol[i], mbnatmol[i]);
362
        mtop->molblock[i].nmol = mbnmol[i];
363
        mtop->molblock[i].natoms_mol = mbnatmol[i];
294 364
    }
295
    mtop->moltype[0].atoms = top.atoms;
296
    mtop->moltype[0].cgs   = top.cgs;
297
    mtop->moltype[0].excls = top.excls;
298

  
299
    mtop->nmolblock = 1;
300
    snew(mtop->molblock, mtop->nmolblock);
301
    mtop->molblock[0].type       = 0;
302
    mtop->molblock[0].nmol       = 1;
303
    mtop->molblock[0].natoms_mol = top.atoms.nr;
304
    mtop->molblock[0].nposres_xA = 0;
305
    mtop->molblock[0].nposres_xB = 0;
365
    fprintf(stderr, "check2: mtop->nmolblock = %d\n", mtop->nmolblock);
366
    mtop->mols.nr = top.mols.nr;
367

  
368
//    mtop->nmoltype = 1;
369
//    snew(mtop->moltype, mtop->nmoltype);
370
//    mtop->moltype[0].name  = mtop->name;
371
//    mtop->moltype[0].atoms = top.atoms;
372
//    for (i = 0; i < F_NRE; i++)
373
//    {
374
//        mtop->moltype[0].ilist[i] = top.idef.il[i];
375
//    }
376
//    mtop->moltype[0].atoms = top.atoms;
377
//    mtop->moltype[0].cgs   = top.cgs;
378
//    mtop->moltype[0].excls = top.excls;
306 379

  
307 380
    mtop->natoms                 = top.atoms.nr;
381
    gmx_mtop_atomlookup_destroy(alook);
308 382
}
309 383

  
310 384
static void zeroq(atom_id index[], gmx_mtop_t *mtop)