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

Re: ncdigest V1 #644



Dr. Murty,

>     Recently we have downloaded POM model from
> websit:http://sea-mat.whoi.edu, which works under MATLAB
> environment. It has many functions. Examples are given below:
> 1) function [var]=get_point(file,vname,iindex,jindex,kinde,itime)
>        file .... the name of the netCDF file
>        vname ...  the name of the netCDF variable
>        iindex ... i-index of point
>        jindex ... j-index of point
>        etc.
> 
>  Question No.1: I have data files (temp.dat ) in DOS
> environment. temp.dat contains data on temperature ( 30 rows and 17
> columns). I am reading the same data from source code (in fortran
> using statement: read(1,*)((a(i,j),j=1,17),i=1,30) ). For above such
> models, I have to supply netcdf file. I would like to know, how to
> convert temp.dat file in netcdf file?

You will need to write a Fortran program that reads the temperature
data from the temp.dat file and writes it to a netCDF file (for
example, temp.nc).  There is no simple conversion program available
from Fortran binary files to netCDF binary files, partly because
netCDF files contain more information about the data than is in the
Fortran binary file, including a name for each dimension and variable
as well as attributes such as units for variables.

You will need to decide whether to use the Fortran 77 interface:

  http://www.unidata.ucar.edu/packages/netcdf/guidef/

or the Fortran 90 interface for netCDF:

  http://www.unidata.ucar.edu/packages/netcdf/f90/Documentation/f90-html-docs/

In either case, an introduction to the function calls that are
necessary to create a netCDF file is Section 4.1, "Creating a NetCDF
Dataset".

Another way to create a netCDF dataset is to first create a text file
describing the structure of the data, then use the "ncgen" netCDF
utility to generate appropriate Fortran source to create the
corresponding netCDF file.  To see how to do this, consult Chapter 10,
"NetCDF Utilities".  The ncgen utility will generate a small program
that initializes arrays with DATA statements.  You can replace these
DATA statements with Fortran READ statements to read the data from
your temp.dat file.

If you would rather work in MATLAB than Fortran, you can use one of
the freely-available software packages that implement a MATLAB/netCDF
interface:

  http://www.unidata.ucar.edu/packages/netcdf/software.html#MATLAB

> Question No.2. I have some software in fortran. I would like to run
> those software in MATLAB environment.How?

You'll have to consult the MATLAB documentation or ask MATLAB support
about that.

Finally, as a reminder, usage questions about netCDF should generally
be sent to 

  address@hidden 

rather than the netcdfgroup mailing list, which is intended for
announcements and discussion.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu