Memory management for array in custom fix

Dear all,

I am writing a custom fix for which I intend to read in the elements of a 2D array, ef, from a user supplied text file. As the dimensions of this array are unknown in advance, I intend to use code similar to the following:

vector< vector > ef;
double x;
string line;

ifstream fp(“field.dat”);

while ( !fp.eof() ) {
vector v;
istringstream is( line );
while(is >> x) {
v.push_back ( x );

ef.push_back (v);

However, I am also aware that the LAMMPS code has been designed such that the allocation of all large arrays is handled by the memory class. Therefore, I am wondering whether there might be any issues with the use of vectors in the manner described above?


DISCLAIMER The sender of this email is an alumnus of National University of Singapore (NUS). Kindly note that NUS is not responsible for the contents of this email, and views and opinions expressed are solely the sender’s.


As stated in the LAMMPs manual, , objects from the STL library such as vector are not fully supported since it relies on C++ 2011 and later. It will certainly work for your purposes but it is not ideal as an addition to the LAMMPs distribution.

In code you are writing for yourself, you can of course do whatever you
wish. LAMMPS has no coding conflicts that would prevent you
from using the STL. If you plan to contribute your code to LAMMPS,
that is a different issue, as Adrian pointed out.