[ncl-talk] An "2d" Attribute Array Conundrum

Philippe Papin ppapin at albany.edu
Wed May 13 10:56:38 MDT 2015


Hi NCL-talk,

I came across a strange conundrum today when testing some code. I use
attributes in my code to send 1d variables through attributes into
subroutines without explicitly defining it in the new subroutine. This
practice is limited to 1d arrays since attributes in theory can only be 1d.
However, if this is the case, why can you "create" a 2d attribute array and
then print this attribute array without error?

Here is a code snippet of an example of what I am talking about. I'm using
NCL version 6.2.1

*opt = True*
*array2d = (/ (/1,2,3/) , (/4,5,6/) /)*
*opt at array2d = array2d*
*print(opt at array2d) ;;; output below seem to print out array correctly in
2d*

(0,0) 1

(0,1) 2

(0,2) 3

(1,0) 4

(1,1) 5

(1,2) 6

However if you try to actually subscript the data, you get an error message
that attributes only have one dimension.

*subarray2d = opt at array2d(0,1)*

*fatal:Attributes only have one dimension, 2 subscripts used*

*fatal:["Execute.c":8576]:Execute: Error occurred at or near line 6*

This is a bit counterintuitive to me. Perhaps the 2d attribute array I
created is really 1d, but just gives the appearance of a 2d array when
printed. Sorry if this is a trivial question, but hopefully that means it
won't take much to figure out what is going on here.

Thanks for any additional information!

-Philippe

-- 
-------------------------------------
Philippe P. Papin
Dept. of Atmospheric and Environmental Sciences
University at Albany, SUNY
1400 Washington Ave, Albany, NY 12222
http://www.atmos.albany.edu/student/ppapin/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150513/25d36b12/attachment.html 


More information about the ncl-talk mailing list