[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #TZR-904820]: Using OpenMP and Netcdf
- Subject: [netCDF #TZR-904820]: Using OpenMP and Netcdf
- Date: Wed, 09 Mar 2011 14:16:30 -0700
Hi Ali,
> I noticed on your website you state that Netcdf is not threadsafe. By
> this I presume that you mean that it will not handle multithreading,
> such as that provided by OpenMP? If this is true, are there any
> workarounds, or am I just out of luck? Thank you so much for your
> time.
It's not threadsafe if you have multiple netCDF files writing the same
file at the same time, or if you open and close netCDF files in
different threads.
With netCDF-3 classic format files, you can have multiple threads
reading the same file simultaneously or even one thread writing to a
file and multiple other threads or processes reading from the same
file at the same time. In the latter case, you must use the NC_SHARE
flag (in the C interface) on opening or creating the file (or the
corresponding flags in Fortran-77 or Fortran-90 interfaces), as
described in the C Users Guide:
At most one process should have a netCDF dataset open for writing
at one time. The library is designed to provide limited support for
multiple concurrent readers with one writer, via disciplined use of
the nc_sync function and the NC_SHARE flag. If a writer makes
changes in define mode, such as the addition of new variables,
dimensions, or attributes, some means external to the library is
necessary to prevent readers from making concurrent accesses and to
inform readers to call nc_sync before the next access.
With netCDF-4, you can use parallel I/O to permit multiple writers to
write a file at the same time, but you must open or create files with
special flags to permit this. The netCDF-4 library supports two kinds
of parallel I/O, one that uses the Argonne/Northwestern Parallel
NetCDF software, and the other that takes advantage of the HDF5
parallel I/O in the HDF5 layer used for storage of netCDF-4 files.
For details, see:
Parallel Access with NetCDF-4
http://www.unidata.ucar.edu/netcdf/docs/netcdf.html#Parallel-Access
--Russ
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: TZR-904820
Department: Support netCDF
Priority: Normal
Status: Closed