Go to the previous, next section.
The function ncsync
(or NCSNC
for FORTRAN) makes sure that
the disk copy of a netCDF file open for writing is current. The netCDF
file must be in data mode. A netCDF file in define mode is synchronized
to disk only when ncendef
(or NCENDF
) is called. A
process that is reading a netCDF file that another process is writing
can also call ncsync
(or NCSNC
for FORTRAN) to get updated
with the changes made by the writing process (e.g. the number of records
written), without having to close and reopen the file.
It can be expensive in computer resources to always synchronize to disk after every write of variable data or change of an attribute value. There are two reasons you might want to synchronize after writes:
ncsync
; to accomplish this, the reading process
must call ncsync
.
Data is automatically synchronized to disk when a netCDF file is closed, or whenever you leave define mode.
In case of an error, ncsync
returns -1; NCSNC
returns a
nonzero value in rcode
. Possible causes of errors include:
int ncsync(int ncid);
ncid
ncopen
or nccreate
.
Here is an example using ncsync
to synchronize the disk writes of
a netCDF file named `foo.nc':
#include "netcdf.h" ... int ncid; ... ncid = ncopen("foo.nc", NC_WRITE); /* open for writing */ ... /* write data or change attributes */ ncsync(ncid); /* synchronize to disk */
SUBROUTINE NCSNC(INTEGER NCID, INTEGER RCODE)
NCID
NCOPN
or NCCRE
.
RCODE
Here is an example using NCSNC
to synchronize the disk writes of
a netCDF file named `foo.nc':
INCLUDE 'netcdf.inc' ... INTEGER NCID, RCODE ... NCID = NCOPN('foo.nc', NCWRITE, RCODE) ... * write data or change attributes ... CALL NCSNC(NCID, RCODE)
Go to the previous, next section.