monitoring memory use in NCL

From: Stephen Wood <s.wood_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 30 2010 - 20:03:47 MDT

Hi
 
I'm wanting to carefully monitor memory usage on a set of NCL scripts.
 
My first attempt was to do something like this
 
print ("I'm at this point")
system("ps u")
the problem is that the output of system calls is output before all the NCL print commands so if you have several of these report lines you can't match each report from the "ps -u" with the point in the script it belongs to
 
My next try was
 
print ("I'm here")
psrep=systemfunc("ps u")
print (psrep)
 
this works better - several lines are reported like this
 
(0) USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
(1) woodsw 5970 0.2 0.0 14248 3628 pts/1 S+ 08:43 0:00 /usr/bin/python ./main.py namelist_tst
(2) woodsw 5971 89.7 1.9 215732 161936 pts/1 S+ 08:43 0:03 ncl ./main.ncl
(3) woodsw 5982 0.0 1.9 215732 156688 pts/1 S+ 08:43 0:00 ncl ./main.ncl
(4) woodsw 5983 0.0 0.0 3564 900 pts/1 R+ 08:43 0:00 ps u
(5) woodsw 27690 0.0 0.0 9916 2488 pts/1 Ss Sep30 0:00 bash
(6) woodsw 27944 0.0 0.0 9920 2436 pts/3 Ss+ Sep30 0:00 bash
 
this is a bit verbose, but does what I want,. however, I don't understand why there are *two* lines (and hence two processes) shown running my program main.ncl
 
, or an explanation of these two processes?
 
So, is there a better way to do what I want, monitoring memory usage. I know I can watch with some sort of monitor program, either graphical (system-monitor) or text (top, or ps) but getting the ncl to do it means I can tag it to points in the program.
 
 
Thanks, Stephen wood, NZ
 
 
Dr Stephen W. Wood
National Institute of Water and Atmospheric Research Ltd
Lauder, Private Bag 50061
Omakau, Central Otago
NEW ZEALAND

Phone: work +64-3-4400426, home +64-3-4473789
Fax: work +64-3-4473348, home +64-3-4473789
Email: work s.wood AT niwa.co.nz , home stephen AT centralkennels.co.nz
NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 30 20:04:02 2010

This archive was generated by hypermail 2.1.8 : Wed Oct 06 2010 - 09:53:35 MDT