NCGEN(1) UNIDATA UTILITIES NCGEN(1) (NAME) ncgen - netCDF-3 netCDF-4 C CDL (SYNOPSIS) ncgen [-format_code] [-1|3|4|5|6|7] [-b] [-c] [-d] [-D debuglevel] [-f] [-h] [-H] [-k format_name] [-l b|c|f77|java] [-L loglevel] [-M name] [-n] [-N datasetname] [-o netcdf_filename] [-P] [-x] (DESCRIPTION) ncgen .nc netCDF-3 ( ) .nc netCDF-4 ( /) .nc . ncgen netCDF CDL ( network Common Data form Language) . . ncgen (syntax) CDL CDL . netCDF C C netCDF . ncgen ncgen4 . ncgen ncgen3 . ncgen ncdump netCDF . netCDF ncdump CDL netCDF CDL ncgen netCDF CDL . (OPTIONS) -1|3|4|5|6|7 . 3 => netcdf 4 => netCDF-4 ( ) 5 => netcdf 5 6 => 64- netCDF 7 => netCDF-4 (3+4 == 7) -k . -b netCDF (). -o (basename) CDL <<.nc>> . . -c C netCDF netCDF . C -lc . -d -D1. -D debuglevel (debug). -f FORTRAN 77 netCDF netCDF . -lf77 . -h . -H (header) (data) . -k format_name -format_code -k ncgen ( netcdf-3 () netcdf-4 netcdf-5) . format_code . format_name -k : 'classic' 'nc3' => netCDF '64-bit offset' 'nc6' => 64- netCDF '64-bit data' 'nc5' => netCDF-5 ( 64-) 'netCDF-4' 'nc4' => netCDF-4 ( ) 'netCDF-4 classic model' 'nc7' => netCDF-4 format_code : 3 => netcdf 5 => netcdf 5 6 => 64- netCDF 4 => netCDF-4 ( ) 7 => netCDF-4 <<7>> <<7=3+4>> netCDF-3 netCDF-4 . NCO . : '1' '2' '3' '4' 'nc3' 'nc6' 'nc4' 'nc7' (deprecated) . 'hdf5' 'enhanced-nc3' . -v -k . -l b|c|f77|java -l netCDF netCDF . . : c|C' => C. f77|fortran77' => FORTRAN 77 . j|java' => Java Unidata . (Choosing the output format) : -k _Format ( ). CDF-5 ( 64-) netcdf-4 CDL . << netCDF-4>> _ChunkSizes _DeflateLevel _Endianness . << CDF-5>> 64- . netCDF-4 CDF-5 . : 1. 1 ( ) -k . CDL . 2. -k _Format _Format . -k _Format -k _Format . -k . 3. -k CDL ncgen . 4. -k CDL CDF-5 5 ( 64-) -k . netCDF-4 CDL 3 ( ) -k . 5. CDL 4 ( netCDF-4) -k . 6. ncgen -k 1 ( ) . -L loglevel (log level). -M name (main) C F77 Java. -n . -N datasetname (dataset name). -o netcdf_file <> . ( -l) <<-b>> . netCDF / (seekable) . -P NC_DISKLESS . -W maxwholevarsize maxwholevarsize nc_put_var . . -x (fill values). netCDF . (EXAMPLES) CDL `foo.cdl': ncgen foo.cdl netCDF `x.nc' CDL `foo.cdl': ncgen -o x.nc foo.cdl C netCDF netCDF `x.nc' CDL `foo.cdl': ncgen -lc foo.cdl >x.c (USAGE) CDL (CDL Syntax Overview) CDL netCDF (lat lon time) (Z t p rh lat lon time) (units long_name valid_range _FillValue) . CDL (bold) . ( CDL .) netcdf foo { // an example netCDF specification in CDL types: ubyte enum enum_t {Clear = 0, Cumulonimbus = 1, Stratus = 2}; opaque(11) opaque_t; int(*) vlen_t; dimensions: lat = 10, lon = 5, time = unlimited ; variables: long lat(lat), lon(lon), time(time); float Z(time,lat,lon), t(time,lat,lon); double p(time,lat,lon); long rh(time,lat,lon); string country(time,lat,lon); ubyte tag; // variable attributes lat:long_name = "latitude"; lat:units = "degrees_north"; lon:long_name = "longitude"; lon:units = "degrees_east"; time:units = "seconds since 1992-1-1 00:00:00"; // typed variable attributes string Z:units = "geopotential meters"; float Z:valid_range = 0., 5000.; double p:_FillValue = -9999.; long rh:_FillValue = -1; vlen_t :globalatt = {17, 18, 19}; data: lat = 0, 10, 20, 30, 40, 50, 60, 70, 80, 90; lon = -140, -118, -96, -84, -52; group: g { types: compound cmpd_t { vlen_t f1; enum_t f2;}; } // group g group: h { variables: /g/cmpd_t compoundvar; data: compoundvar = { {3,4,5}, enum_t.Stratus } ; } // group h } CDL (;) . . () <> . CDL : types () dimensions () variables () data () `types:' `dimensions:' `variables:' `data:' . : () () . variables: . . data: ( ). . types: netCDF . : enum vlen opaque compound. (dimension) netCDF netCDF . netCDF . unlimited () . . . ( ) . variables CDL . . . (attribute) netCDF netCDF netCDF . . . <> <> . . ( ) . netCDF-3 . CDL <<:>> . . (global) netCDF . : x : a = ... . x . x x . x . CDL . . (,) . . CDL utf-8 (<>) . (escape) <<\>> . (0-9) . << !"#$%&()*,:;<=>?[]^`'{}|~\>> . (<<_>>) Unidata . `variables' () `dimensions' () `data' () `group' () `types' () CDL . . : netcdf ... { ... variables: int dimensions; dimensions: attribute=0 ; // dimensions : attribute=0 ; // ... } data: CDL netCDF . : ( ) . . . << >> (fill value) <<_FillValue>> . (coercions) . <<_>> . <> <> . (Primitive Data Types) char (characters) byte - short - int - long ( int) int64 - float IEEE ( ) real ( float) double IEEE ( ) ubyte - ushort - uint - uint64 - string CDL C . CDL . . Byte . ncgen byte char C BYTE . Short -32768 32767 . ncgen short short C INTEGER*2 . Int -2147483648 2147483647 . ncgen int int C INTEGER . long int CDL - long C . Int64 -9223372036854775808 9223372036854775807 . ncgen int64 longlong C . Float -3.4+38 3.4+38 . - IEEE . ncgen float float C REAL . real float CDL . Double -1.7+308 1.7+308 . - IEEE . ncgen double double C DOUBLE PRECISION . C . . char - . . char <<_Encoding>> : US- ASCII ISO-8859-1 . UTF-8 US-ASCII UTF-8 - . UTF-8 - US- ASCII . UTF-8 . UTF-8 UTF-8 - . CDL (CDL Constants) netCDF . C short float long double . byte `b' ( `B') . netCDF-2 C `a' `0 . byte char . byte : 0b // -1b // -1 - 255b // -1 - short - . short `s' `S' . short `0' () `0x' () . : -2s // -2 (short) 0123s // 0x7ffs // int - . int `l' `L' ( ). L - - . long C - - . int `0' `0x' ( /opaque ). int : -2 1234567890L 0123 // 0x7ff // int64 - . int64 `ll' `LL' . int64 `0' `0x' . : -2ll // -2 0123LL // 0x7ffLL // float . float C `f' `F' . float : -2.0f 3.14159265358979f // 1.f double . double C . `d' `D' . double : -2.0 3.141592653589793 1.0e-20 1.d 'U' 'u' . 10U 100su 100000ul 1000000llu . . . netCDF . netCDF ( ) . char ASCII (' '..'~') - UTF-8 US- ASCII . C . . netCDF char string . : 'a' // `a' "a" // 'a' "Two\nlines\n" // "a bell:\007" // netCDF "a" NULL . ncdump C . NULL byte . (String) . . string . UTF-8 . UTF-8 . `NIL` . (Opaque) 0X 0x : 0xaa34ffff. . (Compound Constant Expressions) ( ) ( "{"..."}") . . "T(*) vlen_t" T : vlen_t var[2] = {t11,t12,...t1N}, {t21,t22,...t2m}; tij T . "compound cmpd_t {T1 f1; T2 f2...Tn fn}" Ti : cmpd_t var[2] = {t11,t12,...t1N}, {t21,t22,...t2n}; tij Ti . . . (Scoping Rules) . () . : variables: /g1/g2/t1 v1; (t1) g2 g1 . . . : . . ( ) ncgen . . . . ncgen . cdl <<>> . . . : (forward reference) . /g1/g2/t1 g1 g2 . (Specifying Enumeration Constants) ( ) . cdl ncgen . : 1. : enum.econst. 2. : /g1/g2/enum.econst. (Special Attributes) . netCDF-4 . CDL . : `_Format' `_Fletcher32' `_ChunkSizes' `_Endianness' `_DeflateLevel' `_Shuffle' `_Storage'. `_Format' netCDF . `classic' `64-bit offset' `64-bit data' `netCDF-4' `netCDF-4 classic model' . . `nc_def_var_XXX' netCDF-4 . (_Fletcher32 _Shuffle _NOFILL) true `true' `1' 1 . false `false' `0' 0 . : 1. `_Fletcher32' <> . 2. `_Endianness' `little' `big' . 3. `_DeflateLevel' 0 9 ( ) . 4. `_Shuffle' shuffle . 5. `_Storage' `contiguous' `compact' `chunked' . 6. `_ChunkSizes' (chunk sizes) . "add_offset" "scale_factor" ncgen . NCO . (Specifying Datalists) `data:` . ncgen . {...} . (scalar) N . : 1. UNLIMITED ( ) {...} . 2. (compound) {...} . 3. {...} . 4. vlen {...} . ( ) . 7. . . int var(d1)(d2)...(dn) d2...dn . D=d1*d2*...dn D (fill values) . : ( vlen) . (Specifying Character Datalists) char . : dimensions: u=UNLIMITED; d1=1; d2=2; d3=3; d4=4; d5=5; u2=UNLIMITED; variables: char var(d4,d5); datalist: var="1", "two", "three"; var (d5 X d4) . ncgen (ncgen3) . : 1. D1..Dn D1 . Di ( ). 2. C1..Cm D1 Dn . . 3. D1 D(n-1) Dx . 4. Ci Dn . 5. C1..Cm S . 6. S Dn . 8. S Dx * Dn . : 1. . . 2. vlen <> . 3. . netcdf-4 . {...} . : variables: char var(u,u2); datalist: var={"1", "two"}, {"three"}; u . u2 : datalist: var={"1","t","w","o"}, {"t","h","r","e","e"}; u2 ( ) : datalist: var={"1","t","w","o","\0"}, {"t","h","r","e","e"}; : variables: char var(u,u2,u3); datalist: var={{"1", "two"}}, {{"three"},{"four","xy"}}; u . u2 = max(1,2) = 2 . u2 : datalist: var={{"1","t","w","o"}}, {{"t","h","r","e","e"},{"f","o","u","r","x","y"}}; u3 ( ) : datalist: var={{"1","t","w","o"," "," "}}, {{"t","h","r","e","e"," "},{"f","o","u","r","x","y"}}; u2 u2 u2 : datalist: var={{"1","t","w","o"," "," "},{" "," "," "," "," "," "}}, {{"t","h","r","e","e"," "},{"f","o","u","r","x","y"}}; (BUGS) ncgen -c . CDL netCDF . string . (Identifiers and Keywords) : 1. cdl. . cdl. netCDF-3 <> <> . 2. <> <> . CDL (CDL Grammar) ncgen.y CDL . ncdesc: NETCDF datasetid rootgroup ; datasetid: DATASETID rootgroup: '{' groupbody subgrouplist '}'; groupbody: attrdecllist typesection dimsection vasection datasection ; subgrouplist: /*empty*/ | subgrouplist namedgroup ; namedgroup: GROUP ident '{' groupbody subgrouplist '}' attrdecllist ; typesection: /* empty */ | TYPES | TYPES typedecls ; typedecls: type_or_attr_decl | typedecls type_or_attr_decl ; typename: ident ; type_or_attr_decl: typedecl | attrdecl ';' ; typedecl: enumdecl optsemicolon | compounddecl optsemicolon | vlendecl optsemicolon | opaquedecl optsemicolon ; optsemicolon: /*empty*/ | ';' ; enumdecl: primtype ENUM typename ; enumidlist: enumid | enumidlist ',' enumid ; enumid: ident '=' constint ; opaquedecl: OPAQUE '(' INT_CONST ')' typename ; vlendecl: typeref '(' '*' ')' typename ; compounddecl: COMPOUND typename '{' fields '}' ; fields: field ';' | fields field ';' ; field: typeref fieldlist ; primtype: CHAR_K | BYTE_K | SHORT_K | INT_K | FLOAT_K | DOUBLE_K | UBYTE_K | USHORT_K | UINT_K | INT64_K | UINT64_K ; dimsection: /* empty */ | DIMENSIONS | DIMENSIONS dimdecls ; dimdecls: dim_or_attr_decl ';' | dimdecls dim_or_attr_decl ';' ; dim_or_attr_decl: dimdeclist | attrdecl ; dimdeclist: dimdecl | dimdeclist ',' dimdecl ; dimdecl: dimd '=' UINT_CONST | dimd '=' INT_CONST | dimd '=' DOUBLE_CONST | dimd '=' NC_UNLIMITED_K ; dimd: ident ; vasection: /* empty */ | VARIABLES | VARIABLES vadecls ; vadecls: vadecl_or_attr ';' | vadecls vadecl_or_attr ';' ; vadecl_or_attr: vardecl | attrdecl ; vardecl: typeref varlist ; varlist: varspec | varlist ',' varspec ; varspec: ident dimspec ; dimspec: /* empty */ | '(' dimlist ')' ; dimlist: dimref | dimlist ',' dimref ; dimref: path ; fieldlist: fieldspec | fieldlist ',' fieldspec ; fieldspec: ident fielddimspec ; fielddimspec: /* empty */ | '(' fielddimlist ')' ; fielddimlist: fielddim | fielddimlist ',' fielddim ; fielddim: UINT_CONST | INT_CONST ; /* Use this when referencing defined objects */ varref: type_var_ref ; typeref: type_var_ref ; type_var_ref: path | primtype ; /* Use this for all attribute decls */ /* Watch out; this is left recursive */ attrdecllist: /*empty*/ | attrdecl ';' attrdecllist ; attrdecl: ':' ident '=' datalist | typeref type_var_ref ':' ident '=' datalist | type_var_ref ':' ident '=' datalist | type_var_ref ':' _FILLVALUE '=' datalist | typeref type_var_ref ':' _FILLVALUE '=' datalist | type_var_ref ':' _STORAGE '=' conststring | type_var_ref ':' _CHUNKSIZES '=' intlist | type_var_ref ':' _FLETCHER32 '=' constbool | type_var_ref ':' _DEFLATELEVEL '=' constint | type_var_ref ':' _SHUFFLE '=' constbool | type_var_ref ':' _ENDIANNESS '=' conststring | type_var_ref ':' _NOFILL '=' constbool | ':' _FORMAT '=' conststring ; path: ident | PATH ; datasection: /* empty */ | DATA | DATA datadecls ; datadecls: datadecl ';' | datadecls datadecl ';' ; datadecl: varref '=' datalist ; datalist: datalist0 | datalist1 ; datalist0: /*empty*/ ; /* Must have at least 1 element */ datalist1: dataitem | datalist ',' dataitem ; dataitem: constdata | '{' datalist '}' ; constdata: simpleconstant | OPAQUESTRING | FILLMARKER | NIL | econstref | function ; econstref: path ; function: ident '(' arglist ')' ; arglist: simpleconstant | arglist ',' simpleconstant ; simpleconstant: CHAR_CONST /* never used apparently*/ | BYTE_CONST | SHORT_CONST | INT_CONST | INT64_CONST | UBYTE_CONST | USHORT_CONST | UINT_CONST | UINT64_CONST | FLOAT_CONST | DOUBLE_CONST | TERMSTRING ; intlist: constint | intlist ',' constint ; constint: INT_CONST | UINT_CONST | INT64_CONST | UINT64_CONST ; conststring: TERMSTRING ; constbool: conststring | constint ; /* Push all idents thru here for tracking */ ident: IDENT ; Printed: 0-0-0 $Date: 2010/04/29 16:38:55 $ NCGEN(1)