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

Re: netCDF files and data access



>From: Lihua Li <address@hidden>
>Organization: University of Massachussetts
>Keywords: 199408222035.AA12492 ncdump

Lihua,

>       Thank you for help. As you instrution, I got the netcdf-232pl2.tar.Z 
>and netcdf.tar.Z,then built them in my directory and used ncdump utility to 
>convert a netCDF file named aP.nc (I got it from the pub/netcdf/sample_data)
>into CDL fromat  as following: (according to the format of User's Guide, UNIX 
>enviroment )
>
>        ncdump -b c aP.nc > aP.cdl
>
>Whenever I execute it, the computer creates a aP.cdl file with 0 size ( I mean
>there is nothing in this aP.cdl file) and tells me the error message at the 
>same time
>
>       ncdump: Exec format error. Wrong Architecture.
>
>I don't know what is wrong with it. 

Did you build netcdf on one computer, and try to use ncdump from
another? It looks like you may be trying to use a version of ncdump
that is not compatible with the computer that gave this error message.
Are you using the ncdump you just made or is there another ncdump somewhere
on the system that your PATH is allowing you to see?

Could you send details of how you built netcdf? What type of machine,
which compiler? 

Did you run the "configure" script first to create a Makefile? If so,
did you get any error messages during the build process?

More information usually helps resolve these type of questions.
 
>At the same time I got a file named gennet.f from pub/netcdf/contrib. It 
>is said that this program can be used to
>open and  read ANY netCDF file. I also used it to open and read ap.nc as follo
> wing:
>
>       > f77 gennet.f
>
>computer created an a.out file and told me :
>
>       gennet.f:
>           MAIN:
>       ld: Undefined external -
>          _ncopn
>          _ncinq
>          _ncdinq
>          _ncvinq
>          _ncanam
>          _ncainq
>       ld: output file still contains undefined symbols
>       ld: (warning) undefined externals may be assumed to be procedures

This means the compiler didn't know where the netcdf library was. The 
names _ncopn, _ncinq, etc are defined in the netcdf library. When you
built netcdf, you should have created a library file called libnetcdf.a 
When compiling programs that use netcdf commands (those described in
the guide), the compiler must be told where to find libnetcdf.a to allow
it to include the correct code.

To get gennet.f to compile correctly, you need to do

       f77 gennet.f /path/libnetcdf.a

For example, if libnetcdf.a were in the directory /usr/local/netcdf/lib, 
you would do

       f77 gennet.f /usr/local/netcdf/lib/libnetcdf.a

>then I tried to run a.out, computer reaction is :
>       ENTER NETCDF FILE NAME  
>enter file name :
>       aP.nc (Return)

When you then run a.out, you should get an output
 
        ***GENERATED FORTRAN PGM CALLED readnet.for***

readnet.for is a text file of fortran code.

>    I don't know how to deal with these problems. I'm a novice about netCDF.
>So, your advice is helpful to me. My task is to open netCDF files and read 
>the data out.  

When you build netcdf, you create a library called libnetcdf.a . This is
a library of routines that can be used in other programs to allow you
to read or write netcdf files. For example, you may want to read the
contents of a netcdf file. You could use the ncdump facility to give you
text output. 

However, you may want to use some of the data in another application. You 
must then write a piece of code, say in C, that uses the netcdf calls as 
described in the guide book. This code would be included in the application
so the application could extract information from a netcdf file. The 
code resource you write would need to be compiled and linked against
the netcdf library.

A CDL file is a template that can be used in creating netcdf files to speed
up their creation.

Mike