diff --git a/doc/src/pair_snap.rst b/doc/src/pair_snap.rst index 3369dfe7b2..22dea8e2fc 100644 --- a/doc/src/pair_snap.rst +++ b/doc/src/pair_snap.rst @@ -188,7 +188,7 @@ of linear coefficients for element :math:`\mu_i`. The SNAP coefficient file shou a total of :math:`K N_{elem}^3` coefficients in each element block, where :math:`N_{elem}` is the number of elements in the SNAP coefficient file, which must equal the number of unique elements appearing in the -LAMMPS pair_coeff command, to avoid ambiguity in the +LAMMPS pair_coeff command, to avoid ambiguity in the number of coefficients. The keyword *chunksize* is only applicable when using the diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 0e87792754..aedc552719 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -622,20 +622,20 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) if (strcmp(words[0],elements[jelem]) == 0) break; // if this element not needed, skip this block - + if (jelem == nelements) { if (comm->me == 0) { - for (int icoeff = 0; icoeff < ncoeffall; icoeff++) { - ptr = fgets(line,MAXLINE,fpcoeff); - if (ptr == nullptr) { - eof = 1; - fclose(fpcoeff); - } - } + for (int icoeff = 0; icoeff < ncoeffall; icoeff++) { + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == nullptr) { + eof = 1; + fclose(fpcoeff); + } + } } MPI_Bcast(&eof,1,MPI_INT,0,world); if (eof) - error->all(FLERR,"Incorrect format in SNAP coefficient file"); + error->all(FLERR,"Incorrect format in SNAP coefficient file"); continue; } @@ -647,31 +647,28 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) radelem[jelem] = atof(words[1]); wjelem[jelem] = atof(words[2]); - if (comm->me == 0) { - if (screen) fprintf(screen,"SNAP Element = %s, Radius %g, Weight %g \n", - elements[jelem], radelem[jelem], wjelem[jelem]); - if (logfile) fprintf(logfile,"SNAP Element = %s, Radius %g, Weight %g \n", - elements[jelem], radelem[jelem], wjelem[jelem]); - } + if (comm->me == 0) + utils::logmesg(lmp,fmt::format("SNAP Element = {}, Radius {}, Weight {}\n", + elements[jelem], radelem[jelem], wjelem[jelem]); for (int icoeff = 0; icoeff < ncoeffall; icoeff++) { if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fpcoeff); - if (ptr == nullptr) { - eof = 1; - fclose(fpcoeff); - } else n = strlen(line) + 1; + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == nullptr) { + eof = 1; + fclose(fpcoeff); + } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); if (eof) - error->all(FLERR,"Incorrect format in SNAP coefficient file"); + error->all(FLERR,"Incorrect format in SNAP coefficient file"); MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); nwords = utils::trim_and_count_words(line); if (nwords != 1) - error->all(FLERR,"Incorrect format in SNAP coefficient file"); + error->all(FLERR,"Incorrect format in SNAP coefficient file"); iword = 0; words[iword] = strtok(line,"' \t\n\r\f");