|
| 1 | +--- |
| 2 | +title: Section Specification |
| 3 | +last_updated: 2026-06-23 |
| 4 | +sidebar: netcdfJavaTutorial_sidebar |
| 5 | +toc: false |
| 6 | +permalink: section_specification_ref.html |
| 7 | +--- |
| 8 | +## CDM Section Specification |
| 9 | + |
| 10 | +### Syntax |
| 11 | + |
| 12 | +Array sections can be specified with Fortran 90 array section syntax, using zero-based indexing. For example: |
| 13 | + |
| 14 | +`/group1/group2/varName(12:22,0:100:2,:,17)` |
| 15 | + |
| 16 | +specifies an array section for a four-dimensional variable: |
| 17 | + |
| 18 | +1. `12:22` includes all the elements from 12 to 22 inclusive |
| 19 | +1. `0:100:2` includes the elements from 0 to 100 inclusive, with a stride of 2 |
| 20 | +1. `:` includes all the elements |
| 21 | +1. `17` includes just the 18th element. |
| 22 | + |
| 23 | +For structures, you can specify nested selectors, e.g. `record(12).wind(1:20,:,3)` does a selection on the `wind` member variable of the `record` structure at index 12. |
| 24 | +If you don’t specify a section, it means read the entire variable, e.g. `record.wind` means all the data in all the wind variables in all the record structures. |
| 25 | + |
| 26 | +Formally: |
| 27 | + |
| 28 | +``` |
| 29 | +sectionSpec := selector | selector '.' selector |
| 30 | +selector := varName ['(' sectionSpec ')'] |
| 31 | +varName := STRING |
| 32 | +sectionSpec := dim | dim ',' sectionSpec |
| 33 | +dim := ':' | slice | start ':' end | start ':' end ':' stride |
| 34 | +
|
| 35 | +
|
| 36 | +slice := INTEGER |
| 37 | +start := INTEGER |
| 38 | +stride := INTEGER |
| 39 | +end := INTEGER |
| 40 | +STRING := String with escaped chars = '.', '/', '(', and ')' |
| 41 | +``` |
| 42 | + |
| 43 | +where: |
| 44 | + |
| 45 | +* Nonterminals are in lower case, terminals are in upper case, and literals are in single quotes. |
| 46 | +* Optional components are enclosed between square braces `[` and `]`. |
| 47 | + |
| 48 | +TBD: |
| 49 | + |
| 50 | +* escape mechanism is currently %xx , mostly following opendap |
| 51 | +* not sure if any other chars need to be escaped. |
| 52 | + |
| 53 | +### Restrictions |
| 54 | + |
| 55 | +A Sequence is a one-dimensional Structure with a variable length, it cannot be subsetted. |
| 56 | + |
| 57 | +A variable long name must be used, that is with its group names: `/group1/group2/varName` |
| 58 | + |
| 59 | +### Use |
| 60 | + |
| 61 | +`public Array NetcdfFile.readSection(String variableSection);` |
0 commit comments