<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Will,<br>
    <br>
    Depending on what you are doing, you might be able to flatten into a
    lower dimensional array, do whatever operation, then convert back.
    I've attached an example to get you started: it returns a random
    sample in the left-most dimension of any 2+ dimensional array. To
    run it just go into an interactive NCL session, load the file, and
    run the test procedure:<br>
    <br>
    <tt>[user@machine ~]$ ncl</tt><tt><br>
    </tt><tt> Copyright (C) 1995-2014 - All Rights Reserved</tt><tt><br>
    </tt><tt> University Corporation for Atmospheric Research</tt><tt><br>
    </tt><tt> NCAR Command Language Version 6.2.0</tt><tt><br>
    </tt><tt> The use of this software is governed by a License
      Agreement.</tt><tt><br>
    </tt><tt> See <a class="moz-txt-link-freetext" href="http://www.ncl.ucar.edu/">http://www.ncl.ucar.edu/</a> for more details.</tt><tt><br>
    </tt><tt>ncl 0&gt; load "takeSample.ncl"</tt><tt><br>
    </tt><tt>ncl 1&gt; test_takeSample()</tt><br>
    <br>
    - Walter<br>
    <br>
    <div class="moz-cite-prefix">On 02-Jun-15 02:43, Will Hobbs wrote:<br>
    </div>
    <blockquote cite="mid:D1938DB3.B99B%25will.hobbs@utas.edu.au"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div>Hi all</div>
      <div><br>
      </div>
      <div>I wonder if anyone has any suggestions for a generic way of
        writing functions that deal with input/output arrays which may
        have different numbers of dimensions, e.g.</div>
      <div><br>
      </div>
      <div><span class="Apple-tab-span" style="white-space:pre"></span>function

        generic_example(input:numeric)</div>
      <div><br>
      </div>
      <div><span class="Apple-tab-span" style="white-space:pre"></span>begin</div>
      <div><span class="Apple-tab-span" style="white-space:pre"></span></div>
      <div><span class="Apple-tab-span" style="white-space:pre"></span> 
        output = some_subset_of_(input)</div>
      <div><span class="Apple-tab-span" style="white-space:pre"></span>  </div>
      <div><span class="Apple-tab-span" style="white-space:pre"></span>  return(output)<span
          class="Apple-tab-span" style="white-space:pre"> </span></div>
      <div>        end</div>
      <div><br>
      </div>
      <div>where input/output might be 1, 2, 3, 4 or more dimensions,
        and so a different line is needed to do the subsetting step.</div>
      <div><br>
      </div>
      <div>At the moment I just use nested 'if' statements based on the
        rank of the array (where rank is the number of dimensions, i.e.
        dimsizes(dim sizes(input)), and this works fine. But, it does
        not make for particularly 'clean' or efficient code, so I wonder
        if anyone has any nicer ways of doing this.</div>
      <div><br>
      </div>
      <div>Many thanks</div>
      <div><br>
      </div>
      <div>Will</div>
      <p style="font-size:10pt; line-height:10pt; calibri"><br>
        <br>
        University of Tasmania Electronic Communications Policy
        (December, 2014). <br>
        This email is confidential, and is for the intended recipient
        only. Access, disclosure, copying, distribution, or reliance on
        any of it by anyone outside the intended recipient organisation
        is prohibited and may be a criminal offence. Please delete if
        obtained in error and email confirmation to the sender. The
        views expressed in this email are not necessarily the views of
        the University of Tasmania, unless clearly intended otherwise. </p>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Walter Kolczynski, Jr.
Global Ensemble Team
NOAA/NWS/NCEP/EMC (via I.M. Systems Group)
(301) 683-3781</pre>
  </body>
</html>