<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[1]:string)<br> begin<br> recon_data := asciiread(rfile,-1,"string")<br> if (var .eq. "lat") then<br> return (stringtofloat(str_get_cols(recon_data, 9,15)))<br> end if<br> if (var .eq. "lon") then<br> return (stringtofloat(str_get_cols(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="gmail-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(<wbr>recon_data, 9,15))<br>
rlon = stringtofloat(str_get_cols(<wbr>recon_data, 23,29))</div>
return
<p></p>
<p style="margin-top:0px;margin-bottom:0px"> end<br>
<span>fatal:Variable (lat) is undefined</span><br></p></div></div></blockquote></div></div></div></div></div>