359 
359 
}

360 
360 
}

361 
361 

362 

static void center_x(int ecenter,rvec x[],matrix box,int n,int nc,atom_id ci[])


362 
static void center_x(int ecenter,rvec x[],matrix box,int n,int nc,atom_id ci[],bool omitLastDim)

363 
363 
{

364 
364 
int i,m,ai;

365 
365 
rvec cmin,cmax,box_center,dx;

...  ...  
378 
378 
}

379 
379 
calc_box_center(ecenter,box,box_center);

380 
380 
for(m=0; m<DIM; m++)


381 
if ((omitLastDim) && (m==DIM1)){


382 
dx[m]=0.0;


383 
}


384 
else{

381 
385 
dx[m] = box_center[m](cmin[m]+cmax[m])*0.5;

382 



386 
}

383 
387 
for(i=0; i<n; i++)

384 
388 
rvec_inc(x[i],dx);

385 
389 
}

...  ...  
614 
618 
{ NULL, "none", "rot+trans", "rotxy+transxy", "translation", "progressive", NULL };

615 
619 

616 
620 
static bool bAppend=FALSE,bSeparate=FALSE,bVels=TRUE,bForce=FALSE;

617 

static bool bCenter=FALSE,bTer=FALSE;


621 
static bool bCenter=FALSE,bCenterxy=FALSE,bTer=FALSE;

618 
622 
static int skip_nr=1,ndec=3,nzero=0;

619 
623 
static real tzero=0,delta_t=0,timestep=0,ttrunc=1,tdump=1,split_t=0;

620 
624 
static rvec newbox = {0,0,0}, shift = {0,0,0}, trans = {0,0,0};

...  ...  
638 
642 
"Unitcell representation" },

639 
643 
{ "center", FALSE, etBOOL, {&bCenter},

640 
644 
"Center atoms in box" },


645 
{ "centerxy", FALSE, etBOOL, {&bCenterxy},


646 
"Center atoms in box along x and y coordinate" },

641 
647 
{ "boxcenter", FALSE, etENUM, {center_opt},

642 
648 
"Center for pbc and center" },

643 
649 
{ "box", FALSE, etRVEC, {newbox},

...  ...  
904 
910 
}

905 
911 

906 
912 
if (bIndex) {

907 

if (bCenter) {


913 
if (bCenter  bCenterxy) {

908 
914 
printf("Select group for centering\n");

909 
915 
get_index(atoms,ftp2fn_null(efNDX,NFILE,fnm),

910 
916 
1,&ncent,&cindex,&grpnm);

...  ...  
923 
929 
for(i=0;i<natoms;i++)

924 
930 
index[i]=i;

925 
931 
nout=natoms;

926 

if (bCenter) {


932 
if (bCenter  bCenterxy) {

927 
933 
ncent = nout;

928 
934 
cindex = index;

929 
935 
}

...  ...  
1204 
1210 
reset_x_ndim(nfitdim,ifit,ind_fit,natoms,NULL,fr.x,w_rls);

1205 
1211 
if (bFit)

1206 
1212 
do_fit_ndim(nfitdim,natoms,w_rls,xp,fr.x);

1207 

if (!bCenter)


1213 
if (!bCenter  bCenterxy)

1208 
1214 
for(i=0; i<natoms; i++)

1209 
1215 
rvec_inc(fr.x[i],x_shift);

1210 
1216 
}

1211 
1217 

1212 

if (bCenter)

1213 

center_x(ecenter,fr.x,fr.box,natoms,ncent,cindex);


1218 
if (bCenter  bCenterxy)


1219 
center_x(ecenter,fr.x,fr.box,natoms,ncent,cindex,bCenterxy);

1214 
1220 
}

1215 
1221 

1216 
1222 
if (bPBCcomAtom) {
