diff --git a/cmake/Modules/ExternalCMakeProject.cmake b/cmake/Modules/ExternalCMakeProject.cmake index 75c33ab99e..7e3681dc28 100644 --- a/cmake/Modules/ExternalCMakeProject.cmake +++ b/cmake/Modules/ExternalCMakeProject.cmake @@ -43,5 +43,5 @@ function(ExternalCMakeProject target url hash basedir cmakedir cmakefile) "${CMAKE_BINARY_DIR}/_deps/${target}-src/${cmakedir}/CMakeLists.txt") endif() add_subdirectory("${CMAKE_BINARY_DIR}/_deps/${target}-src/${cmakedir}" - "${CMAKE_BINARY_DIR}/_deps/${target}-build") + "${CMAKE_BINARY_DIR}/_deps/${target}-build" EXCLUDE_FROM_ALL) endfunction(ExternalCMakeProject) diff --git a/cmake/Modules/OpenCLLoader.cmake b/cmake/Modules/OpenCLLoader.cmake index 23ca81a5f2..4b5c5a1200 100644 --- a/cmake/Modules/OpenCLLoader.cmake +++ b/cmake/Modules/OpenCLLoader.cmake @@ -1,6 +1,6 @@ message(STATUS "Downloading and building OpenCL loader library") -set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2022.01.04.tar.gz" CACHE STRING "URL for OpenCL loader tarball") -set(OPENCL_LOADER_MD5 "8d3a801e87a2c6653bf0e27707063914" CACHE STRING "MD5 checksum of OpenCL loader tarball") +set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2024.02.09.tar.gz" CACHE STRING "URL for OpenCL loader tarball") +set(OPENCL_LOADER_MD5 "f3573cf9daa3558ba46fd5866517f38f" CACHE STRING "MD5 checksum of OpenCL loader tarball") mark_as_advanced(OPENCL_LOADER_URL) mark_as_advanced(OPENCL_LOADER_MD5) @@ -8,4 +8,3 @@ set(INSTALL_LIBOPENCL OFF CACHE BOOL "" FORCE) include(ExternalCMakeProject) ExternalCMakeProject(opencl_loader ${OPENCL_LOADER_URL} ${OPENCL_LOADER_MD5} opencl-loader . "") -add_library(OpenCL::OpenCL ALIAS OpenCL) diff --git a/cmake/Modules/Packages/KSPACE.cmake b/cmake/Modules/Packages/KSPACE.cmake index 6060d4b1db..1fdd898144 100644 --- a/cmake/Modules/Packages/KSPACE.cmake +++ b/cmake/Modules/Packages/KSPACE.cmake @@ -91,7 +91,7 @@ if(FFT_USE_HEFFTE) string(REPLACE "@Heffte_GIT_HASH@" "(unknown)" HEFFTE_CFG_FILE_TEXT "${HEFFTE_CFG_FILE_TEXT}") file(WRITE ${heffte_project_SOURCE_DIR}/include/heffte_config.cmake.h "${HEFFTE_CFG_FILE_TEXT}") - add_subdirectory(${heffte_project_SOURCE_DIR} ${heffte_project_BINARY_DIR}) + add_subdirectory(${heffte_project_SOURCE_DIR} ${heffte_project_BINARY_DIR} EXCLUDE_FROM_ALL) add_library(Heffte::Heffte ALIAS Heffte) if(BUILD_SHARED_LIBS_WAS_ON) set(BUILD_SHARED_LIBS ON) diff --git a/cmake/Modules/Packages/PLUMED.cmake b/cmake/Modules/Packages/PLUMED.cmake index b90bff4b9c..b1a4f3cc72 100644 --- a/cmake/Modules/Packages/PLUMED.cmake +++ b/cmake/Modules/Packages/PLUMED.cmake @@ -21,9 +21,9 @@ else() set(PLUMED_CONFIG_OMP "--disable-openmp") endif() -set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.8.2/plumed-src-2.8.2.tgz" +set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.8.3/plumed-src-2.8.3.tgz" CACHE STRING "URL for PLUMED tarball") -set(PLUMED_MD5 "599092b6a0aa6fff992612537ad98994" CACHE STRING "MD5 checksum of PLUMED tarball") +set(PLUMED_MD5 "76d23cd394eba9e6530316ed1184e219" CACHE STRING "MD5 checksum of PLUMED tarball") mark_as_advanced(PLUMED_URL) mark_as_advanced(PLUMED_MD5) diff --git a/doc/src/create_atoms.rst b/doc/src/create_atoms.rst index 5d1e7c872c..f0dc857dcd 100644 --- a/doc/src/create_atoms.rst +++ b/doc/src/create_atoms.rst @@ -536,6 +536,11 @@ command. A rotation vector specified for a single molecule must be in the z-direction for a 2d model. +For :doc:`molecule templates ` that are created from multiple +files, i.e. contain multiple molecule *sets*, only the first set is +used. To create multiple molecules the files currently need to be +merged and different molecule IDs assigned with a Molecules section. + Related commands """""""""""""""" diff --git a/lib/gpu/Makefile.lammps.mingw-cross b/lib/gpu/Makefile.lammps.mingw-cross deleted file mode 100644 index 0b304b0e0c..0000000000 --- a/lib/gpu/Makefile.lammps.mingw-cross +++ /dev/null @@ -1,6 +0,0 @@ -# Settings that the LAMMPS build will import when this package library is used -# settings for OpenCL builds -gpu_SYSINC = -gpu_SYSLIB = -Wl,--enable-stdcall-fixup -L../../tools/mingw-cross$(LIBOBJDIR) -Wl,-Bdynamic,-lOpenCL,-Bstatic -gpu_SYSPATH = - diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index 9c42da4089..4a158cb31f 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -17,17 +17,17 @@ parser = ArgumentParser(prog='Install.py', # settings -version = "2.8.2" +version = "2.8.3" mode = "static" # help message HELP = """ Syntax from src dir: make lib-plumed args="-b" - or: make lib-plumed args="-b -v 2.8.2" + or: make lib-plumed args="-b -v 2.8.3" or: make lib-plumed args="-p /usr/local/plumed2 -m shared" -Syntax from lib dir: python Install.py -b -v 2.8.2 +Syntax from lib dir: python Install.py -b -v 2.8.3 or: python Install.py -b or: python Install.py -p /usr/local/plumed2 -m shared @@ -45,6 +45,8 @@ checksums = { \ '2.7.6' : 'fb8c0ec10f97a9353eb123a5c4c35aa6', \ '2.8.1' : '6bfe72ebdae63dc38a9ca27d9b0e08f8', \ '2.8.2' : '599092b6a0aa6fff992612537ad98994', \ + '2.8.3' : '76d23cd394eba9e6530316ed1184e219', \ + '2.9.0' : '661eabeebee05cf84bbf9dc23d7d5f46', \ } # parse and process arguments diff --git a/src/AMOEBA/pair_amoeba.cpp b/src/AMOEBA/pair_amoeba.cpp index 4cb5c39b61..1bdd36dd94 100644 --- a/src/AMOEBA/pair_amoeba.cpp +++ b/src/AMOEBA/pair_amoeba.cpp @@ -843,7 +843,7 @@ void PairAmoeba::init_style() } else { index[i] = atom->find_custom(names[i], flag, cols); } - std::string err = ""; + std::string err; if (index[i] < 0) err = "was not defined"; else if (flag_check[i] != flag) err = "has the wrong type"; else if (cols_check[i] != cols) err = "has the wrong number of columns"; diff --git a/src/MGPT/mgpt_readpot.cpp b/src/MGPT/mgpt_readpot.cpp index 05c9e2ddfc..3cc5d5d693 100644 --- a/src/MGPT/mgpt_readpot.cpp +++ b/src/MGPT/mgpt_readpot.cpp @@ -387,8 +387,6 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl if (bscreen == 1 && rrws >= r0rws) { double arg = rrws/r0rwstab[i]; - double arg1 = arg - 1.0; - double arg12 = arg1*arg1; double f; if (mode <= 2) { f = fgauss(arg,al); diff --git a/src/REPLICA/fix_pimd_langevin.cpp b/src/REPLICA/fix_pimd_langevin.cpp index bd8c76d52f..01cfa66ebd 100644 --- a/src/REPLICA/fix_pimd_langevin.cpp +++ b/src/REPLICA/fix_pimd_langevin.cpp @@ -35,6 +35,7 @@ #include "force.h" #include "group.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "random_mars.h" @@ -48,7 +49,10 @@ using namespace LAMMPS_NS; using namespace FixConst; using MathConst::MY_PI; +using MathConst::MY_2PI; using MathConst::THIRD; +using MathConst::MY_SQRT2; +using MathSpecial::powint; enum { PIMD, NMPIMD }; enum { PHYSICAL, NORMAL }; @@ -436,7 +440,7 @@ void FixPIMDLangevin::init() planck = force->hplanck; } planck *= sp; - hbar = planck / (2.0 * MY_PI); + hbar = planck / (MY_2PI); double beta = 1.0 / (force->boltz * temp); double _fbond = 1.0 * np * np / (beta * beta * hbar * hbar); @@ -738,10 +742,11 @@ void FixPIMDLangevin::collect_xc() } } + const double sqrtnp = sqrt((double)np); for (int i = 0; i < nlocal; i++) { - xcall[3 * (tag[i] - 1) + 0] = x[i][0] / sqrt(np); - xcall[3 * (tag[i] - 1) + 1] = x[i][1] / sqrt(np); - xcall[3 * (tag[i] - 1) + 2] = x[i][2] / sqrt(np); + xcall[3 * (tag[i] - 1) + 0] = x[i][0] / sqrtnp; + xcall[3 * (tag[i] - 1) + 1] = x[i][1] / sqrtnp; + xcall[3 * (tag[i] - 1) + 2] = x[i][2] / sqrtnp; } if (cmode == MULTI_PROC) { @@ -1107,19 +1112,20 @@ void FixPIMDLangevin::nmpimd_init() } // Set up eigenvectors for degenerated modes + const double sqrtnp = sqrt((double)np); for (int j = 0; j < np; j++) { for (int i = 1; i < int(np / 2) + 1; i++) { - M_x2xp[i][j] = sqrt(2.0) * cos(2.0 * MY_PI * double(i) * double(j) / double(np)) / sqrt(np); + M_x2xp[i][j] = MY_SQRT2 * cos(MY_2PI * double(i) * double(j) / double(np)) / sqrtnp; } for (int i = int(np / 2) + 1; i < np; i++) { - M_x2xp[i][j] = sqrt(2.0) * sin(2.0 * MY_PI * double(i) * double(j) / double(np)) / sqrt(np); + M_x2xp[i][j] = MY_SQRT2 * sin(MY_2PI * double(i) * double(j) / double(np)) / sqrtnp; } } // Set up eigenvectors for non-degenerated modes for (int i = 0; i < np; i++) { - M_x2xp[0][i] = 1.0 / sqrt(np); - if (np % 2 == 0) M_x2xp[np / 2][i] = 1.0 / sqrt(np) * pow(-1.0, i); + M_x2xp[0][i] = 1.0 / sqrtnp; + if (np % 2 == 0) M_x2xp[np / 2][i] = 1.0 / sqrtnp * powint(-1.0, i); } // Set up Ut diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 75c30bd0b8..03b3c7b78c 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -179,7 +179,8 @@ void CreateAtoms::command(int narg, char **arg) if (imol == -1) error->all(FLERR, "Molecule template ID {} for create_atoms does not exist", arg[iarg + 1]); if ((atom->molecules[imol]->nset > 1) && (comm->me == 0)) - error->warning(FLERR, "Molecule template for create_atoms has multiple molecules"); + error->warning(FLERR, "Molecule template for create_atoms has multiple molecule sets. " + "Only the first set will be used."); mode = MOLECULE; onemol = atom->molecules[imol]; molseed = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); @@ -504,7 +505,7 @@ void CreateAtoms::command(int narg, char **arg) // molcreate = # of molecules I created - tagint molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms; + tagint molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms * onemol->nmolecules; // increment total bonds,angles,etc diff --git a/src/fix_ave_grid.cpp b/src/fix_ave_grid.cpp index 8b391a08b5..a1e545a3cf 100644 --- a/src/fix_ave_grid.cpp +++ b/src/fix_ave_grid.cpp @@ -280,33 +280,32 @@ FixAveGrid::FixAveGrid(LAMMPS *lmp, int narg, char **arg) : if (modeatom) { for (int i = 0; i < nvalues; i++) { if (which[i] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[i]); - if (icompute < 0) - error->all(FLERR,"Compute ID for fix ave/grid does not exist"); - if (modify->compute[icompute]->peratom_flag == 0) - error->all(FLERR, "Fix ave/atom compute does not calculate per-atom values"); - if (argindex[i] == 0 && - modify->compute[icompute]->size_peratom_cols != 0) - error->all(FLERR,"Fix ave/atom compute does not calculate a per-atom vector"); - if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0) - error->all(FLERR,"Fix ave/atom compute does not calculate a per-atom array"); - if (argindex[i] && argindex[i] > modify->compute[icompute]->size_peratom_cols) - error->all(FLERR,"Fix ave/atom compute array is accessed out-of-range"); + auto icompute = modify->get_compute_by_id(ids[i]); + if (!icompute) + error->all(FLERR,"Compute {} for fix ave/grid does not exist", ids[i]); + if (icompute->peratom_flag == 0) + error->all(FLERR, "Fix ave/atom compute {} does not calculate per-atom values", ids[i]); + if ((argindex[i] == 0) && (icompute->size_peratom_cols != 0)) + error->all(FLERR,"Fix ave/atom compute {} does not calculate a per-atom vector", ids[i]); + if (argindex[i] && (icompute->size_peratom_cols == 0)) + error->all(FLERR,"Fix ave/atom compute {} does not calculate a per-atom array", ids[i]); + if (argindex[i] && (argindex[i] > icompute->size_peratom_cols)) + error->all(FLERR,"Fix ave/atom compute {} array is accessed out-of-range", ids[i]); } else if (which[i] == ArgInfo::FIX) { - int ifix = modify->find_fix(ids[i]); - if (ifix < 0) - error->all(FLERR,"Fix ID for fix ave/atom does not exist"); - if (modify->fix[ifix]->peratom_flag == 0) - error->all(FLERR,"Fix ave/atom fix does not calculate per-atom values"); - if (argindex[i] == 0 && modify->fix[ifix]->size_peratom_cols != 0) - error->all(FLERR, "Fix ave/atom fix does not calculate a per-atom vector"); - if (argindex[i] && modify->fix[ifix]->size_peratom_cols == 0) - error->all(FLERR, "Fix ave/atom fix does not calculate a per-atom array"); - if (argindex[i] && argindex[i] > modify->fix[ifix]->size_peratom_cols) - error->all(FLERR,"Fix ave/atom fix array is accessed out-of-range"); - if (nevery % modify->fix[ifix]->peratom_freq) - error->all(FLERR, "Fix for fix ave/atom not computed at compatible time"); + auto ifix = modify->get_fix_by_id(ids[i]); + if (!ifix) + error->all(FLERR,"Fix {} for fix ave/atom does not exist", ids[i]); + if (ifix->peratom_flag == 0) + error->all(FLERR,"Fix ave/atom fix {} does not calculate per-atom values", ids[i]); + if ((argindex[i] == 0) && (ifix->size_peratom_cols != 0)) + error->all(FLERR, "Fix ave/atom fix {} does not calculate a per-atom vector", ids[i]); + if (argindex[i] && (ifix->size_peratom_cols == 0)) + error->all(FLERR, "Fix ave/atom fix {} does not calculate a per-atom array", ids[i]); + if (argindex[i] && (argindex[i] > ifix->size_peratom_cols)) + error->all(FLERR,"Fix ave/atom fix {} array is accessed out-of-range", ids[i]); + if (nevery % ifix->peratom_freq) + error->all(FLERR, "Fix {} for fix ave/atom not computed at compatible time", ids[i]); } else if (which[i] == ArgInfo::VARIABLE) { int ivariable = input->variable->find(ids[i]); @@ -431,13 +430,13 @@ void FixAveGrid::init() if (which[m] == ArgInfo::COMPUTE) { int icompute = modify->find_compute(ids[m]); if (icompute < 0) - error->all(FLERR,"Compute ID for fix ave/grid does not exist"); + error->all(FLERR,"Compute {} for fix ave/grid does not exist", ids[m]); value2index[m] = icompute; } else if (which[m] == ArgInfo::FIX) { int ifix = modify->find_fix(ids[m]); if (ifix < 0) - error->all(FLERR,"Fix ID for fix ave/grid does not exist"); + error->all(FLERR,"Fix {} for fix ave/grid does not exist", ids[m]); value2index[m] = ifix; } else if (which[m] == ArgInfo::VARIABLE) { @@ -462,10 +461,10 @@ void FixAveGrid::init() for (int m = 0; m < nvalues; m++) { if (dimension == 2) { if (which[m] == ArgInfo::COMPUTE) { - compute = modify->compute[value2index[m]]; + compute = modify->get_compute_by_index(value2index[m]); grid2d = (Grid2d *) compute->get_grid_by_index(value2grid[m]); } else { - fix = modify->fix[value2index[m]]; + fix = modify->get_fix_by_index(value2index[m]); grid2d = (Grid2d *) fix->get_grid_by_index(value2grid[m]); } grid2d->get_size(nxtmp,nytmp); @@ -474,10 +473,10 @@ void FixAveGrid::init() } else { if (which[m] == ArgInfo::COMPUTE) { - compute = modify->compute[value2index[m]]; + compute = modify->get_compute_by_index(value2index[m]); grid3d = (Grid3d *) compute->get_grid_by_index(value2grid[m]); } else { - fix = modify->fix[value2index[m]]; + fix = modify->get_fix_by_index(value2index[m]); grid3d = (Grid3d *) fix->get_grid_by_index(value2grid[m]); } grid3d->get_size(nxtmp,nytmp,nztmp); @@ -966,7 +965,7 @@ void FixAveGrid::atom2grid() double *ovector,**oarray; if (which[m] == ArgInfo::COMPUTE) { - Compute *compute = modify->compute[n]; + Compute *compute = modify->get_compute_by_index(n); if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); compute->invoked_flag |= Compute::INVOKED_PERATOM; @@ -975,7 +974,7 @@ void FixAveGrid::atom2grid() else oarray = compute->array_atom; } else if (which[m] == ArgInfo::FIX) { - Fix *fix = modify->fix[n]; + Fix *fix = modify->get_fix_by_index(n); if (j == 0) ovector = fix->vector_atom; else oarray = fix->array_atom; } else if (which[m] == ArgInfo::VARIABLE) { @@ -1075,12 +1074,12 @@ void FixAveGrid::grid2grid() Fix *fix; if (which[m] == ArgInfo::COMPUTE) { - compute = modify->compute[n]; + compute = modify->get_compute_by_index(n); if (!(compute->invoked_flag & Compute::INVOKED_PERGRID)) { compute->compute_pergrid(); compute->invoked_flag |= Compute::INVOKED_PERGRID; } - } else if (which[m] == ArgInfo::FIX) fix = modify->fix[n]; + } else if (which[m] == ArgInfo::FIX) fix = modify->get_fix_by_index(n); if (dimension == 2) { double **ovec2d,***oarray2d; diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 077e064871..7339ddada1 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -230,11 +230,10 @@ void FixLangevin::init() // warn if any integrate fix comes after this one int before = 1; int flag = 0; - for (int i = 0; i < modify->nfix; i++) { - auto ifix = modify->get_fix_by_index(i); + for (auto ifix : modify->get_fix_list()) { if (strcmp(id, ifix->id) == 0) before = 0; - else if ((modify->fmask[i] && utils::strmatch(ifix->style, "^nve")) && before) + else if ((modify->get_fix_mask(ifix) && utils::strmatch(ifix->style, "^nve")) && before) flag = 1; } if (flag) error->all(FLERR, "Fix langevin gjf should come before fix nve"); diff --git a/src/lammps.cpp b/src/lammps.cpp index 2a71714dcc..3329cb8d7b 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -150,7 +150,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : if (has_git_info() && ((update_string == " - Development") || (update_string == " - Maintenance"))) update_string += fmt::format(" - {}", git_descriptor()); - external_comm = 0; + external_comm = MPI_COMM_NULL; mdicomm = nullptr; skiprunflag = 0; @@ -807,7 +807,7 @@ LAMMPS::~LAMMPS() noexcept(false) // free a copy of uorig here, so check in universe destructor will still work MPI_Comm copy = universe->uorig; - if (external_comm) MPI_Comm_free(©); + if (external_comm != MPI_COMM_NULL) MPI_Comm_free(©); delete input; delete universe; @@ -1267,7 +1267,7 @@ void _noopt LAMMPS::help() "-reorder topology-specs : processor reordering (-r)\n" "-screen none/filename : where to send screen output (-sc)\n" "-skiprun : skip loops in run and minimize (-sr)\n" - "-suffix gpu/intel/opt/omp : style suffix to apply (-sf)\n" + "-suffix gpu/intel/kk/opt/omp: style suffix to apply (-sf)\n" "-var varname value : set index style variable (-v)\n\n", exename); diff --git a/src/version.h b/src/version.h index ee367b68b7..76ede29b68 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1,2 @@ #define LAMMPS_VERSION "7 Feb 2024" +#define LAMMPS_UPDATE "Development" diff --git a/tools/phonon/disp.cpp b/tools/phonon/disp.cpp index 79a22aeee4..9cc1b99762 100644 --- a/tools/phonon/disp.cpp +++ b/tools/phonon/disp.cpp @@ -53,7 +53,7 @@ void Phonon::pdisp() #ifdef UseSPG if (method == 1){ #endif - while (1){ + while (true){ for (int i = 0; i < 3; ++i) qstr[i] = qend[i]; printf("\nPlease input the start q-point in unit of B1->B3, q to exit [%g %g %g]: ", qstr[0], qstr[1], qstr[2]); @@ -67,7 +67,7 @@ void Phonon::pdisp() qstr[2] = atof(strtok(NULL, " \t\n\r\f")); } - while ( 1 ){ + while ( true ){ printf("Please input the end q-point in unit of B1->B3: "); input->read_stdin(str); if (count_words(str) >= 3) break; @@ -166,8 +166,6 @@ void Phonon::pdisp() delete []fname; delete qnodes; - -return; } /*----------------------------------------------------------------------------*/ diff --git a/tools/phonon/dynmat.cpp b/tools/phonon/dynmat.cpp index 5994ce703e..bdcce7a3bc 100644 --- a/tools/phonon/dynmat.cpp +++ b/tools/phonon/dynmat.cpp @@ -200,8 +200,6 @@ DynMat::DynMat(int narg, char **arg) // ask for the interpolation method interpolate->set_method(); - - return; } @@ -222,8 +220,6 @@ DynMat::~DynMat() memory->destroy(DM_all); memory->destroy(M_inv_sqrt); delete memory; - - return; } /* ---------------------------------------------------------------------------- @@ -234,10 +230,10 @@ void DynMat::writeDMq(double *q) FILE *fp; // only ask for file name for the first time // other calls will append the result to the file. - if (dmfile == NULL){ + if (dmfile == nullptr){ char str[MAXLINE], *ptr; printf("\n"); - while ( 1 ){ + while ( true ){ printf("Please input the filename to output the DM at selected q: "); input->read_stdin(str); ptr = strtok(str, " \r\t\n\f"); @@ -260,8 +256,6 @@ void DynMat::writeDMq(double *q) } fprintf(fp,"\n"); fclose(fp); - - return; } /* ---------------------------------------------------------------------------- @@ -275,7 +269,6 @@ void DynMat::writeDMq(double *q, const double qr, FILE *fp) for (int j = 0; j < fftdim; ++j) fprintf(fp,"%lg %lg\t", DM_q[i][j].r, DM_q[i][j].i); fprintf(fp,"\n"); - return; } /* ---------------------------------------------------------------------------- @@ -327,8 +320,6 @@ int DynMat::geteigen(double *egv, int flag) void DynMat::getDMq(double *q) { interpolate->execute(q, DM_q[0]); - - return; } /* ---------------------------------------------------------------------------- @@ -339,7 +330,6 @@ void DynMat::getDMq(double *q, double *wt) interpolate->execute(q, DM_q[0]); if (flag_skip && interpolate->UseGamma ) wt[0] = 0.; - return; } /* ---------------------------------------------------------------------------- @@ -359,8 +349,7 @@ void DynMat::car2dir() basis[i][idim] = x[0]*mat[idim] + x[1]*mat[3+idim] + x[2]*mat[6+idim]; } - return; -} + } /* ---------------------------------------------------------------------------- * private method to enforce the acoustic sum rule on force constant matrix at G @@ -463,7 +452,6 @@ void DynMat::EnforceASR() } delete[] egvs; puts("\n================================================================================\n"); - return; } /* ---------------------------------------------------------------------------- @@ -501,7 +489,6 @@ void DynMat::real2rec() for (int j = 0; j < sysdim; ++j) printf("%8.4f ", ibasevec[i*3+j]); } puts("\n================================================================================"); - return; } /* ---------------------------------------------------------------------- @@ -590,8 +577,6 @@ void DynMat::GaussJordan(int n, double *Mat) delete []indxr; delete []indxc; delete []ipiv; - - return; } /* ---------------------------------------------------------------------------- @@ -600,8 +585,6 @@ void DynMat::GaussJordan(int n, double *Mat) void DynMat::reset_interp_method() { interpolate->set_method(); - - return; } /* ---------------------------------------------------------------------------- @@ -644,8 +627,6 @@ void DynMat::ShowVersion() printf(" (__) (_) (_)(__)(__)(_)\\_)(__)(__)\n"); printf("\nPHonon ANAlyzer for Fix-Phonon, version 2.%02d, compiled on %s.\n", VERSION, __DATE__); printf("Reference: https://doi.org/10.1016/j.cpc.2011.04.019\n"); - - return; } /* ---------------------------------------------------------------------------- @@ -696,8 +677,7 @@ void DynMat::Define_Conversion_Factor() printf("sqrt(E/ML^2)/(2*pi) into THz, instead, I set it to 1; you should check the unit\nused by LAMMPS.\n"); eml2f = eml2fc = 1.; } - return; -} + } /* ---------------------------------------------------------------------------- * Private method to output the information read @@ -711,6 +691,5 @@ void DynMat::ShowInfo() printf("System dimension : %d\n", sysdim); printf("Boltzmann constant in used units : %g\n", boltz); puts("================================================================================"); - return; } /* --------------------------------------------------------------------*/ diff --git a/tools/phonon/green.cpp b/tools/phonon/green.cpp index 0f687fd834..63b820dd2c 100644 --- a/tools/phonon/green.cpp +++ b/tools/phonon/green.cpp @@ -65,8 +65,6 @@ Green::Green(const int ntm, const int sdim, const int niter, const double min, c // Get the inverser of the treated hessian by continued fractional method Recursion(); - - return; } /*------------------------------------------------------------------------------ @@ -74,14 +72,12 @@ Green::Green(const int ntm, const int sdim, const int niter, const double min, c *----------------------------------------------------------------------------*/ Green::~Green() { - H = NULL; - ldos = NULL; + H = nullptr; + ldos = nullptr; memory->destroy(alpha); memory->destroy(beta); delete memory; - - return; } /*------------------------------------------------------------------------------ @@ -134,8 +130,6 @@ void Green::Lanczos() delete []vp; delete []v; delete []w; - - return; } /*------------------------------------------------------------------------------ @@ -211,8 +205,6 @@ void Green::Recursion() delete []beta_inf; delete []xmin; delete []xmax; - - return; } /*------------------------------------------------------------------------------ @@ -239,7 +231,6 @@ void Green::recursion() } w += dw; } - return; -} + } /*------------------------------------------------------------------------------*/ diff --git a/tools/phonon/input.cpp b/tools/phonon/input.cpp index c2059043c7..7b496796d0 100644 --- a/tools/phonon/input.cpp +++ b/tools/phonon/input.cpp @@ -7,10 +7,8 @@ * ---------------------------------------------------------------- */ UserInput::UserInput(int flag) { - fp = NULL; + fp = nullptr; if (flag) fp = fopen("script.inp", "w"); - - return; } /* ------------------------------------------------------------------- @@ -19,7 +17,7 @@ UserInput::UserInput(int flag) UserInput::~UserInput() { if (fp) fclose(fp); - fp = NULL; + fp = nullptr; } /* ------------------------------------------------------------------- @@ -29,7 +27,5 @@ void UserInput::read_stdin(char *str) { fgets(str, MAXLINE, stdin); if (fp) fprintf(fp, "%s", str); - - return; } /* ---------------------------------------------------------------- */ diff --git a/tools/phonon/interpolate.cpp b/tools/phonon/interpolate.cpp index 8ea551d1a8..5ce4c55651 100644 --- a/tools/phonon/interpolate.cpp +++ b/tools/phonon/interpolate.cpp @@ -28,8 +28,6 @@ Interpolate::Interpolate(int nx, int ny, int nz, int ndm, doublecomplex **DM) Dfdx = Dfdy = Dfdz = D2fdxdy = D2fdxdz = D2fdydz = D3fdxdydz = NULL; flag_reset_gamma = flag_allocated_dfs = 0; input = NULL; - - return; } /* ---------------------------------------------------------------------------- @@ -106,8 +104,7 @@ void Interpolate::tricubic_init() } n++; } - return; -} + } /* ---------------------------------------------------------------------------- * Deconstructor used to free memory @@ -123,8 +120,6 @@ Interpolate::~Interpolate() memory->destroy(D2fdydz); memory->destroy(D3fdxdydz); delete memory; - - return; } /* ---------------------------------------------------------------------------- @@ -184,8 +179,7 @@ void Interpolate::tricubic(double *qin, doublecomplex *DMq) tricubic_get_coeff(&a[0],&f[0],&dfdx[0],&dfdy[0],&dfdz[0],&d2fdxdy[0],&d2fdxdz[0],&d2fdydz[0],&d3fdxdydz[0]); DMq[idim].i = tricubic_eval(&a[0],x,y,z); } - return; -} + } /* ---------------------------------------------------------------------------- * method to interpolate the DM at an arbitrary q point; @@ -250,8 +244,7 @@ void Interpolate::trilinear(double *qin, doublecomplex *DMq) } } - return; -} + } /* ---------------------------------------------------------------------------- * To invoke the interpolation @@ -263,8 +256,6 @@ void Interpolate::execute(double *qin, doublecomplex *DMq) tricubic(qin, DMq); else // otherwise: trilinear trilinear(qin, DMq); - - return; } /* ---------------------------------------------------------------------------- @@ -274,7 +265,7 @@ void Interpolate::set_method() { char str[MAXLINE]; int im = 1; - if (input == NULL) input = new UserInput(0); + if (input == nullptr) input = new UserInput(0); puts("\n================================================================================"); printf("Which interpolation method would you like to use?\n"); @@ -289,8 +280,6 @@ void Interpolate::set_method() puts("================================================================================\n"); if (which == 1) tricubic_init(); - - return; } /* ---------------------------------------------------------------------------- @@ -316,6 +305,5 @@ void Interpolate::reset_gamma() + (data[im1][idim].r + data[ip1][idim].r) * two3; } - return; -} + } /* ---------------------------------------------------------------------------- */ diff --git a/tools/phonon/kpath.cpp b/tools/phonon/kpath.cpp index 49730b42b6..aa868f2bce 100644 --- a/tools/phonon/kpath.cpp +++ b/tools/phonon/kpath.cpp @@ -64,7 +64,6 @@ kPath::kPath(DynMat *dm, QNodes *qn) for (int j = 0; j < 3; ++j) pos[i][j] = atpos[i][j]; spgnum = spg_get_international(symbol, latvec, (double (*)[3])pos, attyp, num_atom, symprec); memory->destroy(pos); - return; } /* ---------------------------------------------------------------------------- @@ -89,7 +88,6 @@ void kPath::show_info() printf("The space group number of your unit cell is: %d => %s\n", spgnum, symbol); puts("--------------------------------------------------------------------------------"); - return; } /* ---------------------------------------------------------------------------- @@ -102,8 +100,6 @@ kPath::~kPath( ) delete memory; dynmat = NULL; q = NULL; - - return; } /* ---------------------------------------------------------------------------- @@ -2764,15 +2760,14 @@ void kPath::kpath( ) q->nqbin.push_back(nqpt); } - return; -} + } /* ---------------------------------------------------------------------------- * Show the k-path info * ---------------------------------------------------------------------------- */ void kPath::show_path() { - if (q == NULL) return; + if (q == nullptr) return; int nbin = q->ndstr.size(); if (nbin > 0){ puts("\n--------------------------------------------------------------------------------"); @@ -2787,7 +2782,6 @@ void kPath::show_path() puts("--------------------------------------------------------------------------------"); } - return; -} + } /* ---------------------------------------------------------------------------- */ #endif diff --git a/tools/phonon/phonon.cpp b/tools/phonon/phonon.cpp index 06372dcd1b..718f5c43b5 100644 --- a/tools/phonon/phonon.cpp +++ b/tools/phonon/phonon.cpp @@ -96,15 +96,14 @@ Phonon::Phonon(DynMat *dm) else if (job ==-1) dynmat->reset_interp_method(); else break; } - return; -} + } /* ---------------------------------------------------------------------------- * Deconstructor to free memory * ---------------------------------------------------------------------------- */ Phonon::~Phonon() { - dynmat = NULL; + dynmat = nullptr; memory->destroy(wt); memory->destroy(qpts); @@ -120,8 +119,6 @@ Phonon::~Phonon() memory->destroy(atpos); #endif delete memory; - - return; } /* ---------------------------------------------------------------------------- @@ -191,8 +188,6 @@ void Phonon::pdos() // output DOS writeDOS(); - - return; } /* ---------------------------------------------------------------------------- @@ -200,7 +195,7 @@ void Phonon::pdos() * ---------------------------------------------------------------------------- */ void Phonon::writeDOS() { - if (dos == NULL) return; + if (dos == nullptr) return; char str[MAXLINE]; // now to output the phonon DOS @@ -231,8 +226,6 @@ void Phonon::writeDOS() fclose(fp); fname = NULL; - - return; } /* ---------------------------------------------------------------------------- @@ -265,8 +258,7 @@ void Phonon::writeLDOS() fclose(fp); } - return; -} + } /* ---------------------------------------------------------------------------- * Private method to calculate the local phonon DOS via the real space Green's @@ -303,7 +295,7 @@ void Phonon::ldos_rsgf() int ik = 0, nit = MAX(ndim*0.1, MIN(ndim,50)); double eps = 12.; // for Cu with 1000+ atoms, 12 is enough; for small system, eps should be large. - while (1) { + while (true) { int istr, iend, iinc; // ask for relevant info printf("\nThere are %d atoms in each unit cell of your lattice.\n", dynmat->nucell); @@ -401,8 +393,6 @@ void Phonon::ldos_rsgf() } memory->destroy(Hessian); - - return; } /* ---------------------------------------------------------------------------- @@ -412,19 +402,17 @@ void Phonon::dmanyq() { char str[MAXLINE]; double q[3]; - while ( 1 ){ + while ( true ){ printf("Please input the q-point to output the dynamical matrix: "); input->read_stdin(str); if (count_words(str) >= 3) break; } q[0] = atof(strtok(str," \t\n\r\f")); - q[1] = atof(strtok(NULL," \t\n\r\f")); - q[2] = atof(strtok(NULL," \t\n\r\f")); + q[1] = atof(strtok(nullptr," \t\n\r\f")); + q[2] = atof(strtok(nullptr," \t\n\r\f")); dynmat->getDMq(q); dynmat->writeDMq(q); - - return; } /* ---------------------------------------------------------------------------- @@ -436,7 +424,7 @@ void Phonon::vfanyq() double q[3]; double *egvs = new double[ndim]; - while ( 1 ){ + while ( true ){ printf("Please input the q-point to compute the frequencies, q to exit: "); input->read_stdin(str); if (count_words(str) < 3) break; @@ -454,7 +442,6 @@ void Phonon::vfanyq() } delete[] egvs; - return; } /* ---------------------------------------------------------------------------- @@ -471,7 +458,7 @@ void Phonon::vecanyq() if (count_words(str) < 1) strcpy(str,"eigvec.dat"); FILE *fp = fopen(strtok(str," \t\n\r\f"), "w"); - while ( 1 ){ + while ( true ){ printf("Please input the q-point to compute the frequencies, q to exit: "); input->read_stdin(str); if (count_words(str) < 3) break; @@ -504,7 +491,6 @@ void Phonon::vecanyq() fclose(fp); delete[] egvs; eigvec = NULL; - return; } /* ---------------------------------------------------------------------------- @@ -528,7 +514,7 @@ void Phonon::DMdisp() int nq = MAX(MAX(dynmat->nx,dynmat->ny),dynmat->nz)/2; qend[0] = qend[1] = qend[2] = 0.; - while ( 1 ){ + while ( true ){ for (int i = 0; i < 3; ++i) qstr[i] = qend[i]; printf("\nPlease input the start q-point in unit of B1->B3, q to exit [%g %g %g]: ", qstr[0], qstr[1], qstr[2]); @@ -542,7 +528,7 @@ void Phonon::DMdisp() qstr[2] = atof(strtok(NULL," \t\n\r\f")); } - while ( 1 ){ + while ( true ){ printf("Please input the end q-point in unit of B1->B3: "); input->read_stdin(str); if (count_words(str) >= 3) break; @@ -569,8 +555,6 @@ void Phonon::DMdisp() qr -= dq; } fclose(fp); - - return; } /* ---------------------------------------------------------------------------- @@ -605,8 +589,6 @@ void Phonon::smooth(double *array, const int npt) memory->destroy(tmp); memory->destroy(table); - - return; } /* ---------------------------------------------------------------------------- @@ -671,8 +653,6 @@ void Phonon::therm() } while (T > 0.); fclose(fp); - - return; } /* ---------------------------------------------------------------------------- @@ -707,7 +687,7 @@ void Phonon::local_therm() // constants J.s J/K J const double h = 6.62606896e-34, Kb = 1.380658e-23, eV = 1.60217733e-19; double T = dynmat->Tmeasure; - while ( 1 ){ + while ( true ){ printf("\nPlease input the temperature at which to evaluate the local vibrational\n"); printf("thermal properties, non-positive number to exit [%g]: ", T); input->read_stdin(str); @@ -789,8 +769,6 @@ void Phonon::local_therm() } } fclose(fp); - - return; } /* ---------------------------------------------------------------------------- @@ -935,8 +913,6 @@ void Phonon::QMesh() } #endif printf("Your new q-mesh size would be: %d x %d x %d => %d points\n", nx,ny,nz,nq); - - return; } /* ---------------------------------------------------------------------------- @@ -1055,8 +1031,6 @@ void Phonon::ldos_egv() // evaluate the local vibrational thermal properties optionally local_therm(); - - return; } /* ---------------------------------------------------------------------------- @@ -1078,8 +1052,6 @@ void Phonon::ShowCell() for (int i = 0; i < dynmat->nucell; ++i) printf("%4d %12.8f %12.8f %12.8f\n", dynmat->attyp[i], dynmat->basis[i][0], dynmat->basis[i][1], dynmat->basis[i][2]); puts("================================================================================"); - - return; } /* ---------------------------------------------------------------------------- @@ -1112,8 +1084,7 @@ void Phonon::Normalize() } } - return; -} + } /* ---------------------------------------------------------------------------- * Private method to calculate vibrational frequencies for all q-points @@ -1138,8 +1109,6 @@ void Phonon::ComputeAll() } printf("Done!\n"); time->stop(); time->print(); delete time; - - return; } /*------------------------------------------------------------------------------ diff --git a/tools/phonon/phonopy.cpp b/tools/phonon/phonopy.cpp index 2cee319aa7..95a734ea56 100644 --- a/tools/phonon/phonopy.cpp +++ b/tools/phonon/phonopy.cpp @@ -60,8 +60,6 @@ Phonopy::Phonopy(DynMat *dynmat) phonopy(); -return; - } /* ---------------------------------------------------------------------------- @@ -72,8 +70,7 @@ Phonopy::~Phonopy() memory->destroy(mass); memory->destroy(FC_all); delete memory; - dm = NULL; -return; + dm = nullptr; } /* ---------------------------------------------------------------------------- @@ -111,7 +108,6 @@ void Phonopy::write(int flag) } else if (flag == 5){ puts("================================================================================"); } -return; } /* ---------------------------------------------------------------------------- @@ -141,7 +137,6 @@ void Phonopy::get_my_FC() } ++ipt; } -return; } /* ---------------------------------------------------------------------------- @@ -304,7 +299,6 @@ void Phonopy::phonopy() write(5); delete[] type_id; delete[] num_type; - return; } /*------------------------------------------------------------------------------ diff --git a/tools/phonon/qnodes.cpp b/tools/phonon/qnodes.cpp index 32e57f9736..fb1103138b 100644 --- a/tools/phonon/qnodes.cpp +++ b/tools/phonon/qnodes.cpp @@ -11,8 +11,6 @@ QNodes::QNodes() qs.clear(); qe.clear(); nqbin.clear(); - - return; } /* ---------------------------------------------------------------------------- @@ -25,6 +23,4 @@ QNodes::~QNodes() qs.clear(); qe.clear(); nqbin.clear(); - - return; } diff --git a/tools/phonon/timer.cpp b/tools/phonon/timer.cpp index 9ae4e94441..43126d0f55 100644 --- a/tools/phonon/timer.cpp +++ b/tools/phonon/timer.cpp @@ -9,8 +9,6 @@ Timer::Timer() { flag = 0; start(); - - return; } /* ----------------------------------------------------------------------------- @@ -20,7 +18,6 @@ void Timer::start() { t1 = clock(); flag |= 1; - return; } /* ----------------------------------------------------------------------------- @@ -32,8 +29,7 @@ void Timer::stop() t2 = clock(); flag |= 2; } - return; -} + } /* ----------------------------------------------------------------------------- * public function, print the total time used after timer stops @@ -44,8 +40,6 @@ void Timer::print() double cpu_time_used = ((double) (t2 - t1)) / CLOCKS_PER_SEC; printf("Total CPU time used: %g seconds.\n", cpu_time_used); - - return; } /* ----------------------------------------------------------------------------- diff --git a/tools/phonon/tricubic/tricubic.cpp b/tools/phonon/tricubic/tricubic.cpp index 974ed6aa52..dff3227048 100644 --- a/tools/phonon/tricubic/tricubic.cpp +++ b/tools/phonon/tricubic/tricubic.cpp @@ -90,7 +90,7 @@ static void point2xyz(int p, int *x, int *y, int *z) { } } -const char *tricubic_version(void) { +const char *tricubic_version() { return(tricubic_version_stored); } diff --git a/unittest/formats/test_dump_netcdf.cpp b/unittest/formats/test_dump_netcdf.cpp index 879d332250..e7288377ae 100644 --- a/unittest/formats/test_dump_netcdf.cpp +++ b/unittest/formats/test_dump_netcdf.cpp @@ -110,10 +110,18 @@ TEST_F(DumpNetCDFTest, run0_plain) for (auto line = ++section; line < lines.end(); ++line) { auto words = utils::split_words(*line); if ((words.size() < 1) || (words[0] == "variables:")) break; - if (words[0] == "atom") ASSERT_THAT(words[2], Eq("32")); - if (words[0] == "label") ASSERT_THAT(words[2], Eq("10")); - if (words[0] == "Voigt") ASSERT_THAT(words[2], Eq("6")); - if (words[0] == "spatial") ASSERT_THAT(words[2], Eq("3")); + if (words[0] == "atom") { + ASSERT_THAT(words[2], Eq("32")); + } + if (words[0] == "label") { + ASSERT_THAT(words[2], Eq("10")); + } + if (words[0] == "Voigt") { + ASSERT_THAT(words[2], Eq("6")); + } + if (words[0] == "spatial") { + ASSERT_THAT(words[2], Eq("3")); + } } // check variables section @@ -121,22 +129,54 @@ TEST_F(DumpNetCDFTest, run0_plain) for (auto line = ++section; line < lines.end(); ++line) { auto words = utils::split_words(*line); if ((words.size() < 2) || (words[0] == "data:")) break; - if (words[0] == "time:units") ASSERT_THAT(words[2], Eq("lj")); - if (words[0] == "time:scale_factor") ASSERT_THAT(words[2], Eq("0.005f")); - if (words[0] == "cell_origin:units") ASSERT_THAT(words[2], Eq("lj")); - if (words[0] == "cell_angles:units") ASSERT_THAT(words[2], Eq("degree")); - if (words[1] == "id(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "type(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "proc(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "procp1(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "mass(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "ix(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "iy(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "iz(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[0] == ":Conventions") ASSERT_THAT(words[2], Eq("AMBER")); - if (words[0] == ":ConventionVersion") ASSERT_THAT(words[2], Eq("1.0")); - if (words[0] == ":program") ASSERT_THAT(words[2], Eq("LAMMPS")); - if (words[0] == ":programVersion") ASSERT_THAT(words[2], Eq(LAMMPS_VERSION)); + if (words[0] == "time:units") { + ASSERT_THAT(words[2], Eq("lj")); + } + if (words[0] == "time:scale_factor") { + ASSERT_THAT(words[2], Eq("0.005f")); + } + if (words[0] == "cell_origin:units") { + ASSERT_THAT(words[2], Eq("lj")); + } + if (words[0] == "cell_angles:units") { + ASSERT_THAT(words[2], Eq("degree")); + } + if (words[1] == "id(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "type(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "proc(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "procp1(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "mass(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "ix(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "iy(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "iz(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[0] == ":Conventions") { + ASSERT_THAT(words[2], Eq("AMBER")); + } + if (words[0] == ":ConventionVersion") { + ASSERT_THAT(words[2], Eq("1.0")); + } + if (words[0] == ":program") { + ASSERT_THAT(words[2], Eq("LAMMPS")); + } + if (words[0] == ":programVersion") { + ASSERT_THAT(words[2], Eq(LAMMPS_VERSION)); + } } // check data section @@ -144,8 +184,12 @@ TEST_F(DumpNetCDFTest, run0_plain) for (auto line = ++section; line < lines.end(); ++line) { auto words = utils::split_words(*line); if (words.size() > 0) { - if (words[0] == "spatial") ASSERT_THAT(words[2], Eq("xyz")); - if (words[0] == "cell_spatial") ASSERT_THAT(words[2], Eq("abc")); + if (words[0] == "spatial") { + ASSERT_THAT(words[2], Eq("xyz")); + } + if (words[0] == "cell_spatial") { + ASSERT_THAT(words[2], Eq("abc")); + } if (words[0] == "cell_origin") { ++line; words = utils::split_words(*line); @@ -260,10 +304,18 @@ TEST_F(DumpNetCDFTest, run0_mpi) for (auto line = ++section; line < lines.end(); ++line) { auto words = utils::split_words(*line); if ((words.size() < 1) || (words[0] == "variables:")) break; - if (words[0] == "atom") ASSERT_THAT(words[2], Eq("32")); - if (words[0] == "label") ASSERT_THAT(words[2], Eq("10")); - if (words[0] == "Voigt") ASSERT_THAT(words[2], Eq("6")); - if (words[0] == "spatial") ASSERT_THAT(words[2], Eq("3")); + if (words[0] == "atom") { + ASSERT_THAT(words[2], Eq("32")); + } + if (words[0] == "label") { + ASSERT_THAT(words[2], Eq("10")); + } + if (words[0] == "Voigt") { + ASSERT_THAT(words[2], Eq("6")); + } + if (words[0] == "spatial") { + ASSERT_THAT(words[2], Eq("3")); + } } // check variables section @@ -271,22 +323,54 @@ TEST_F(DumpNetCDFTest, run0_mpi) for (auto line = ++section; line < lines.end(); ++line) { auto words = utils::split_words(*line); if ((words.size() < 2) || (words[0] == "data:")) break; - if (words[0] == "time:units") ASSERT_THAT(words[2], Eq("lj")); - if (words[0] == "time:scale_factor") ASSERT_THAT(words[2], Eq("0.005f")); - if (words[0] == "cell_origin:units") ASSERT_THAT(words[2], Eq("lj")); - if (words[0] == "cell_angles:units") ASSERT_THAT(words[2], Eq("degree")); - if (words[1] == "id(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "type(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "proc(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "procp1(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "mass(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "ix(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "iy(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[1] == "iz(frame,") ASSERT_THAT(words[2], Eq("atom)")); - if (words[0] == ":Conventions") ASSERT_THAT(words[2], Eq("AMBER")); - if (words[0] == ":ConventionVersion") ASSERT_THAT(words[2], Eq("1.0")); - if (words[0] == ":program") ASSERT_THAT(words[2], Eq("LAMMPS")); - if (words[0] == ":programVersion") ASSERT_THAT(words[2], Eq(LAMMPS_VERSION)); + if (words[0] == "time:units") { + ASSERT_THAT(words[2], Eq("lj")); + } + if (words[0] == "time:scale_factor") { + ASSERT_THAT(words[2], Eq("0.005f")); + } + if (words[0] == "cell_origin:units") { + ASSERT_THAT(words[2], Eq("lj")); + } + if (words[0] == "cell_angles:units") { + ASSERT_THAT(words[2], Eq("degree")); + } + if (words[1] == "id(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "type(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "proc(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "procp1(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "mass(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "ix(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "iy(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[1] == "iz(frame,") { + ASSERT_THAT(words[2], Eq("atom)")); + } + if (words[0] == ":Conventions") { + ASSERT_THAT(words[2], Eq("AMBER")); + } + if (words[0] == ":ConventionVersion") { + ASSERT_THAT(words[2], Eq("1.0")); + } + if (words[0] == ":program") { + ASSERT_THAT(words[2], Eq("LAMMPS")); + } + if (words[0] == ":programVersion") { + ASSERT_THAT(words[2], Eq(LAMMPS_VERSION)); + } } // check data section @@ -294,8 +378,12 @@ TEST_F(DumpNetCDFTest, run0_mpi) for (auto line = ++section; line < lines.end(); ++line) { auto words = utils::split_words(*line); if (words.size() > 0) { - if (words[0] == "spatial") ASSERT_THAT(words[2], Eq("xyz")); - if (words[0] == "cell_spatial") ASSERT_THAT(words[2], Eq("abc")); + if (words[0] == "spatial") { + ASSERT_THAT(words[2], Eq("xyz")); + } + if (words[0] == "cell_spatial") { + ASSERT_THAT(words[2], Eq("abc")); + } if (words[0] == "cell_origin") { ++line; words = utils::split_words(*line); diff --git a/unittest/formats/test_molecule_file.cpp b/unittest/formats/test_molecule_file.cpp index c798d2f4c2..743a8fbbfa 100644 --- a/unittest/formats/test_molecule_file.cpp +++ b/unittest/formats/test_molecule_file.cpp @@ -147,7 +147,7 @@ protected: fclose(fp); command(fmt::format("molecule {} {} {}", name, file, args)); - platform::unlink(file.c_str()); + platform::unlink(file); } };