LAMMPS+MEAM+MATLAB R2015a on MacBook Core i5 + Yosemite + Xcode 6.4

Hello lammps-users,

My apologies if this post is out of place in this list.

I built a graphical MATLAB application for interactive semi-automated calibration of MEAM parameters for single elements, binaries and ternaries. The application calls the lammps functions listed in ‘src/library.h’ which are implemented as C mexfunctions. This application works well on Windows 7 64-bit + MATLAB R2013a or R2014b + Gnumex.

A certain professor wishes to test the application on a Mac. He provided the following machine:

  • MacBook Pro, Intel core i5, OS X Yosemite 10.10.5, MATLAB R2015a

So,

  • MEAM was compiled using gfortran 4.3 (MATLAB R2015a supported compiler) that came with Macports apple-gcc42

  • LAMMPS, MPI stubs, and the C mexfunctions were compiled with clang in Xcode 6.4

The application runs: EV curves, vacancy formation, generalized stacking fault, elastic constants, binding energies, and others. The problem is that sometimes, it runs to completion, and sometimes the application crashes due to “Segmentation violation”. The Windows version does not have this problem.

I isolated a short MATLAB script from the whole application that I can run with ‘matlab -nodisplay -nojvm’ in order to avoid OpenGL graphics and Java issues (Mathworks Tech Support initially thinks so), but still, the script sometimes completes, and sometimes it crashes (always Segmentation violation) for the same inputs. And it crashes at different places in the simulations - a mexfunction may or may not be executing when the violation occurs.

Which brings me to the question: when the same LAMMPS script+input file is ran several times, is there anything that LAMMPS does differently at each run, which can potentially cause a segmentation violation on this particular MacBook setup?

I compared the log.lamps for the successful runs, and the differences are only in the timings (loop time, pair time, etc), which I attribute to other system tasks waking up/going to sleep during the runs.

I have built other MATLAB-based calibration tools that mix MATLAB and Fortran (no C/C++ involved). These applications run with no problems on the same setup.

Any ideas on where I should look at?

Or should I just tell the professor to switch to Microsoft Windows?

Yours truly,

Ricolindo L Carino

Which brings me to the question: when the same LAMMPS script+input file is ran several times, is there >anything that LAMMPS does differently at each run, which can potentially cause a segmentation violation >on this particular MacBook setup?

No. But there could be a bug anywhere in what you are doing, e.g.a memory

issue, that causes a non-reproducible segfault due to bad memory access.

You’d need to run it under a debugger to get some clues as to where the failure

point is.

Steve

Such an open question is always hard to answer. On top of what already has been suggested I would recommend, if nothing else works, to try porting your minimum test matlab script into another scripting language. Octave comes to mind due to the big similarities with Matlab. You can go “a la python” if wanted assuming no major overhead. By switching the language (while keeping lammps files intact) you may be able to look at the data processing from a different point of view. Interpreters may complain in different ways with alternative messages to the ones you have seen so far thus enlighting you a bit more. Nevertheless, note this is not the most straightforward pathway to quickly identify the problem.

And as a linux lover (or sucker if you whish) I would not recommend the prof to switch to the windows version (you cannot even get good support for lammps under windows). Besides, just because it has run so far doesn’t mean its bug free.

Carlos

Thanks to all who gave some thought to this post. The error was traced to the mexfile that implements “char lammps_command(void lmp, char* command));”

An additional byte was needed when allocating memory for ‘command’.