Previous: Parallel I/O Example Next: Example of Simple Parallel I/O Access (part 2) Table of contents Frames 2012 Unidata NetCDF Workshop > Parallel I/O with NetCDF

35.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 2012 Unidata NetCDF Workshop > Parallel I/O with NetCDF