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

20001114: How to append data to a existing file?



Zhenjiang Li,

> To: address@hidden
> From: address@hidden (Zhenjiang Li)
> Organization: UCAR/Unidata
> Keywords: 200011102214.eAAMEtD15923
> Subject: How to append data to a existing file?

The above message contained the following:

> Hello, Netcdf experts:
> 
>        I am using netcdf to store my circulation model data. 
> I got a source code from someone else.  that netcdf code allows
> me systematically output data to a file.  My model is doing
> nowcast modeling, sometimes, the integration stops, so I have 
> to let the model run again from where it stops, and hope
> the data can be appended to the existing file.    
> 
>       I need instructions how to modify the netcdf code. 
> in my netcdf code, there are certain statements like the following:
> 
>         CDFID = NCOPN(pout,NCWRITE,IRET)
>         IFILL = NCSFIL(CDFID,NCNOFILL,IRET)
> 
> and 
> 
>        CDFID = NCCRE(pout,NCCLOB,IRET)
>         IFILL = NCSFIL(CDFID,NCNOFILL,IRET)
> 
> I have tried all my best to adjust those arguments in these
> statements, but I can not have the code do what I wants. 
> 
> I am looking for your help.  My netcdf code is attached below

I'm afraid that we don't have the resources to debug specific user code.

The netCDF package can, however, do what you want.  My advice on
a general solution includes the following:

    1.  Declare the integration dimension to be UNLIMITED;

    2.  Ensure that pre-filling of values is TURNED OFF;

    3.  Declare a scalar, integer variable (e.g. "lastValid") and have
        it contain the index of the last, valid, completely-written,
        netCDF record; and

    4.  If you have to restart, then use the index stored in "lastValid"
        to help initialize the model.

You also might try posting to the netCDF email list.  I'm sure someone
has solved a similar problem using the netCDF package.

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>