diff --git a/lib/atc/LammpsInterface.h b/lib/atc/LammpsInterface.h index e9fb58293f..3b36adeac8 100644 --- a/lib/atc/LammpsInterface.h +++ b/lib/atc/LammpsInterface.h @@ -259,7 +259,7 @@ class LammpsInterface { /*@{*/ int atomPE_create(void); void atomPE_init(void); - void atomPE_addstep(int step); + void atomPE_addstep(LAMMPS_NS::bigint step); double * atomPE_compute(void); /*@}*/ diff --git a/src/FLD/pair_lubricateU_poly.cpp b/src/FLD/pair_lubricateU_poly.cpp index ae26bee060..894c778789 100644 --- a/src/FLD/pair_lubricateU_poly.cpp +++ b/src/FLD/pair_lubricateU_poly.cpp @@ -1127,15 +1127,15 @@ void PairLubricateUPoly::settings(int narg, char **arg) if (narg < 5 || narg > 7) error->all(FLERR,"Illegal pair_style command"); - mu = atof(arg[0]); - flaglog = atoi(arg[1]); - cut_inner_global = atof(arg[2]); - cut_global = atof(arg[3]); - gdot = atof(arg[4]); + mu = force->numeric(FLERR,arg[0]); + flaglog = force->inumeric(FLERR,arg[1]); + cut_inner_global = force->numeric(FLERR,arg[2]); + cut_global = force->numeric(FLERR,arg[3]); + gdot = force->numeric(FLERR,arg[4]); flagHI = flagVF = 1; - if (narg >= 6) flagHI = atoi(arg[5]); - if (narg == 7) flagVF = atoi(arg[6]); + if (narg >= 6) flagHI = force->inumeric(FLERR,arg[5]); + if (narg == 7) flagVF = force->inumeric(FLERR,arg[6]); if (flaglog == 1 && flagHI == 0) { error->warning(FLERR,"Cannot include log terms without 1/r terms; " diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 9707531d16..59876a82fa 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -68,8 +68,8 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : } else error->all(FLERR,"Illegal fix GPU command"); - first_gpu = atoi(arg[4]); - last_gpu = atoi(arg[5]); + first_gpu = force->inumeric(FLERR,arg[4]); + last_gpu = force->inumeric(FLERR,arg[5]); _particle_split = force->numeric(FLERR,arg[6]); if (_particle_split==0 || _particle_split>1) @@ -84,11 +84,11 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal fix GPU command"); if (strcmp(arg[iarg],"threads_per_atom") == 0) - threads_per_atom = atoi(arg[iarg+1]); + threads_per_atom = force->inumeric(FLERR,arg[iarg+1]); else if (strcmp(arg[iarg],"nthreads") == 0) - nthreads = atoi(arg[iarg+1]); + nthreads = force->inumeric(FLERR,arg[iarg+1]); else if (strcmp(arg[iarg],"cellsize") == 0) - cell_size = atof(arg[iarg+1]); + cell_size = force->numeric(FLERR,arg[iarg+1]); else error->all(FLERR,"Illegal fix GPU command"); diff --git a/src/KSPACE/fix_tune_kspace.cpp b/src/KSPACE/fix_tune_kspace.cpp index 014b9c70fe..2d854622ea 100644 --- a/src/KSPACE/fix_tune_kspace.cpp +++ b/src/KSPACE/fix_tune_kspace.cpp @@ -63,7 +63,7 @@ FixTuneKspace::FixTuneKspace(LAMMPS *lmp, int narg, char **arg) : // parse arguments - nevery = atoi(arg[3]); + nevery = force->inumeric(FLERR,arg[3]); // set up reneighboring diff --git a/src/KSPACE/pppm_old.cpp b/src/KSPACE/pppm_old.cpp index f050c734c9..911e296b1c 100644 --- a/src/KSPACE/pppm_old.cpp +++ b/src/KSPACE/pppm_old.cpp @@ -64,7 +64,7 @@ PPPMOld::PPPMOld(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg) pppmflag = 1; group_group_enable = 1; - accuracy_relative = atof(arg[0]); + accuracy_relative = fabs(force->numeric(FLERR,arg[0])); nfactors = 3; factors = new int[nfactors]; diff --git a/src/MAKE/Makefile.mingw b/src/MAKE/Makefile.mingw deleted file mode 100644 index 9dfaec5132..0000000000 --- a/src/MAKE/Makefile.mingw +++ /dev/null @@ -1,113 +0,0 @@ -# mingw = Windows 32bit, cross-compiled on Linux, gcc-4.4.1, MinGW x-compiler - -SHELL = /bin/sh - -# --------------------------------------------------------------------- -# compiler/linker settings -# specify flags and libraries needed for your compiler - -CC = i686-pc-mingw32-g++ -CCFLAGS = -O3 -march=i686 -mtune=generic -mfpmath=387 -mpc64 \ - -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fstrict-aliasing -Wall -W -Wno-uninitialized -SHFLAGS = -fPIC -DEPFLAGS = -M - -LINK = i686-pc-mingw32-g++ -LINKFLAGS = -O -LIB = -lwsock32 # -lwsock32 is needed for USER-IMD which uses tcp/ip sockets. -SIZE = i686-pc-mingw32-size - -ARCHIVE = ar -ARFLAGS = -rcsv -SHLIBFLAGS = -shared - -# --------------------------------------------------------------------- -# LAMMPS-specific settings -# specify settings for LAMMPS features you will use -# if you change any -D setting, do full re-compile after "make clean" - -# LAMMPS ifdef settings, OPTIONAL -# see possible settings in doc/Section_start.html#2_2 (step 4) - -LMP_INC = -DLAMMPS_XDR # -DLAMMPS_GZIP -DMALLOC_MEMALIGN=64 - -# MPI library, REQUIRED -# see discussion in doc/Section_start.html#2_2 (step 5) -# can point to dummy MPI library in src/STUBS as in Makefile.serial -# INC = path for mpi.h, MPI compiler settings -# PATH = path for MPI library -# LIB = name of MPI library - -MPI_INC = -I../STUBS -MPI_PATH = -MPI_LIB = mpi.o - -# FFT library, OPTIONAL -# see discussion in doc/Section_start.html#2_2 (step 6) -# can be left blank to use provided KISS FFT library -# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings -# PATH = path for FFT library -# LIB = name of FFT library - -FFT_INC = -DFFT_NONE #-DFFT_SINGLE -FFT_PATH = -FFT_LIB = #-lfftw - -# JPEG library, OPTIONAL -# see discussion in doc/Section_start.html#2_2 (step 7) -# only needed if -DLAMMPS_JPEG listed with LMP_INC -# INC = path for jpeglib.h -# PATH = path for JPEG library -# LIB = name of JPEG library - -JPG_INC = -JPG_PATH = -JPG_LIB = - -# --------------------------------------------------------------------- -# build rules and dependencies -# no need to edit this section - -include Makefile.package.settings -include Makefile.package - -EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC) -EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH) -EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB) - -# Path to src files - -vpath %.cpp .. -vpath %.h .. - -# Link target - -$(EXE): $(EXE).exe ../MAKE/mingw_cross.nsis - makensis ../MAKE/mingw_cross.nsis - (cd ..; zip -0 lammps-icms-win.zip lammps-icms-win.exe) - touch $(EXE) - -$(EXE).exe: $(OBJ) mpi.o - $(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE).exe - $(SIZE) $(EXE).exe - -# Library target - -lib: $(OBJ) - $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ) - -# Compilation rules - -%.o:%.cpp - $(CC) $(CCFLAGS) $(EXTRA_INC) -c $< - -%.d:%.cpp - $(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $< > $@ - -# Individual dependencies - -mpi.o: ../STUBS/mpi.c ../STUBS/mpi.h - $(CC) $(CCFLAGS) $(EXTRA_INC) -c $< - -DEPENDS = $(OBJ:.o=.d) -sinclude $(DEPENDS) diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index f298f431c9..b13f24c10d 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -50,8 +50,10 @@ #include "neigh_request.h" #include "memory.h" #include "error.h" +#include "math_special.h" using namespace LAMMPS_NS; +using namespace MathSpecial; #define MAXLINE 1024 #define EPSILON 1.0e-6 @@ -7223,9 +7225,9 @@ void PairBOP::PiBo() // piB is similary formulation to (a) Eq. 36 and (b) Eq. 18 piB[n]=(ABrtR1+ABrtR2)*pi_a[iij]*betaP[temp_ij]; - dPiB1=-.5*(pow(ABrtR1,3)+pow(ABrtR2,3))*pi_c[iij]*pi_a[iij]*betaP[temp_ij]; - dPiB2=.25*BBrtR*(pow(ABrtR2,3)-pow(ABrtR1,3))*pi_c[iij]*pi_a[iij]*betaP[temp_ij]; - dPiB3=((ABrtR1+ABrtR2)*pi_a[iij]-(pow(ABrtR1,3)+pow(ABrtR2,3))*pi_a[iij] + dPiB1=-.5*(cube(ABrtR1)+cube(ABrtR2))*pi_c[iij]*pi_a[iij]*betaP[temp_ij]; + dPiB2=.25*BBrtR*(cube(ABrtR2)-cube(ABrtR1))*pi_c[iij]*pi_a[iij]*betaP[temp_ij]; + dPiB3=((ABrtR1+ABrtR2)*pi_a[iij]-(cube(ABrtR1)+cube(ABrtR2))*pi_a[iij] *betaP[temp_ij]*betaP[temp_ij])*dBetaP[temp_ij]/rij[temp_ij]; n++; pp2=2.0*betaP[temp_ij]; @@ -8147,9 +8149,9 @@ void PairBOP::PiBo_otf() // piB is similary formulation to (a) Eq. 36 and (b) Eq. 18 piB[n]=(ABrtR1+ABrtR2)*pi_a[iij]*betaP_ij; - dPiB1=-.5*(pow(ABrtR1,3)+pow(ABrtR2,3))*pi_c[iij]*pi_a[iij]*betaP_ij; - dPiB2=.25*BBrtR*(pow(ABrtR2,3)-pow(ABrtR1,3))*pi_c[iij]*pi_a[iij]*betaP_ij; - dPiB3=((ABrtR1+ABrtR2)*pi_a[iij]-(pow(ABrtR1,3)+pow(ABrtR2,3))*pi_a[iij] + dPiB1=-.5*(cube(ABrtR1)+cube(ABrtR2))*pi_c[iij]*pi_a[iij]*betaP_ij; + dPiB2=.25*BBrtR*(cube(ABrtR2)-cube(ABrtR1))*pi_c[iij]*pi_a[iij]*betaP_ij; + dPiB3=((ABrtR1+ABrtR2)*pi_a[iij]-(cube(ABrtR1)+cube(ABrtR2))*pi_a[iij] *betaP_ij*betaP_ij)*dBetaP_ij/r_ij; n++; @@ -9017,7 +9019,7 @@ void PairBOP::setSign() cs=0.0; if(xBOsfree(params); params = NULL; - nparams = 0; + nparams = maxparam = 0; // open file on proc 0 diff --git a/src/OPT/pair_lj_cut_tip4p_long_opt.cpp b/src/OPT/pair_lj_cut_tip4p_long_opt.cpp index 8520496423..30ef318799 100644 --- a/src/OPT/pair_lj_cut_tip4p_long_opt.cpp +++ b/src/OPT/pair_lj_cut_tip4p_long_opt.cpp @@ -106,19 +106,19 @@ template < const int CTABLE, const int EVFLAG, const int EFLAG, const int VFLAG> void PairLJCutTIP4PLongOpt::eval() { + double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul; + double fraction,table; + double r,rsq,r2inv,r6inv,forcecoul,forcelj,cforce; + double factor_coul,factor_lj; + double grij,expm2,prefactor,t,erfc; + double v[6],xH1[3],xH2[3]; + double fdx,fdy,fdz,fOx,fOy,fOz,fHx,fHy,fHz; + const double *x1,*x2; + + int *ilist,*jlist,*numneigh,**firstneigh; int i,j,ii,jj,inum,jnum,itype,jtype,itable,key; int n,vlist[6]; int iH1,iH2,jH1,jH2; - double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul; - double fraction,table; - double delxOM,delyOM,delzOM; - double r,rsq,r2inv,r6inv,forcecoul,forcelj,cforce; - double factor_coul,factor_lj; - double grij,expm2,prefactor,t,erfc,ddotf; - double v[6],xH1[3],xH2[3]; - double fdx,fdy,fdz,f1x,f1y,f1z,fOx,fOy,fOz,fHx,fHy,fHz; - const double *x1,*x2; - int *ilist,*jlist,*numneigh,**firstneigh; evdwl = ecoul = 0.0; @@ -434,7 +434,6 @@ void PairLJCutTIP4PLongOpt::eval() } } -/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- compute position xM of fictitious charge site for O atom and 2 H atoms return it as xM diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 86922826d3..f3b958f491 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -31,6 +31,7 @@ #include "timer.h" #include "memory.h" #include "error.h" +#include "force.h" using namespace LAMMPS_NS; @@ -105,11 +106,11 @@ void NEB::command(int narg, char **arg) if (narg != 6) error->universe_all(FLERR,"Illegal NEB command"); - etol = atof(arg[0]); - ftol = atof(arg[1]); - n1steps = atoi(arg[2]); - n2steps = atoi(arg[3]); - nevery = atoi(arg[4]); + etol = force->numeric(FLERR,arg[0]); + ftol = force->numeric(FLERR,arg[1]); + n1steps = force->inumeric(FLERR,arg[2]); + n2steps = force->inumeric(FLERR,arg[3]); + nevery = force->inumeric(FLERR,arg[4]); infile = arg[5]; // error checks diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index e68f53b309..727c728ae9 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -73,15 +73,15 @@ void PRD::command(int narg, char **arg) if (narg < 7) error->universe_all(FLERR,"Illegal prd command"); - nsteps = atoi(arg[0]); - t_event = atoi(arg[1]); - n_dephase = atoi(arg[2]); - t_dephase = atoi(arg[3]); - t_corr = atoi(arg[4]); + nsteps = force->inumeric(FLERR,arg[0]); + t_event = force->inumeric(FLERR,arg[1]); + n_dephase = force->inumeric(FLERR,arg[2]); + t_dephase = force->inumeric(FLERR,arg[3]); + t_corr = force->inumeric(FLERR,arg[4]); char *id_compute = new char[strlen(arg[5])+1]; strcpy(id_compute,arg[5]); - int seed = atoi(arg[6]); + int seed = force->inumeric(FLERR,arg[6]); options(narg-7,&arg[7]); diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index d0d8336f61..9510038e63 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -91,12 +91,12 @@ void TAD::command(int narg, char **arg) if (narg < 7) error->universe_all(FLERR,"Illegal tad command"); - nsteps = atoi(arg[0]); - t_event = atoi(arg[1]); - templo = atof(arg[2]); - temphi = atof(arg[3]); - delta_conf = atof(arg[4]); - tmax = atof(arg[5]); + nsteps = force->inumeric(FLERR,arg[0]); + t_event = force->inumeric(FLERR,arg[1]); + templo = force->numeric(FLERR,arg[2]); + temphi = force->numeric(FLERR,arg[3]); + delta_conf = force->numeric(FLERR,arg[4]); + tmax = force->numeric(FLERR,arg[5]); char *id_compute = new char[strlen(arg[6])+1]; strcpy(id_compute,arg[6]); diff --git a/src/REPLICA/temper.cpp b/src/REPLICA/temper.cpp index f0e0a93190..6714c365e3 100644 --- a/src/REPLICA/temper.cpp +++ b/src/REPLICA/temper.cpp @@ -70,20 +70,20 @@ void Temper::command(int narg, char **arg) if (narg != 6 && narg != 7) error->universe_all(FLERR,"Illegal temper command"); - int nsteps = atoi(arg[0]); - nevery = atoi(arg[1]); - double temp = atof(arg[2]); + int nsteps = force->inumeric(FLERR,arg[0]); + nevery = force->inumeric(FLERR,arg[1]); + double temp = force->numeric(FLERR,arg[2]); for (whichfix = 0; whichfix < modify->nfix; whichfix++) if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; if (whichfix == modify->nfix) error->universe_all(FLERR,"Tempering fix ID is not defined"); - seed_swap = atoi(arg[4]); - seed_boltz = atoi(arg[5]); + seed_swap = force->inumeric(FLERR,arg[4]); + seed_boltz = force->inumeric(FLERR,arg[5]); my_set_temp = universe->iworld; - if (narg == 7) my_set_temp = atoi(arg[6]); + if (narg == 7) my_set_temp = force->inumeric(FLERR,arg[6]); // swap frequency must evenly divide total # of timesteps diff --git a/src/RIGID/fix_rigid_nh.cpp b/src/RIGID/fix_rigid_nh.cpp index 6bcabe2a7b..5bf931db62 100644 --- a/src/RIGID/fix_rigid_nh.cpp +++ b/src/RIGID/fix_rigid_nh.cpp @@ -612,7 +612,7 @@ void FixRigidNH::final_integrate() // sum over atoms to get force and torque on rigid body - int *image = atom->image; + tagint *image = atom->image; double **x = atom->x; double **f = atom->f; int nlocal = atom->nlocal; diff --git a/src/XTC/xdr_compat.h b/src/XTC/xdr_compat.h index d1946ef0af..d51663a793 100644 --- a/src/XTC/xdr_compat.h +++ b/src/XTC/xdr_compat.h @@ -60,7 +60,7 @@ extern "C" { typedef int bool_t; -#if defined(__MINGW32_VERSION) +#if defined(__MINGW32__) typedef char * caddr_t; typedef unsigned int u_int; #endif diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 49684020c8..2f1793dfba 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -40,7 +40,7 @@ enum{DIAMETER,CHARGE}; FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { if (narg < 5) error->all(FLERR,"Illegal fix adapt command"); - nevery = atoi(arg[3]); + nevery = force->inumeric(FLERR,arg[3]); if (nevery < 0) error->all(FLERR,"Illegal fix adapt command"); // count # of adaptations diff --git a/src/min.cpp b/src/min.cpp index 8fb1eb8330..a158fb9739 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -606,7 +606,7 @@ void Min::modify_params(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"dmax") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal min_modify command"); - dmax = atof(arg[iarg+1]); + dmax = force->numeric(FLERR,arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"line") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal min_modify command"); diff --git a/src/minimize.cpp b/src/minimize.cpp index 98dfa6e558..44a037c49f 100644 --- a/src/minimize.cpp +++ b/src/minimize.cpp @@ -19,6 +19,7 @@ #include "finish.h" #include "timer.h" #include "error.h" +#include "force.h" using namespace LAMMPS_NS; @@ -35,10 +36,10 @@ void Minimize::command(int narg, char **arg) if (domain->box_exist == 0) error->all(FLERR,"Minimize command before simulation box is defined"); - update->etol = atof(arg[0]); - update->ftol = atof(arg[1]); - update->nsteps = atoi(arg[2]); - update->max_eval = atoi(arg[3]); + update->etol = force->numeric(FLERR,arg[0]); + update->ftol = force->numeric(FLERR,arg[1]); + update->nsteps = force->inumeric(FLERR,arg[2]); + update->max_eval = force->inumeric(FLERR,arg[3]); if (update->etol < 0.0 || update->ftol < 0.0) error->all(FLERR,"Illegal minimize command"); diff --git a/src/pair.cpp b/src/pair.cpp index fb24b9fd5d..cc8e0f2551 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -127,23 +127,23 @@ void Pair::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"table") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - ncoultablebits = atoi(arg[iarg+1]); + ncoultablebits = force->inumeric(FLERR,arg[iarg+1]); if (ncoultablebits > sizeof(float)*CHAR_BIT) error->all(FLERR,"Too many total bits for bitmapped lookup table"); iarg += 2; } else if (strcmp(arg[iarg],"table/disp") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - ndisptablebits = atoi(arg[iarg+1]); + ndisptablebits = force->inumeric(FLERR,arg[iarg+1]); if (ndisptablebits > sizeof(float)*CHAR_BIT) error->all(FLERR,"Too many total bits for bitmapped lookup table"); iarg += 2; } else if (strcmp(arg[iarg],"tabinner") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - tabinner = atof(arg[iarg+1]); + tabinner = force->numeric(FLERR,arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"tabinner/disp") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - tabinner_disp = atof(arg[iarg+1]); + tabinner_disp = force->numeric(FLERR,arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"tail") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); @@ -1449,12 +1449,12 @@ void Pair::write_file(int narg, char **arg) // parse arguments - int itype = atoi(arg[0]); - int jtype = atoi(arg[1]); + int itype = force->inumeric(FLERR,arg[0]); + int jtype = force->inumeric(FLERR,arg[1]); if (itype < 1 || itype > atom->ntypes || jtype < 1 || jtype > atom->ntypes) error->all(FLERR,"Invalid atom types in pair_write command"); - int n = atoi(arg[2]); + int n = force->inumeric(FLERR,arg[2]); int style; if (strcmp(arg[3],"r") == 0) style = RLINEAR; @@ -1462,8 +1462,8 @@ void Pair::write_file(int narg, char **arg) else if (strcmp(arg[3],"bitmap") == 0) style = BMP; else error->all(FLERR,"Invalid style in pair_write command"); - double inner = atof(arg[4]); - double outer = atof(arg[5]); + double inner = force->numeric(FLERR,arg[4]); + double outer = force->numeric(FLERR,arg[5]); if (inner <= 0.0 || inner >= outer) error->all(FLERR,"Invalid cutoffs in pair_write command"); @@ -1503,8 +1503,8 @@ void Pair::write_file(int narg, char **arg) double q[2]; q[0] = q[1] = 1.0; if (narg == 10) { - q[0] = atof(arg[8]); - q[1] = atof(arg[9]); + q[0] = force->numeric(FLERR,arg[8]); + q[1] = force->numeric(FLERR,arg[9]); } double *q_hold; @@ -1623,6 +1623,8 @@ FILE *Pair::open_potential(const char *name) { FILE *fp; + if (name == NULL) return NULL; + // attempt to open file directly // if successful, return ptr @@ -1635,10 +1637,12 @@ FILE *Pair::open_potential(const char *name) if (path == NULL) return NULL; const char *pot = potname(name); + if (pot == NULL) return NULL; + size_t len1 = strlen(path); size_t len2 = strlen(pot); + char *newpath = new char[len1+len2+2]; - char *newpath = new char[len1+len2]; strcpy(newpath,path); #if defined(_WIN32) newpath[len1] = '\\'; @@ -1662,6 +1666,8 @@ const char *Pair::potname(const char *path) { const char *pot; + if (path == NULL) return NULL; + #if defined(_WIN32) // skip over the disk drive part of windows pathnames if (isalpha(path[0]) && path[1] == ':') @@ -1687,3 +1693,4 @@ double Pair::memory_usage() bytes += comm->nthreads*maxvatom*6 * sizeof(double); return bytes; } + diff --git a/src/rerun.cpp b/src/rerun.cpp index 94600bc882..56d416cfc0 100644 --- a/src/rerun.cpp +++ b/src/rerun.cpp @@ -24,6 +24,7 @@ #include "finish.h" #include "timer.h" #include "error.h" +#include "force.h" using namespace LAMMPS_NS; @@ -80,12 +81,12 @@ void Rerun::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"every") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal rerun command"); - nevery = atoi(arg[iarg+1]); + nevery = force->inumeric(FLERR,arg[iarg+1]); if (nevery < 0) error->all(FLERR,"Illegal rerun command"); iarg += 2; } else if (strcmp(arg[iarg],"skip") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal rerun command"); - nskip = atoi(arg[iarg+1]); + nskip = force->inumeric(FLERR,arg[iarg+1]); if (nskip <= 0) error->all(FLERR,"Illegal rerun command"); iarg += 2; } else if (strcmp(arg[iarg],"start") == 0) { diff --git a/src/respa.cpp b/src/respa.cpp index 42da6ccbf4..67783ab2d1 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -46,13 +46,13 @@ Respa::Respa(LAMMPS *lmp, int narg, char **arg) : Integrate(lmp, narg, arg) { if (narg < 1) error->all(FLERR,"Illegal run_style respa command"); - nlevels = atoi(arg[0]); + nlevels = force->inumeric(FLERR,arg[0]); if (nlevels < 1) error->all(FLERR,"Respa levels must be >= 1"); if (narg < nlevels) error->all(FLERR,"Illegal run_style respa command"); loop = new int[nlevels]; for (int iarg = 1; iarg < nlevels; iarg++) { - loop[iarg-1] = atoi(arg[iarg]); + loop[iarg-1] = force->inumeric(FLERR,arg[iarg]); if (loop[iarg-1] <= 0) error->all(FLERR,"Illegal run_style respa command"); } loop[nlevels-1] = 1; @@ -68,43 +68,43 @@ Respa::Respa(LAMMPS *lmp, int narg, char **arg) : Integrate(lmp, narg, arg) while (iarg < narg) { if (strcmp(arg[iarg],"bond") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_bond = atoi(arg[iarg+1]) - 1; + level_bond = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else if (strcmp(arg[iarg],"angle") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_angle = atoi(arg[iarg+1]) - 1; + level_angle = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else if (strcmp(arg[iarg],"dihedral") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_dihedral = atoi(arg[iarg+1]) - 1; + level_dihedral = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else if (strcmp(arg[iarg],"improper") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_improper = atoi(arg[iarg+1]) - 1; + level_improper = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else if (strcmp(arg[iarg],"pair") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_pair = atoi(arg[iarg+1]) - 1; + level_pair = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else if (strcmp(arg[iarg],"inner") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_inner = atoi(arg[iarg+1]) - 1; - cutoff[0] = atof(arg[iarg+2]); - cutoff[1] = atof(arg[iarg+3]); + level_inner = force->inumeric(FLERR,arg[iarg+1]) - 1; + cutoff[0] = force->numeric(FLERR,arg[iarg+2]); + cutoff[1] = force->numeric(FLERR,arg[iarg+3]); iarg += 4; } else if (strcmp(arg[iarg],"middle") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_middle = atoi(arg[iarg+1]) - 1; - cutoff[2] = atof(arg[iarg+2]); - cutoff[3] = atof(arg[iarg+3]); + level_middle = force->inumeric(FLERR,arg[iarg+1]) - 1; + cutoff[2] = force->numeric(FLERR,arg[iarg+2]); + cutoff[3] = force->numeric(FLERR,arg[iarg+3]); iarg += 4; } else if (strcmp(arg[iarg],"outer") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_outer = atoi(arg[iarg+1]) - 1; + level_outer = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else if (strcmp(arg[iarg],"kspace") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run_style respa command"); - level_kspace = atoi(arg[iarg+1]) - 1; + level_kspace = force->inumeric(FLERR,arg[iarg+1]) - 1; iarg += 2; } else error->all(FLERR,"Illegal run_style respa command"); } diff --git a/src/run.cpp b/src/run.cpp index 781001ae9f..4aaedcfd63 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -23,6 +23,7 @@ #include "input.h" #include "timer.h" #include "error.h" +#include "force.h" using namespace LAMMPS_NS; @@ -90,7 +91,7 @@ void Run::command(int narg, char **arg) } else if (strcmp(arg[iarg],"every") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal run command"); - nevery = atoi(arg[iarg+1]); + nevery = force->inumeric(FLERR,arg[iarg+1]); if (nevery <= 0) error->all(FLERR,"Illegal run command"); first = iarg+2; last = narg-1; diff --git a/src/universe.cpp b/src/universe.cpp index 62048c55a9..35d8f2cf24 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -18,6 +18,7 @@ #include "universe.h" #include "version.h" #include "error.h" +#include "force.h" #include "memory.h" using namespace LAMMPS_NS; @@ -77,7 +78,7 @@ void Universe::reorder(char *style, char *arg) if (uworld != uorig) MPI_Comm_free(&uworld); if (strcmp(style,"nth") == 0) { - int n = atoi(arg); + int n = force->inumeric(FLERR,arg); if (n <= 0) error->universe_all(FLERR,"Invalid -reorder N value"); if (nprocs % n)