<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div>Use NCL's list variable. The contents can be variables of different types, shapes and sizes<br><br></div>undef("ansari")<br></div>function ansari(x,y,z,......)<br></div>local co, o3,no2, so2, pm25, pm10<br></div>begin<br></div> co = ...<br></div> o3 =<br> :<br></div> pm10 = <br><br></div><div> co@long_nme = ...<br></div><div> o3@long_name = ...<br> <br></div><div> co@units = ...<br></div><div> o3@units = ...<br><br></div><div> copy_VarCoords(x, co) <br> :<br></div><div><br></div> return([/co, o3,no2, so2, pm25, pm10/]) ; return as list<br></div>end<br>;========<br></div>; MAIN<br>;========<br><br></div> var6 = ansari(...) ; var6 will contain <br><br></div>; you can access the list variable elements <br>; list uses [...] to access elements<br><br></div> print( var6[0] ) ; co<br> <br><div><div><div><div> print( var6[5] ) ; pm10<br><br>=========<br></div><div>For clarity, my preference is to explicitly extract each list element into a separate variable<br><br> var6 = ansari(...) <br></div><div> co = var6[0]<br></div><div> o3 = var6[1]<br><br>+++++++++++++++++<br><br></div><div>If the co, o3, ...pm10 are all the same shape, size and type you could place them into a single variable.<br></div><div> nvar = 6<br></div><div> VAR = new ( 9/nvar,.../), typeof(co), getVarFillValue(x))<br><br></div><div> VAR(0,:,,,) = co_calculation<br></div><div> VAR(1,...) = o3 <br><br></div><div> return(VAR) <br><br></div><div>The issues is thateach element may have different units, coordinates, etc<br><br></div><div>Good Luck<br></div><div><br><a href="https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml">https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml</a><br> </div><div><div><div> <br><div><div><div><div><div><div><br><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 21, 2017 at 12:14 PM, Tabish Ansari <span dir="ltr"><<a href="mailto:tabishumaransari@gmail.com" target="_blank">tabishumaransari@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"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I'm trying to write a user defined function which calculates 6 arrays, say, co, o3,no2, so2, pm25, pm10. I want to call this function inside a loop which supplies different station-names each time - so that the function computes these variables for each station. But is it possible to return 6 variables through one function?<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">How would the format be where this function is called, and also in the return statement?<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I would really appreciate an example for this.<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish<br> <br clear="all"></div><div><div class="m_-740401129433383336gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></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></div>