<div dir="ltr">Oops, I missed a simpler approach which is fine when your returned arrays do not need any custom attached attributes.<div><br></div><div><span style="font-size:14px">function data_read(rfile[1]:string</span><span style="font-size:14px">)</span><br style="font-size:14px"><span style="font-size:14px"> begin</span></div><div> x = True ; simple container variable<br style="font-size:14px"><span style="font-size:14px"> recon_data := asciiread(rfile,-1,"string")</span><br style="font-size:14px"><span style="font-size:14px"> x@lat = stringtofloat(str_get_cols(</span><span style="font-size:14px">rec<wbr>on_data, 9,15))</span><br style="font-size:14px"><span style="font-size:14px"> x@lon = stringtofloat(str_get_cols(</span><span style="font-size:14px">rec<wbr>on_data, 23,29))</span></div><div> return (x)<br style="font-size:14px"><span style="font-size:14px"> end</span><div style="font-size:14px"><br></div><span style="font-size:14px">Main script:</span><br style="font-size:14px"><br style="font-size:14px"><span style="font-size:14px"> rdat = data_read(file)</span><br style="font-size:14px"><span style="font-size:14px"> </span><span style="font-size:14px"> </span><span style="font-size:14px">printVarSummary (rdat@lat)</span></div><div><div><span style="font-size:14px"> printVarSummary (rdat@lon)</span><br style="font-size:14px"></div></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">--Dave A.</span></div><div><span style="font-size:14px"><br></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 2, 2018 at 2:57 PM, Dave Allured - NOAA Affiliate <span dir="ltr"><<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</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">Dave V,<br><br>Here is one possible approach which I have used in similar applications.<br><br>function data_read(rfile[1]:string,var[<wbr>1]:string)<br> begin<br> recon_data := asciiread(rfile,-1,"string")<br> if (var .eq. "lat") then<br> return (stringtofloat(str_get_cols(<wbr>recon_data, 9,15)))<br> end if<br> if (var .eq. "lon") then<br> return (stringtofloat(str_get_cols(<wbr>recon_data, 23,29)))<br> end if<br> ; optional handling here for "unknown variable name"<br> end<div><br></div>Main script:<br><br> lat = data_read(file,"lat")<br> lon = data_read(file,"lon")<br><br>This might seem klunky, but it avoids predefinition tricks and is fairly simple, given the constraints of NCL procedure calling.<div><br></div><div>--Dave<br><div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 2, 2018 at 2:10 PM, Vollaro, David <span dir="ltr"><<a href="mailto:dvollaro@albany.edu" target="_blank">dvollaro@albany.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="m_2594729063504328904gmail-m_-7522905112404451363divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0px;margin-bottom:0px">Hi,</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px">I have created a procedure to read an ASCII dataset. The procedure will fill several 1D variable arrays and pass them back to the main NCL script. My problem is that the call statement contains several variables that
have not been previously defined. The length of these arrays will be determined in the procedure and is dataset dependent. Is there a way to predefine a variable array w/o knowing its size? Attached is a snippet of code:</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px">Dave Vollaro<br>
</p>
<p style="margin-top:0px;margin-bottom:0px">...</p>
<p style="margin-top:0px;margin-bottom:0px">main script...</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
<span>data_read(file,lat,lon)</span></p>
<p style="margin-top:0px;margin-bottom:0px"><span></span>....</p>
<p style="margin-top:0px;margin-bottom:0px"></p>
<div> procedure data_read(rfile:string,rlat[*]<wbr>:float,rlon[*]:float)<br>
begin<br>
<br>
recon_data := asciiread(rfile,-1,"string")<br>
rlat = stringtofloat(str_get_cols(rec<wbr>on_data, 9,15))<br>
rlon = stringtofloat(str_get_cols(rec<wbr>on_data, 23,29))</div>
return
<p></p>
<p style="margin-top:0px;margin-bottom:0px"> end<br>
<span>fatal:Variable (lat) is undefined</span></p></div></div></blockquote></div></div></div></div></div></blockquote></div></div></div>