NCL Home>
Application examples>
File IO ||
Data files for some examples
Support for NetCDF-4 files is in beta-testing in V6.1.1.
We encourage people to test it out and give us feedback on our ncl-talk email list.
Create a file to write NetCDF4 vlen data.
Define some file attributes:
Define dimensions:
Define the variable:
Write the compound data out, and close the file:
This script produced (use "ncl_filedump nc4_vl.nc"):
Example pages containing:
tips |
resources |
functions/procedures
>
write netCDF
NCL: Write netCDF4 vlen(variable LENgth array) data
Support for NetCDF-4 files is in beta-testing in V6.1.1.
We encourage people to test it out and give us feedback on our ncl-talk email list.
Below is a script which demonstrates how to read/write NetCDF4 vlen data.
Read NetCDF4 vlen data from a file generated from NetCDF vlen example code.
fn = "$NCARGTEST/nclscripts/nc4_files/vlen.nc"
fa = addfile(fn, "r")
;printVarSummary(fa)
;print(fa)
var = fa->var
ne = ListCount(var)
print("Number of Elements = " + ne)
delete(fa)
Create a file to write NetCDF4 vlen data.
;===================================================================
setfileoption("nc", "format", "NETCDF4")
fn = "nc4_vl.nc"
system("/bin/rm -f " + fn)
fo = addfile(fn, "c")
Define some file attributes:
;===================================================================
fAtt = True
fAtt@title = "NCL generated netCDF file"
fAtt@source_file = fn
fAtt@Conventions = "None"
fAtt@creation_date = systemfunc("date")
fileattdef(fo, fAtt)
Define dimensions:
;=================================================================== dimNames = (/"vldim"/) dimSizes = (/ ne /) dimUnlim = (/ False /) filedimdef(fo, dimNames, dimSizes, dimUnlim)
Define the variable:
;=================================================================== vlen_name = "vlen" var_name = "var" filevlendef(fo, vlen_name, var_name, "integer", dimNames) ;printVarSummary(var)
Write the compound data out, and close the file:
;=================================================================== fo->$var_name$ = (/var/) delete(fo)
This script produced (use "ncl_filedump nc4_vl.nc"):
Variable: f
Type: file
filename: nc4_vl
path: nc4_vl.nc
User Defined Types:
vlen
{
};
Number of Attributes:4
creation_date : Tue Nov 5 13:32:18 MST 2013
Conventions : None
source_file : nc4_vl.nc
title : NCL generated netCDF4 file
dimensions:
vldim = 3
variables:
Variable: var
Type: list
Total Size: 3 values
12 bytes
Number of Dimensions: 1
Dimensions and sizes: [ 3 ]
Coordinates: