diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index 55421bb4e3..2e2c3ef04e 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -1723,7 +1723,7 @@ void PairExp6rxKokkos::read_file(char *file) FILE *fp; fp = NULL; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open exp6/rx potential file %s",file); diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index 01c8a3fffe..4f5041090f 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -504,7 +504,7 @@ void PairEAMCD::read_h_coeff(char *filename) char line[MAXLINE]; char nextline[MAXLINE]; int convert_flag = unit_convert_flag; - fptr = force->open_potential(filename, &convert_flag); + fptr = utils::open_potential(filename, lmp, &convert_flag); if (fptr == NULL) error->one(FLERR,fmt::format("Cannot open EAMCD potential file {}", filename)); diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index 4321bd9f8b..cdd928788b 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -1061,7 +1061,7 @@ EIMPotentialFileReader::EIMPotentialFileReader(LAMMPS *lmp, } int unit_convert = auto_convert; - FILE *fp = force->open_potential(filename.c_str(), &unit_convert); + FILE *fp = utils::open_potential(filename, lmp, &unit_convert); conversion_factor = utils::get_conversion_factor(utils::ENERGY,unit_convert); if (fp == NULL) { diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index 7c29f44afc..56ef70d8f9 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -969,7 +969,7 @@ void PairLCBOP::read_file(char *filename) // read file on proc 0 if (me == 0) { - FILE *fp = force->open_potential(filename); + FILE *fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open LCBOP potential file %s",filename); diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp index 24e8b19a65..fd1bf18330 100644 --- a/src/MLIAP/mliap_descriptor_snap.cpp +++ b/src/MLIAP/mliap_descriptor_snap.cpp @@ -376,7 +376,7 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename) FILE *fpparam; if (comm->me == 0) { - fpparam = force->open_potential(paramfilename); + fpparam = utils::open_potential(paramfilename,lmp,nullptr); if (fpparam == NULL) error->one(FLERR,fmt::format("Cannot open SNAP parameter file {}: {}", paramfilename, utils::getsyserror())); diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index bc760b7a68..b8ad1913a0 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -85,7 +85,7 @@ void MLIAPModel::read_coeffs(char *coefffilename) FILE *fpcoeff; if (comm->me == 0) { - fpcoeff = force->open_potential(coefffilename); + fpcoeff = utils::open_potential(coefffilename,lmp,nullptr); if (fpcoeff == NULL) error->one(FLERR,fmt::format("Cannot open MLIAPModel coeff file {}: {}", coefffilename,utils::getsyserror())); diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index 5d95ae73c2..ddf035070b 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -633,7 +633,7 @@ void FixCMAP::read_grid_map(char *cmapfile) FILE *fp = NULL; if (comm->me == 0) { - fp = force->open_potential(cmapfile); + fp = utils::open_potential(cmapfile,lmp,nullptr); if (fp == NULL) error->one(FLERR,fmt::format("Cannot open fix cmap file {}: {}", cmapfile, utils::getsyserror())); diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 877d75734c..ba4932a485 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -707,7 +707,7 @@ void FixQEq::read_file(char *file) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open fix qeq parameter file %s",file); diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 63867f1691..48014592ed 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -515,7 +515,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) FILE *fpcoeff; if (comm->me == 0) { - fpcoeff = force->open_potential(coefffilename); + fpcoeff = utils::open_potential(coefffilename,lmp,nullptr); if (fpcoeff == NULL) { char str[128]; snprintf(str,128,"Cannot open SNAP coefficient file %s",coefffilename); @@ -662,7 +662,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) FILE *fpparam; if (comm->me == 0) { - fpparam = force->open_potential(paramfilename); + fpparam = utils::open_potential(paramfilename,lmp,nullptr); if (fpparam == NULL) { char str[128]; snprintf(str,128,"Cannot open SNAP parameter file %s",paramfilename); diff --git a/src/USER-DPD/fix_eos_table.cpp b/src/USER-DPD/fix_eos_table.cpp index 04a619ac3d..69e5336945 100644 --- a/src/USER-DPD/fix_eos_table.cpp +++ b/src/USER-DPD/fix_eos_table.cpp @@ -199,7 +199,7 @@ void FixEOStable::read_table(Table *tb, Table *tb2, char *file, char *keyword) // open file - FILE *fp = force->open_potential(file); + FILE *fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open file %s",file); diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 77efd1842b..ced7283ef4 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -266,7 +266,7 @@ void FixRX::post_constructor() FILE *fp; fp = NULL; if (comm->me == 0) { - fp = force->open_potential(kineticsFile); + fp = utils::open_potential(kineticsFile,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open rx file %s",kineticsFile); @@ -855,7 +855,7 @@ void FixRX::read_file(char *file) FILE *fp; fp = NULL; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open rx file %s",file); @@ -892,7 +892,7 @@ void FixRX::read_file(char *file) } // open file on proc 0 - if (comm->me == 0) fp = force->open_potential(file); + if (comm->me == 0) fp = utils::open_potential(file,lmp,nullptr); // read each reaction from kinetics file eof=0; diff --git a/src/USER-DPD/pair_exp6_rx.cpp b/src/USER-DPD/pair_exp6_rx.cpp index 4ba088201e..839d22b50b 100644 --- a/src/USER-DPD/pair_exp6_rx.cpp +++ b/src/USER-DPD/pair_exp6_rx.cpp @@ -725,7 +725,7 @@ void PairExp6rx::read_file(char *file) FILE *fp; fp = NULL; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open exp6/rx potential file %s",file); diff --git a/src/USER-DPD/pair_multi_lucy_rx.cpp b/src/USER-DPD/pair_multi_lucy_rx.cpp index a8e588fe01..90f6dc6170 100644 --- a/src/USER-DPD/pair_multi_lucy_rx.cpp +++ b/src/USER-DPD/pair_multi_lucy_rx.cpp @@ -493,7 +493,7 @@ void PairMultiLucyRX::read_table(Table *tb, char *file, char *keyword) // open file - FILE *fp = force->open_potential(file); + FILE *fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open file %s",file); diff --git a/src/USER-MEAMC/pair_meamc.cpp b/src/USER-MEAMC/pair_meamc.cpp index b344dee10a..f40df56c19 100644 --- a/src/USER-MEAMC/pair_meamc.cpp +++ b/src/USER-MEAMC/pair_meamc.cpp @@ -364,7 +364,7 @@ void PairMEAMC::read_files(const std::string &globalfile, FILE *fp; if (comm->me == 0) { - fp = force->open_potential(globalfile.c_str()); + fp = utils::open_potential(globalfile,lmp,nullptr); if (fp == NULL) error->one(FLERR,fmt::format("Cannot open MEAM potential file {}", globalfile)); @@ -563,7 +563,7 @@ void PairMEAMC::read_files(const std::string &globalfile, // open user param file on proc 0 if (comm->me == 0) { - fp = force->open_potential(userfile.c_str()); + fp = utils::open_potential(userfile,lmp,nullptr); if (fp == NULL) error->one(FLERR,fmt::format("Cannot open MEAM potential file {}", userfile)); diff --git a/src/USER-MESONT/pair_mesocnt.cpp b/src/USER-MESONT/pair_mesocnt.cpp index f486814feb..4af8a99d6f 100644 --- a/src/USER-MESONT/pair_mesocnt.cpp +++ b/src/USER-MESONT/pair_mesocnt.cpp @@ -759,7 +759,7 @@ void PairMesoCNT::read_file() // open file - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) error->one(FLERR,fmt::format("Cannot open mesocnt file: {}",file)); diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index 213f73f05a..e7ab62608a 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -1904,8 +1904,8 @@ void PairMGPT::coeff(int narg, char **arg) printf("Volumetric pressure is %s.\n",volpres_flag ? "on" : "off"); if(comm->me == 0) { - FILE *parmin_fp = force->open_potential(arg[2]); - FILE *potin_fp = force->open_potential(arg[3]); + FILE *parmin_fp = utils::open_potential(arg[2],lmp,nullptr); + FILE *potin_fp = utils::open_potential(arg[3],lmp,nullptr); if (parmin_fp == NULL || potin_fp == NULL) { char str[128]; sprintf(str,"Cannot open MGPT potential files %s %s",arg[2],arg[3]); diff --git a/src/USER-MISC/dihedral_table_cut.cpp b/src/USER-MISC/dihedral_table_cut.cpp index a734a8e998..2a5b46a4f1 100644 --- a/src/USER-MISC/dihedral_table_cut.cpp +++ b/src/USER-MISC/dihedral_table_cut.cpp @@ -1078,7 +1078,7 @@ void DihedralTableCut::read_table(Table *tb, char *file, char *keyword) // open file - FILE *fp = force->open_potential(file); + FILE *fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { string err_msg = string("Cannot open file ") + string(file); error->one(FLERR,err_msg); diff --git a/src/USER-MISC/fix_electron_stopping.cpp b/src/USER-MISC/fix_electron_stopping.cpp index 5ef0a1cb2f..bf97066275 100644 --- a/src/USER-MISC/fix_electron_stopping.cpp +++ b/src/USER-MISC/fix_electron_stopping.cpp @@ -240,7 +240,7 @@ void FixElectronStopping::read_table(const char *file) { char line[MAXLINE]; - FILE *fp = force->open_potential(file); + FILE *fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str, 128, "Cannot open stopping range table %s", file); diff --git a/src/USER-MISC/fix_gle.cpp b/src/USER-MISC/fix_gle.cpp index aa791679cb..30e62c7eb9 100644 --- a/src/USER-MISC/fix_gle.cpp +++ b/src/USER-MISC/fix_gle.cpp @@ -221,7 +221,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : FILE *fgle = NULL; char *fname = arg[7]; if (comm->me == 0) { - fgle = force->open_potential(fname); + fgle = utils::open_potential(fname,lmp,nullptr); if (fgle == NULL) { char str[128]; snprintf(str,128,"Cannot open A-matrix file %s",fname); @@ -291,7 +291,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : } else { if (comm->me == 0) { - fgle = force->open_potential(fname); + fgle = utils::open_potential(fname,lmp,nullptr); if (fgle == NULL) { char str[128]; snprintf(str,128,"Cannot open C-matrix file %s",fname); diff --git a/src/USER-MISC/fix_orient_eco.cpp b/src/USER-MISC/fix_orient_eco.cpp index 272ba1ca93..4e97cac3f9 100644 --- a/src/USER-MISC/fix_orient_eco.cpp +++ b/src/USER-MISC/fix_orient_eco.cpp @@ -97,7 +97,7 @@ FixOrientECO::FixOrientECO(LAMMPS *lmp, int narg, char **arg) : char *result; int count; - FILE *infile = force->open_potential(dir_filename); + FILE *infile = utils::open_potential(dir_filename,lmp,nullptr); if (infile == NULL) error->one(FLERR,fmt::format("Cannot open fix orient/eco file {}: {}", dir_filename, utils::getsyserror())); diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index 4941f2c7b3..764ccc587f 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -358,7 +358,7 @@ void PairAGNI::read_file(char *file) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open AGNI potential file %s",file); diff --git a/src/USER-MISC/pair_drip.cpp b/src/USER-MISC/pair_drip.cpp index 2e9221537a..cc890f8c94 100644 --- a/src/USER-MISC/pair_drip.cpp +++ b/src/USER-MISC/pair_drip.cpp @@ -223,7 +223,7 @@ void PairDRIP::read_file(char *filename) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(filename); + fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open DRIP potential file %s",filename); diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index 288160459a..bb9c742212 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -883,7 +883,7 @@ void PairEDIP::read_file(char *file) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open EDIP potential file %s",file); diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 7fe620223b..90a3502eae 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -640,7 +640,7 @@ void PairEDIPMulti::read_file(char *file) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open EDIP potential file %s",file); diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index 65f792b493..8f8d539679 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -589,7 +589,7 @@ void PairExTeP::read_file(char *file) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open ExTeP potential file %s",file); diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index e7689acda5..62101d0e80 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -256,7 +256,7 @@ void PairILPGrapheneHBN::read_file(char *filename) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(filename); + fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open ILP potential file %s",filename); diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index ee3eec3869..fb1da5dab8 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -257,7 +257,7 @@ void PairKolmogorovCrespiFull::read_file(char *filename) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(filename); + fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open KC potential file %s",filename); diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index bf88bac6e2..f02423e952 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -315,7 +315,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(filename); + fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { char str[128]; snprintf(str,128,"Cannot open KC potential file %s",filename); diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index 27e21a12e3..5a84882cd9 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -311,7 +311,7 @@ void PairLebedevaZ::read_file(char *filename) FILE *fp; if (comm->me == 0) { - fp = force->open_potential(filename); + fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { char str[128]; sprintf(str,"Cannot open Lebedeva potential file %s",filename); diff --git a/src/USER-MISC/pair_list.cpp b/src/USER-MISC/pair_list.cpp index 44811316a8..c553e671cb 100644 --- a/src/USER-MISC/pair_list.cpp +++ b/src/USER-MISC/pair_list.cpp @@ -209,7 +209,7 @@ void PairList::settings(int narg, char **arg) if (strcmp(arg[2],"check") == 0) check_flag = 1; } - FILE *fp = force->open_potential(arg[0]); + FILE *fp = utils::open_potential(arg[0],lmp,nullptr); char line[1024]; if (fp == NULL) error->all(FLERR,"Cannot open pair list file"); diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index 5764b09d8a..6091b95837 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -458,7 +458,7 @@ void PairMEAMSpline::read_file(const char* filename) int nmultichoose2; // = (n+1)*n/2; if(comm->me == 0) { - FILE *fp = force->open_potential(filename); + FILE *fp = utils::open_potential(filename,lmp,nullptr); if(fp == NULL) { char str[1024]; snprintf(str,128,"Cannot open spline MEAM potential file %s", filename); diff --git a/src/USER-MISC/pair_meam_sw_spline.cpp b/src/USER-MISC/pair_meam_sw_spline.cpp index 8d33a6f04f..34cbe82581 100644 --- a/src/USER-MISC/pair_meam_sw_spline.cpp +++ b/src/USER-MISC/pair_meam_sw_spline.cpp @@ -460,7 +460,7 @@ void PairMEAMSWSpline::coeff(int narg, char **arg) void PairMEAMSWSpline::read_file(const char* filename) { if(comm->me == 0) { - FILE *fp = force->open_potential(filename); + FILE *fp = utils::open_potential(filename,lmp,nullptr); if(fp == NULL) { char str[1024]; snprintf(str,1024,"Cannot open spline MEAM potential file %s", filename); diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index 0262ffc14d..e0888e8514 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -317,7 +317,7 @@ void PairReaxC::coeff( int nargs, char **args ) char *file = args[2]; FILE *fp; - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if (fp != NULL) Read_Force_Field(fp, &(system->reax_param), control); else { diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index fcf6d141f2..f6ecd40bb6 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -410,7 +410,7 @@ void PairSMTBQ::read_file(char *file) // open file on all processors FILE *fp; - fp = force->open_potential(file); + fp = utils::open_potential(file,lmp,nullptr); if ( fp == NULL ) { char str[128]; snprintf(str,128,"Cannot open SMTBQ potential file %s",file); diff --git a/src/force.cpp b/src/force.cpp index cb0e0ac5a8..10b82afabe 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -836,59 +836,6 @@ void Force::set_special(int narg, char **arg) error->all(FLERR,"Illegal special_bonds command"); } -/* ---------------------------------------------------------------------- - open a potential file as specified by name - if fails, search in dir specified by env variable LAMMPS_POTENTIALS -------------------------------------------------------------------------- */ - -FILE *Force::open_potential(const char *name, int *auto_convert) -{ - std::string filepath = utils::get_potential_file_path(name); - - if(!filepath.empty()) { - std::string unit_style = update->unit_style; - std::string date = utils::get_potential_date(filepath, "potential"); - std::string units = utils::get_potential_units(filepath, "potential"); - - if(!date.empty() && (comm->me == 0)) { - utils::logmesg(lmp, fmt::format("Reading potential file {} " - "with DATE: {}\n", name, date)); - } - - if (auto_convert == nullptr) { - if (!units.empty() && (units != unit_style) && (comm->me == 0)) { - error->one(FLERR, fmt::format("Potential file {} requires {} units " - "but {} units are in use", name, units, - unit_style)); - return nullptr; - } - } else { - if (units.empty() || units == unit_style) { - *auto_convert = utils::NOCONVERT; - } else { - if ((units == "metal") && (unit_style == "real") - && (*auto_convert & utils::METAL2REAL)) { - *auto_convert = utils::METAL2REAL; - } else if ((units == "real") && (unit_style == "metal") - && (*auto_convert & utils::REAL2METAL)) { - *auto_convert = utils::REAL2METAL; - } else { - error->one(FLERR, fmt::format("Potential file {} requires {} units " - "but {} units are in use", name, - units, unit_style)); - return nullptr; - } - } - if ((*auto_convert != utils::NOCONVERT) && (comm->me == 0)) - lmp->error->warning(FLERR, fmt::format("Converting potential file in " - "{} units to {} units", - units, unit_style)); - } - return fopen(filepath.c_str(), "r"); - } - return nullptr; -} - /* ---------------------------------------------------------------------- memory usage of force classes ------------------------------------------------------------------------- */ diff --git a/src/force.h b/src/force.h index 8d3ae25294..d7824ea90e 100644 --- a/src/force.h +++ b/src/force.h @@ -129,8 +129,6 @@ class Force : protected Pointers { void store_style(char *&, const std::string &, int); void set_special(int, char **); - FILE *open_potential(const char *, int *auto_convert = nullptr); - bigint memory_usage(); private: diff --git a/src/utils.cpp b/src/utils.cpp index eecc88a529..486a84b601 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -939,7 +939,8 @@ double utils::get_conversion_factor(const int property, const int conversion) if fails, search in dir specified by env variable LAMMPS_POTENTIALS ------------------------------------------------------------------------- */ -FILE *utils::open_potential(const char *name, LAMMPS *lmp, int *auto_convert) +FILE *utils::open_potential(const std::string &name, LAMMPS *lmp, + int *auto_convert) { auto error = lmp->error; auto me = lmp->comm->me; diff --git a/src/utils.h b/src/utils.h index 2b647cfd87..9c897d5d7b 100644 --- a/src/utils.h +++ b/src/utils.h @@ -382,8 +382,7 @@ value is compared to the current :doc:`unit style ` setting. * \param auto_convert pointer to automatic unit conversion bitmask * \return FILE pointer of the opened potential file or NULL */ - FILE *open_potential(const char *name, LAMMPS *lmp, - int *auto_convert=nullptr); + FILE *open_potential(const std::string &name, LAMMPS *lmp, int *auto_convert); /** Convert a time string to seconds *