Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 
Previous: Parallel I/O Example Next: Example of Simple Parallel I/O Access (part 2) Table of contents Frames User guide
2008 Unidata NetCDF Workshop for Developers and Data Providers > Parallel I/O with NetCDF

13.8 Example of Simple Parallel I/O Access
The nc_test4/tst_parallel3.c program provides an example of parallel I/O.

 

    /* Initialize MPI. */
    MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
    MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);

    /* Create a parallel netcdf-4 file. */
    if ((res = nc_create_par(FILENAME, facc_type, comm, info, &ncid)))
        BAIL(res);

    /* The first case is two dimensional variables, no unlimited
    dimension */

    /* Create two dimensions. */
    if ((res = nc_def_dim(ncid, "d1", DIMSIZE2, dimids)))
       BAIL(res);
    if ((res = nc_def_dim(ncid, "d2", DIMSIZE, &dimids[1])))
       BAIL(res);

    /* Create one var. */
    if ((res = nc_def_var(ncid, "v1", NC_INT, NDIMS1, dimids, &nvid)))
       BAIL(res);

    if ((res = nc_enddef(ncid)))
       BAIL(res);

 


Previous: Parallel I/O Example Next: Example of Simple Parallel I/O Access (part 2) Table of contents Frames User guide
2008 Unidata NetCDF Workshop for Developers and Data Providers > Parallel I/O with NetCDF

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690