<html><head></head><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1500395669624_39295">Dear NCL talk,</div><div id="yui_3_16_0_ym19_1_1500395669624_40902"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_39363">I was wondering how one can write variables with attributes to HDF5 files. Following the examples on the NCL website I can successfully write variables to HDF5 files, however the variable's attributes are always missing when I perform <b id="yui_3_16_0_ym19_1_1500395669624_47756">ncl_filedump</b> or <b id="yui_3_16_0_ym19_1_1500395669624_40904">h5dump</b> on the resulting file.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_39380"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_39386">I've pasted a simple script at the end of this mail to illustrate the problem.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_40901"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_39587">Any suggestions would be greatly appreciated!</div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_40890"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_40898">Best wishes,</div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_40913">Dave.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_40899"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_40900">=====================================================================================<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_39586"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1500395669624_39577">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br id="yui_3_16_0_ym19_1_1500395669624_39527">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br id="yui_3_16_0_ym19_1_1500395669624_39528">load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br id="yui_3_16_0_ym19_1_1500395669624_39529"><br id="yui_3_16_0_ym19_1_1500395669624_39530">begin<br id="yui_3_16_0_ym19_1_1500395669624_39531"><br id="yui_3_16_0_ym19_1_1500395669624_39532">; Step 1: Make variable<br id="yui_3_16_0_ym19_1_1500395669624_39533"><br id="yui_3_16_0_ym19_1_1500395669624_39534"> variable = new((/20,20/),"double")<br id="yui_3_16_0_ym19_1_1500395669624_39535"> variable = 7.<br id="yui_3_16_0_ym19_1_1500395669624_39536"> variable@units = "m"<br id="yui_3_16_0_ym19_1_1500395669624_39537"> variable@comment = "this is a comment"<br id="yui_3_16_0_ym19_1_1500395669624_39538"> variable@_FillValue = default_fillvalue(typeof(variable))<br id="yui_3_16_0_ym19_1_1500395669624_39539"><br id="yui_3_16_0_ym19_1_1500395669624_39540"> variable!0 = "y"<br id="yui_3_16_0_ym19_1_1500395669624_39541"> variable!1 = "x"<br id="yui_3_16_0_ym19_1_1500395669624_39542"><br id="yui_3_16_0_ym19_1_1500395669624_39543"> dim_y = dimsizes(variable(:,0))<br id="yui_3_16_0_ym19_1_1500395669624_39544"> dim_x = dimsizes(variable(0,:))<br id="yui_3_16_0_ym19_1_1500395669624_39545"><br id="yui_3_16_0_ym19_1_1500395669624_39546">; Step 2: Now write this stuff to a HDF5 file with group "Results"<br id="yui_3_16_0_ym19_1_1500395669624_39547"><br id="yui_3_16_0_ym19_1_1500395669624_39548"> ofile = "hdf5_test_ncl.h5"<br id="yui_3_16_0_ym19_1_1500395669624_39549"> system("if [[ -e "+ofile+" ]] ; then rm -f "+ofile+" ; fi")<br id="yui_3_16_0_ym19_1_1500395669624_39550"> setfileoption("h5", "FileStructure", "Advanced")<br id="yui_3_16_0_ym19_1_1500395669624_39551"> hdf5_data = addfile(ofile,"c")<br id="yui_3_16_0_ym19_1_1500395669624_39552"><br id="yui_3_16_0_ym19_1_1500395669624_39553"> groupnames = (/"Results"/)<br id="yui_3_16_0_ym19_1_1500395669624_39554"> filegrpdef(hdf5_data, groupnames)<br id="yui_3_16_0_ym19_1_1500395669624_39555"><br id="yui_3_16_0_ym19_1_1500395669624_39556"> g1 = hdf5_data=>/Results<br id="yui_3_16_0_ym19_1_1500395669624_39557"><br id="yui_3_16_0_ym19_1_1500395669624_39558"> dimNames = (/"y","x"/)<br id="yui_3_16_0_ym19_1_1500395669624_39559"> dim_Sizes = (/dim_y,dim_x/)<br id="yui_3_16_0_ym19_1_1500395669624_39560"> dimUnlim = (/False,False/)<br id="yui_3_16_0_ym19_1_1500395669624_39561"> filedimdef(g1,dimNames,dim_Sizes,dimUnlim)<br id="yui_3_16_0_ym19_1_1500395669624_39562"><br id="yui_3_16_0_ym19_1_1500395669624_39563"> my = dim_y/2<br id="yui_3_16_0_ym19_1_1500395669624_39564"> mx = dim_x/2<br id="yui_3_16_0_ym19_1_1500395669624_39565"> chunkSizes = (/my,mx/)<br id="yui_3_16_0_ym19_1_1500395669624_39566"> filechunkdimdef(g1,dimNames,chunkSizes,dimUnlim)<br id="yui_3_16_0_ym19_1_1500395669624_39567"><br id="yui_3_16_0_ym19_1_1500395669624_39568"> filevardef(g1, "OUTVAR", typeof(variable), getvardims(variable))<br id="yui_3_16_0_ym19_1_1500395669624_39569"> filevarattdef(g1,"OUTVAR", variable) ; copying the attributes<br id="yui_3_16_0_ym19_1_1500395669624_39570"> filevarchunkdef(g1, "OUTVAR", chunkSizes)<br id="yui_3_16_0_ym19_1_1500395669624_39571"> filevarcompressleveldef(g1, "OUTVAR", 2)<br id="yui_3_16_0_ym19_1_1500395669624_39572"> g1->OUTVAR = (/variable/)<br id="yui_3_16_0_ym19_1_1500395669624_39573"><br id="yui_3_16_0_ym19_1_1500395669624_39574"> printVarSummary(variable)<br id="yui_3_16_0_ym19_1_1500395669624_39575">end<br id="yui_3_16_0_ym19_1_1500395669624_39576"><br></div></div></body></html>