[ncl-talk] Issue writing to netcdf4
    Andrew Kren - NOAA Affiliate 
    andrew.kren at noaa.gov
       
    Tue Jun 18 20:55:27 MDT 2019
    
    
  
Hi ncl-talk,
I'm writing a number of variables to netcdf-4. The variables are a mix of
intengers, strings, and floats so I thought netcdf4 is the right way to go.
I followed instructions on the ncl support page, but appear to be getting
issues with writing the data.
*I have this written below. More is written after it but it fails before
getting to the rest.*
filo = "/home/arsenic1/scripts/gfs/" + utc_start + "z/
saved_14er_variables_gfs_new.nc"
;===================================================================
 setfileoption("nc", "Format",  "NetCDF4")
 fon = filo
 system("/bin/rm -f " + fon) ; remove if exists
 fo = addfile(fon, "c")
;===================================================================
; explicitly declare file definition mode. Improve efficiency.
;===================================================================
 setfileoption(fo,"DefineMode",True)
 ; create global attributes of the file
 ;===================================================================
 fAtt               = True            ; assign file attributes
 fAtt at title         = "GFS 14er Data File"
 fAtt at source_file   = filo
 fAtt at Conventions   = "None"
 fAtt at creation_date = systemfunc ("date")
 fileattdef(fo, fAtt)   ; copy file attributes
;===================================================================
; predefine the coordinate variables and their dimensionality
; Note: to get an UNLIMITED record dimension, we set the dimensionality
; to -1 (or the actual size) and set the dimension name to True.
;===================================================================
 dimNames = (/"peaks","time"/)
 dimSizes = (/dimsizes(names_14ers),dimsizes(fcst_hr)/)
 dimUnlim = (/False,False/)
 filedimdef(fo, dimNames, dimSizes, dimUnlim)
 mtim = dimsizes(fcst_hr)
 mname = dimsizes(names_14ers)
 chunkSizes = (/ mtim, mname/)
 filechunkdimdef(fo,dimNames,chunkSizes,dimUnlim)
 grpnames = (/"grp1", "group2", "g3"/)
 filegrpdef(fo,grpnames)
 ; predefine the the dimensionality of the variables to be written out
 ;===================================================================
 ; Here we are using NCL functions to facilitate defining
 ; each variable's dimension name(s) and type.
 ;===================================================================
 filevardef(fo, "peaks", typeof(names_14ers), getvardims(names_14ers))
 filevarattdef(fo,"peaks", names_14ers)                   ; copy time
attributes
 fo->peaks   = (/names_14ers/)
The program gives a fatal error at the green line, and I'm not sure why. My
actual dims of my variables are name by time so I'm confused. When I do an
ncl_filedump on the file, I get this message in the report:
*ERROR: Invalid _NCProperties attribute*
Any help on this is much appreciated, as I have tried a number of different
ways to rectify this.
Thanks!
-- 
Andrew Kren
Assistant Scientist
University of Miami CIMAS - NOAA/AOML
Global Observing Systems Analysis (GOSA) Group
NOAA/AOML Quantitative Observing System Assessment Program (QOSAP)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190618/16004334/attachment.html>
    
    
More information about the ncl-talk
mailing list