update formatting to closer match LAMMPS' programming style

This commit is contained in:
Axel Kohlmeyer
2018-11-02 21:33:30 -04:00
parent d185b34b19
commit df3390e224

View File

@ -55,6 +55,8 @@
#include "plumed/wrapper/Plumed.h"
/* -------------------------------------------------------------------- */
using namespace LAMMPS_NS;
using namespace FixConst;
@ -62,28 +64,37 @@ using namespace FixConst;
FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
p(NULL),
nlocal(0),
gatindex(NULL),
masses(NULL),
charges(NULL),
id_pe(NULL),
id_press(NULL)
p(NULL), nlocal(0), gatindex(NULL), masses(NULL), charges(NULL),
id_pe(NULL), id_press(NULL)
{
// Not sure this is really necessary:
if (!atom->tag_enable) error->all(FLERR,"fix plumed requires atom tags");
// Initialize plumed:
p=new PLMD::Plumed;
// Check API version
int api_version; p->cmd("getApiVersion",&api_version);
if( api_version>6 ) error->all(FLERR,"invalid api version for PLUMED");
// If the -partition option is activated then enable inter-partition communication
if (!atom->tag_enable)
error->all(FLERR,"Fix plumed requires atom tags");
if (igroup != 0 && comm->me == 0)
error->warning(FLERR,"Fix group for fix plumed is not 'all'. "
"Group will be ignored.");
p=new PLMD::Plumed;
// Check API version
int api_version;
p->cmd("getApiVersion",&api_version);
if (api_version > 6)
error->all(FLERR,"Incompatible API version for PLUMED in fix plumed");
// If the -partition option is activated then enable
// inter-partition communication
if (universe->existflag == 1) {
int me;
MPI_Comm inter_comm;
MPI_Comm_rank(world,&me);
// Change MPI_COMM_WORLD to universe->uworld which seems more appropriate
MPI_Comm_split(universe->uworld,me,0,&inter_comm);
p->cmd("GREX setMPIIntracomm",&world);
if (me == 0) {
@ -94,9 +105,12 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
}
p->cmd("GREX init",NULL);
}
// The general communicator is independent of the existence of partitions,
// if there are partitions, world is defined within each partition,
// whereas if partitions are not defined then world is equal to MPI_COMM_WORLD.
// whereas if partitions are not defined then world is equal to
// MPI_COMM_WORLD.
p->cmd("setMPIComm",&world);
// Set up units
@ -144,8 +158,9 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
// Read fix parameters:
int next=0;
for (int i=3;i<narg;++i) {
if(!strcmp(arg[i],"outfile")) next=1;
else if(next==1){
if (!strcmp(arg[i],"outfile")) {
next=1;
} else if (next==1) {
if (universe->existflag == 1) {
// Each replica writes an independent log file
// with suffix equal to the replica id
@ -160,13 +175,13 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
p->cmd("setLogFile",arg[i]);
next=0;
}
}
else if(!strcmp(arg[i],"plumedfile"))next=2;
else if(next==2){
} else if (!strcmp(arg[i],"plumedfile")) {
next=2;
} else if (next==2) {
p->cmd("setPlumedDat",arg[i]);
next=0;
}
else error->all(FLERR,"syntax error in fix plumed - use 'fix name plumed plumedfile plumed.dat outfile plumed.out' ");
} else error->all(FLERR,"Syntax error - use 'fix <fix-ID> plumed "
"plumedfile plumed.dat outfile plumed.out' ");
}
if (next==1) error->all(FLERR,"missing argument for outfile option");
if (next==2) error->all(FLERR,"missing argument for plumedfile option");
@ -184,9 +199,11 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
scalar_flag = 1;
// This is the real initialization:
p->cmd("init");
// Define compute to calculate potential energy
id_pe = new char[7];
id_pe = (char *) "plmd_pe";
char **newarg = new char*[3];