From: Philipp Schön (phschoen_at_web.de)
Date: Tue Aug 14 2007 - 05:28:13 CDT

dear users,
this is a small fraction of my code where i look for some atoms in a bin to get the indices and from that i got all atoms for use in a second step.
i do it by using arrays as ictmp($k) [INTEGER], bin($k) [ATOMSELECT], atmbin($k) [ATOMSELECT] and some more.
after i did all this i delete selected atoms and unset variables. however, the program still uses more and more RAM during run-time.
are there some special features to consider when using arrays?
Any help is appreciated since i need to post-process rather huge files.
cheers
philipp

for {set k 1 } { $k < $kcloop } {incr k } {
    set SB($k) 0.0
}
# ENTER MAIN LOOP HERE!
for {set i 0 } { $i < $nf } {incr i } {
    set zbin(0) $z0
for {set k 1 } { $k < $kcloop } {incr k } {
        set ictmp($k) 0
        set ic($k) 0
        set zbin($k) [expr $z0 + [expr $k * $binheight]]
        set m [expr $k - 1]
        set zlowerbound $zbin($m)
        set zupperbound $zbin($k)
        set bin($k) [atomselect $mol0 "water and same residue as $zlowerbound <= z and z < $zupperbound"]
        $bin($k) frame $i
        $bin($k) update
        set binlist($k) [$bin($k) get index]
        set ictmp($k) [llength $binlist($k)]
        if {$ictmp($k)!= 0} {
            set atmbin($k) [atomselect $mol1 "index $binlist($k)"]
            $atmbin($k) frame $i
            $atmbin($k) update
        }
}
... DO SOMETHING HERE

for {set k 1 } { $k < $kcloop } {incr k } {
            # clean up selections before re-entering the loop
            # and empty RAM if work is done
            $atmbin($k) delete
            $bin($k) delete
            unset binlist($k)
            unset sum($k)
            unset tmp($k)
            unset ictmp($k)
            unset m
            # finish calculation of averaged quantity SB
        }
        unset zupperbound
        unset zlowerbound
        # finish k-loop (spatial bins)
    }
    # finish i-loop (time frames)
}

_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066