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

Re: 19990611: netCDF problem



>To: address@hidden
>From: Zhang tinglu <address@hidden>
>Subject: (Kein Bezug)
>Organization: FU Berlin, Institut f r Weltraumwissenschaften, Fabeckstr. 69, 
>14195 Berlin, Germany
>Keywords: 199906111355.HAA16586

Hi Tinglu Zhang,

> I am  user of netCDF. I have created a netCDF data file
> (name://win95/zhang/opt_data/optics.ncdf) under the IDL. When I ran a
> file attached in this E-mail , the bytes of the netCDF data file became
> zero. Would you like tell me the reason ?

I'm unable to duplicate the problem, so I can't tell you why it is
happening.  I invoked IDL version 5.0 and used a netCDF test file I
have (since you did not send the data file you were using, but I do
not think the problem is data dependent):

    $ /opt/rsi/idl_5/bin/idl
    IDL Version 5.0 (sunos sparc). Research Systems, Inc.
    Installation number: 3298-1.
    Licensed for use by: UCAR/UNIDATA

    For basic information, enter "IDLInfo" at the IDL> prompt.

    IDL> Id = NCDF_OPEN('ex2.nc',/WRITE)
    Id = NCDF_OPEN('ex2.nc',/WRITE)
    IDL> NCDF_CONTROL, Id, /REDEF
    NCDF_CONTROL, Id, /REDEF
    IDL> NCDF_CLOSE, Id
    NCDF_CLOSE, Id

When I dumped the file ex2.nc, its contents were unchanged, although
its modification time had changed.

I also compiled and linked an equivalent sequence of netCDF calls in C
(which I've appended) with the currently released library (version
3.4) as well as two older versions of the library, since I think IDL
may have been built with one of these older versions (version 2.4.2
and version 2.3.2pl2).

In all cases, calling ncopen to open with write access, calling
ncredef to enter define mode, then calling ncclose worked as expected,
and the data in the file did not change.

To make further progress on this problem, we would have to know what
version of IDL you are using, what platform (machine and operating
system version) you are running on, and get a copy of the input file
you are using, or at least an "ncdump" of the file if it's not too
big.  It also might help to know whether the directory in which you
are trying this is writable by you, since that made a difference in
the method employed in older versions of netCDF.

Alternatively, if you expect this might be an IDL problem, you could
ask RSI, if they know why this is happening.

--Russ

---------- test I tried with netCDF 3.4 ------------

#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

void
check_err(const int stat, const int line, const char *file) {
    if (stat != NC_NOERR) {
           (void) fprintf(stderr, "line %d of %s: %s\n", line, file, 
nc_strerror(stat));
        exit(1);
    }
}


int
main(int argc, char *args[]) {                  /* test open, redef, close 
sequence */

   int  ncid;                   /* netCDF id */

   int stat = nc_open(args[1], NC_WRITE, &ncid);
   check_err(stat,__LINE__,__FILE__);

   printf("opened %s\n", args[1]);

   stat = nc_redef(ncid);
   check_err(stat,__LINE__,__FILE__);

   stat = nc_close(ncid);
   check_err(stat,__LINE__,__FILE__);

   return 0;
}


---------- test I tried with netCDF 2.4.2 and 2.3.2pl2 ------------

#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>


int
main(int argc, char *args[]) {                  /* test open, redef, close 
sequence */

   int ncid = ncopen(args[1], NC_WRITE);
   printf("opened %s\n", args[1]);

   ncredef(ncid);

   /* ncclose(ncid); */

   return 0;
}