[gradsusr] Writing a netcdf in fortran that's readable by grads

Thomas Robinson ter at hawaii.edu
Thu Jan 15 16:38:31 EST 2015


Aloha Grads Users,

I am bringing in some data and running calculations using fortran 90.  I
want to output the data as a netCDF file, and I would like it to be
readable by grads.  I have no problem creating a file called foo.nc and
putting my lat, lon, and ref variables in the file.  The problem is if I go
to grads and type 'sdfopen foo.nc', it says
ga-> sdfopen foo.nc
Scanning self-describing file:  foo.nc
gadsdf: SDF file has no discernable X coordinate.
  To open this file with GrADS, use a descriptor file with an XDEF entry.
  Documentation is at http://iges.org/grads/gadoc/SDFdescriptorfile.html
What do I need to add to make the file self describing?
  I'm not sure what I need to add to get this to work.  Here is what I have
so far:

istatus = nf90_create(path = "foo.nc", cmode = nf90_noclobber, ncid = ncid)
          write (6,*) trim(nf90_strerror(istatus))

istatus =nf90_def_dim(ncid,'latitude',ny,ila)
          write (6,*) trim(nf90_strerror(istatus))
istatus =nf90_def_dim(ncid,'longitude',nx,ilo)
          write (6,*) trim(nf90_strerror(istatus))
istatus =nf90_def_dim(ncid,'time',1,itt)
          write (6,*) trim(nf90_strerror(istatus))

iids = (/ilo,ila,itt/)

istatus = nf90_def_var(ncid,"ref", nf90_float, iids, iref )
          write (6,*) trim(nf90_strerror(istatus))
istatus = nf90_def_var(ncid,"lat", nf90_float, ila, ilat )
          write (6,*) trim(nf90_strerror(istatus))
istatus = nf90_def_var(ncid,"lon", nf90_float, ilo, ilon )
          write (6,*) trim(nf90_strerror(istatus))
istatus = nf90_enddef(ncid)
          write (6,*) trim(nf90_strerror(istatus))

istatus = nf90_put_var(ncid,iref,ref)
          write (6,*) trim(nf90_strerror(istatus))
istatus = nf90_put_var(ncid,ilat,latrad)
          write (6,*) trim(nf90_strerror(istatus))
istatus = nf90_put_var(ncid,ilon,lonref)
          write (6,*) trim(nf90_strerror(istatus))

istatus = nf90_close(ncid)
          write (6,*) trim(nf90_strerror(istatus))

-- 
Tom Robinson
Treasurer - Graduate Student Organization
Secretary - Student Athletic Fee Committee
Graduate Student - Department of Atmospheric Science
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150115/7edd721f/attachment.html 


More information about the gradsusr mailing list