[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

971022: translating netCDF data into another format



Perry,

>Date: Wed, 22 Oct 1997 14:43:18 -0400 (EDT) 
>From: Perry Shafran <address@hidden>
>Organization: General Sciences Corporation
>To: Steve Emmerson <address@hidden>
>Subject: Another question regarding netCDF 
>Keywords: 199710221843.MAA28482 

In the above message, you wrote:

> I was able to successfully build the netCDF library to run the programs 
> ncdump and ncgen on my machine.  The output of ncdump on a typical netCDF 
> file, however, does not seem regularly formatted, and hence difficult to 
> be able to read into another program.  To make this clear, here is some 
> typical output from ncdump:
> 
>  wspd =
>   40.9, 44.6, 48, 50.3, 52.2, 51.8, 51.3, 50.5, 49.5, 48, 45.7, 42.7, 41.3, 
>     40.7, 40.1, 38.9, 37.6, 38.3, 38.1, 38.2, 36.9, 35.3, 34.5, 33.5, 33.1, 
>     31.8, 30.6, 29.4, 29.4, 26.3, 22, 64.4, 65.2, 64.5, 65.5, -999,
>   39.5, 42.4, 44.4, 46.1, 48.1, 48.9, 48.4, 48.3, 48.1, 47.5, 45.8, 42.9, 
>     41.4, 41.1, 40.9, 40, 39, 38, 37.3, 36.8, 35.8, 37.2, 35.9, 33.4, 33, 
>     32.5, 31.2, 29.2, 27.2, 25.4, 23, 21.6, 20.3, -999, -999, -999,
>   36.1, 38.7, 40.4, 41.7, 43.4, 45.2, 45, 44.2, 43.9, 43.8, 43.6, 43.3, 42.6, 
>     42.2, 40.2, 41.2, 38.2, 35.5, 35.3, 35, 33.4, -999, 33.2, 32.7, -999, 
>     -999, -999, 27, 26, 25.5, 24.6, 22.7, 20.9, 20.1, -999, -999,
>   34.8, 36.2, 37.8, 40.2, 42.5, 42.7, 42.4, 42, 42.5, 42.6, 42.5, 42.2, 41.7, 
>     41.2, 40.7, 39.7, 40.3, 37.5, 37.1, 36, 34.1, 33, 32.1, 30.8, 31.5, 30.2, 
>     30.5, 29.5, 28.4, 27.2, 24.3, 23, 22, 21.1, 18.7, 41.7,
>   34.6, 37.1, 39.4, 41.6, 42.5, 43.2, 44.2, 43.5, 43.6, 43.3, 42.8, 41.7, 
>     41.9, 42.8, 42.7, 42.3, 40.5, 39.3, 37.2, 36.5, 34.8, 33.8, 30.8, -999, 
>     29.2, 30.8, 30.8, 31.7, 30.8, 28.9, 26.5, 23.4, 22, 20.5, 17.9, 16.4,
>   36.3, 38.6, 40.6, 43.7, 46.7, 46.6, 46.1, 45.5, 44.9, 43.4, 42.9, 42.4, 
>     42.6, 43.6, 44.4, 42.7, 41.3, 40.2, 36.8, 35.4, 33.9, 32.3, 31, -999, 
>     -999, -999, -999, -999, 27.1, 24.8, 24, 23, 21.5, 20.1, 17.6, 16.6,
>   36.4, 39.6, 42.3, 48.6, 51.7, 51.3, 50.5, 50.2, 49.3, 47.8, 46.2, 45.2, 
>     44.1, 42.7, 42, 42.4, 40.8, 41.1, -999, -999, 33.3, 33.1, 32.5, 30.5, 
>     30.4, 30.1, 31.6, 32.5, 32.5, 30.9, 29, 26.7, 22.3, -999, 18, 17.7,
>   39.3, 41.2, 44, 46.4, 51.2, 52.2, 54.3, 54.3, 53.4, 52.8, 52.2, 51.2, 49.2, 
>     45.3, 43.5, 41.4, 44.5, 51.5, 41.5, 38.2, 36.2, 33.7, 31.6, 30.8, 30.1, 
>     30.7, 31.6, 31.7, 31.3, 30.7, 28.7, 23.6, 22.3, 20.3, 19.6, 19.5,
> 
> In each block of data, there are 36 levels of data.  In the first block, 
> there 13,12, and 11 levels in rows 1,2, and 3 respectively.  However, 
> there are 12,13, and 11 levels in rows 1,2, and 3 in the second block.  
> The problem lies in the fact that the number of data items in each row in 
> each block differs from block to block, making no easy way to read the 
> ASCII output from ncdump.  
> 
> Perhaps there is another way around this.  I have data in netCDF format 
> that I want to read and put into another format.  Are there any FORTRAN 
> subroutines that read netCDF files directly?  I could use that code to 
> read in my netCDF files.  
> 
> Thank you for any help you could offer.
> 
> Perry

In general, if you want to translate data in format X into format
Y, you must write a translation program that reads the data using
the X API and writes it out using the Y API.  The netCDF package
contains a complete API for both reading and writing data in both C
and Fortran.  Documentation on the API is available in the netCDF
User's Guide and UNIX manual pages.  The manual pages come with the
package.  Both the manual pages and the user's guide are available at
<http://www.unidata.ucar.edu/packages/netcdf/docs.html>.

--------
Steve Emmerson   <http://www.unidata.ucar.edu>