pro pp_writencdf,strin,double=double
if (n_elements(double) ne 1) then double=0
a=strin
at=strlowcase(tag_names(a))
adt=where((at eq 'dims')+(at eq 'd'))
avt=where((at eq 'vars')+(at eq 'v'))
ant=where((at eq 'nams')+(at eq 'n'))
an=strlowcase(tag_names(a.(avt)))
ad=strlowcase(tag_names(a.(adt)))
nid=ncdf_create(a.ncdfname,/clobber)
dids=lonarr(n_elements(ad))
for i=0,n_elements(ad)-1 do dids[i]=ncdf_dimdef(nid,ad[i],(a.(adt)).(i))
vids=lonarr(n_elements(an))
adnt=strlowcase(tag_names(a.(ant)))
for i=0,n_elements(an)-1 do begin
w=where(adnt eq an[i])
tmp=(a.(ant).(w))
inds=lonarr(n_elements(tmp))
for j=0,n_elements(tmp)-1 do inds[j]=where(ad eq tmp[j])
dims=dids[inds]
vids[i]=ncdf_vardef(nid,an[i],dims,double=double)
endfor
ncdf_control,nid,/endef
for i=0,n_elements(an)-1 do ncdf_varput,nid,vids[i],a.(avt).(i)
ncdf_close,nid
print,'netcdf file ',a.ncdfname,' done'
end