I am doing this on Cray XE6 machine where I can't log in on compute nodes and there is no possibility for interactive session, therefore I would need to somehow use top command: run top in the background and have it take snapshot at regular times and send it to a log file... Can somebody make an example of how to do this?
Thanks
Use the resource module to query for current memory usage. Then, somewhere in your MPI program, dump the usage to a log at certain intervals.
For example, the following measures maximum resident memory size of the current process, and appends the value to a file. What you would presumably do is insert the snippet somewhere at each timestep of your simulation.
Note the naming of the file, using the rank of the running MPI process (as per @Hristo's recommendation).