About netcdf output

From: Li,Guilong [Ontario] <Guilong.Li_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 25 2014 - 15:27:34 MST

Hi,

I am using ncl to calculate standardized precipitation index, and I want
to output the result in netcdf format which can be read be some graph
software, such as GrADS. I use the following program but it seems I have
something wrong on the program

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

   f = addfile("pr_mon.nc", "r")
   prc = f->pr ; PREC(time,lat,lon)
   lon = f->lon ; Longitude(lon)
   lat = f->lat ; Latitude(lat)
   time = f->time ; Time(time)
   printVarSummary(prc)

   dimp = dimsizes(prc) ; # monthly precipitation values
   ntim = dimp(0)
   nlat = dimp(1)
   mlon = dimp(2)

   lev = (/3, 6, 12, 24, 36, 48 /)
   klev = dimsizes(lev)
   spi = new((/klev,ntim,nlat,mlon/) ,float,prc@_FillValue)

   do k=0,klev-1
      spi(k,:,:,:) = dim_spi_n(prc, lev(k), False, 0)
   end do

   printVarSummary(lev)
   copy_VarCoords(prc,spi(0,:,:,:))
   spi@long_name = "SPI"
   lev@long_name = "Levels"
   lev@units = "months"
   lev@axis = "Z"
   spi!0 = "lev"
   spi&lev = lev
   spi!1 = "time"
   spi&time = time
   spi!2 = "lat"
   spi&lat = lat
   spi!3 = "lon"
   spi&lon = lon
   printVarSummary(spi)

setfileoption("nc","Format","NetCDF4")
fout = addfile("out1.nc","c")
fout->spi = spi ; spi(lev,time,lat,lon)
fout->lon = lon ; longitude(lon)
fout->lat = lat ; latitude(lat)
fout->lev = lev ; levels(lev)
fout->time = time ; time(time)

As I am new in ncl group, I just wonder whether someone can help me on
this problem. If I don't output the lon, lat, lev, and time, I can write
a control file to read the output. But I still want to know how to write
it in netcdf format which can be read by GrADS directly.

Thanks,

Guilong

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 25 15:27:47 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST