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

James T. Potemra jimp at hawaii.edu
Thu Jan 15 16:53:46 EST 2015


Hi Tom,

I think you'll need to add attributes to your variables, specifically 
the units.  For lat and lon these
should be "degrees_north" and "degrees_east".

Jim

On 1/15/15 11:38 AM, Thomas Robinson wrote:
> 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 
> <http://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 
> <http://foo.nc>', it says
> ga-> sdfopen foo.nc <http://foo.nc>
> Scanning self-describing file: foo.nc <http://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 <http://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
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150115/aec70566/attachment.html 


More information about the gradsusr mailing list