<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">To piggyback on Phillipe's email. I just coincidentally came across this problem myself, worse though I get seg faults. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Easy work around but seg faults are never good. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">e.g.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default"><font face="verdana, sans-serif">res = True</font></div><div class="gmail_default"><font face="verdana, sans-serif"><div>res@test := new( (/10,10/) , float)<br></div><div>; print(res@test(0,3)) ;;; we can't do this, so is it actually a 1d array? </div><div>print(res@test(3)) ;; Seg fault. <br></div><div><br></div><div><br></div><div>~alan</div><div><br></div><div><br></div></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 May 2015 at 17:01, Philippe Papin <span dir="ltr"><<a href="mailto:ppapin@albany.edu" target="_blank">ppapin@albany.edu</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 David,<div><br></div><div>Thanks for the detailed reply and suggestions. I can easily assign the attribute values to a local variable! Also good to know that 2d arrays are allowed in attributes even if the are not fully supported!</div><div><br></div><div>Have a great day!</div><span class="HOEnZb"><font color="#888888"><div>-Philippe</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 13, 2015 at 2:17 PM, David Brown <span dir="ltr"><<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Phillipe,<br>
That's a good question. Actually the error message, as you discovered,<br>
is a bit misleading. NCL was originally designed to only allow 1D<br>
attributes in keeping with the NetCDF data model. Later, however, when<br>
we needed the ability to transmit 2D coordinate information to the<br>
graphics routines (mainly), we loosened the restriction to allow NCL<br>
variables to have multi-d attributes as a convenience. However, as you<br>
have found, we did not implement full support for this feature. Partly<br>
this is because you cannot write such an attribute to any of the<br>
output file formats we support -- so it can never be truly integrated<br>
into the data model.<br>
Practically speaking, if you wanted to have a routine that handles<br>
subscripting of 2D attributes, I'm guessing you could do it by<br>
assigning the attribute value to a local variable, subscripting the<br>
variable, and using the 'reassign' syntax to give the attribute its<br>
new subscripted value.<br>
We will try to make the error message a little more informative.<br>
Eventually maybe we can make subscripting work in this situation.<br>
-dave<br>
<div><div><br>
On Wed, May 13, 2015 at 10:56 AM, Philippe Papin <<a href="mailto:ppapin@albany.edu" target="_blank">ppapin@albany.edu</a>> wrote:<br>
> Hi NCL-talk,<br>
><br>
> I came across a strange conundrum today when testing some code. I use<br>
> attributes in my code to send 1d variables through attributes into<br>
> subroutines without explicitly defining it in the new subroutine. This<br>
> practice is limited to 1d arrays since attributes in theory can only be 1d.<br>
> However, if this is the case, why can you "create" a 2d attribute array and<br>
> then print this attribute array without error?<br>
><br>
> Here is a code snippet of an example of what I am talking about. I'm using<br>
> NCL version 6.2.1<br>
><br>
> opt = True<br>
> array2d = (/ (/1,2,3/) , (/4,5,6/) /)<br>
> opt@array2d = array2d<br>
> print(opt@array2d) ;;; output below seem to print out array correctly in 2d<br>
><br>
> (0,0) 1<br>
><br>
> (0,1) 2<br>
><br>
> (0,2) 3<br>
><br>
> (1,0) 4<br>
><br>
> (1,1) 5<br>
><br>
> (1,2) 6<br>
><br>
> However if you try to actually subscript the data, you get an error message<br>
> that attributes only have one dimension.<br>
><br>
> subarray2d = opt@array2d(0,1)<br>
><br>
> fatal:Attributes only have one dimension, 2 subscripts used<br>
><br>
> fatal:["Execute.c":8576]:Execute: Error occurred at or near line 6<br>
><br>
> This is a bit counterintuitive to me. Perhaps the 2d attribute array I<br>
> created is really 1d, but just gives the appearance of a 2d array when<br>
> printed. Sorry if this is a trivial question, but hopefully that means it<br>
> won't take much to figure out what is going on here.<br>
><br>
> Thanks for any additional information!<br>
><br>
> -Philippe<br>
><br>
><br>
> --<br>
> -------------------------------------<br>
> Philippe P. Papin<br>
> Dept. of Atmospheric and Environmental Sciences<br>
> University at Albany, SUNY<br>
> 1400 Washington Ave, Albany, NY 12222<br>
> <a href="http://www.atmos.albany.edu/student/ppapin/" target="_blank">http://www.atmos.albany.edu/student/ppapin/</a><br>
><br>
</div></div>> _______________________________________________<br>
> ncl-talk mailing list<br>
> List instructions, subscriber options, unsubscribe:<br>
> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
><br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div>-------------------------------------</div><div>Philippe P. Papin<br><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Dept. of Atmospheric and Environmental Sciences</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">University at Albany, SUNY</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">1400 Washington Ave, Albany, NY 12222</div></div></div><div><font color="#222222" face="arial, sans-serif"><a href="http://www.atmos.albany.edu/student/ppapin/" target="_blank">http://www.atmos.albany.edu/student/ppapin/</a></font></div></div>
</div>
</div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>