[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NetCDF and DDI -- file format
- Subject: Re: NetCDF and DDI -- file format
- Date: Wed, 28 Jun 1995 16:43:58 -0600
Hi Mike,
> Hello, again. I was a little unsure of the procedure you suggested
> in your e-mail reponse. I realize that I need to write a fortran program
> to read in the data from my data files ( easily done ) and then create
> another data file in NetCDF format. You said to follow NetCDF form, using
> the interfaces in the netCDF library. I am not sure what library or
> interfaces you are referring to. Is it somewhere explained how this
> NetCDF format works so that I know what commands to put into my fortran
> program in order to rearranged the data into NetCDF format? I know, for
> instance, that our current data files are read in using status='old',
> form='unformatted', access='direct', and recl=7840 and the following read
> statement: READ (101,REC=1) ((X(LAT,LON),LON=1,49),LAT=1,40). Are there
> any such commands which I need to use when outputting into the new file?
Yes, the netCDF data model, Fortran and C library interfaces, and format are
documented in the NetCDF Users Guide, which is available in either hard-copy
or on-line form. The on-line documentation is best viewed with a WWW
browser such as Netscape or Mosaic, aimed at the netCDF home page:
http://www.unidata.ucar.edu/packages/netcdf/
where you will find links to a list of Frequently Asked Questions about
netCDF, on-line documentation, pointers to freely-available and commercial
software for manipulating or displaying netCDF data, information about the
netCDF mailing list, and indexed searches through information about netCDF.
I've appended a short example Fortran program contributed by a netCDF user
that might give you the flavor of the netCDF interface, but to use the
netCDF library in a program you will probably need to consult the Users
Guide. A PostScript version is available via anonymous FTP from
ftp://ftp.unidata.ucar.edu/pub/netcdf/guide.ps.Z
but we would be happy to mail you a printed copy if you supply your mailing
address.
______________________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
PROGRAM wrt_ncdf
C Simple example from Jeremy Kepner <address@hidden>
IMPLICIT NONE
INCLUDE '/usr/local/include/netcdf.inc'
INTEGER n_dim,x_dim,y_dim,z_dim
PARAMETER(n_dim = 3, x_dim = 20, y_dim = 10, z_dim = 5)
INTEGER dim_array(n_dim)
INTEGER start(n_dim),count(n_dim)
INTEGER ncid, errcode
INTEGER x_id,y_id,z_id,arr_id
REAL array(x_dim,y_dim,z_dim)
INTEGER i,j,k
C Put something into the array.
DO i=1,x_dim
DO j=1,y_dim
DO k=1,z_dim
array(i,j,k) = (i-1) + x_dim*(j-1) + x_dim*y_dim*(k-1)
ENDDO
ENDDO
ENDDO
C Create netCDF file.
ncid = NCCRE('test.nc', NCCLOB, errcode)
C Create netCDF dimensions.
x_id = NCDDEF(ncid, 'X', x_dim, errcode)
y_id = NCDDEF(ncid, 'Y', y_dim, errcode)
z_id = NCDDEF(ncid, 'Z', z_dim, errcode)
C Create a netCDF variable.
C Assign dimensions to array.
dim_array(1) = z_id
dim_array(2) = y_id
dim_array(3) = x_id
arr_id = NCVDEF(ncid,'array',NCFLOAT,n_dim,dim_array,errcode)
C Skip attributes.
C Leave definitions.
CALL NCENDF(ncid, errcode)
C Write variable to file.
start(1) = 1
start(2) = 1
start(3) = 1
count(1) = z_dim
count(2) = y_dim
count(3) = x_dim
CALL NCVPT(ncid,arr_id,start,count,array,errcode)
C Close the file.
CALL NCCLOS(ncid, errcode)
END