This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: "murad ali" <address@hidden> >Subject: An example of netCDF with Grace >Organization: UCAR/Unidata >Keywords: 200302031457.h13Evv624684 Hi Murad, > I m Murad Ali from Pakistan.I have Installed Grace Sw, But I m un > able to understand how to enter data / Communicate with it Via > netCDf. Kindly send me An EXAMPLE for doing this. I will be very > thank ful to you for this Kindeness. There is a simple example of a netCDF file representing a simple function of one variable here: ftp://ftp.unidata.ucar.edu/pub/netcdf/sample_data/xy.nc The file "xy.nc" is a binary file in netCDF format that represents two variables, x and y, where y is a function of x (in this case y = x*x). Here is the text form of this data: netcdf xy { // simple file with a function of one variable dimensions: x = 10; variables: float x(x); // coordinate variable float y(x); data: x = 0, 0.5, 1, 2, 2.5, 3, 4, 5, 7, 8; y = 0, 0.25, 1, 4, 6.25, 9, 16, 25, 49, 64; } The notation above is called "CDL" and is the text form of the netCDF file in xy.nc. If you install the netCDF software, it comes with a utility program "ncdump" that produces readable CDL from the binary netCDF files. Another utility program "ncgen" creates binary netCDF files from the readable CDL files. So one way to create netCDF files, if you don't want to write a program that uses the netCDF library, is to use a text editor to create a CDL file, then use the "ncgen" utility program to generate a binary netCDF file from the CDL file. Once you have a netCDF file, such as xy.nc above, you should be able to use Grace to plot it. For example, grace -netcdfxy x y xy.nc should plot y versus x with the netCDF file example you can get using the URL above. There are many other ways to create netCDF files, using the library and one of the language interfaces, for example Fortran77, C, C++ Fortran90, Java Perl, Python, or Ruby. You can access information about netCDF or various language interfaces to netCDF files from the netCDF web site at http://my.unidata.ucar.edu/content/software/netcdf/index.html --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu