From 0ead219a8b0bbed2db629fb96842ebf912de11c2 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 18 Feb 2023 00:37:28 -0500 Subject: [PATCH] backward compatibility with restart keep new maxline limit (1024 chars), but old react-ID length limit (256 chars) --- src/REACTION/fix_bond_react.cpp | 8 ++++---- src/REACTION/fix_bond_react.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index dbdd5116fd..75f9070fe4 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -216,7 +216,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : // this looks excessive // the price of vectorization (all reactions in one command)? - memory->create(rxn_name,nreacts,MAXLINE,"bond/react:rxn_name"); + memory->create(rxn_name,nreacts,MAXNAME,"bond/react:rxn_name"); memory->create(nevery,nreacts,"bond/react:nevery"); memory->create(cutsq,nreacts,2,"bond/react:cutsq"); memory->create(unreacted_mol,nreacts,"bond/react:unreacted_mol"); @@ -287,7 +287,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : iarg++; int n = strlen(arg[iarg]) + 1; - if (n > MAXLINE) error->all(FLERR,"Reaction name (react-ID) is too long (limit: 256 characters)"); + if (n > MAXNAME) error->all(FLERR,"Reaction name (react-ID) is too long (limit: 256 characters)"); strcpy(rxn_name[rxn],arg[iarg++]); int groupid = group->find(arg[iarg++]); @@ -4438,8 +4438,8 @@ void FixBondReact::write_restart(FILE *fp) for (int i = 0; i < nreacts; i++) { set[i].reaction_count_total = reaction_count_total[i]; - strncpy(set[i].rxn_name,rxn_name[i],MAXLINE-1); - set[i].rxn_name[MAXLINE-1] = '\0'; + strncpy(set[i].rxn_name,rxn_name[i],MAXNAME-1); + set[i].rxn_name[MAXNAME-1] = '\0'; } int rbufcount = max_rate_limit_steps*nreacts; diff --git a/src/REACTION/fix_bond_react.h b/src/REACTION/fix_bond_react.h index 9c21aa2ea1..66a5e4d6a0 100644 --- a/src/REACTION/fix_bond_react.h +++ b/src/REACTION/fix_bond_react.h @@ -33,7 +33,8 @@ namespace LAMMPS_NS { class FixBondReact : public Fix { public: - enum { MAXLINE = 1024 }; // max length of line read from files + enum { MAXLINE = 1024 }; // max length of line read from files + enum { MAXNAME = 256 }; // max character length of react-ID enum { MAXCONIDS = 4 }; // max # of IDs used by any constraint enum { MAXCONPAR = 5 }; // max # of constraint parameters @@ -218,7 +219,7 @@ class FixBondReact : public Fix { // store restart data struct Set { int nreacts; - char rxn_name[MAXLINE]; + char rxn_name[MAXNAME]; int reaction_count_total; int max_rate_limit_steps; };