[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help needed: netCDF in FORTRAN
- Subject: Re: help needed: netCDF in FORTRAN
- Date: Thu, 12 May 1994 15:36:08 -0600
> Organization: NCAR/ACD
> Keywords: 199405122005.AA14988
Hi Wanli,
> I am a new user to netCDF. I need to download a lot of
> datasets in netCDF on IBM RS6000
> (AIX3.2) for my FORTRAN program.
> Now I have installed netCDF package on the workstation(AIX3.2)
> followed README
>
> export CFLAGS=""
> export FC=xlf
> configure --prefix=/scratch/wanliwu/nmcdata
> make "all"
> make "test"
> make "install"
> make "clean"
>
> It seems so far so good for the installation.
>
> Is the netCDF ready for me? if not, what else should I do? go to
> fortran directory to do some
> similiar make again?
> if it is ready , how can I do in my FORTRAN program to connect to the
> dataset, say I get a dataset in netCDF -- hgt85.nc ? What I want is
> tranfor the netCDF data to FORTRAN data so that my numerical model can read
> it ?
Your FORTRAN program has to make calls to the netCDF library subroutines to
open the netCDF file and read data from the file into FORTRAN arrays. To
read the data, you will need to know the names of the variables in the
netCDF dataset. For this purpose, the "ncdump" program is useful. For
example,
% ncdump -c hgt85.nc
will tell you the names and shapes of variables in the file, as well as
their attributes and coordinate values. This is all documented in the
netCDF User's Guide, which is part of the software distribution but also
available online using Mosaic at
http://www.unidata.ucar.edu/packages/netcdf/
To open the file in a FORTRAN program, look at the netCDF User's Guide to
see how to call the NCOPN subroutine. For example:
INCLUDE 'netcdf.inc'
...
INTEGER NCID, RCODE
...
NCID = NCOPN('hgt85.nc.nc', NCNOWRIT, RCODE)
To get data from a netCDF variable named "Z" into your FORTRAN array
named "RH", for example, read the netCDF User's Guide to learn how to use
the NCVID and NCVGT subroutines:
PARAMETER (NDIMS=3) ! number of dimensions
PARAMETER (TIMES=3, LATS=5, LONS=10) ! dimension sizes
INTEGER NCID, RCODE
INTEGER ZID ! variable ID
INTEGER START(NDIMS), COUNT(NDIMS) ! hyperslab
DOUBLE RH(LONS, LATS, TIMES)
DATA START /1, 1, 1/ ! start at first value
DATA COUNT /LONS, LATS, TIMES/ ! how many values in each dimension
...
ZID = NCVID (NCID, 'Z', RCODE) ! get ID
CALL NCVGT (NCID, ZID, START, COUNT, RH, RCODE) ! read the values
This is just an example. You will need to read the documentation to use the
netCDF library.
Also, questions about the netCDF library should be sent to
"address@hidden" so that they will be directed to the right person
to answer the question.
__________________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden P.O. Box 3000
(303)497-8645 Boulder, Colorado 80307-3000