<div dir="ltr"><div>Additional information to Dave's netCDF overview:</div><div><br></div><div>NCL is row major like C. A language like fortran is column major.</div><div><br></div><div>On 'paper' the following look opposite however they are arranged <b>exactly the same in memory:</b></div><div><br></div><div>NCL:     TEMP(ntim,klev,nlat,mlon)     <== fastest varying dimension is the <b>rightmost; row major</b><br></div><div>Fortran: TEMP(mlon,nlat,klev,ntim)     <== fastest varying dimension is the <b>leftmost  ; column major<br></b></div><div><b><br></b></div><div><br></div><div><b></b></div><div><b>===========</b></div><div>NCAR's  Climate Analysis Section<b> </b>provides the <b> <a href="https://climatedataguide.ucar.edu/">Climate Data Guide</a><br></b></div><div>You should explore it. There is a lot of information.<b><br></b></div><div><b><br></b></div><div>Specifically:<br></div><div><b></b></div><div><a href="https://climatedataguide.ucar.edu/climate-data-tools-and-analysis/common-climate-data-formats-overview"><b>https://climatedataguide.ucar.edu/climate-data-tools-and-analysis/common-climate-data-formats-overview</b></a></div><div><a href="https://climatedataguide.ucar.edu/climate-data-tools-and-analysis/netcdf-overview"><b>https://climatedataguide.ucar.edu/climate-data-tools-and-analysis/netcdf-overview</b></a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 21, 2020 at 8:25 PM Dave Allured - NOAA Affiliate via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>NCL uses zero-based subscripting for both memory variables and file variables.  Therefore the first element in your example is <b>temp [0] [0] [0] [0]</b>.</div><div><br></div><div>There are some problems with the Netcdf users guide, which you cited.  You found the Netcdf-4 data model, which is rather complicated.  Here is a simplified summary of the <b>data storage model</b> for the three most common types of Netcdf storage.  For small, simple applications, the user should not be at all concerned with the internal file format.  When performance becomes an issue, it is good to have a general understanding of format issues, so as to help optimize read and write strategies.</div><div><br></div><div><b>Netcdf-3 fixed size variable.</b>  The entire N-dimensional array is stored contiguously in the file, with the NCL rightmost (last) dimension varying the fastest.  The physical layout is generally the same as you would have for a simple array in program memory.  This storage is not expandable.<br><br><b>Netcdf-3 record variable.</b>  The array is stored in chunks across the leftmost (first, slowest varying) dimension, with all the other dimensions stored contiguously in each chunk.  The first dimension is also called the <b>record</b> or <b>unlimited</b> dimension.  This storage can be <b>expanded</b> by appending on the leftmost (slowest) dimension only.  A typical application is a gridded data set where new grids are added over time, as new data become available.<br><br><b>Netcdf-4 chunked variable.</b>  The array is subdivided and stored in equal-sized chunks across all dimensions.  The individual chunk dimension sizes may be arbitrarily chosen when a new file variable is first created.  Inside each chunk, storage is contiguous across dimensions, just like in the other two storage models.  There is hidden infrastructure to keep track of all the chunks.  This strategy has some advantages for arbitrary unlimited (expandable) dimensions, and automatic internal data compression.</div><div><br></div><div>There are two simple approaches to optimizing file access.  Either read and write the <b>entire variable</b> in a single statement, or else read and write <b>contiguous file chunks</b> or <b>contiguous subsets of file chunks</b>.  A common example is to set up a gridded file variable so that each 2-D grid is stored contiguously, then read and write a whole grid each time.  This is why you see many examples where <b>lat</b> and <b>lon</b> are the rightmost dimensions; that generally results in contiguous grids.</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 21, 2020 at 6:10 PM Gurer, Kemal@ARB via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div>
<p class="MsoNormal">Hello ncl’ers,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have been searching a detailed description for the dimensional order of the data points of a multi-dimensional variable to be written
<u></u><u></u></p>
<p class="MsoNormal">to a netcdf file. I found some locations, but am also equally confused with different explanations or my lack of understanding. One example
<u></u><u></u></p>
<p class="MsoNormal">for such an explanation for the variable:<u></u><u></u></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">temp [TIMES] [LEVELS] [LATS] [LONS];<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">with <u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">TIMES = 3, <u></u>
<u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">LEVELS = 1, <u></u>
<u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">LATS = 5, <u></u>
<u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">LONS = 10</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">being written into the netcdf file in the order of dimensions is given at:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><a href="https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_data_set_components.html" target="_blank">https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_data_set_components.html</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">and mentions “<span style="color:black;background-color:white">The order in which the data will be
<b><u>returned</u></b> is with the last dimension, LONS, varying fastest:”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:white">at the time of retrieval of the data.
<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">What I am wondering is when I write the variable “temp” above into the netcdf file, is the
<b><u>first data element of temp</u></b>:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">Temp [2] [1] [4] [9]
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">or,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)">temp [0] [1] [0] [0]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:rgb(251,252,253)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:white">Thank you for your help.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:white"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black;background-color:white">Kemal.</span></p></div></div></blockquote></div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>