<div dir="ltr">Hi Soma,<div>Malloc errors usually mean you are running out of memory on your machine. Your printVarSummary statement shows that the variable is 1GB in size, and is of type short. You will want to convert this to type float to process and/or to plot it, but when you do that the size of your array will double. <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">You might not be able to read multiple variables into NCL at once due to the size of your machine. One thing you can do though is read in a variable, convert it to float, and average across the time dimension all at once:</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">T=dim_avg_n_Wrap(short2flt(in-<wbr>>t),0) ; temperature</span><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I am honestly not sure whether it is good practice to do all that upon read in, someone else can possibly chime in here. If not, one can do this:</span></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Tt = in->T</span></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">T = <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">dim_avg_n_Wrap(short2flt(Tt)<wbr>,0) ; temperature</span></span></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">delete(Tt)</span></span></span></div><div><br></div><div>and then repeat for U and V the same way. Again though, it comes down to whether your machine is big enough memory wise to handle the size of these arrays. If it is not, you will have to chunk your data read-ins in either time or lat x lon.</div><div><br></div><div>Hope that helps. If not, please respond to the ncl-talk email list.</div><div>Adam</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 8, 2018 at 8:35 AM, Soma Roy <span dir="ltr"><<a href="mailto:somaroy892@gmail.com" target="_blank">somaroy892@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am trying to access multiple variables from a file and need to average over time for each variables.</div><div><br></div><div>I am running the following codes:</div><div><br></div><div><div> fn = "ERA_Plev.nc" ; define filename</div><div> in = addfile(fn,"r") ; open netcdf file</div><div> printVarSummary(in)</div><div><br></div><div>T=in->t ; temperature</div><div>U=in->u ; U wind</div><div>V=in->v ; V wind</div><div><br></div><div>printVarSummary(T)</div><div>printVarSummary(U)</div><div>printVarSummary(V)</div><div><br></div><div>;T1 = dim_avg_n(T,0)</div><div>;T@units = "K"</div><div><span style="white-space:pre-wrap"> </span></div><div>end</div></div><div><br></div><div>Summary of the file is like below;<br></div><div><br></div><div><div>Variable: in</div><div>Type: file</div><div>File path: ERA_Plev.nc</div><div>Number of global attributes: 2</div><div>Number of dimensions: 4</div><div>Number of variables: 18</div><div>fatal:NclMalloc Failed:[errno=12]</div><div>Segmentation fault (core dumped)</div></div><div><br></div><div>When I am calling only Temperature using the codes below;</div><div><br></div><div><div>fn = "ERA_Plev.nc" ; define filename</div><div>in = addfile(fn,"r") ; open netcdf file</div><div> printVarSummary(in)</div><div><br></div><div>T=in->t ; temperature</div><div>;U=in->u ; U wind</div><div>;V=in->v ; V wind</div><div><br></div><div>printVarSummary(T)</div><div>;printVarSummary(U)</div><div>;printVarSummary(V)</div><div><br></div><div>;T1 = dim_avg_n(T,0)</div><div>;T@units = "K"</div><div><span style="white-space:pre-wrap"> </span></div><div>end</div></div><div> </div><div>It shows</div><div><br></div><div><div>Variable: T</div><div>Type: short</div><div>Total Size: 1042566000 bytes</div><div> 521283000 values</div><div>Number of Dimensions: 4</div><div>Dimensions and sizes: [time | 120] x [level | 25] x [latitude | 721] x [longitude | 241]</div><div>Coordinates:</div><div> time: [994176..994890]</div><div> level: [50..125]</div><div> latitude: [90..-90]</div><div> longitude: [60..120]</div><div>Number Of Attributes: 7</div><div> scale_factor : 0.00218919045579553</div><div> add_offset : 252.4797479951041</div><div> _FillValue : -32767</div><div> missing_value : -32767</div><div> units : K</div><div> long_name : Temperature</div><div> standard_name : air_temperature</div></div><div><br></div><div><br></div><div>I have to call several other variables from this file (14 GB) and I need to average over time such that 'Dimensions' of each variables will be like below;</div><div><br></div><div>[time | 1]*
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">[level | 25] x [latitude | 721] x [longitude | 241]</span>
</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div>Which function I have to use in this case?</div><div><br></div><div><br></div><div>When I am trying to call other variables from the file I am getting the error message as;</div><div><br></div><div><div>Variable: in</div><div>Type: file</div><div>File path: ERA_Plev.nc</div><div>Number of global attributes: 2</div><div>Number of dimensions: 4</div><div>Number of variables: 18</div><div>fatal:NclMalloc Failed:[errno=12]</div><div>Segmentation fault (core dumped)</div></div><div><br></div><div>Please kindly inform me how to resolve this issue.</div><div><br></div><div><br></div><div>Thank you,</div><div>Soma</div><div><br></div><div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br></div></div></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist, </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</div>