<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
 Hi, Bob -- <div>I have cc'd gradsusr on this answer because it is of general interest ... </div><div><br class="webkit-block-placeholder"></div><div><br><div>GrADS caches grib2 grids in memory. This facilitates the I/O if you make a 2nd display request for a variable -- it will be read from the cache instead of the grib2 file (and therefore won't need to be uncompressed again). The limit of the cache size is (for now) hard-coded in gaio around line 76:</div><div>  #define MAXG2CACHE 500100100</div><div>You can change this and recompile if you want to limit or expand your memory usage. I intend to make grib2 cache size a command line argument at some point. When the cache reaches its max size, it releases the oldest grid in the cache (i.e., the one you read in first).  You can also release all the memory in the grib2 cache with the 'flush' command. </div><div><br class="webkit-block-placeholder"></div><div>Using 'define' with grib2 data is redundant, and it doubles your memory usage -- retrieving a cached grib2 variable is just as fast as retrieving a defined variable. Use 'define' if you think you'll need a variable for longer than it will linger in the cache, or if you are flushing the cache regularly. </div><div><br class="webkit-block-placeholder"></div><div>Your script uses 'define' at almost every line, but this is not really necessary. For example, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">    "define A=2.53e9"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">    "define B=5.42e3"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">    "define Td=B/log(A*0.622/(mix*lev(z+1)))"</font></div></div><div> could be </div><div>    A='2.53e9'</div><div>    B='5.42e3'</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">    "define Td="B"/log("A"*0.622/(mix*lev(z+1)))"</font></div></div><div><div><br class="webkit-block-placeholder"></div><div>Depending on the complexity of the expressions "A" and "B" you will save a lot of memory if you don't define them at every step but let the GrADS recursive expression handling do the job for you. </div><div><br class="webkit-block-placeholder"></div><div>Jennifer</div></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><div><div>On Mar 4, 2008, at 2:05 PM, Robert Hart wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">I'm noticing that scripts that worked fine now cause memory allocation errors with GrADS v2a.  Even when I have the correct undefines, the memory usage continues to grow.</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">As an example, please see:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://moe.met.fsu.edu/~rhart/grads-mem">http://moe.met.fsu.edu/~rhart/grads-mem</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This uses the NAM 12km GRIB2 data from, e.g.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nam/prod/nam.20080304/nam.t00z.awphys00.grb2.tm00">ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nam/prod/nam.20080304/nam.t00z.awphys00.grb2.tm00</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">through 84hr</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">By time step 14 or 15, the script has accumulated 1GB of memory and then crashes due to memory allocation errors.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This worked fine in 1.94 and earlier.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Bob</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div> </blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Jennifer M. Adams</div><div>IGES/COLA</div><div>4041 Powder Mill Road, Suite 302</div><div>Calverton, MD 20705</div><div><a href="mailto:jma@cola.iges.org">jma@cola.iges.org</a></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span></span> </div><br></div></div></body></html>