<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Dale, Rick:</div><div dir="ltr"><br></div><div>Please ignore my previous message, I hit send by accident.</div><div dir="ltr"><br></div><div dir="ltr">The scheme for storing 2-D coordinates in Netcdf files is described by an external convention, and is not part of the core Netcdf structure.  A full description is in CF Conventions (1.8) section 5.1.  By conforming to the convention, you enable the 2-D coordinates to be properly understood by a wide range of generic software, not just NCL.  This also overcomes the structural problem that 2-D attributes are allowed in NCL memory variables, but not in Netcdf files.</div><div dir="ltr"><br></div><div dir="ltr">Here is an example of the bare minimum Netcdf structure needed to conform.  There is a more complicated example in the CF document.</div><div dir="ltr"><br></div><div dir="ltr"><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">dimensions:<br>  j = 384 ;<br>  i = 320 ;<br>variables:<br>  integer VRH(j,i) ;<br>    VRH:coordinates = "lon lat" ;<br>  float lon(j,i) ;<br>    lon:units = "degrees_east" ;<br>  float lat(j,i) ;<br>    lat:units = "degrees_north" ;</blockquote><div><br></div><div>All variable names and dimension names are arbitrary.  You can use any names you want.  But notice the special "coordinates" attribute which lists the names of the two 2-D coordinate variables.  This is required by the CF convention.<br></div></div><div dir="ltr"><br></div><div>1-D coordinates are handled automatically by NCL, but not 2-D coordinates.  It is always necessary to have a little extra code to separately read and write the 2-D coordinate variables.</div><div dir="ltr"><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 8:33 AM Rick Brownrigg via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><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>Hi Dale,</div><div><br></div><div>You seem to be doing the proper things to attach coordinate variables to a variable. But by NetCDF convention (not due to NCL), "coordinate variables" are by definition !D arrays with a dimension name the same as the variable name.</div><div><br></div><div>If you have 2D coordinates, the technique is generally to assign those to special lat2d/lon2d *attributes* of the variable.  Check out the quote below and the web page it was taken from.</div><div><br></div><div>Rick<br></div><div><br></div><div>"To plot data on a curvilinear grid, you must read these 2D lat/lon
variables from the file and attach them to the data variable as special
attributes called "lat2d" and "lon2d":"</div><div>,,,</div><div><pre>  temp@lat2d = a->gridlat_236    ;     113 x 151
  temp@lon2d = a->gridlon_236    ;     113 x 151</pre><p>

</p><pre><a href="http://ncl.ucar.edu/Applications/plot_data_on_map.shtml" target="_blank">http://ncl.ucar.edu/Applications/plot_data_on_map.shtml</a><br><br></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 3:33 AM dale zuri via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><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">Hi NCL user,<br><div>I have been trying to write a variable that is function of 2dlat/lon to the netcdf file. </div><div>I'm getting following error. I would appreciate any help to fix this error. </div><div><br></div><div>Thanks</div><div><br></div><div>





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">VRH!</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span style="font-variant-ligatures:no-common-ligatures"><span>    </span>= </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"lat2d"</span><span style="font-variant-ligatures:no-common-ligatures"><span>                      </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(83,48,225)">; assign named dimensions</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">VRH!</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">1</span><span style="font-variant-ligatures:no-common-ligatures"><span>    </span>= </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"lon2d"</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">VRH&lat2d<span>  </span>= lat2d <span>                    </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(83,48,225)">; copy lat from T to ORO</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">VRH&lat2d<span>  </span>= lon2d</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">





</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">ncdf->VRH = VRH <span> </span></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span><br></span></span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Variable: VRH</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Type: integer</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Total Size: 491520 bytes</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span>            </span>122880 values</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Number of Dimensions: 2</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Dimensions and sizes:<span style="white-space:pre-wrap">    </span>[nj | 384] x [ni | 320]</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Coordinates:<span> </span></span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">Number Of Attributes: 3</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span>  </span>lat2d :<span style="white-space:pre-wrap">    </span><ARRAY of 122880 elements></span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span>  </span>lon2d :<span style="white-space:pre-wrap"> </span><ARRAY of 122880 elements></span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span>  </span>_FillValue :<span style="white-space:pre-wrap">    </span>-2147483647</span></p><p style="margin:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">fatal:Coordinate variables must have one dimension only</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span>

















</span></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">fatal:No coordinate variable exists for dimension (lat2d) in variable (VRH)</span></p></div></div></blockquote></div></blockquote></div></div></div>