diff --git a/src/input.cpp b/src/input.cpp index 79bffa2af3..d506ddacc3 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1199,9 +1199,7 @@ void Input::package() fixarg[1] = (char *) "all"; fixarg[2] = (char *) "GPU"; for (int i = 1; i < narg; i++) fixarg[i+2] = arg[i]; - modify->allow_early_fix = 1; modify->add_fix(2+narg,fixarg,NULL); - modify->allow_early_fix = 0; delete [] fixarg; } else if (strcmp(arg[0],"omp") == 0) { @@ -1210,9 +1208,7 @@ void Input::package() fixarg[1] = (char *) "all"; fixarg[2] = (char *) "OMP"; for (int i = 1; i < narg; i++) fixarg[i+2] = arg[i]; - modify->allow_early_fix = 1; modify->add_fix(2+narg,fixarg,NULL); - modify->allow_early_fix = 0; delete [] fixarg; } else error->all(FLERR,"Illegal package command"); diff --git a/src/modify.cpp b/src/modify.cpp index b5713a5b2c..ebe9880fc2 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -30,9 +30,8 @@ using namespace LAMMPS_NS; using namespace FixConst; #define DELTA 4 - - #define BIG 1.0e20 +#define NEXCEPT 3 // change when add to exceptions in add_fix() /* ---------------------------------------------------------------------- */ @@ -70,8 +69,6 @@ Modify::Modify(LAMMPS *lmp) : Pointers(lmp) id_restart_peratom = style_restart_peratom = NULL; index_restart_peratom = NULL; - allow_early_fix = 0; - ncompute = maxcompute = 0; compute = NULL; } @@ -216,7 +213,8 @@ void Modify::init() int checkall; MPI_Allreduce(&check,&checkall,1,MPI_INT,MPI_SUM,world); if (comm->me == 0 && checkall) - error->warning(FLERR,"One or more atoms are time integrated more than once"); + error->warning(FLERR, + "One or more atoms are time integrated more than once"); } /* ---------------------------------------------------------------------- @@ -570,10 +568,24 @@ int Modify::min_reset_ref() void Modify::add_fix(int narg, char **arg, char *suffix) { - if (domain->box_exist == 0 && allow_early_fix == 0) - error->all(FLERR,"Fix command before simulation box is defined"); + const char *exceptions[NEXCEPT] = {"GPU","OMP","cmap"}; + if (narg < 3) error->all(FLERR,"Illegal fix command"); + // cannot define fix before box exists unless style is in exception list + // don't like this way of checking for exceptions by adding to list, + // but can't think of better way + // too late if instantiate fix, then check flag set in fix constructor, + // since some fixes access domain settings in their constructor + + if (domain->box_exist == 0) { + int m; + for (m = 0; m < NEXCEPT; m++) + if (strcmp(arg[2],exceptions[m]) == 0) break; + if (m == NEXCEPT) + error->all(FLERR,"Fix command before simulation box is defined"); + } + // check group ID int igroup = group->find(arg[1]); diff --git a/src/modify.h b/src/modify.h index 695d314294..cedf478d30 100644 --- a/src/modify.h +++ b/src/modify.h @@ -33,8 +33,6 @@ class Modify : protected Pointers { int nfix_restart_global; // stored fix global info from restart file int nfix_restart_peratom; // stored fix peratom info from restart file - int allow_early_fix; // 1 if allow fix creation at start of script - class Fix **fix; // list of fixes int *fmask; // bit mask for when each fix is applied