implement "mem" command into LAMMPS shell to print current and max memory use

This commit is contained in:
Axel Kohlmeyer
2020-10-07 18:36:43 -04:00
parent 50bfb9142d
commit ac6e99ae81
3 changed files with 10 additions and 0 deletions

View File

@ -463,6 +463,7 @@ static void init_commands()
commands.push_back("exit");
commands.push_back("pwd");
commands.push_back("cd");
commands.push_back("mem");
commands.push_back("history");
commands.push_back("clear_history");
@ -562,6 +563,13 @@ static int shell_cmd(const std::string &cmd)
lammps_command(lmp, shellcmd.c_str());
free(text);
return 0;
} else if (words[0] == "mem") {
double meminfo[3];
lammps_memory_usage(lmp,meminfo);
std::cout << "Memory usage. Current: " << meminfo[0] << " MByte, "
<< "Maximum : " << meminfo[2] << " MByte\n";
free(text);
return 0;
} else if (words[0] == "history") {
free(text);
HIST_ENTRY **list = history_list();