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

20041105: no data in netcdf file



Shuhua,

> To: address@hidden
> From: "S. Yi" <address@hidden>
> Subject: no data in netcdf file
> Organization: McMaster University
> Keywords: 200411052131.iA5LVEvV006138

The above message contained the following:

>  I have a problem of creating a netcdf file correctly. Following is my
> source file, test.f90
> 
>  program test
> 
>  implicit none
>  include 'netcdf.inc'
> integer :: ierr , ncid
> integer :: timdmid, varid, il
> 
> ierr = nf_create('test.nc',nf_clobber, ncid)
> ierr = nf_def_dim(ncid, 'time', nf_unlimited, timdmid)
> ierr = nf_def_var(ncid, 'temp', nf_double, 1, timdmid, varid)

The "timdmid" argument in the last statement above should be a vector
instead of a scalar.  The first element of the vector should have the
same value as "timdmid".

Details of the netCDF Fortran-77 API can be found at

    http://my.unidata.ucar.edu/content/software/netcdf/guidef/

> ierr = nf_enddef(ncid)
> 
> do il = 1, 10
> ierr = nf_put_var_double(ncid, varid,1.0) 
> enddo
> ierr = nf_close(ncid)
> end program

You should also check the return code "ierr" every time.

> This program can be compiled and run successfully, however, the output
> from ncdump shows that,
> 
> netcdf test {
> dimensions:
>       time = UNLIMITED ; // (0 currently)
> variables:
>       double temp(time) ;
> data:
> }
> 
> 
> Thanks
> 
> 
> Yi, Shuhua
> School of Geography and Geology
> McMaster University
> Hamilton, ON, CA L8S 4K1
> --------------------------------
> Office: GSB-221
> Phone: 905-525-9140 Ext. 24776
> --------------------------------

Regards,
Steve Emmerson

> NOTE: All email exchanges with Unidata User Support are recorded in the
> Unidata inquiry tracking system and then made publicly available
> through the web.  If you do not want to have your interactions made
> available in this way, you must let us know in each email you send to us.